Lean / Reader
Lean reader

ExactChallenge.lean

29 lines3 declarationsno sorryimports Lean
  1. import Lean
  2. open Lean
  3. def goals : Array Name :=
  4. #[`Solution.mainTheorem, `Solution.mainTheoremApprox, `Solution.separation,
  5. `Solution.separationClosure, `Solution.permanent_over_real]
  6. def lookupTheorem (moduleName : String) (data : ModuleData) (name : Name) : IO TheoremVal := do
  7. let some entry := data.constants.find? (fun entry => entry.name == name)
  8. | throw (IO.userError s!"{moduleName} is missing {name}")
  9. match entry with
  10. | .thmInfo info => pure info
  11. | _ => throw (IO.userError s!"{name} is not a theorem in {moduleName}")
  12. def main (args : List String) : IO Unit := do
  13. let [challengePath, solutionPath] := args
  14. | throw (IO.userError "Usage: ExactChallenge Challenge.olean Solution.olean")
  15. let (challenge, challengeRegion) ← readModuleData challengePath
  16. let (solution, solutionRegion) ← readModuleData solutionPath
  17. for goal in goals do
  18. let expected ← lookupTheorem "Challenge" challenge goal
  19. let actual ← lookupTheorem "Solution" solution goal
  20. unless expected.levelParams == actual.levelParams && expected.type == actual.type do
  21. throw (IO.userError s!"Statement mismatch: {goal}")
  22. IO.println s!"MATCH {goal}"
  23. let _ := challengeRegion
  24. let _ := solutionRegion