Lean / Reader
Lean reader

ReadAxiomIndex.lean

23 lines2 declarationsno sorryimports Lean
  1. import Lean
  2. open Lean
  3. def theoremNames : Array Name :=
  4. #[`Solution.mainTheorem, `Solution.mainTheoremApprox, `Solution.separation,
  5. `Solution.separationClosure, `Solution.permanent_over_real]
  6. -- Pinned Lean 4.33.1 specifies this entry type in Lean.Util.CollectAxioms.
  7. unsafe def main (args : List String) : IO Unit := do
  8. let [path] := args | throw (IO.userError "Usage: ReadAxiomIndex Solution.olean")
  9. let (data, region) ← readModuleData path
  10. let some (name, entries) := data.entries.find? (fun entry =>
  11. entry.1.toString.endsWith ".exportedAxiomsExt")
  12. | throw (IO.userError "No exported axiom index in the source module")
  13. IO.println s!"Axiom index {name}"
  14. let typed : Array (Name × Array Name) := entries.map unsafeCast
  15. for target in theoremNames do
  16. let some (_, axioms) := typed.find? (fun entry => entry.1 == target)
  17. | throw (IO.userError s!"Axiom index missing {target}")
  18. IO.println s!"{target} {axioms.toList}"
  19. let _ := region