Replace hardcoded universe levels with a proper level language and constraint solving

This commit is contained in:
2026-04-19 15:50:59 +00:00
parent 963c9f3e94
commit 28c9f2f9f8
8 changed files with 90 additions and 13 deletions
+4 -4
View File
@@ -122,7 +122,7 @@ mutual
let _ := level
pure (.idElim motive' r' target' eq', resultTy)
| _ => throw s!"expected Id type in idElim, got {showTy cxt.lvl eqTy}"
| .univ i => pure (.univ i, .univ (i + 1))
| .univ i => pure (.univ i.normalise, .univ i.succ')
| .app t u => do
let (t', tty) infer cxt t
match tty with
@@ -150,12 +150,12 @@ mutual
let (a', i) inferUniverse cxt a
let va eval cxt.env a'
let (b', j) inferUniverse (cxt.bind x va) b
pure (.pi a' b', .univ (Nat.max i j))
pure (.pi a' b', .univ (i.max' j))
| .sig x a b => do
let (a', i) inferUniverse cxt a
let va eval cxt.env a'
let (b', j) inferUniverse (cxt.bind x va) b
pure (.sig a' b', .univ (Nat.max i j))
pure (.sig a' b', .univ (i.max' j))
| .ann t a => do
let (a', _) inferUniverse cxt a
let va eval cxt.env a'
@@ -171,7 +171,7 @@ mutual
| .lam _ _ => throw "cannot infer type of lambda, use an annotation"
| .pair _ _ => throw "cannot infer type of pair, use an annotation"
partial def inferUniverse (cxt : Cxt) (r : Raw) : TCM (Tm × Nat) := do
partial def inferUniverse (cxt : Cxt) (r : Raw) : TCM (Tm × Level) := do
let (t, ty) infer cxt r
match ty with
| .univ level => pure (t, level)