lean-interact 0.3.0__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lean_interact-0.3.0 → lean_interact-0.3.2}/PKG-INFO +1 -1
- {lean_interact-0.3.0 → lean_interact-0.3.2}/pyproject.toml +1 -1
- {lean_interact-0.3.0 → lean_interact-0.3.2}/src/lean_interact/server.py +4 -2
- {lean_interact-0.3.0 → lean_interact-0.3.2}/tests/test_server.py +19 -7
- {lean_interact-0.3.0 → lean_interact-0.3.2}/uv.lock +1 -1
- {lean_interact-0.3.0 → lean_interact-0.3.2}/.devcontainer/devcontainer.json +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/.github/workflows/ci.yml +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/.github/workflows/publish-to-pypi.yml +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/.gitignore +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/LICENSE +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/README.md +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/examples/beq_plus.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/examples/proof_generation_and_autoformalization.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/examples/type_check.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/src/lean_interact/__init__.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/src/lean_interact/config.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/src/lean_interact/interface.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/src/lean_interact/utils.py +0 -0
- {lean_interact-0.3.0 → lean_interact-0.3.2}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "lean-interact"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.2"
|
|
4
4
|
description = "LeanInteract is a Python package that allows you to interact with the Lean theorem prover."
|
|
5
5
|
keywords = ["Lean", "theorem proving", "autoformalization", "REPL"]
|
|
6
6
|
license = { file = "LICENSE" }
|
|
@@ -64,9 +64,10 @@ class LeanServer:
|
|
|
64
64
|
echo=False,
|
|
65
65
|
preexec_fn=lambda: _limit_memory(self.config.memory_hard_limit_mb),
|
|
66
66
|
)
|
|
67
|
+
self._proc.delaybeforesend = None
|
|
67
68
|
# `stty -icanon` is required to handle arbitrary long inputs in the Lean REPL
|
|
68
69
|
self._proc.sendline("stty -icanon")
|
|
69
|
-
self._proc.sendline(f"lake env {self.config._cache_repl_dir}/.lake/build/bin/repl")
|
|
70
|
+
self._proc.sendline(f"lake env {self.config._cache_repl_dir}/.lake/build/bin/repl || exit")
|
|
70
71
|
|
|
71
72
|
def is_alive(self) -> bool:
|
|
72
73
|
return hasattr(self, "_proc") and self._proc is not None and self._proc.isalive()
|
|
@@ -131,8 +132,9 @@ class LeanServer:
|
|
|
131
132
|
self.kill()
|
|
132
133
|
raise ConnectionAbortedError(
|
|
133
134
|
"The Lean server closed unexpectedly. Possible reasons (not exhaustive):\n"
|
|
135
|
+
"- An uncaught exception in the Lean REPL (for example, an unexistent file has been requested)\n"
|
|
134
136
|
"- Not enough memory and/or compute available\n"
|
|
135
|
-
"-
|
|
137
|
+
"- The cached Lean REPL is corrupted. In this case, clear the cache"
|
|
136
138
|
" using the `clear_cache` (`from pyleanrepl import clear_cache`) method."
|
|
137
139
|
) from e
|
|
138
140
|
|
|
@@ -411,6 +411,18 @@ class TestLeanServer(unittest.TestCase):
|
|
|
411
411
|
step2 = server.run(ProofStep(tactic="rfl", proof_state=step1.proof_state))
|
|
412
412
|
self.assertEqual(step2, ProofStepResponse(proof_state=2, goals=[]))
|
|
413
413
|
|
|
414
|
+
def test_run_lots_of_commands(self):
|
|
415
|
+
server = LeanServer(LeanREPLConfig(verbose=True))
|
|
416
|
+
|
|
417
|
+
init_env = server.run(Command(cmd="#eval 1"))
|
|
418
|
+
assert isinstance(init_env, CommandResponse)
|
|
419
|
+
for i in range(1000):
|
|
420
|
+
cmd = Command(
|
|
421
|
+
cmd=f"theorem womp{i} (a{i} b c : Nat) : (a{i} + b) + c = c + a{i} + b := by sorry", env=init_env.env
|
|
422
|
+
)
|
|
423
|
+
result = server.run(cmd)
|
|
424
|
+
self.assertIsInstance(result, CommandResponse)
|
|
425
|
+
|
|
414
426
|
def test_bug_increasing_memory(self):
|
|
415
427
|
mem_limit = 512
|
|
416
428
|
server = AutoLeanServer(config=LeanREPLConfig(memory_hard_limit_mb=mem_limit, verbose=True))
|
|
@@ -435,6 +447,8 @@ class TestLeanServer(unittest.TestCase):
|
|
|
435
447
|
result_queue.put(("success", result))
|
|
436
448
|
except TimeoutError as e:
|
|
437
449
|
result_queue.put(("timeout", e))
|
|
450
|
+
except ConnectionAbortedError as e:
|
|
451
|
+
result_queue.put(("connection_aborted", e)) # out of memory
|
|
438
452
|
except Exception as e:
|
|
439
453
|
result_queue.put(("error", e))
|
|
440
454
|
|
|
@@ -549,13 +563,11 @@ class TestLeanServer(unittest.TestCase):
|
|
|
549
563
|
# Try to unpickle invalid data
|
|
550
564
|
temp_pickle_file = tempfile.mkstemp(suffix=".olean")[1]
|
|
551
565
|
|
|
552
|
-
#
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
with self.assertRaises(TimeoutError):
|
|
558
|
-
server.run(UnpickleProofState(unpickle_proof_state_from=temp_pickle_file), timeout=5)
|
|
566
|
+
# Try to unpickle invalid data
|
|
567
|
+
with self.assertRaises(ConnectionAbortedError):
|
|
568
|
+
server.run(UnpickleEnvironment(unpickle_env_from=temp_pickle_file))
|
|
569
|
+
with self.assertRaises(ConnectionAbortedError):
|
|
570
|
+
server.run(UnpickleProofState(unpickle_proof_state_from=temp_pickle_file))
|
|
559
571
|
|
|
560
572
|
# delete the temp file
|
|
561
573
|
os.remove(temp_pickle_file)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lean_interact-0.3.0 → lean_interact-0.3.2}/examples/proof_generation_and_autoformalization.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|