Replace hardcoded universe levels with a proper level language and constraint solving
This commit is contained in:
+22
-1
@@ -25,8 +25,12 @@ structure TestCase where
|
||||
def cases : List TestCase := [
|
||||
⟨"U0 is typed by U1", Examples.univ0,
|
||||
.okTy (.univ 1)⟩,
|
||||
⟨"U(max 0 1) is typed by U2", Examples.univMax,
|
||||
.okTy (.univ 2)⟩,
|
||||
⟨"U0 subsumes into U2", .ann (.univ 0) (.univ 2),
|
||||
.okTy (.univ 2)⟩,
|
||||
⟨"U0 subsumes into U(max 0 2)", .ann (.univ 0) (.univ (.max 0 2)),
|
||||
.okTy (.univ 2)⟩,
|
||||
⟨"Nat is typed by U0", .nat,
|
||||
.okTy (.univ 0)⟩,
|
||||
⟨"succ zero infers Nat", (.succ .zero),
|
||||
@@ -164,6 +168,22 @@ def runNeutralRepresentationChecks : IO Bool := do
|
||||
IO.println "fail stuck eliminators stay in the neutral fragment"
|
||||
pure false
|
||||
|
||||
def runLevelSolverChecks : IO Bool := do
|
||||
let satOk :=
|
||||
match solveLevelConstraints [(.max 0 1, 1), (1, .succ 1)] with
|
||||
| Except.ok _ => true
|
||||
| Except.error _ => false
|
||||
let unsatOk :=
|
||||
match solveLevelConstraints [(.succ 1, 1)] with
|
||||
| Except.error err => containsText err "unsatisfiable level constraint"
|
||||
| Except.ok _ => false
|
||||
if satOk && unsatOk then
|
||||
IO.println "pass level constraints are solved consistently"
|
||||
pure true
|
||||
else
|
||||
IO.println "fail level constraints are solved consistently"
|
||||
pure false
|
||||
|
||||
def runPrettyPrinterChecks : IO Bool := do
|
||||
match checkTop Examples.idAnn with
|
||||
| .ok (tm, ty) =>
|
||||
@@ -192,8 +212,9 @@ def main : IO UInt32 := do
|
||||
let results ← cases.mapM runCase
|
||||
let safetyOk ← runInternalSafetyChecks
|
||||
let neutralOk ← runNeutralRepresentationChecks
|
||||
let levelOk ← runLevelSolverChecks
|
||||
let prettyOk ← runPrettyPrinterChecks
|
||||
let allResults := results ++ [safetyOk, neutralOk, prettyOk]
|
||||
let allResults := results ++ [safetyOk, neutralOk, levelOk, prettyOk]
|
||||
let failed := allResults.countP (· == false)
|
||||
if failed == 0 then
|
||||
IO.println s!"\n{allResults.length} passed, 0 failed"
|
||||
|
||||
Reference in New Issue
Block a user