lean-interact 0.4.0__tar.gz → 0.5.0__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.
Files changed (21) hide show
  1. lean_interact-0.5.0/.github/workflows/ci.yml +62 -0
  2. {lean_interact-0.4.0 → lean_interact-0.5.0}/PKG-INFO +29 -13
  3. {lean_interact-0.4.0 → lean_interact-0.5.0}/README.md +27 -11
  4. {lean_interact-0.4.0 → lean_interact-0.5.0}/examples/proof_generation_and_autoformalization.py +1 -1
  5. {lean_interact-0.4.0 → lean_interact-0.5.0}/examples/type_check.py +1 -1
  6. {lean_interact-0.4.0 → lean_interact-0.5.0}/pyproject.toml +2 -2
  7. {lean_interact-0.4.0 → lean_interact-0.5.0}/src/lean_interact/config.py +169 -100
  8. {lean_interact-0.4.0 → lean_interact-0.5.0}/src/lean_interact/interface.py +4 -4
  9. {lean_interact-0.4.0 → lean_interact-0.5.0}/src/lean_interact/server.py +188 -67
  10. {lean_interact-0.4.0 → lean_interact-0.5.0}/src/lean_interact/utils.py +118 -35
  11. lean_interact-0.5.0/tests/test_concurrency.py +429 -0
  12. {lean_interact-0.4.0 → lean_interact-0.5.0}/tests/test_server.py +165 -83
  13. {lean_interact-0.4.0 → lean_interact-0.5.0}/uv.lock +12 -3
  14. lean_interact-0.4.0/.github/workflows/ci.yml +0 -29
  15. {lean_interact-0.4.0 → lean_interact-0.5.0}/.devcontainer/devcontainer.json +0 -0
  16. {lean_interact-0.4.0 → lean_interact-0.5.0}/.github/workflows/publish-to-pypi.yml +0 -0
  17. {lean_interact-0.4.0 → lean_interact-0.5.0}/.gitignore +0 -0
  18. {lean_interact-0.4.0 → lean_interact-0.5.0}/LICENSE +0 -0
  19. {lean_interact-0.4.0 → lean_interact-0.5.0}/examples/beq_plus.py +0 -0
  20. {lean_interact-0.4.0 → lean_interact-0.5.0}/src/lean_interact/__init__.py +0 -0
  21. {lean_interact-0.4.0 → lean_interact-0.5.0}/tests/test_utils.py +0 -0
@@ -0,0 +1,62 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: Test on ${{ matrix.os }}
8
+ runs-on: ${{ matrix.os }}
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os: [ubuntu-latest, macos-latest, windows-latest]
13
+ python-version: ['3.10']
14
+
15
+ steps:
16
+ - name: Configure Windows for long paths
17
+ if: runner.os == 'Windows'
18
+ shell: pwsh
19
+ run: |
20
+ # Enable long paths in registry
21
+ New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
22
+ # Configure Git for long paths
23
+ git config --system core.longpaths true
24
+
25
+ - name: Checkout
26
+ uses: actions/checkout@v3
27
+
28
+ - name: Set up Python ${{ matrix.python-version }}
29
+ uses: actions/setup-python@v4
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ - name: Install dependencies
34
+ run: |
35
+ python -m pip install --upgrade pip
36
+ python -m pip install .
37
+
38
+ - name: Install Lean (Linux/macOS)
39
+ if: runner.os != 'Windows'
40
+ run: |
41
+ install-lean
42
+ echo "$HOME/.elan/bin" >> $GITHUB_PATH
43
+
44
+ - name: Install Lean (Windows)
45
+ if: runner.os == 'Windows'
46
+ shell: pwsh
47
+ run: |
48
+ install-lean
49
+ echo "$env:USERPROFILE\.elan\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
50
+
51
+ - name: Run tests (Linux/macOS)
52
+ if: runner.os != 'Windows'
53
+ run: python -m unittest discover -s ./tests
54
+ env:
55
+ PYTHONIOENCODING: utf-8
56
+
57
+ - name: Run tests (Windows)
58
+ if: runner.os == 'Windows'
59
+ shell: pwsh
60
+ run: python -m unittest discover -s ./tests
61
+ env:
62
+ PYTHONIOENCODING: utf-8
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lean-interact
3
- Version: 0.4.0
3
+ Version: 0.5.0
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
@@ -27,8 +27,8 @@ License: MIT License
27
27
  License-File: LICENSE
28
28
  Keywords: Lean,REPL,autoformalization,theorem proving
29
29
  Requires-Python: >=3.10
