lean-interact 0.8.2__tar.gz → 0.9.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 (53) hide show
  1. {lean_interact-0.8.2 → lean_interact-0.9.0}/.github/workflows/docs.yml +12 -10
  2. {lean_interact-0.8.2 → lean_interact-0.9.0}/.gitignore +4 -0
  3. {lean_interact-0.8.2 → lean_interact-0.9.0}/PKG-INFO +13 -3
  4. {lean_interact-0.8.2 → lean_interact-0.9.0}/README.md +12 -2
  5. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/api/interface.md +11 -0
  6. lean_interact-0.9.0/docs/api/server.md +20 -0
  7. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/index.md +3 -1
  8. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/basic-usage.md +12 -13
  9. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/custom-lean-configuration.md +3 -3
  10. lean_interact-0.9.0/docs/user-guide/data-extraction.md +71 -0
  11. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/examples.md +7 -11
  12. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/getting-started.md +1 -5
  13. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/installation.md +6 -10
  14. lean_interact-0.9.0/docs/user-guide/performance.md +199 -0
  15. lean_interact-0.9.0/docs/user-guide/set-options.md +26 -0
  16. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/tactic-mode.md +10 -40
  17. lean_interact-0.9.0/examples/extract_mathlib_decls.py +92 -0
  18. {lean_interact-0.8.2 → lean_interact-0.9.0}/mkdocs.yml +4 -11
  19. {lean_interact-0.8.2 → lean_interact-0.9.0}/pyproject.toml +8 -2
  20. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/config.py +29 -7
  21. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/interface.py +93 -0
  22. lean_interact-0.9.0/src/lean_interact/py.typed +0 -0
  23. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/server.py +38 -9
  24. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/utils.py +16 -5
  25. {lean_interact-0.8.2 → lean_interact-0.9.0}/tests/test_server.py +139 -11
  26. lean_interact-0.8.2/docs/api/server.md +0 -8
  27. lean_interact-0.8.2/docs/user-guide/multi-processing.md +0 -164
  28. lean_interact-0.8.2/uv.lock +0 -1825
  29. {lean_interact-0.8.2 → lean_interact-0.9.0}/.devcontainer/devcontainer.json +0 -0
  30. {lean_interact-0.8.2 → lean_interact-0.9.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  31. {lean_interact-0.8.2 → lean_interact-0.9.0}/.github/copilot-instructions.md +0 -0
  32. {lean_interact-0.8.2 → lean_interact-0.9.0}/.github/workflows/ci.yml +0 -0
  33. {lean_interact-0.8.2 → lean_interact-0.9.0}/.github/workflows/publish-to-pypi.yml +0 -0
  34. {lean_interact-0.8.2 → lean_interact-0.9.0}/LICENSE +0 -0
  35. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/.nojekyll +0 -0
  36. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/api/config.md +0 -0
  37. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/api/project.md +0 -0
  38. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/api/sessioncache.md +0 -0
  39. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/api/utils.md +0 -0
  40. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/contributing.md +0 -0
  41. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/generate_changelog.py +0 -0
  42. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/theme/main.html +0 -0
  43. {lean_interact-0.8.2 → lean_interact-0.9.0}/docs/user-guide/troubleshooting.md +0 -0
  44. {lean_interact-0.8.2 → lean_interact-0.9.0}/examples/beq_plus.py +0 -0
  45. {lean_interact-0.8.2 → lean_interact-0.9.0}/examples/multi_processing.py +0 -0
  46. {lean_interact-0.8.2 → lean_interact-0.9.0}/examples/proof_generation_and_autoformalization.py +0 -0
  47. {lean_interact-0.8.2 → lean_interact-0.9.0}/examples/type_check.py +0 -0
  48. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/__init__.py +0 -0
  49. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/project.py +0 -0
  50. {lean_interact-0.8.2 → lean_interact-0.9.0}/src/lean_interact/sessioncache.py +0 -0
  51. {lean_interact-0.8.2 → lean_interact-0.9.0}/tests/test_concurrency.py +0 -0
  52. {lean_interact-0.8.2 → lean_interact-0.9.0}/tests/test_git_functionality.py +0 -0
  53. {lean_interact-0.8.2 → lean_interact-0.9.0}/tests/test_utils.py +0 -0
@@ -5,20 +5,20 @@ on:
5
5
  branches:
6
6
  - main
7
7
  paths:
8
- - 'docs/**'
9
- - 'mkdocs.yml'
10
- - 'src/lean_interact/**'
11
- - '.github/workflows/docs.yml'
8
+ - "docs/**"
9
+ - "mkdocs.yml"
10
+ - "src/lean_interact/**"
11
+ - ".github/workflows/docs.yml"
12
12
  tags:
13
- - 'v*' # Deploy on version tags
13
+ - "v*" # Deploy on version tags
14
14
  workflow_dispatch:
15
15
  inputs:
16
16
  version:
17
- description: 'Version to deploy (e.g., v0.7.0, latest, dev)'
17
+ description: "Version to deploy (e.g., v0.7.0, latest, dev)"
18
18
  required: false
19
- default: 'dev'
19
+ default: "dev"
20
20
  alias:
21
- description: 'Alias for this version (e.g., stable, latest)'
21
+ description: "Alias for this version (e.g., stable, latest)"
22
22
  required: false
23
23
 
24
24
  # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
@@ -29,7 +29,7 @@ permissions:
29
29
 
30
30
  # Allow only one concurrent deployment
31
31
  concurrency:
32
- group: 'pages'
32
+ group: "pages"
33
33
  cancel-in-progress: false
34
34
 
35
35
  jobs:
@@ -44,7 +44,7 @@ jobs:
44
44
  - name: Setup Python
45
45
  uses: actions/setup-python@v5
46
46
  with:
47
- python-version: '3.10'
47
+ python-version: "3.10"
48
48
 
49
49
  - name: Install uv
50
50
  uses: astral-sh/setup-uv@v4
@@ -72,6 +72,8 @@ jobs:
72
72
 
73
73
  - name: Generate changelog
74
74
  run: |
75
+ # First wait a bit to ensure changelogs from the last release are available
76
+ sleep 120
75
77
  uv run python docs/generate_changelog.py
76
78
 
77
79
  - name: Determine version and alias
@@ -12,6 +12,10 @@ __pycache__
12
12
 
13
13
  sandbox*
14
14
  .vscode
15
+ *.lock
15
16
 
16
17
  # Doc build
17
18
  site
19
+
20
+ # MacOS
21
+ .DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lean-interact
3
- Version: 0.8.2
3
+ Version: 0.9.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
@@ -53,10 +53,12 @@ Check the [documentation](https://augustepoiroux.github.io/LeanInteract/) for de
53
53
  - **🔗 Interactivity**: Execute Lean code and files directly from Python.
54
54
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
55
55
  - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems.
56
- - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.23.0-rc2`.
56
+ - **🔧 Compatibility**: Supports all Lean versions between `v4.8.0-rc1` and `v4.24.0-rc1`.
57
57
  - We backport the latest features of Lean REPL to older versions of Lean (see [fork](https://github.com/augustepoiroux/repl)).
58
58
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
59
59
  - 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).
60
+ - **🧾 Data extraction (new in v0.9.0)**: Extract declarations and info trees for analysis and dataset building.
61
+ - **⚡ Incremental + Parallel elaboration (new in v0.9.0)**: Automatically reuse partial computations from previous commands, and enable `Elab.async` for faster processing.
60
62
 
61
63
  ## Table of Contents
62
64
 
@@ -259,7 +261,7 @@ ProofStepResponse(proof_state=3, goals=[], proof_status='Completed')
259
261
  #### Specific Lean version
260
262
 
261
263
  ```python
262
- config = LeanREPLConfig(lean_version="v4.7.0")
264
+ config = LeanREPLConfig(lean_version="v4.8.0")
263
265
  ```
264
266
 
265
267
  #### Existing Lean projects
@@ -412,6 +414,14 @@ response = server.run(FileCommand(path="myfile.lean"))
412
414
  response = server.run(FileCommand(path="myfile.lean", root_goals=True))
413
415
  ```
414
416
 
417
+ Extract Lean declarations while processing a file:
418
+
419
+ ```python
420
+ response = server.run(FileCommand(path="myfile.lean", declarations=True))
421
+ for d in response.declarations:
422
+ print(d.full_name, d.signature.pp)
423
+ ```
424
+
415
425
  ### ProofStep
416
426
 
417
427
  Work with proofs step by step using tactics:
@@ -15,10 +15,12 @@ Check the [documentation](https://augustepoiroux.github.io/LeanInteract/) for de
15
15
  - **🔗 Interactivity**: Execute Lean code and files directly from Python.
16
16
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction.
17
17
  - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems.
18
- - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.23.0-rc2`.
18
+ - **🔧 Compatibility**: Supports all Lean versions between `v4.8.0-rc1` and `v4.24.0-rc1`.
19
19
  - We backport the latest features of Lean REPL to older versions of Lean (see [fork](https://github.com/augustepoiroux/repl)).
20
20
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments.
21
21
  - 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).
22
+ - **🧾 Data extraction (new in v0.9.0)**: Extract declarations and info trees for analysis and dataset building.
23
+ - **⚡ Incremental + Parallel elaboration (new in v0.9.0)**: Automatically reuse partial computations from previous commands, and enable `Elab.async` for faster processing.
22
24
 
23
25
  ## Table of Contents
24
26
 
@@ -221,7 +223,7 @@ ProofStepResponse(proof_state=3, goals=[], proof_status='Completed')
221
223
  #### Specific Lean version
222
224
 
223
225
  ```python
224
- config = LeanREPLConfig(lean_version="v4.7.0")
226
+ config = LeanREPLConfig(lean_version="v4.8.0")
225
227
  ```
226
228
 
227
229
  #### Existing Lean projects
@@ -374,6 +376,14 @@ response = server.run(FileCommand(path="myfile.lean"))
374
376
  response = server.run(FileCommand(path="myfile.lean", root_goals=True))
375
377
  ```
376
378
 
379
+ Extract Lean declarations while processing a file:
380
+
381
+ ```python
382
+ response = server.run(FileCommand(path="myfile.lean", declarations=True))
383
+ for d in response.declarations:
384
+ print(d.full_name, d.signature.pp)
385
+ ```
386
+
377
387
  ### ProofStep
378
388
 
379
389
  Work with proofs step by step using tactics:
@@ -4,6 +4,7 @@
4
4
  heading: "Interface"
5
5
  show_symbol_type_heading: false
6
6
  members:
7
+ - CommandOptions
7
8
  - Command
8
9
  - FileCommand
9
10
  - ProofStep
@@ -24,3 +25,13 @@
24
25
  - CommandNode
25
26
  - TermNode
26
27
  - Syntax
28
+ - DocString
29
+ - DeclModifiers
30
+ - DeclSignature
31
+ - BinderView
32
+ - DeclBinders
33
+ - DeclType
34
+ - DeclValue
35
+ - OpenDecl
36
+ - ScopeInfo
37
+ - DeclarationInfo
@@ -0,0 +1,20 @@
1
+ ::: lean_interact.server
2
+ options:
3
+ heading_level: 1
4
+ heading: "Lean Servers"
5
+ show_symbol_type_heading: false
6
+ members:
7
+ - LeanServer
8
+ - AutoLeanServer
9
+
10
+ ---
11
+
12
+ ## Notes on performance features
13
+
14
+ LeanInteract automatically augments `Command` and `FileCommand` requests to speed up elaboration and processing of files:
15
+
16
+ - Incremental elaboration is enabled by default
17
+ - Parallel elaboration is enabled via `set_option Elab.async true` by default when supported (Lean >= v4.19.0)
18
+
19
+ You can disable these behaviors in `LeanREPLConfig` by setting
20
+ `enable_incremental_optimization=False` and/or `enable_parallel_elaboration=False`.
@@ -17,10 +17,12 @@ hide:
17
17
  - **🔗 Interactivity**: Execute Lean code and files directly from Python
18
18
  - **🚀 Ease of Use**: LeanInteract abstracts the complexities of Lean setup and interaction
19
19
  - **💻 Cross-platform**: Works on Windows, macOS, and Linux operating systems
20
- - **🔧 Compatibility**: Supports all Lean versions between `v4.7.0-rc1` and `v4.23.0-rc2`
20
+ - **🔧 Compatibility**: Supports all Lean versions between `v4.8.0-rc1` and `v4.24.0-rc1`
21
21
  - We backport the latest features of Lean REPL to older versions of Lean (see [fork](https://github.com/augustepoiroux/repl)).
22
22
  - **📦 Temporary Projects**: Easily instantiate temporary Lean environments
23
23
  - 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)
24
+ - **🧾 Data extraction**: Extract declarations and info trees for analysis and dataset building.
25
+ - **⚡ Incremental + Parallel elaboration**: Automatically reuse partial computations from previous commands, and enable `Elab.async` for faster processing.
24
26
 
25
27
  ## Quick Start
26
28
 
@@ -1,7 +1,3 @@
1
- ---
2
- execute: true
3
- ---
4
-
5
1
  # Basic Usage
6
2
 
7
3
  This guide covers the fundamental operations and command types in LeanInteract.
@@ -10,7 +6,7 @@ This guide covers the fundamental operations and command types in LeanInteract.
10
6
 
11
7
  The most common operation in LeanInteract is executing Lean code directly using the `Command` class:
12
8
 
13
- ```python tags=["execute"]
9
+ ```python exec="on" source="above" session="base" result="python"
14
10
  from lean_interact import LeanREPLConfig, LeanServer, Command
15
11
 
16
12
  # Setup
@@ -18,24 +14,24 @@ config = LeanREPLConfig()
18
14
  server = LeanServer(config)
19
15
 
20
16
  # Run a simple theorem
21
- server.run(Command(cmd="theorem ex (n : Nat) : n = 5 → n = 5 := id"))
17
+ print(server.run(Command(cmd="theorem ex (n : Nat) : n = 5 → n = 5 := id")))
22
18
  ```
23
19
 
24
20
  The response contains:
25
21
 
26
- - An environment state (`env`) that can be used for subsequent commands
27
22
  - Messages returned by Lean if any (errors, information, etc.)
23
+ - An environment state (`env`) that can be used for subsequent commands.
28
24
 
29
25
  ### Working with Environment States
30
26
 
31
27
  Each command execution creates a new environment state. You can use this state in subsequent commands:
32
28
 
33
- ```python tags=["execute"]
29
+ ```python exec="on" source="above" session="base" result="python"
34
30
  # First command creates environment state
35
31
  response1 = server.run(Command(cmd="def x := 5"))
36
32
 
37
33
  # Use environment state 0 for the next command
38
- server.run(Command(cmd="#check x", env=response1.env))
34
+ print(server.run(Command(cmd="#check x", env=response1.env)))
39
35
  ```
40
36
 
41
37
  ## Processing Lean Files
@@ -57,13 +53,16 @@ response = server.run(FileCommand(path="myfile.lean", root_goals=True))
57
53
  Both `Command` and `FileCommand` support several options:
58
54
 
59
55
  - `all_tactics`: Get information about tactics used
56
+ - `declarations`: Extract fine-grained information about declarations in the code
60
57
  - `root_goals`: Get information about goals in theorems and definitions
61
- - `infotree`: Get Lean infotree containing various informations about declarations and tactics
58
+ - `infotree`: Get Lean infotree containing various informations from the Lean syntax tree
59
+ - `incrementality`: Enable or disable incremental elaboration for this specific command.
60
+ - `set_options`: Set Lean options for this command (see [Set Options](set-options.md))
62
61
  - `env`: The environment from a previous command to be used as context. If `env = None`, starts from scratch.
63
62
 
64
63
  Example with options:
65
64
 
66
- ```python tags=["execute"]
65
+ ```python exec="on" source="above" session="base" result="python"
67
66
  response = server.run(Command(
68
67
  cmd="theorem ex (n : Nat) : n = 5 → n = 5 := by simp",
69
68
  all_tactics=True
@@ -75,7 +74,7 @@ print(response.tactics) # Shows tactics used
75
74
 
76
75
  When Lean code contains `sorry` (incomplete proofs), LeanInteract returns information about these `sorry`:
77
76
 
78
- ```python tags=["execute"]
77
+ ```python exec="on" source="above" session="base" result="python"
79
78
  response = server.run(Command(cmd="theorem ex (n : Nat) : n = 5 → n = 5 := sorry"))
80
79
  print(response.sorries[0])
81
80
  ```
@@ -88,7 +87,7 @@ This response will include a list of `Sorry` objects, each containing:
88
87
 
89
88
  ## Error Handling
90
89
 
91
- ```python tags=["execute"]
90
+ ```python exec="on" source="above" session="base" result="python"
92
91
  from lean_interact.interface import LeanError
93
92
 
94
93
  try:
@@ -10,7 +10,7 @@ You can specify which version of Lean 4 you want to use when no project is speci
10
10
  from lean_interact import LeanREPLConfig, LeanServer
11
11
 
12
12
  # Use a specific Lean version
13
- config = LeanREPLConfig(lean_version="v4.7.0")
13
+ config = LeanREPLConfig(lean_version="v4.8.0")
14
14
  server = LeanServer(config)
15
15
  ```
16
16
 
@@ -81,12 +81,12 @@ from lean_interact import LeanREPLConfig, TempRequireProject, LeanRequire
81
81
 
82
82
  # Create a temporary project with Mathlib as a dependency
83
83
  project = TempRequireProject(
84
- lean_version="v4.7.0",
84
+ lean_version="v4.8.0",
85
85
  require=[
86
86
  LeanRequire(
87
87
  name="mathlib",
88
88
  git="https://github.com/leanprover-community/mathlib4.git",
89
- rev="v4.7.0"
89
+ rev="v4.8.0"
90
90
  )
91
91
  ]
92
92
  )
@@ -0,0 +1,71 @@
1
+ # Data Extraction: Declarations, Tactics, and InfoTrees
2
+
3
+ LeanInteract makes it easy to extract rich data from elaboration, including declarations, tactics, and detailed InfoTrees.
4
+
5
+ ## Declarations
6
+
7
+ Set `declarations=True` to retrieve a list of `DeclarationInfo` for each declaration introduced in your Lean code.
8
+ Full details about the fields in `DeclarationInfo` can be found in the [API reference](../api/interface.md#lean_interact.interface.DeclarationInfo).
9
+
10
+ ```python exec="on" source="above" session="extraction" result="python"
11
+ from lean_interact import LeanServer, LeanREPLConfig, Command
12
+ from lean_interact.interface import CommandResponse
13
+
14
+ code = """
15
+ theorem ex (n : Nat) : n = 5 → n = 5 := by
16
+ intro h; exact h
17
+ """
18
+
19
+ server = LeanServer(LeanREPLConfig())
20
+ res = server.run(Command(cmd=code, declarations=True))
21
+ assert isinstance(res, CommandResponse)
22
+ for d in res.declarations:
23
+ print(f"Full name: `{d.full_name}`")
24
+ print(f"Kind: `{d.kind}`")
25
+ print(f"Signature: `{d.signature}`")
26
+ print(f"Value: `{d.value}`")
27
+ print(f"Binders: `{d.binders}`")
28
+ ```
29
+
30
+ For files:
31
+
32
+ ```python
33
+ from lean_interact import FileCommand
34
+ res = server.run(FileCommand(path="myfile.lean", declarations=True))
35
+ ```
36
+
37
+ Tip: See [`examples/extract_mathlib_decls.py`](https://github.com/augustepoiroux/LeanInteract/blob/main/examples/extract_mathlib_decls.py) for a scalable, per-file parallel extractor over Mathlib.
38
+
39
+ ## Tactics
40
+
41
+ Use `all_tactics=True` to collect tactic applications with their goals and used constants.
42
+
43
+ ```python exec="on" source="above" session="extraction" result="python"
44
+ resp = server.run(Command(cmd=code, all_tactics=True))
45
+ for t in resp.tactics:
46
+ print(t.tactic, "::: used:", t.used_constants)
47
+ ```
48
+
49
+ ## InfoTrees
50
+
51
+ Request `infotree` to obtain structured elaboration information. Accepted values include `"full"`, `"tactics"`, `"original"`, and `"substantive"`.
52
+
53
+ ```python exec="on" source="above" session="extraction" result="python"
54
+ from lean_interact.interface import InfoTree
55
+
56
+ res = server.run(Command(cmd=code, infotree="full"))
57
+ trees: list[InfoTree] = res.infotree or []
58
+
59
+ # Example: iterate over all command-level nodes and print their kind
60
+ for tree in trees:
61
+ for cmd_node in tree.commands():
62
+ print(cmd_node.kind, cmd_node.node.stx)
63
+ ```
64
+
65
+ ## Root goals and messages
66
+
67
+ You can also ask for `root_goals=True` to retrieve initial goals for declarations (even if already proved).
68
+
69
+ ```python exec="on" source="above" session="extraction" result="python"
70
+ print(server.run(Command(cmd=code, root_goals=True)))
71
+ ```
@@ -1,7 +1,3 @@
1
- ---
2
- execute: true
3
- ---
4
-
5
1
  # Examples
6
2
 
7
3
  This page provides practical examples of using LeanInteract in different scenarios. You can find a few full example scripts in the [`examples`](https://github.com/augustepoiroux/LeanInteract/tree/main/examples) directory of the repository.
@@ -10,7 +6,7 @@ This page provides practical examples of using LeanInteract in different scenari
10
6
 
11
7
  This example demonstrates how to define a simple theorem with a partial proof in Lean using LeanInteract:
12
8
 
13
- ```python tags=["execute"]
9
+ ```python exec="on" source="above" result="python"
14
10
  from lean_interact import LeanREPLConfig, LeanServer, Command
15
11
 
16
12
  # Initialize configuration and server
@@ -18,19 +14,19 @@ config = LeanREPLConfig()
18
14
  server = LeanServer(config)
19
15
 
20
16
  # Define a simple theorem
21
- server.run(Command(cmd="""
17
+ print(server.run(Command(cmd="""
22
18
  theorem add_comm (a b : Nat) : a + b = b + a := by
23
19
  induction a with
24
20
  | zero => simp
25
21
  | succ a ih => sorry
26
- """))
22
+ """)))
27
23
  ```
28
24
 
29
25
  ## Working with Mathlib
30
26
 
31
27
  This example shows how to use Mathlib to work with more advanced mathematical concepts:
32
28
 
33
- ```python
29
+ ```python exec="on" source="above" result="python"
34
30
  from lean_interact import LeanREPLConfig, LeanServer, Command, TempRequireProject
35
31
 
36
32
  # Create configuration with Mathlib
@@ -38,7 +34,7 @@ config = LeanREPLConfig(project=TempRequireProject(lean_version="v4.19.0", requi
38
34
  server = LeanServer(config)
39
35
 
40
36
  # Define a theorem using Mathlib's real numbers
41
- server.run(Command(cmd="""
37
+ print(server.run(Command(cmd="""
42
38
  import Mathlib
43
39
 
44
40
  theorem irrational_plus_rational
@@ -46,14 +42,14 @@ theorem irrational_plus_rational
46
42
  intro h
47
43
  simp
48
44
  assumption
49
- """))
45
+ """)))
50
46
  ```
51
47
 
52
48
  ## Using Custom REPL Versions
53
49
 
54
50
  This example demonstrates how to use a specific REPL version from a custom repository:
55
51
 
56
- ```python
52
+ ```python exec="on" source="above" result="python"
57
53
  from lean_interact import LeanREPLConfig, LeanServer, Command
58
54
 
59
55
  # Use a specific REPL version from the official Lean repository
@@ -1,7 +1,3 @@
1
- ---
2
- execute: true
3
- ---
4
-
5
1
  # Getting Started with LeanInteract
6
2
 
7
3
  ## Overview
@@ -14,7 +10,7 @@ LeanInteract provides a Python interface to the Lean 4 theorem prover via the Le
14
10
 
15
11
  ## Quick Example
16
12
 
17
- ```python tags=["execute"]
13
+ ```python exec="on" source="above" session="getting-started" result="python"
18
14
  from lean_interact import LeanREPLConfig, LeanServer, Command
19
15
 
20
16
  # Create a Lean REPL configuration
@@ -1,7 +1,3 @@
1
- ---
2
- execute: true
3
- ---
4
-
5
1
  # Installation
6
2
 
7
3
  ## Prerequisites
@@ -20,7 +16,7 @@ We recommend using Linux or macOS for the best experience, but LeanInteract also
20
16
 
21
17
  You can install LeanInteract directly from PyPI:
22
18
 
23
- ```
19
+ ```bash
24
20
  pip install lean-interact
25
21
  ```
26
22
 
@@ -28,7 +24,7 @@ pip install lean-interact
28
24
 
29
25
  LeanInteract provides a convenient command to install Lean 4 along with its official [Elan](https://github.com/leanprover/elan) version manager:
30
26
 
31
- ```
27
+ ```bash
32
28
  install-lean
33
29
  ```
34
30
 
@@ -41,7 +37,7 @@ This command will install Elan, which manages Lean versions.
41
37
 
42
38
  You can verify that LeanInteract is properly installed by running a simple Python script:
43
39
 
44
- ```python tags=["execute"]
40
+ ```python exec="on" source="above" session="install" result="python"
45
41
  from lean_interact import LeanREPLConfig, LeanServer, Command
46
42
 
47
43
  # Create a configuration
@@ -66,7 +62,7 @@ If everything is set up correctly, the script should output a successful respons
66
62
 
67
63
  On Windows, you might encounter path length limitations. If you get an error related to path length, you can enable long paths in Windows 10 and later versions by running the following command in an administrator PowerShell:
68
64
 
69
- ```
65
+ ```powershell
70
66
  New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -Value 1 -PropertyType DWord -Force
71
67
  git config --system core.longpaths true
72
68
  ```
@@ -81,12 +77,12 @@ If you're using LeanInteract in a Docker container, make sure to include Git in
81
77
 
82
78
  If you need to clear the LeanInteract cache (for troubleshooting or disk space reasons), you can use:
83
79
 
84
- ```
80
+ ```bash
85
81
  clear-lean-cache
86
82
  ```
87
83
 
88
84
  To completely uninstall:
89
85
 
90
- ```
86
+ ```bash
91
87
  pip uninstall lean-interact
92
88
  ```