lean-interact 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lean-interact
3
- Version: 0.3.2
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.18.0`.
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.18.0`.
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
 
@@ -2,7 +2,7 @@
2
2
  # requires-python = ">=3.10"
3
3
  # dependencies = [
4
4
  # "datasets",
5
- # "lean-interact @ file:///home/poiroux/Documents/EPFL/PhD/Lean/LeanInteract",
5
+ # "lean-interact",
6
6
  # "rich",
7
7
  # "tqdm",
8
8
  # "scikit-learn",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lean-interact"
3
- version = "0.3.2"
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" }
@@ -90,17 +90,17 @@ class LeanServer:
90
90
  assert self._proc is not None
91
91
  if verbose:
92
92
  logger.info("Sending query: %s", json_query)
93
- self._proc.sendline(json_query)
94
- self._proc.sendline()
95
- _ = 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)
96
95
  return self._proc.before or ""
97
96
 
98
97
  def _parse_repl_output(self, raw_output: str, verbose: bool) -> dict:
99
98
  """Clean up raw REPL output and parse JSON response."""
99
+ if verbose:
100
+ logger.info("Server raw output: `%s", raw_output)
100
101
  output = raw_output.replace("\r\n", "\n")
101
102
  output = output[output.find('{"') :] if '{"' in output else ""
102
103
  if verbose:
103
- logger.info("Server raw output: `%s", raw_output)
104
104
  logger.info("Server cleaned output: `%s", output)
105
105
  try:
106
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.4"
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,11 +404,21 @@ 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
+
414
416
  def test_run_lots_of_commands(self):
417
+ # Test this issue: https://github.com/leanprover-community/repl/issues/77
415
418
  server = LeanServer(LeanREPLConfig(verbose=True))
416
419
 
417
420
  init_env = server.run(Command(cmd="#eval 1"))
418
- assert isinstance(init_env, CommandResponse)
421
+ assert not isinstance(init_env, LeanError)
419
422
  for i in range(1000):
420
423
  cmd = Command(
421
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
File without changes
File without changes
File without changes