pub enum Term {
Sort(Universe),
Var(String),
Global(String),
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>,
},
Lit(Literal),
Hole,
}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
Variants§
Sort(Universe)
Universe: Type n or Prop
Var(String)
Local variable reference (bound by λ or Π)
Global(String)
Global definition (inductive type or constructor)
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
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.