@@ -36,9 +36,40 @@ pub enum Term {
3636 body : Box < Term > ,
3737 } ,
3838
39- /// Type universe
39+ /// Type universe at level
40+ Type ( usize ) ,
41+
42+ /// Sort universe at level
43+ Sort ( usize ) ,
44+
45+ /// Type universe (legacy alias for Type)
4046 Universe ( usize ) ,
4147
48+ /// Let binding: let name : ty = value in body
49+ Let {
50+ name : String ,
51+ ty : Option < Box < Term > > ,
52+ value : Box < Term > ,
53+ body : Box < Term > ,
54+ } ,
55+
56+ /// Pattern matching: match scrutinee with branches
57+ Match {
58+ scrutinee : Box < Term > ,
59+ return_type : Option < Box < Term > > ,
60+ branches : Vec < ( Pattern , Term ) > ,
61+ } ,
62+
63+ /// Fixed-point combinator: fix name. body
64+ Fix {
65+ name : String ,
66+ ty : Option < Box < Term > > ,
67+ body : Box < Term > ,
68+ } ,
69+
70+ /// Hole/goal marker
71+ Hole ( String ) ,
72+
4273 /// Meta-variable (for unification)
4374 Meta ( usize ) ,
4475
@@ -49,6 +80,20 @@ pub enum Term {
4980 } ,
5081}
5182
83+ /// Pattern for match expressions
84+ #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq , Eq , Hash ) ]
85+ pub enum Pattern {
86+ /// Wildcard pattern _
87+ Wildcard ,
88+ /// Variable pattern
89+ Var ( String ) ,
90+ /// Constructor pattern C(p1, p2, ...)
91+ Constructor {
92+ name : String ,
93+ args : Vec < Pattern > ,
94+ } ,
95+ }
96+
5297impl fmt:: Display for Term {
5398 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
5499 match self {
@@ -72,7 +117,23 @@ impl fmt::Display for Term {
72117 Term :: Pi { param, param_type, body } => {
73118 write ! ( f, "(Π {}: {}. {})" , param, param_type, body)
74119 } ,
120+ Term :: Type ( level) => write ! ( f, "Type{}" , level) ,
121+ Term :: Sort ( level) => write ! ( f, "Sort{}" , level) ,
75122 Term :: Universe ( level) => write ! ( f, "Type{}" , level) ,
123+ Term :: Let { name, ty, value, body } => {
124+ if let Some ( t) = ty {
125+ write ! ( f, "(let {} : {} = {} in {})" , name, t, value, body)
126+ } else {
127+ write ! ( f, "(let {} = {} in {})" , name, value, body)
128+ }
129+ } ,
130+ Term :: Match { scrutinee, .. } => {
131+ write ! ( f, "(match {} with ...)" , scrutinee)
132+ } ,
133+ Term :: Fix { name, body, .. } => {
134+ write ! ( f, "(fix {}. {})" , name, body)
135+ } ,
136+ Term :: Hole ( name) => write ! ( f, "?{}" , name) ,
76137 Term :: Meta ( id) => write ! ( f, "?{}" , id) ,
77138 Term :: ProverSpecific { prover, .. } => write ! ( f, "<{}-term>" , prover) ,
78139 }
0 commit comments