forked from minchaowu/mm-lean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.m
22 lines (11 loc) · 1.45 KB
/
demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
OutputFormat[i_Integer] := "I[" <> ToString[i] <> "]"
OutputFormat[s_String] := "T[\"" <> s <> "\"]"
OutputFormat[s_Symbol] := "Y[" <> ToString[s] <> "]"
OutputFormat[h_[args___]] :=
"A" <> OutputFormat[h] <> "[" <>
StringRiffle[Map[OutputFormat, List[args]], ","] <> "]"
RunLeanTactic[x_, t_String, b_?BooleanQ]:=Module[{s,cmd}, s=OpenWrite["temp.lean", CharacterEncoding -> "UTF8"]; cmd=StringForm["run_cmd `1` \"`2`\" `3` >>= write_string",t,x // OutputFormat, If[b, "tt", "ff"]]; WriteString[s, "import demo", "\n", cmd]; Close[s];RunThrough["lean temp.lean", 0];ReadString["temp.txt"]];
RunLeanTactic[x_,t_]:=RunLeanTactic[x,t,False]
ProveUsingLeanTactic[x_, t_String, b_?BooleanQ] :=
Module[{s,cmd}, s=OpenWrite["temp.lean", CharacterEncoding -> "UTF8"]; cmd=StringForm["run_cmd prove_using_tac (`1`) \"`2`\" `3` >>= write_string",t,x // OutputFormat, If[b, "tt", "ff"]]; WriteString[s, "import demo", "\n", cmd]; Close[s];RunThrough["lean temp.lean", 0];ReadString["temp.txt"]];
ProveUsingLeanTactic[x_,t_] := ProveUsingLeanTactic[x,t,False]