lean-interact 0.5.2__tar.gz → 0.6.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 (41) hide show
  1. {lean_interact-0.5.2 → lean_interact-0.6.0}/.github/workflows/ci.yml +6 -2
  2. lean_interact-0.6.0/.github/workflows/docs.yml +70 -0
  3. lean_interact-0.6.0/.github/workflows/update-changelog.yml +55 -0
  4. {lean_interact-0.5.2 → lean_interact-0.6.0}/.gitignore +3 -0
  5. {lean_interact-0.5.2 → lean_interact-0.6.0}/PKG-INFO +29 -6
  6. {lean_interact-0.5.2 → lean_interact-0.6.0}/README.md +27 -5
  7. lean_interact-0.6.0/docs/.nojekyll +0 -0
  8. lean_interact-0.6.0/docs/api/config.md +90 -0
  9. lean_interact-0.6.0/docs/api/interface.md +121 -0
  10. lean_interact-0.6.0/docs/api/server.md +34 -0
  11. lean_interact-0.6.0/docs/api/sessioncache.md +52 -0
  12. lean_interact-0.6.0/docs/api/utils.md +98 -0
  13. lean_interact-0.6.0/docs/changelog.md +65 -0
  14. lean_interact-0.6.0/docs/contributing.md +72 -0
  15. lean_interact-0.6.0/docs/examples.md +90 -0
  16. lean_interact-0.6.0/docs/index.md +49 -0
  17. lean_interact-0.6.0/docs/installation.md +93 -0
  18. lean_interact-0.6.0/docs/troubleshooting.md +155 -0
  19. lean_interact-0.6.0/docs/user-guide/basic-usage.md +111 -0
  20. lean_interact-0.6.0/docs/user-guide/custom-lean-configuration.md +166 -0
  21. lean_interact-0.6.0/docs/user-guide/getting-started.md +97 -0
  22. lean_interact-0.6.0/docs/user-guide/tactic-mode.md +137 -0
  23. {lean_interact-0.5.2 → lean_interact-0.6.0}/examples/proof_generation_and_autoformalization.py +15 -12
  24. lean_interact-0.6.0/mkdocs.yml +129 -0
  25. {lean_interact-0.5.2 → lean_interact-0.6.0}/pyproject.toml +11 -3
  26. {lean_interact-0.5.2 → lean_interact-0.6.0}/src/lean_interact/__init__.py +1 -0
  27. lean_interact-0.6.0/src/lean_interact/config.py +567 -0
  28. {lean_interact-0.5.2 → lean_interact-0.6.0}/src/lean_interact/interface.py +5 -1
  29. {lean_interact-0.5.2 → lean_interact-0.6.0}/src/lean_interact/server.py +36 -116
  30. lean_interact-0.6.0/src/lean_interact/sessioncache.py +203 -0
  31. {lean_interact-0.5.2 → lean_interact-0.6.0}/src/lean_interact/utils.py +14 -14
  32. {lean_interact-0.5.2 → lean_interact-0.6.0}/tests/test_concurrency.py +10 -6
  33. {lean_interact-0.5.2 → lean_interact-0.6.0}/tests/test_server.py +40 -11
  34. {lean_interact-0.5.2 → lean_interact-0.6.0}/uv.lock +822 -2
  35. lean_interact-0.5.2/src/lean_interact/config.py +0 -412
  36. {lean_interact-0.5.2 → lean_interact-0.6.0}/.devcontainer/devcontainer.json +0 -0
  37. {lean_interact-0.5.2 → lean_interact-0.6.0}/.github/workflows/publish-to-pypi.yml +0 -0
  38. {lean_interact-0.5.2 → lean_interact-0.6.0}/LICENSE +0 -0
  39. {lean_interact-0.5.2 → lean_interact-0.6.0}/examples/beq_plus.py +0 -0
  40. {lean_interact-0.5.2 → lean_interact-0.6.0}/examples/type_check.py +0 -0
  41. {lean_interact-0.5.2 → lean_interact-0.6.0}/tests/test_utils.py +0 -0
