forked from siddhartha-gadgil/LeanAide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnearest_embeddings_test.lean
43 lines (37 loc) · 1.32 KB
/
nearest_embeddings_test.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
39
40
41
42
43
import Lean
import Mathlib.Tactic
open Lean
def nearestEmbeddingsCmd : IO.Process.SpawnArgs := {
cmd := "lake",
args := #["exe", "nearest_embeddings_full"],
cwd := ".",
stdin := .piped,
stdout := .piped,
stderr := .piped
}
initialize nearestEmbeddingsProcessRef : IO.Ref
(Option <| IO.Process.Child nearestEmbeddingsCmd.toStdioConfig) ← IO.mkRef none
def getNearestEmbeddingsProcess : IO (IO.Process.Child nearestEmbeddingsCmd.toStdioConfig) := do
match ← nearestEmbeddingsProcessRef.get with
| some child => return child
| none =>
let child ← IO.Process.spawn nearestEmbeddingsCmd
nearestEmbeddingsProcessRef.set child
return child
def queryNearestEmbeddingsProcess (queries : Array String) : IO (Array String) := do
let child ← getNearestEmbeddingsProcess
let stdin := child.stdin
let mut outputs : Array String := #[]
for query in queries do
stdin.putStrLn query
stdin.flush
let out ← child.stdout.getLine
outputs := outputs.push out
return outputs
def statements := #[
"There are infinitely many odd numbers",
"Every vector space of dimension 2 is finite dimensional",
"Every subgroup of an Abelian group is Abelian"]
def main : IO Unit := timeit "nearest_embeddings_test" do
let results ← queryNearestEmbeddingsProcess statements
IO.println results