lean-interact 0.3.1__tar.gz → 0.3.3__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.1 → lean_interact-0.3.3}/PKG-INFO +2 -2
- {lean_interact-0.3.1 → lean_interact-0.3.3}/README.md +1 -1
- {lean_interact-0.3.1 → lean_interact-0.3.3}/examples/beq_plus.py +1 -1
- {lean_interact-0.3.1 → lean_interact-0.3.3}/pyproject.toml +1 -1
- {lean_interact-0.3.1 → lean_interact-0.3.3}/src/lean_interact/server.py +5 -4
- {lean_interact-0.3.1 → lean_interact-0.3.3}/src/lean_interact/utils.py +1 -1
- {lean_interact-0.3.1 → lean_interact-0.3.3}/tests/test_server.py +24 -7
- {lean_interact-0.3.1 → lean_interact-0.3.3}/uv.lock +1 -1
- {lean_interact-0.3.1 → lean_interact-0.3.3}/.devcontainer/devcontainer.json +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/.github/workflows/ci.yml +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/.github/workflows/publish-to-pypi.yml +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/.gitignore +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/LICENSE +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/examples/proof_generation_and_autoformalization.py +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/examples/type_check.py +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/src/lean_interact/__init__.py +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/src/lean_interact/config.py +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/src/lean_interact/interface.py +0 -0
- {lean_interact-0.3.1 → lean_interact-0.3.3}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lean-interact
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: LeanInteract is a Python package that allows you to interact with the Lean theorem prover.
|
|
5
5
|
Author-email: Auguste Poiroux <auguste.poiroux@epfl.ch>
|
|
6
6
|
License: MIT License
|
|
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
|
|
|
43
43
|
|
|
44
44
|
- **🔗 Interactivity**: Execute Lean code and files directly from Python.
|
|
45
45
|
- **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
|
|
46
|
-
- **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.
|
|
46
|
+
- **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.19.0-rc2`.
|
|
47
47
|
- **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
|
|
48
48
|
- Useful for experimenting with benchmarks depending on [Mathlib](https://github.com/leanprover-community/mathlib4) like [ProofNet#](https://huggingface.co/datasets/PAug/ProofNetSharp) and [MiniF2F](https://github.com/yangky11/miniF2F-lean4).
|
|
49
49
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- **🔗 Interactivity**: Execute Lean code and files directly from Python.
|
|
8
8
|
- **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
|
|
9
|
-
- **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.
|
|
9
|
+
- **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.19.0-rc2`.
|
|
10
10
|
- **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
|
|
11
11
|
- Useful for experimenting with benchmarks depending on [Mathlib](https://github.com/leanprover-community/mathlib4) like [ProofNet#](https://huggingface.co/datasets/PAug/ProofNetSharp) and [MiniF2F](https://github.com/yangky11/miniF2F-lean4).
|
|
12
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "lean-interact"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.3"
|
|
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,6 +64,7 @@ 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
70
|
self._proc.sendline(f"lake env {self.config._cache_repl_dir}/.lake/build/bin/repl || exit")
|
|
@@ -89,17 +90,17 @@ class LeanServer:
|
|
|
89
90
|
assert self._proc is not None
|
|
90
91
|
if verbose:
|
|
91
92
|
logger.info("Sending query: %s", json_query)
|
|
92
|
-
self._proc.
|
|
93
|
-
self._proc.
|
|
94
|
-
_ = self._proc.expect_exact("\r\n\r\n", timeout=timeout)
|
|
93
|
+
self._proc.send(json_query + "\n\n")
|
|
94
|
+
self._proc.expect_exact("\r\n\r\n", timeout=timeout)
|
|
95
95
|
return self._proc.before or ""
|
|
96
96
|
|
|
97
97
|
def _parse_repl_output(self, raw_output: str, verbose: bool) -> dict:
|
|
98
98
|
"""Clean up raw REPL output and parse JSON response."""
|
|
99
|
+
if verbose:
|
|
100
|
+
logger.info("Server raw output: `%s", raw_output)
|
|
99
101
|
output = raw_output.replace("\r\n", "\n")
|
|
100
102
|
output = output[output.find('{"') :] if '{"' in output else ""
|
|
101
103
|
if verbose:
|
|
102
|
-
logger.info("Server raw output: `%s", raw_output)
|
|
103
104
|
logger.info("Server cleaned output: `%s", output)
|
|
104
105
|
try:
|
|
105
106
|
return json.loads(output)
|
|
@@ -21,7 +21,7 @@ logger.addHandler(handler)
|
|
|
21
21
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
22
22
|
DEFAULT_CACHE_DIR = os.path.join(ROOT_DIR, "cache")
|
|
23
23
|
DEFAULT_REPL_GIT_URL = "https://github.com/augustepoiroux/repl"
|
|
24
|
-
DEFAULT_REPL_VERSION = "v1.0.
|
|
24
|
+
DEFAULT_REPL_VERSION = "v1.0.5"
|
|
25
25
|
|
|
26
26
|
os.makedirs(DEFAULT_CACHE_DIR, exist_ok=True)
|
|
27
27
|
|
|
@@ -199,13 +199,6 @@ class TestLeanServer(unittest.TestCase):
|
|
|
199
199
|
result = server.run(ProofStep(tactic="rfl", proof_state=0))
|
|
200
200
|
self.assertEqual(result, ProofStepResponse(proof_state=1, goals=[]))
|
|
201
201
|
|
|
202
|
-
def test_run_multiple_commands(self):
|
|
203
|
-
server = AutoLeanServer(config=LeanREPLConfig(memory_hard_limit_mb=4096, verbose=True))
|
|
204
|
-
|
|
205
|
-
for i in range(100):
|
|
206
|
-
cmd = Command(cmd=f"theorem womp{i} (a{i} b c : Nat) : (a{i} + b) + c = c + a{i} + b := by sorry")
|
|
207
|
-
server.run(cmd)
|
|
208
|
-
|
|
209
202
|
def test_lean_version(self):
|
|
210
203
|
server = AutoLeanServer(config=LeanREPLConfig(lean_version="v4.14.0", verbose=True))
|
|
211
204
|
result = server.run(Command(cmd="#eval Lean.versionString"))
|
|
@@ -411,6 +404,28 @@ class TestLeanServer(unittest.TestCase):
|
|
|
411
404
|
step2 = server.run(ProofStep(tactic="rfl", proof_state=step1.proof_state))
|
|
412
405
|
self.assertEqual(step2, ProofStepResponse(proof_state=2, goals=[]))
|
|
413
406
|
|
|
407
|
+
def test_run_multiple_commands(self):
|
|
408
|
+
# Test this issue: https://github.com/leanprover-community/repl/issues/77
|
|
409
|
+
server = AutoLeanServer(config=LeanREPLConfig(memory_hard_limit_mb=4096, verbose=True))
|
|
410
|
+
|
|
411
|
+
with self.assertRaises(ConnectionAbortedError):
|
|
412
|
+
for i in range(1000):
|
|
413
|
+
cmd = Command(cmd=f"theorem womp{i} (a{i} b c : Nat) : (a{i} + b) + c = c + a{i} + b := by sorry")
|
|
414
|
+
server.run(cmd)
|
|
415
|
+
|
|
416
|
+
def test_run_lots_of_commands(self):
|
|
417
|
+
# Test this issue: https://github.com/leanprover-community/repl/issues/77
|
|
418
|
+
server = LeanServer(LeanREPLConfig(verbose=True))
|
|
419
|
+
|
|
420
|
+
init_env = server.run(Command(cmd="#eval 1"))
|
|
421
|
+
assert not isinstance(init_env, LeanError)
|
|
422
|
+
for i in range(1000):
|
|
423
|
+
cmd = Command(
|
|
424
|
+
cmd=f"theorem womp{i} (a{i} b c : Nat) : (a{i} + b) + c = c + a{i} + b := by sorry", env=init_env.env
|
|
425
|
+
)
|
|
426
|
+
result = server.run(cmd)
|
|
427
|
+
self.assertIsInstance(result, CommandResponse)
|
|
428
|
+
|
|
414
429
|
def test_bug_increasing_memory(self):
|
|
415
430
|
mem_limit = 512
|
|
416
431
|
server = AutoLeanServer(config=LeanREPLConfig(memory_hard_limit_mb=mem_limit, verbose=True))
|
|
@@ -435,6 +450,8 @@ class TestLeanServer(unittest.TestCase):
|
|
|
435
450
|
result_queue.put(("success", result))
|
|
436
451
|
except TimeoutError as e:
|
|
437
452
|
result_queue.put(("timeout", e))
|
|
453
|
+
except ConnectionAbortedError as e:
|
|
454
|
+
result_queue.put(("connection_aborted", e)) # out of memory
|
|
438
455
|
except Exception as e:
|
|
439
456
|
result_queue.put(("error", e))
|
|
440
457
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lean_interact-0.3.1 → lean_interact-0.3.3}/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
|