@@ -32,8 +32,8 @@ jobs:
32
32
 
33
33
  - name: Install dependencies
34
34
  run: |
35
- python -m pip install --upgrade pip
36
- python -m pip install .
35
+ pip install --upgrade pip
36
+ pip install . --group dev
37
37
 
38
38
  - name: Install Lean (Linux/macOS)
39
39
  if: runner.os != 'Windows'
@@ -60,3 +60,7 @@ jobs:
60
60
  run: python -m unittest discover -s ./tests
61
61
  env:
62
62
  PYTHONIOENCODING: utf-8
63
+
64
+ - name: Build documentation
65
+ if: runner.os == 'Linux'
66
+ run: mkdocs build
@@ -0,0 +1,70 @@
1
+ name: Deploy Documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main # Default branch
7
+ - docs-test # Test branch for documentation
8
+ paths:
9
+ - 'docs/**'
10
+ - 'mkdocs.yml'
11
+ - 'src/lean_interact/**'
12
+ - '.github/workflows/docs.yml'
13
+ workflow_dispatch:
14
+
15
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16
+ permissions:
17
+ contents: read
18
+ pages: write
19
+ id-token: write
20
+
21
+ # Allow only one concurrent deployment
22
+ concurrency:
23
+ group: 'pages'
24
+ cancel-in-progress: false
25
+
26
+ jobs:
27
+ build:
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - name: Checkout
31
+ uses: actions/checkout@v4
32
+
33
+ - name: Setup Python
34
+ uses: actions/setup-python@v5
35
+ with:
36
+ python-version: '3.10'
37
+ cache: 'pip'
38
+
39
+ - name: Install dependencies
40
+ run: |
41
+ pip install --upgrade pip
42
+ pip install . --group dev
43
+
44
+ - name: Install Lean
45
+ run: |
46
+ install-lean
47
+ echo "$HOME/.elan/bin" >> $GITHUB_PATH
48
+
49
+ - name: Build documentation
50
+ run: mkdocs build
51
+
52
+ - name: Setup Pages
53
+ uses: actions/configure-pages@v4
54
+
55
+ - name: Upload artifact
56
+ uses: actions/upload-pages-artifact@v3
57
+ with:
58
+ path: './site'
59
+
60
+ deploy:
61
+ if: github.ref == 'refs/heads/main'
62
+ environment:
63
+ name: github-pages
64
+ url: ${{ steps.deployment.outputs.page_url }}
65
+ runs-on: ubuntu-latest
66
+ needs: build
67
+ steps:
68
+ - name: Deploy to GitHub Pages
69
+ id: deployment
70
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,55 @@
1
+ name: Update Changelog
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ update-changelog:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: write
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: '3.10'
20
+
21
+ - name: Update Changelog
22
+ run: |
23
+ # Get the release information
24
+ RELEASE_TAG="${{ github.event.release.tag_name }}"
25
+ RELEASE_NAME="${{ github.event.release.name }}"
26
+ RELEASE_BODY="${{ github.event.release.body }}"
27
+ RELEASE_DATE=$(date +"%B %d, %Y")
28
+
29
+ # Prepare the content to insert
30
+ CHANGELOG_ENTRY="## ${RELEASE_NAME} (${RELEASE_DATE})\n\n${RELEASE_BODY}\n\n"
31
+
32
+ # Check if changelog file exists
33
+ if [ ! -f "docs/changelog.md" ]; then
34
+ echo "# Changelog\n\nThis page documents the notable changes to LeanInteract.\n\n" > docs/changelog.md
35
+ fi
36
+
37
+ # Insert the new release notes after the header
38
+ awk -v entry="${CHANGELOG_ENTRY}" '
39
+ /^# Changelog/ {
40
+ print;
41
+ getline;
42
+ print;
43
+ print entry;
44
+ next;
45
+ }
46
+ { print }
47
+ ' docs/changelog.md > changelog.tmp && mv changelog.tmp docs/changelog.md
48
+
49
+ - name: Commit and push changelog
50
+ run: |
51
+ git config --local user.email "action@github.com"
52
+ git config --local user.name "GitHub Action"
53
+ git add docs/changelog.md
54
+ git commit -m "Update changelog with ${{ github.event.release.tag_name }} release notes"
55
+ git push origin ${GITHUB_REF_NAME}
@@ -12,3 +12,6 @@ __pycache__
12
12
 
