This page answers: what’s the syntax for every declaration form, with one minimal example each?
For semantics and rationale, follow the cross-links into the book chapters and the RFDs.
Form Syntax (minimal) What it declares See
metatypepub metatype kind = { rigid, sortal, provides }A user-defined metatype with axis assignments ch02-01
metaxispub metaxis rigidity for type { rigid, anti_rigid }A user-defined axis a metatype can take values on. Typed-domain form: pub metaxis order : Nat for type (optionally where { _ > 0 }). Cross-cutting: for [type, rel]. Valid kinds: type, rel, dec, field, individual, frame, metarel. ch02-01 , ch02-06
metarelpub metarel mediates = { source: relator, target: kind, ... }A user-defined relation kind ch02-01
decoratorpub decorator transitive() on rel { lowers_to: shape::Transitive }A user-defined decorator that recognized-shape lowers ch02-01
Form Syntax (minimal) See
Concept pub kind Person <: Agentch02-02
Concept with constraints pub kind Person <: Agent where { age >= 0 }ch02-02 , RFD-0018
Anonymous concept let _: Concept; (synthesizes __anon_<hash>_<n>)ch02-02
Group axiom disjoint(A, B, C) / complete(A, B, C) / partition(A, B, C)ch02-02
Specialization atom: Tenant <: Person (typeset alias ⊑). In a concept-header supertype slot, : is admitted as documented sugar for <: (pub subkind X : Y ≡ pub subkind X <: Y). ch02-02 , RFD-0017
Instantiation atom: alice : Tenant (instance-of-type). : at every non-header position is the instantiation operator and never overlaps with <:. ch02-02
Form Syntax (minimal) See
Relation pub rel works_at(p: Person, o: Organization)ch02-03
Relation with metarel pub rel mediates(c: Commitment, p: Person) :: Mediationch02-03
Relation with decorator @[transitive] pub rel ancestor_of(a: Person, b: Person)ch02-03
Property pub property age(p: Person) -> Natch02-03
Cardinality pub rel hires(o: Organization, p: Person) { cardinality: 1..* }ch02-03
Form Syntax (minimal) See
Derive rule pub derive adult(P) :- Person(P), age(P, A), A >= 18ch02-04
Multi-head derive Multiple pub derive same_head(...) :- ... rules ch02-04
Strict rule pub strict adult(P) :- ...ch02-04
Defeasible rule (default) — same as pub derive ch02-04
Override @override(other_rule) pub derive ...ch02-04
Theorem mark @[theorem] pub derive ...ch02-04
Modal box(P), diamond(P) operatorsRFD-0018
FOL escape unsafe logic { ... }RFD-0018
The compiler exposes the type lattice through one intrinsic and seven std::meta predicates. All evaluate at tier:structural. Import via use std::meta::*.
Form Syntax (minimal) What it does
meta() intrinsicmeta(c) == kindType-of subject. Sugar form c :: kind lowers to the same atom. No use required (substrate, not a std::meta predicate). Ground argument required (OE0212 if free).
is_type(X)is_type(c)Universal classification — every concept satisfies it.
metatype(X, M)metatype(c, m)Bind M to the metatype keyword as a string.
supers(X, S)supers(c, s)Direct supertypes.
ancestors(X, A)ancestors(c, a)Transitive ancestors.
fields(X, F)fields(c, f)Declared field names.
axioms(X, A)axioms(c, a)Declared axioms.
module(X, M)module(c, m)Owning module path as a string.
See ch02-06 , ch03-03 .
Form Syntax (minimal) When to use
Form 1 (expr) compute capital_gain(s: Sale) = s.proceeds - s.basisOne-shot calculation
Form 2 (inline) compute f(x: T) { input { ... } body { ... } out { ... } }Multi-step, tier-bounded, dynamically loadable
Form 3 (Rust) compute f(x: T) -> R { ... impl rust("crate::path::fn") }Native FFI; requires Rust rebuild
See ch02-05 , RFD-0006 .
Form Syntax (minimal) See
Query query adults() :- Person(P), age(P, A), A >= 18 => Pch02-05
Mutation mutation hire(o: Organization, p: Person) { do { works_at(p, o); } return p; }ch02-05
Singular clause names: require, do, retract, emit, return. See RFD-0007 .
Form Syntax (minimal) See
Test test t1 { ... expect { diagnostic OE0211 at //~ marker } }ch03-03
Fixture fixture { let p: Person = ...; } (test-local mini-module)ch03-03
Frame pub frame F { ... } + using F in testch03-03
Proof status #[unproven] test ..., #[assumed] test ...RFD-0008
Source marker //~ <label> (anchors expect blocks)ch03-03
Form Syntax (minimal) See
Pattern decl pub pattern correlative<R, D> { ... }ch03-01
Pattern instantiation use pattern correlative<Right, Duty> as RDch03-01
Bespoke surface correlative_pair(Right, Duty)ch03-01
See RFD-0019 .
Form Syntax See
Module declaration mod foo; (file foo.ar)ch04-01
Single-symbol import use std::math::Nat;ch04-01
Glob import use ufo::prelude::*;ch04-01
Re-export pub use ufo::prelude::*;ch04-01
Visibility pub (package-public) / unmarked (module-internal)RFD-0011
Form Syntax Effect See
Module-scope #dec(tier:closure) at file topCaps every declaration in this module ch05-03
Block-scope #dec(tier:fol) in blockCaps the surrounding block ch05-03
Decl-scope #dec(tier:expressive) on declarationCaps the single declaration ch05-03
See RFD-0004 and tier-selection.md .
The five type constructors and their expression-level surface. See ch02-08 and RFD-0039 .
Form Syntax (minimal) What it does
Type constructors Set[T], List[T], Map[K, V], Optional[T], Range[T]Closed-set parametric type constructors. Brackets, not angle brackets.
Optional sugar T? ≡ Optional[T]Same type; reach for T? for the common 0-or-1 case.
Method call xs.size(), xs.contains(x)Desugars to <TypeOf(xs)>::m(xs, args) at elaboration.
Indexing xs[i]Desugars to List::at(xs, i) -> Optional[T] (or Map::get). Set[T] rejects with OE2406.
Slicing xs[i..j], xs[i..], xs[..j]Desugars to List::slice(xs, Range::new(i, j)). Literal bounds checked at elaboration.
Range literal i..j (half-open) / i..=j (inclusive)Constructs Range[T]. Doesn’t materialize in v1.
Membership x in xs, x not in xsDesugars to <TypeOf(xs)>::contains(xs, x) (and negation).
Comprehension [expr for x in xs where pred]Desugars to xs.filter(<pred>).map(<expr>). Binder shadowing fires OW2403.
Constructor calls Set::of(a, b), List::of(a, b), Map::of((k, v), ...), Some(x), None()Variadic / per-arity.
Mutation idiom do { l.parents = l.parents.append(p) }Functional rebuild-and-assign; no in-place mutators in v1.
Form Syntax (minimal) See
Diagram block diagram T { concepts { Person, Organization }; layout: sugiyama; }ch03-04
See RFD-0026 .