30
+ Requires-Dist: filelock>=3.18.0
30
31
  Requires-Dist: gitpython>=3.1.44
31
- Requires-Dist: pexpect>=4.9.0
32
32
  Requires-Dist: psutil>=6.1.0
33
33
  Requires-Dist: pydantic>=2.11.1
34
34
  Requires-Dist: requests>=2.32.3
@@ -37,7 +37,8 @@ Description-Content-Type: text/markdown
37
37
 
38
38
  # LeanInteract
39
39
 
40
- [![PyPI version](https://badge.fury.io/py/lean-interact.svg)](https://badge.fury.io/py/lean-interact)
40
+ [![PyPI version](https://img.shields.io/pypi/v/lean-interact.svg)](https://pypi.org/project/lean-interact/)
41
+ [![PyPI downloads](https://img.shields.io/pepy/dt/lean-interact.svg)](https://pypi.org/project/lean-interact/)
41
42
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
42
43
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
43
44
 
@@ -47,6 +48,7 @@ Description-Content-Type: text/markdown
47
48
 
48
49
  - **🔗 Interactivity**: Execute Lean code and files directly from Python.
49
50
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
51
+ - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems.
50
52
  - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.19.0-rc2`.
51
53
  - We backport the latest features of Lean REPL to older versions of Lean.
52
54
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
@@ -97,11 +99,11 @@ Requirements:
97
99
 
98
100
  ## Script examples
99
101
 
100
- In the `examples` directory, you will find a few scripts demonstrating how to use LeanInteract.
102
+ In the [`examples`](examples) directory, you will find a few scripts demonstrating how to use LeanInteract.
101
103
 
102
- - `proof_generation_and_autoformalization.py`: use [DeepSeek-Prover-V1.5](https://arxiv.org/abs/2408.08152), [Goedel-Prover](https://goedel-lm.github.io/), and other models on [MiniF2F](https://github.com/yangky11/miniF2F-lean4) and [ProofNet#](https://huggingface.co/datasets/PAug/ProofNetSharp) benchmarks.
103
- - `beq_plus.py`: run the autoformalization [BEq+](https://arxiv.org/abs/2406.07222) metric on the [ProofNetVerif](https://huggingface.co/datasets/PAug/ProofNetVerif) benchmark.
104
- - `type_check.py`: optimize type checking using environment states.
104
+ - [`proof_generation_and_autoformalization.py`](examples/proof_generation_and_autoformalization.py): use [DeepSeek-Prover-V1.5](https://arxiv.org/abs/2408.08152), [Goedel-Prover](https://goedel-lm.github.io/), and other models on [MiniF2F](https://github.com/yangky11/miniF2F-lean4) and [ProofNet#](https://huggingface.co/datasets/PAug/ProofNetSharp) benchmarks.
105
+ - [`beq_plus.py`](examples/beq_plus.py): run the autoformalization [BEq+](https://arxiv.org/abs/2406.07222) metric on the [ProofNetVerif](https://huggingface.co/datasets/PAug/ProofNetVerif) benchmark.
106
+ - [`type_check.py`](examples/type_check.py): optimize type checking using environment states.
105
107
 
106
108
  ## Usage
107
109
 
@@ -334,7 +336,7 @@ CommandResponse(
334
336
 
335
337
  #### Fine-grained temporary project
336
338
 
337
- For more control over the temporary project, you can use `TemporaryProject` to specify the content of the lakefile.
339
+ For more control over the temporary project, you can use `TemporaryProject` to specify the content of the lakefile (`.lean` format).
338
340
 
339
341
  ```python
340
342
  from lean_interact import TemporaryProject
@@ -392,7 +394,7 @@ response = server.run(FileCommand(path="myfile.lean", root_goals=True))
392
394
 
393
395
  ### ProofStep
394
396
 
395
- Work with proof tactics step by step:
397
+ Work with proofs step by step using tactics:
396
398
 
397
399
  ```python
398
400
  from lean_interact import ProofStep
@@ -401,7 +403,7 @@ from lean_interact import ProofStep
401
403
  response = server.run(ProofStep(proof_state=0, tactic="intro h"))
402
404
 
403
405
  # Apply multiple tactics at once
404
- response = server.run(ProofStep(proof_state=0, tactic="intro h\nexact h"))
406
+ response = server.run(ProofStep(proof_state=0, tactic="(\nintro h\nexact h)"))
405
407
  ```
406
408
 
407
409
  ### Environment Pickling
@@ -479,6 +481,22 @@ Common issues and their solutions:
479
481
 
480
482
  3. **Long waiting times during first run**: This is expected as Lean REPL is being downloaded and built. Additionally, if you are importing Mathlib it will take even more time. Subsequent runs will be much faster.
481
483
 
484
+ 4. **(Windows) Path too long error**: Windows has a maximum path length limitation of 260 characters.
485
+ If you get an error similar to the following one, you are likely affected by this problem:
486
+
487
+ ```
488
+ error: external command 'git' exited with code 128
489
+ ERROR Failed during Lean project setup: Command '['lake', 'update']' returned non-zero exit status 1.
490
+ ```
491
+
492
+ To resolve this, you can enable long paths in Windows 10 and later versions. For more information, refer to the [Microsoft documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation).
493
+ Alternatively, run the following command in a terminal with administrator privileges:
494
+
495
+ ```bash
496
+ New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -Value 1 -PropertyType DWord -Force
497
+ git config --system core.longpaths true
498
+ ```
499
+
482
500
  ## Contributing
483
501
 
484
502
  Contributions are welcome! Here's how you can help:
@@ -489,15 +507,13 @@ Contributions are welcome! Here's how you can help:
489
507
  4. Push to the branch: `git push origin feature-name`
490
508
  5. Submit a pull request
491
509
 
492
- Please ensure your code includes appropriate tests.
493
-
494
510
  ## Citation
495
511
 
496
512
  If you use LeanInteract in your research, please cite it as follows:
497
513
 
498
514
  ```bibtex
499
515
  @software{leaninteract,
500
- author = {Poiroux, Auguste},
516
+ author = {Poiroux, Auguste and Kuncak, Viktor and Bosselut, Antoine},
501
517
  title = {LeanInteract: A Python Interface for Lean 4},
502
518
  url = {https://github.com/augustepoiroux/lean-interact},
503
519
  year = {2025}
@@ -1,6 +1,7 @@
1
1
  # LeanInteract
2
2
 
3
- [![PyPI version](https://badge.fury.io/py/lean-interact.svg)](https://badge.fury.io/py/lean-interact)
3
+ [![PyPI version](https://img.shields.io/pypi/v/lean-interact.svg)](https://pypi.org/project/lean-interact/)
4
+ [![PyPI downloads](https://img.shields.io/pepy/dt/lean-interact.svg)](https://pypi.org/project/lean-interact/)
4
5
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
5
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
 
@@ -10,6 +11,7 @@
10
11
 
11
12
  - **🔗 Interactivity**: Execute Lean code and files directly from Python.
12
13
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
14
+ - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems.
13
15
  - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.19.0-rc2`.
14
16
  - We backport the latest features of Lean REPL to older versions of Lean.
15
17
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
@@ -60,11 +62,11 @@ Requirements:
60
62
 
61
63
  ## Script examples
62
64
 
63
- In the `examples` directory, you will find a few scripts demonstrating how to use LeanInteract.
65
+ In the [`examples`](examples) directory, you will find a few scripts demonstrating how to use LeanInteract.
64
66
 
65
- - `proof_generation_and_autoformalization.py`: use [DeepSeek-Prover-V1.5](https://arxiv.org/abs/2408.08152), [Goedel-Prover](https://goedel-lm.github.io/), and other models on [MiniF2F](https://github.com/yangky11/miniF2F-lean4) and [ProofNet#](https://huggingface.co/datasets/PAug/ProofNetSharp) benchmarks.
66
- - `beq_plus.py`: run the autoformalization [BEq+](https://arxiv.org/abs/2406.07222) metric on the [ProofNetVerif](https://huggingface.co/datasets/PAug/ProofNetVerif) benchmark.
67
- - `type_check.py`: optimize type checking using environment states.
67
+ - [`proof_generation_and_autoformalization.py`](examples/proof_generation_and_autoformalization.py): use [DeepSeek-Prover-V1.5](https://arxiv.org/abs/2408.08152), [Goedel-Prover](https://goedel-lm.github.io/), and other models on [MiniF2F](https://github.com/yangky11/miniF2F-lean4) and [ProofNet#](https://huggingface.co/datasets/PAug/ProofNetSharp) benchmarks.
68
+ - [`beq_plus.py`](examples/beq_plus.py): run the autoformalization [BEq+](https://arxiv.org/abs/2406.07222) metric on the [ProofNetVerif](https://huggingface.co/datasets/PAug/ProofNetVerif) benchmark.
69
+ - [`type_check.py`](examples/type_check.py): optimize type checking using environment states.
68
70
 
69
71
  ## Usage
70
72
 
@@ -297,7 +299,7 @@ CommandResponse(
297
299
 
298
300
  #### Fine-grained temporary project
299
301
 
300
- For more control over the temporary project, you can use `TemporaryProject` to specify the content of the lakefile.
302
+ For more control over the temporary project, you can use `TemporaryProject` to specify the content of the lakefile (`.lean` format).
301
303
 
302
304
  ```python
303
305
  from lean_interact import TemporaryProject
@@ -355,7 +357,7 @@ response = server.run(FileCommand(path="myfile.lean", root_goals=True))
355
357
 
356
358
  ### ProofStep
357
359
 
358
- Work with proof tactics step by step:
360
+ Work with proofs step by step using tactics:
359
361
 
360
362
  ```python
361
363
  from lean_interact import ProofStep
@@ -364,7 +366,7 @@ from lean_interact import ProofStep
364
366
  response = server.run(ProofStep(proof_state=0, tactic="intro h"))
365
367
 
366
368
  # Apply multiple tactics at once
367
- response = server.run(ProofStep(proof_state=0, tactic="intro h\nexact h"))
369
+ response = server.run(ProofStep(proof_state=0, tactic="(\nintro h\nexact h)"))
368
370
  ```
369
371
 
370
372
  ### Environment Pickling
@@ -442,6 +444,22 @@ Common issues and their solutions:
442
444
 
443
445
  3. **Long waiting times during first run**: This is expected as Lean REPL is being downloaded and built. Additionally, if you are importing Mathlib it will take even more time. Subsequent runs will be much faster.
444
446
 
447
+ 4. **(Windows) Path too long error**: Windows has a maximum path length limitation of 260 characters.
448
+ If you get an error similar to the following one, you are likely affected by this problem:
449
+
450
+ ```
451
+ error: external command 'git' exited with code 128
452
+ ERROR Failed during Lean project setup: Command '['lake', 'update']' returned non-zero exit status 1.
453
+ ```
454
+
455
+ To resolve this, you can enable long paths in Windows 10 and later versions. For more information, refer to the [Microsoft documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation).
456
+ Alternatively, run the following command in a terminal with administrator privileges:
457
+
458
+ ```bash
459
+ New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -Value 1 -PropertyType DWord -Force
460
+ git config --system core.longpaths true
461
+ ```
462
+
445
463
  ## Contributing
446
464
 
447
465
  Contributions are welcome! Here's how you can help:
@@ -452,15 +470,13 @@ Contributions are welcome! Here's how you can help:
452
470
  4. Push to the branch: `git push origin feature-name`
453
471
  5. Submit a pull request
454
472
 
455
- Please ensure your code includes appropriate tests.
456
-
457
473
  ## Citation
458
474
 
459
475
  If you use LeanInteract in your research, please cite it as follows:
460
476
 
461
477
  ```bibtex
462
478
  @software{leaninteract,
463
- author = {Poiroux, Auguste},
479
+ author = {Poiroux, Auguste and Kuncak, Viktor and Bosselut, Antoine},
464
480
  title = {LeanInteract: A Python Interface for Lean 4},
465
481
  url = {https://github.com/augustepoiroux/lean-interact},
466
482
  year = {2025}
@@ -97,7 +97,7 @@ def load_proofnetsharp_dataset(split: Literal["valid", "test"] = "valid") -> lis
97
97
 
98
98
  def check_context_proofs(args: tuple[int, LeanREPLConfig, int, tuple[str, str, list[str]]]) -> tuple[int, str | None]:
99
99
  """
100
- Filter function to check if at least one proof is valid for a given context and formalization.
100
+ Filter function to check if at least one proof is valid for a given context and declaration to prove.
101
101
  """
102
102
  idx, repl_config, timeout_per_proof, context_proofs = args
103
103
  context_code, formalization_code, proofs = context_proofs
@@ -9,7 +9,7 @@
9
9
  # ///
10
10
  """
11
11
  This module provides functions to type-check Lean formalizations
12
- using sequential, parallel, and optimized batch methods.
12
+ using sequential and optimized batch methods.
13
13
  """
14
14
 
15
15
  import json
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "lean-interact"
3
- version = "0.4.0"
3
+ version = "0.5.0"
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" }
@@ -8,8 +8,8 @@ readme = "README.md"
8
8
  authors = [{ name = "Auguste Poiroux", email = "auguste.poiroux@epfl.ch" }]
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
11
+ "filelock>=3.18.0",
11
12
  "gitpython>=3.1.44",
12
- "pexpect>=4.9.0",
13
13
  "psutil>=6.1.0",
14
14
  "pydantic>=2.11.1",
15
15
  "requests>=2.32.3",