Replace the listy context API with indexed lookups and explicit scope invariants
This commit is contained in:
+37
-1
@@ -168,6 +168,41 @@ def runNeutralRepresentationChecks : IO Bool := do
|
||||
IO.println "fail stuck eliminators stay in the neutral fragment"
|
||||
pure false
|
||||
|
||||
def runContextInvariantChecks : IO Bool := do
|
||||
let cxt :=
|
||||
(Cxt.empty.bind "A" (.univ 0)).define "x" .zero .nat
|
||||
let wfOk := Cxt.isWellFormed cxt
|
||||
let lookupOk :=
|
||||
match cxt.lookup "x", cxt.lookup "A" with
|
||||
| some (ix, tx), some (iA, tA) =>
|
||||
ix.val == 0 &&
|
||||
iA.val == 1 &&
|
||||
(match tx with | .nat => true | _ => false) &&
|
||||
(match tA with | .univ 0 => true | _ => false)
|
||||
| _, _ =>
|
||||
false
|
||||
let indexedOk :=
|
||||
let latest : Fin cxt.lvl := ⟨0, by decide⟩
|
||||
let outer : Fin cxt.lvl := ⟨1, by decide⟩
|
||||
(match cxt.typeAt latest with
|
||||
| ("x", .nat) => true
|
||||
| _ => false) &&
|
||||
(match cxt.typeAt outer with
|
||||
| ("A", .univ 0) => true
|
||||
| _ => false) &&
|
||||
(match cxt.valueAt latest with
|
||||
| .zero => true
|
||||
| _ => false) &&
|
||||
(match cxt.valueAt outer with
|
||||
| .neu (.var 0) => true
|
||||
| _ => false)
|
||||
if wfOk && lookupOk && indexedOk then
|
||||
IO.println "pass context lookup is indexed and scope invariants hold"
|
||||
pure true
|
||||
else
|
||||
IO.println "fail context lookup is indexed and scope invariants hold"
|
||||
pure false
|
||||
|
||||
def runLevelSolverChecks : IO Bool := do
|
||||
let satOk :=
|
||||
match solveLevelConstraints [(.max 0 1, 1), (1, .succ 1)] with
|
||||
@@ -212,9 +247,10 @@ def main : IO UInt32 := do
|
||||
let results ← cases.mapM runCase
|
||||
let safetyOk ← runInternalSafetyChecks
|
||||
let neutralOk ← runNeutralRepresentationChecks
|
||||
let contextOk ← runContextInvariantChecks
|
||||
let levelOk ← runLevelSolverChecks
|
||||
let prettyOk ← runPrettyPrinterChecks
|
||||
let allResults := results ++ [safetyOk, neutralOk, levelOk, prettyOk]
|
||||
let allResults := results ++ [safetyOk, neutralOk, contextOk, 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