pub enum Term {
Show 14 variants
Sort(Universe),
Var(String),
Global(String),
Const {
name: String,
levels: Vec<Universe>,
},
Pi {
param: String,
param_type: Box<Term>,
body_type: Box<Term>,
},
Lambda {
param: String,
param_type: Box<Term>,
body: Box<Term>,
},
App(Box<Term>, Box<Term>),
Match {
discriminant: Box<Term>,
motive: Box<Term>,
cases: Vec<Term>,
},
Fix {
name: String,
body: Box<Term>,
},
MutualFix {
defs: Vec<(String, Term)>,
index: usize,
},
Let {
name: String,
ty: Box<Term>,
value: Box<Term>,
body: Box<Term>,
},
Lit(Literal),
Hole,
Annotated {
annotation: Annotation,
term: Box<Term>,
},
}Expand description
Unified term representation.
Every expression in CoC is a Term:
Sort(u)- universes (Type 0, Type 1, Prop)Var(x)- variablesPi- dependent function types: Π(x:A). BLambda- functions: λ(x:A). tApp- application: f x
== is the kernel’s identity: it compares kernel meaning and does not see
Term::Annotated. Term::identical is the comparison that does.
Variants§
Sort(Universe)
Universe: Type n or Prop
Var(String)
Local variable reference (bound by λ or Π)
Global(String)
Global definition (inductive type or constructor)
Const
A universe-polymorphic global referenced at explicit levels — name.{ℓ₀, ℓ₁, …}.
Global is the monomorphic case (no level arguments); Const instantiates a
stored universe-polymorphic definition’s universe parameters with levels.
Pi
Dependent function type: Π(x:A). B
When B doesn’t mention x, this is just A → B. When B mentions x, this is a dependent type.
Lambda
Lambda abstraction: λ(x:A). t
App(Box<Term>, Box<Term>)
Application: f x
Match
Pattern matching on inductive types.
match discriminant return motive with cases
- discriminant: the term being matched (must have inductive type)
- motive: λx:I. T — describes the return type
- cases: one case per constructor, in definition order
Fix
Fixpoint (recursive function).
fix name. body binds name to itself within body.
Used for recursive definitions like addition.
Fields
MutualFix
MUTUAL fixpoint — a block of mutually-recursive functions (K3).
mutualfix { f₀ := b₀, …, fₙ := bₙ }.index binds ALL of f₀ … fₙ within EVERY
body bᵢ (that is the mutual part), and the whole term reduces to the
index-th definition. It is the body of a mutual inductive block’s recursor:
Even.rec’s fixpoint calls Odd.rec’s on the smaller sub-proof and vice
versa. Each body’s type is inferred structurally from its λ-telescope (like the
single Fix); termination is the MUTUAL Giménez guard — a call to ANY member
must pass a structurally-smaller argument at that member’s recursive position.
Fields
Let
Local definition: let name : ty := value in body.
name is bound to value (of type ty) transparently within body —
so the body is type-checked and reduced with name ≡ value (ZETA), not
as an opaque hypothesis. The surface let; the sharing seam for the
elaborator.
Lit(Literal)
Primitive literal value.
Hardware-native values like i64, f64, String. These compute via CPU ALU, not recursion.
Hole
Hole (implicit argument).
Represents an argument that should be inferred by the type checker.
Used in Literate syntax like X equals Y where the type of X/Y is implicit.
Annotated
term, carrying an Annotation: a binder’s kind, or where term came
from. TRANSPARENT — no judgment of the kernel reads it, == does not see it, and a
certificate cannot carry it (it has no serialized form). See annotation.rs.
Implementations§
Source§impl Term
impl Term
Sourcepub fn annotated(annotation: Annotation, term: Term) -> Term
pub fn annotated(annotation: Annotation, term: Term) -> Term
term, carrying annotation.
Sourcepub fn peel_annotations(&self) -> &Term
pub fn peel_annotations(&self) -> &Term
The term under every annotation at this term’s head.
Sourcepub fn head_annotations(&self) -> impl Iterator<Item = &Annotation>
pub fn head_annotations(&self) -> impl Iterator<Item = &Annotation>
The annotations at this term’s head, outermost first.
Sourcepub fn binder_kind(&self) -> Option<ParamKind>
pub fn binder_kind(&self) -> Option<ParamKind>
The kind recorded on this binder: the outermost Annotation::Binder at the head of a
fun or Π. None for a binder that records none, and for a term that is not a binder.
Sourcepub fn provenance(&self) -> Option<&Provenance>
pub fn provenance(&self) -> Option<&Provenance>
Where this term came from: the outermost Annotation::Source at its head.
Sourcepub fn has_annotations(&self) -> bool
pub fn has_annotations(&self) -> bool
Whether an annotation stands anywhere in this term.
Sourcepub fn strip_annotations(&self) -> Term
pub fn strip_annotations(&self) -> Term
This term with every annotation erased — its kernel meaning, the only thing a kernel
judgment reads. Erasing is idempotent, and t.strip_annotations() == t always holds.
Sourcepub fn into_stripped(self) -> Term
pub fn into_stripped(self) -> Term
strip_annotations on a term the caller owns: a term with no
annotation is handed back as it is, without a copy.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Term
impl<'de> Deserialize<'de> for Term
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Term
Equality of KERNEL MEANING: annotations are peeled at every node, so a term equals its
annotated copy. Every other variant compares exactly as the derive did, field by field in
declaration order.
impl PartialEq for Term
Equality of KERNEL MEANING: annotations are peeled at every node, so a term equals its annotated copy. Every other variant compares exactly as the derive did, field by field in declaration order.