generated from pitmonticone/LeanProject
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exports the equations defined in `Equations.lean` and `AllEquations.lean` to a JSON file `data/magma_equations.json`. Depends on PR #427. --------- Co-authored-by: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com>
- Loading branch information
1 parent
adc92cb
commit 345f865
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import equational_theories.Equations | ||
import equational_theories.AllEquations | ||
|
||
open Lean Elab Command Meta | ||
|
||
/-! | ||
# Exporting magma equations | ||
This script exports all the magma equations defined in the `Equations` and `AllEquations` files | ||
to the JSON file `data/magma_equations.json`. | ||
The format is | ||
``` | ||
{ | ||
"equation": "EquationName", | ||
"law": { | ||
"lhs": { ... }, | ||
"rhs": { ... } | ||
} | ||
} | ||
-/ | ||
def main : IO Unit := do | ||
searchPathRef.set compile_time_search_path% | ||
let env ← importModules #[ | ||
{ module := `equational_theories.Equations }, | ||
{ module := `equational_theories.AllEquations }] .empty | ||
let laws := magmaLawExt.getState env | ||
let jsonOutput : Json := Json.arr <| laws.map fun ⟨lawName, law⟩ => .mkObj [ | ||
("equation", "Equation" ++ (lawName.toString.drop "Law".length)), | ||
("law", ToJson.toJson law) | ||
] | ||
IO.FS.writeFile ("data" / "magma_equations.json") jsonOutput.pretty |