13
13
  sandbox*
14
14
  .vscode
15
+
16
+ # Doc build
17
+ site
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lean-interact
3
- Version: 0.5.2
3
+ Version: 0.6.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
@@ -29,6 +29,7 @@ Keywords: Lean,REPL,autoformalization,theorem proving
29
29
  Requires-Python: >=3.10
30
30
  Requires-Dist: filelock>=3.18.0
31
31
  Requires-Dist: gitpython>=3.1.44
32
+ Requires-Dist: packaging>=24.2
32
33
  Requires-Dist: psutil>=6.1.0
33
34
  Requires-Dist: pydantic>=2.11.1
34
35
  Requires-Dist: requests>=2.32.3
@@ -37,6 +38,7 @@ Description-Content-Type: text/markdown
37
38
 
38
39
  # LeanInteract
39
40
 
41
+ [![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://augustepoiroux.github.io/LeanInteract/)
40
42
  [![PyPI version](https://img.shields.io/pypi/v/lean-interact.svg)](https://pypi.org/project/lean-interact/)
41
43
  [![PyPI downloads](https://img.shields.io/pepy/dt/lean-interact.svg)](https://pypi.org/project/lean-interact/)
42
44
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
@@ -49,7 +51,7 @@ Description-Content-Type: text/markdown
49
51
  - **🔗 Interactivity**: Execute Lean code and files directly from Python.
50
52
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
51
53
  - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems.
52
- - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.19.0`.
54
+ - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.21.0-rc3`.
53
55
  - We backport the latest features of Lean REPL to older versions of Lean.
54
56
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
55
57
  - 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).
@@ -95,7 +97,9 @@ Requirements:
95
97
 
96
98
  - Python >= 3.10
97
99
  - git
98
- - [Lean 4](https://leanprover-community.github.io/get_started.html) (Tip: use the `install-lean` command from LeanInteract)
100
+ - [Lean 4](https://leanprover-community.github.io/get_started.html)
101
+ - **Tip:** use the cross-platform `install-lean` command from LeanInteract.
102
+ - Your `elan` version should be at least `4.0.0` (`elan --version`).
99
103
 
100
104
  ## Script examples
101
105
 
@@ -107,6 +111,8 @@ In the [`examples`](examples) directory, you will find a few scripts demonstrati
107
111
 
108
112
  ## Usage
109
113
 
114
+ Full documentation is available [here](https://augustepoiroux.github.io/LeanInteract/).
115
+
110
116
  ### Basic example
111
117
 
112
118
  The following code will use the default Lean version (latest available):
@@ -458,7 +464,22 @@ Two versions of Lean servers are available:
458
464
 
459
465
  ### Custom Lean REPL
460
466
 
461
- To use a forked Lean REPL project, specify the git repository using the `repl_git` parameter in the `LeanREPLConfig`. Your fork should have a similar versioning format to <https://github.com/augustepoiroux/repl> (i.e. having a branch with commits for each Lean version). For assistance, feel free to contact [us](mailto:auguste.poiroux@epfl.ch).
467
+ To use a forked Lean REPL project, specify the git repository using the `repl_git` parameter in the `LeanREPLConfig` and the target revision using the `repl_rev` parameter. For example:
468
+
469
+ ```python
470
+ config = LeanREPLConfig(repl_rev="v4.21.0-rc3", repl_git="https://github.com/leanprover-community/repl", verbose=True)
471
+ ```
472
+
473
+ > [!WARNING]
474
+ >
475
+ > Custom REPL implementations may have interfaces that are incompatible with LeanInteract's standard commands. If you encounter incompatibility issues, you can use the `run_dict` method from `LeanServer` to communicate directly with the REPL using the raw JSON protocol:
476
+ >
477
+ > ```python
478
+ > # Using run_dict instead of the standard commands
479
+ > result = server.run_dict({"cmd": "your_command_here"})
480
+ > ```
481
+
482
+ For assistance, feel free to contact [us](mailto:auguste.poiroux@epfl.ch).
462
483
 
463
484
  ## Similar tools
464
485
 
@@ -481,7 +502,9 @@ Common issues and their solutions:
481
502
 
482
503
  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.
483
504
 
484
- 4. **(Windows) Path too long error**: Windows has a maximum path length limitation of 260 characters.
505
+ 4. **`Failed during Lean project setup: Command '['lake', 'update']' returned non-zero exit status 1.`**: This error may occur if your `elan` version is outdated (i.e. < 4.0.0). To resolve this, update `elan` using `elan self update` or read the documentation [here](https://leanprover-community.github.io/get_started.html).
506
+
507
+ 5. **(Windows) Path too long error**: Windows has a maximum path length limitation of 260 characters.
485
508
  If you get an error similar to the following one, you are likely affected by this problem:
486
509
 
487
510
  ```
@@ -515,7 +538,7 @@ If you use LeanInteract in your research, please cite it as follows:
515
538
  @software{leaninteract,
516
539
  author = {Poiroux, Auguste and Kuncak, Viktor and Bosselut, Antoine},
517
540
  title = {LeanInteract: A Python Interface for Lean 4},
518
- url = {https://github.com/augustepoiroux/lean-interact},
541
+ url = {https://github.com/augustepoiroux/LeanInteract},
519
542
  year = {2025}
520
543
  }
521
544
  ```
@@ -1,5 +1,6 @@
1
1
  # LeanInteract
2
2
 
3
+ [![Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://augustepoiroux.github.io/LeanInteract/)
3
4
  [![PyPI version](https://img.shields.io/pypi/v/lean-interact.svg)](https://pypi.org/project/lean-interact/)
4
5
  [![PyPI downloads](https://img.shields.io/pepy/dt/lean-interact.svg)](https://pypi.org/project/lean-interact/)
5
6
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
@@ -12,7 +13,7 @@
12
13
  - **🔗 Interactivity**: Execute Lean code and files directly from Python.
13
14
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
14
15
  - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems.
15
- - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.19.0`.
16
+ - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.21.0-rc3`.
16
17
  - We backport the latest features of Lean REPL to older versions of Lean.
17
18
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
18
19
  - 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).
@@ -58,7 +59,9 @@ Requirements:
58
59
 
59
60
  - Python >= 3.10
60
61
  - git
61
- - [Lean 4](https://leanprover-community.github.io/get_started.html) (Tip: use the `install-lean` command from LeanInteract)
62
+ - [Lean 4](https://leanprover-community.github.io/get_started.html)
63
+ - **Tip:** use the cross-platform `install-lean` command from LeanInteract.
64
+ - Your `elan` version should be at least `4.0.0` (`elan --version`).
62
65
 
63
66
  ## Script examples
64
67
 
@@ -70,6 +73,8 @@ In the [`examples`](examples) directory, you will find a few scripts demonstrati
70
73
 
71
74
  ## Usage
72
75
 
76
+ Full documentation is available [here](https://augustepoiroux.github.io/LeanInteract/).
77
+
73
78
  ### Basic example
74
79
 
75
80
  The following code will use the default Lean version (latest available):
@@ -421,7 +426,22 @@ Two versions of Lean servers are available:
421
426
 
422
427
  ### Custom Lean REPL
423
428
 
424
- To use a forked Lean REPL project, specify the git repository using the `repl_git` parameter in the `LeanREPLConfig`. Your fork should have a similar versioning format to <https://github.com/augustepoiroux/repl> (i.e. having a branch with commits for each Lean version). For assistance, feel free to contact [us](mailto:auguste.poiroux@epfl.ch).
429
+ To use a forked Lean REPL project, specify the git repository using the `repl_git` parameter in the `LeanREPLConfig` and the target revision using the `repl_rev` parameter. For example:
430
+
431
+ ```python
432
+ config = LeanREPLConfig(repl_rev="v4.21.0-rc3", repl_git="https://github.com/leanprover-community/repl", verbose=True)
433
+ ```
434
+
435
+ > [!WARNING]
436
+ >
437
+ > Custom REPL implementations may have interfaces that are incompatible with LeanInteract's standard commands. If you encounter incompatibility issues, you can use the `run_dict` method from `LeanServer` to communicate directly with the REPL using the raw JSON protocol:
438
+ >
439
+ > ```python
440
+ > # Using run_dict instead of the standard commands
441
+ > result = server.run_dict({"cmd": "your_command_here"})
442
+ > ```
443
+
444
+ For assistance, feel free to contact [us](mailto:auguste.poiroux@epfl.ch).
425
445
 
426
446
  ## Similar tools
427
447
 
@@ -444,7 +464,9 @@ Common issues and their solutions:
444
464
 
445
465
  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.
446
466
 
447
- 4. **(Windows) Path too long error**: Windows has a maximum path length limitation of 260 characters.
467
+ 4. **`Failed during Lean project setup: Command '['lake', 'update']' returned non-zero exit status 1.`**: This error may occur if your `elan` version is outdated (i.e. < 4.0.0). To resolve this, update `elan` using `elan self update` or read the documentation [here](https://leanprover-community.github.io/get_started.html).
468
+
469
+ 5. **(Windows) Path too long error**: Windows has a maximum path length limitation of 260 characters.
448
470
  If you get an error similar to the following one, you are likely affected by this problem:
449
471
 
450
472
  ```
@@ -478,7 +500,7 @@ If you use LeanInteract in your research, please cite it as follows:
478
500
  @software{leaninteract,
479
501
  author = {Poiroux, Auguste and Kuncak, Viktor and Bosselut, Antoine},
480
502
  title = {LeanInteract: A Python Interface for Lean 4},
481
- url = {https://github.com/augustepoiroux/lean-interact},
503
+ url = {https://github.com/augustepoiroux/LeanInteract},
482
504
  year = {2025}
483
505
  }
484
506
  ```
File without changes
@@ -0,0 +1,90 @@
1
+ # Configuration API
2
+
3
+ This page documents the configuration classes used to set up the Lean environment.
4
+
5
+ ## LeanREPLConfig
6
+
7
+ ::: lean_interact.config.LeanREPLConfig
8
+ options:
9
+ show_root_heading: true
10
+ show_source: true
11
+ heading_level: 3
12
+
13
+ ### Examples
14
+
15
+ ```python
16
+ # Basic configuration with default settings
17
+ config = LeanREPLConfig(verbose=True)
18
+
19
+ # Configuration with specific Lean version
20
+ config = LeanREPLConfig(lean_version="v4.19.0", verbose=True)
21
+
22
+ # Configuration with memory limits
23
+ config = LeanREPLConfig(memory_hard_limit_mb=2000)
24
+
25
+ # Configuration with custom REPL version and repository
26
+ config = LeanREPLConfig(
27
+ repl_rev="v4.21.0-rc3",
28
+ repl_git="https://github.com/leanprover-community/repl"
29
+ )
30
+ ```
31
+
32
+ ## Project Classes
33
+
34
+ ### BaseProject
35
+
36
+ ::: lean_interact.config.BaseProject
37
+ options:
38
+ show_root_heading: true
39
+ show_source: true
40
+ heading_level: 3
41
+
42
+ ### LocalProject
43
+
44
+ ::: lean_interact.config.LocalProject
45
+ options:
46
+ show_root_heading: true
47
+ show_source: true
48
+ heading_level: 3
49
+
50
+ ### GitProject
51
+
52
+ ::: lean_interact.config.GitProject
53
+ options:
54
+ show_root_heading: true
55
+ show_source: true
56
+ heading_level: 3
57
+
58
+ ### BaseTempProject
59
+
60
+ ::: lean_interact.config.BaseTempProject
61
+ options:
62
+ show_root_heading: true
63
+ show_source: true
64
+ heading_level: 3
65
+
66
+ ### TemporaryProject
67
+
68
+ ::: lean_interact.config.TemporaryProject
69
+ options:
70
+ show_root_heading: true
71
+ show_source: true
72
+ heading_level: 3
73
+
74
+ ## Project Dependencies
75
+
76
+ ### LeanRequire
77
+
78
+ ::: lean_interact.config.LeanRequire
79
+ options:
80
+ show_root_heading: true
81
+ show_source: true
82
+ heading_level: 3
83
+
84
+ ### TempRequireProject
85
+
86
+ ::: lean_interact.config.TempRequireProject
87
+ options:
88
+ show_root_heading: true
89
+ show_source: true
90
+ heading_level: 3
@@ -0,0 +1,121 @@
1
+ # Interface API
2
+
3
+ This page documents the interface classes used to communicate with the Lean REPL.
4
+
5
+ ## Commands
6
+
7
+ ### Command
8
+
9
+ ::: lean_interact.interface.Command
10
+ options:
11
+ show_root_heading: true
12
+ show_source: true
13
+ heading_level: 3
14
+
15
+ ### FileCommand
16
+
17
+ ::: lean_interact.interface.FileCommand
18
+ options:
19
+ show_root_heading: true
20
+ show_source: true
21
+ heading_level: 3
22
+
23
+ ### ProofStep
24
+
25
+ ::: lean_interact.interface.ProofStep
26
+ options:
27
+ show_root_heading: true
28
+ show_source: true
29
+ heading_level: 3
30
+
31
+ ### PickleEnvironment
32
+
33
+ ::: lean_interact.interface.PickleEnvironment
34
+ options:
35
+ show_root_heading: true
36
+ show_source: true
37
+ heading_level: 3
38
+
39
+ ### UnpickleEnvironment
40
+
41
+ ::: lean_interact.interface.UnpickleEnvironment
42
+ options:
43
+ show_root_heading: true
44
+ show_source: true
45
+ heading_level: 3
46
+
47
+ ### PickleProofState
48
+
49
+ ::: lean_interact.interface.PickleProofState
50
+ options:
51
+ show_root_heading: true
52
+ show_source: true
53
+ heading_level: 3
54
+
55
+ ### UnpickleProofState
56
+
57
+ ::: lean_interact.interface.UnpickleProofState
58
+ options:
59
+ show_root_heading: true
60
+ show_source: true
61
+ heading_level: 3
62
+
63
+ ## Responses
64
+
65
+ ### BaseREPLResponse
66
+
67
+ ::: lean_interact.interface.BaseREPLResponse
68
+ options:
69
+ show_root_heading: true
70
+ show_source: true
71
+ heading_level: 3
72
+
73
+ ### CommandResponse
74
+
75
+ ::: lean_interact.interface.CommandResponse
76
+ options:
77
+ show_root_heading: true
78
+ show_source: true
79
+ heading_level: 3
80
+
81
+ ### ProofStepResponse
82
+
83
+ ::: lean_interact.interface.ProofStepResponse
84
+ options:
85
+ show_root_heading: true
86
+ show_source: true
87
+ heading_level: 3
88
+
89
+ ## Helper Classes
90
+
91
+ ### Message
92
+
93
+ ::: lean_interact.interface.Message
94
+ options:
95
+ show_root_heading: true
96
+ show_source: true
97
+ heading_level: 3
98
+
99
+ ### Sorry
100
+
101
+ ::: lean_interact.interface.Sorry
102
+ options:
103
+ show_root_heading: true
104
+ show_source: true
105
+ heading_level: 3
106
+
107
+ ### Pos
108
+
109
+ ::: lean_interact.interface.Pos
110
+ options:
111
+ show_root_heading: true
112
+ show_source: true
113
+ heading_level: 3
114
+
115
+ ### Tactic
116
+
117
+ ::: lean_interact.interface.Tactic
118
+ options:
119
+ show_root_heading: true
120
+ show_source: true
121
+ heading_level: 3
@@ -0,0 +1,34 @@
1
+ # LeanServer API
2
+
3
+ This page documents the server classes responsible for communicating with the Lean REPL.
4
+
5
+ ## LeanServer
6
+
7
+ ::: lean_interact.server.LeanServer
8
+ options:
9
+ show_root_heading: true
10
+ show_source: true
11
+ heading_level: 3
12
+
13
+ ### Using `run_dict` for custom REPLs
14
+
15
+ When working with custom REPL implementations that might have incompatible interfaces with LeanInteract's standard commands, you can use the `run_dict` method to communicate directly with the REPL using the raw JSON protocol:
16
+
17
+ ```python
18
+ # Using run_dict to send a raw command to the REPL
19
+ result = server.run_dict({"cmd": "your_command_here"})
20
+ ```
21
+
22
+ This method bypasses the command-specific parsing and validation, allowing you to work with custom REPL interfaces.
23
+
24
+ ## AutoLeanServer
25
+
26
+ ::: lean_interact.server.AutoLeanServer
27
+ options:
28
+ show_root_heading: true
29
+ show_source: true
30
+ heading_level: 3
31
+
32
+ ## Timeout Configuration
33
+
34
+ ::: lean_interact.server.DEFAULT_TIMEOUT
@@ -0,0 +1,52 @@
1
+ # Session Cache API
2
+
3
+ This page documents the session cache classes responsible for storing and retrieving Lean proof states and environments.
4
+ Session cache is used internally by the `AutoLeanServer` class.
5
+ It enables efficient resumption of proofs and environments after server restarts, timeouts, and automated recover from crashes. While by default `AutoLeanServer` instantiates a fresh `PickleSessionCache` instance, you can also use a custom one. It can be useful to share a session cache between multiple `AutoLeanServer` instances, or to use a custom session cache implementation.
6
+
7
+ ```python
8
+ from lean_interact.sessioncache import PickleSessionCache
9
+ from lean_interact.server import AutoLeanServer
10
+
11
+ # Create a session cache
12
+ cache = PickleSessionCache(working_dir="./cache")
13
+
14
+ # Create a Lean server with the cache
15
+ server = AutoLeanServer(config=..., session_cache=cache)
16
+ ```
17
+
18
+ ## Session State Classes
19
+
20
+ ### SessionState
21
+
22
+ ::: lean_interact.sessioncache.SessionState
23
+ options:
24
+ show_root_heading: true
25
+ show_source: true
26
+ heading_level: 3
27
+
28
+ ### PickleSessionState
29
+
30
+ ::: lean_interact.sessioncache.PickleSessionState
31
+ options:
32
+ show_root_heading: true
33
+ show_source: true
34
+ heading_level: 3
35
+
36
+ ## Cache Implementation
37
+
38
+ ### BaseSessionCache
39
+
40
+ ::: lean_interact.sessioncache.BaseSessionCache
41
+ options:
42
+ show_root_heading: true
43
+ show_source: true
44
+ heading_level: 3
45
+
46
+ ### PickleSessionCache
47
+
48
+ ::: lean_interact.sessioncache.PickleSessionCache
49
+ options:
50
+ show_root_heading: true
51
+ show_source: true
52
+ heading_level: 3