forked from siddhartha-gadgil/LeanAide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubecode.lean
38 lines (36 loc) · 1.12 KB
/
cubecode.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Lean.Meta
import LeanCodePrompts
import LeanCodePrompts.Examples.OldStructured
import LeanAide.Config
import Cli
open Lean Cli
set_option maxHeartbeats 10000000
set_option maxRecDepth 1000
set_option compiler.extract_closed false
def main : IO Unit := do
initSearchPath (← Lean.findSysroot) initFiles
let env ←
importModules #[{module := `Mathlib},
{module:= `LeanAide.StructToLean},
{module:= `LeanCodePrompts.Translate},
{module := `Mathlib}] {}
let core : CoreM <| Option String := cubeCodeCore
let io? :=
core.run' {fileName := "", fileMap := {source:= "", positions := #[]}, maxHeartbeats := 100000000000, maxRecDepth := 1000000}
{env := env}
match ← io?.toIO' with
| Except.ok code? =>
IO.println "Success in running"
match code? with
| some code =>
IO.println "Code generated"
IO.println code
let outFile := "CodeGen/cubes.lean"
IO.FS.writeFile outFile code
| none =>
IO.println "No code generated"
| Except.error e =>
do
IO.println "Ran with error"
let msg ← e.toMessageData.toString
IO.println msg