lean-runtime 0.6.0__tar.gz → 2.0.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 (119) hide show
  1. lean_runtime-2.0.0/CHANGELOG.md +128 -0
  2. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/MANIFEST.in +1 -0
  3. lean_runtime-2.0.0/PKG-INFO +198 -0
  4. lean_runtime-2.0.0/README.md +163 -0
  5. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/docs/architecture.md +11 -0
  6. lean_runtime-2.0.0/docs/case-study-v1.md +47 -0
  7. lean_runtime-2.0.0/docs/cli.md +122 -0
  8. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/docs/environments.md +10 -4
  9. lean_runtime-2.0.0/docs/getting-started.md +103 -0
  10. lean_runtime-2.0.0/docs/index.md +40 -0
  11. lean_runtime-2.0.0/docs/local-projects.md +58 -0
  12. lean_runtime-2.0.0/docs/portable-copies.md +226 -0
  13. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/docs/python-api.md +87 -13
  14. lean_runtime-2.0.0/docs/ready-programs.md +53 -0
  15. lean_runtime-2.0.0/docs/standalone-files.md +52 -0
  16. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/docs/trust-and-limitations.md +15 -3
  17. lean_runtime-2.0.0/docs/v1-precision.md +109 -0
  18. lean_runtime-2.0.0/lean_runtime/__init__.py +141 -0
  19. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/backends.py +21 -10
  20. lean_runtime-2.0.0/lean_runtime/bundles.py +683 -0
  21. lean_runtime-2.0.0/lean_runtime/cli.py +668 -0
  22. lean_runtime-2.0.0/lean_runtime/comparison.py +116 -0
  23. lean_runtime-2.0.0/lean_runtime/decisions.py +24 -0
  24. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/environments.py +32 -3
  25. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/errors.py +24 -0
  26. lean_runtime-2.0.0/lean_runtime/facade.py +210 -0
  27. lean_runtime-2.0.0/lean_runtime/frontmatter.py +75 -0
  28. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/locking.py +13 -1
  29. lean_runtime-2.0.0/lean_runtime/matrix.py +164 -0
  30. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/models.py +76 -0
  31. lean_runtime-2.0.0/lean_runtime/oci.py +672 -0
  32. lean_runtime-2.0.0/lean_runtime/profiling.py +70 -0
  33. lean_runtime-2.0.0/lean_runtime/programs.py +740 -0
  34. lean_runtime-2.0.0/lean_runtime/projects.py +213 -0
  35. lean_runtime-2.0.0/lean_runtime/publisher_verification.py +137 -0
  36. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/references.py +51 -8
  37. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/resolver.py +56 -32
  38. lean_runtime-2.0.0/lean_runtime/run_cli.py +233 -0
  39. lean_runtime-2.0.0/lean_runtime/runtime.py +1016 -0
  40. lean_runtime-2.0.0/lean_runtime/schema_resources.py +31 -0
  41. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/store.py +153 -11
  42. lean_runtime-2.0.0/lean_runtime/timings.py +17 -0
  43. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/toolchains.py +15 -9
  44. lean_runtime-2.0.0/lean_runtime/verification.py +261 -0
  45. lean_runtime-2.0.0/lean_runtime/wire.py +74 -0
  46. lean_runtime-2.0.0/lean_runtime.egg-info/PKG-INFO +198 -0
  47. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime.egg-info/SOURCES.txt +44 -1
  48. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime.egg-info/entry_points.txt +1 -0
  49. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime.egg-info/requires.txt +1 -0
  50. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/mkdocs.yml +7 -1
  51. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/pyproject.toml +8 -4
  52. lean_runtime-2.0.0/schemas/cleanup-v1.schema.json +47 -0
  53. lean_runtime-2.0.0/schemas/comparison-v1.schema.json +50 -0
  54. lean_runtime-2.0.0/schemas/execution-v1.schema.json +134 -0
  55. lean_runtime-2.0.0/schemas/inspect-v1.schema.json +79 -0
  56. lean_runtime-2.0.0/schemas/matrix-v1.schema.json +34 -0
  57. lean_runtime-2.0.0/schemas/profile-v1.schema.json +38 -0
  58. lean_runtime-2.0.0/schemas/verify-v1.schema.json +43 -0
  59. lean_runtime-2.0.0/scripts/run_v1_case_study.py +162 -0
  60. lean_runtime-2.0.0/scripts/smoke_wheel.py +68 -0
  61. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_backend.py +32 -0
  62. lean_runtime-2.0.0/tests/test_bundles.py +388 -0
  63. lean_runtime-2.0.0/tests/test_cli.py +204 -0
  64. lean_runtime-2.0.0/tests/test_environment_integration.py +371 -0
  65. lean_runtime-2.0.0/tests/test_facade.py +111 -0
  66. lean_runtime-2.0.0/tests/test_frontmatter.py +60 -0
  67. lean_runtime-2.0.0/tests/test_prebuilt_policy.py +101 -0
  68. lean_runtime-2.0.0/tests/test_programs.py +92 -0
  69. lean_runtime-2.0.0/tests/test_projects.py +162 -0
  70. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_references.py +14 -0
  71. lean_runtime-2.0.0/tests/test_run_cli.py +122 -0
  72. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_runtime.py +21 -2
  73. lean_runtime-2.0.0/tests/test_schema_resources.py +26 -0
  74. lean_runtime-2.0.0/tests/test_schemas.py +128 -0
  75. lean_runtime-2.0.0/tests/test_signatures.py +79 -0
  76. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_store.py +42 -6
  77. lean_runtime-2.0.0/tests/test_v1_precision.py +253 -0
  78. lean_runtime-2.0.0/tests/test_verification_inventory.py +18 -0
  79. lean_runtime-0.6.0/CHANGELOG.md +0 -49
  80. lean_runtime-0.6.0/PKG-INFO +0 -332
  81. lean_runtime-0.6.0/README.md +0 -298
  82. lean_runtime-0.6.0/docs/cli.md +0 -72
  83. lean_runtime-0.6.0/docs/getting-started.md +0 -108
  84. lean_runtime-0.6.0/docs/index.md +0 -38
  85. lean_runtime-0.6.0/lean_runtime/__init__.py +0 -67
  86. lean_runtime-0.6.0/lean_runtime/cli.py +0 -254
  87. lean_runtime-0.6.0/lean_runtime/runtime.py +0 -430
  88. lean_runtime-0.6.0/lean_runtime.egg-info/PKG-INFO +0 -332
  89. lean_runtime-0.6.0/tests/test_cli.py +0 -110
  90. lean_runtime-0.6.0/tests/test_environment_integration.py +0 -181
  91. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/LICENSE +0 -0
  92. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/compatibility/README.md +0 -0
  93. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/compatibility/mathlib-4.32.2.json +0 -0
  94. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/compatibility/mathlib-4.32.2.toml +0 -0
  95. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/docs/captures.md +0 -0
  96. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/docs/development.md +0 -0
  97. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/examples/mathlib.toml +0 -0
  98. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/__main__.py +0 -0
  99. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/diagnostics.py +0 -0
  100. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/events.py +0 -0
  101. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/health.py +0 -0
  102. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/lake.py +0 -0
  103. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/lockfiles.py +0 -0
  104. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/policies.py +0 -0
  105. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/py.typed +0 -0
  106. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/serialization.py +0 -0
  107. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime/specs.py +0 -0
  108. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime.egg-info/dependency_links.txt +0 -0
  109. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/lean_runtime.egg-info/top_level.txt +0 -0
  110. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/scripts/run_compatibility.py +0 -0
  111. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/setup.cfg +0 -0
  112. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/conftest.py +0 -0
  113. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_diagnostics.py +0 -0
  114. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_events_health.py +0 -0
  115. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_interactive.py +0 -0
  116. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_lockfiles.py +0 -0
  117. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_multifile.py +0 -0
  118. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_specs.py +0 -0
  119. {lean_runtime-0.6.0 → lean_runtime-2.0.0}/tests/test_toolchains.py +0 -0
@@ -0,0 +1,128 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0
4
+
5
+ Version 2 gives the public interface the language used by Lean users rather
6
+ than the language of its storage implementation. The environment format stays
7
+ compatible; command names, Python names, configuration, events, and public
8
+ metadata intentionally change without aliases.
9
+
10
+ ### Public terminology
11
+
12
+ - Environment libraries replace OCI caches in ordinary configuration and docs.
13
+ - Downloadable environments replace prebuilt artifacts.
14
+ - Portable copies replace OCI bundles.
15
+ - Publisher verification replaces signature-policy terminology.
16
+ - Cleanup and storage replace garbage-collection and blob terminology.
17
+ - Ready-to-run programs replace execution-capsule and container terminology.
18
+
19
+ ### Main migrations
20
+
21
+ - `Runtime(caches=..., prebuilt=...)` becomes
22
+ `Runtime(libraries=..., availability=...)`.
23
+ - `resolve`, `ensure`, and named `open` become `prepare`, `open_exact`, and
24
+ `environment` in the explicit Python API.
25
+ - `export_environment` and `import_environment` become `save_portable_copy`
26
+ and `open_portable_copy`.
27
+ - CLI workflows use `prepare`, `open`, `download`, `build-and-publish`,
28
+ `save-copy`, `open-copy`, `compare`, `storage`, and `clean`.
29
+ - Environment libraries accept friendly `ghcr.io/owner/name` locations; the
30
+ OCI transport remains an advanced implementation detail.
31
+ - Ready-to-run programs can be created, verified, copied, downloaded from a
32
+ program library, published for multiple kinds of computers, and interrupted
33
+ during interactive execution.
34
+
35
+ ## 1.0.0
36
+
37
+ Lean Runtime v1 establishes the concise `lean-run` and `lean.setup()` workflows while making
38
+ exact environments independently verifiable, explainable, measurable, and portable.
39
+
40
+ ### Breaking changes
41
+
42
+ - Remove `lean-runtime audit`, `Runtime.audit()`, `AuditReport`, and `ArtifactInventory`;
43
+ `verify` is the sole trust surface and `verify --rebuild` performs independent rebuild checks.
44
+ - Close and version the seven public CLI JSON schemas. Execution payloads now include stable
45
+ phase timings, while `inspect` and `gc` use one canonical data shape each.
46
+ - Remove transitional compatibility surfaces introduced before v1; callers should use the
47
+ top-level façade, `Runtime`, and the documented v1 result types directly.
48
+
49
+ ### Release capabilities
50
+
51
+ - Add lazy `setup`, `check`, `check_file`, and `replay` Python façade functions.
52
+ - Add `lean-run` with strict TOML frontmatter, automatic local-project discovery,
53
+ exact lock input/output, concise progress, and structured JSON output.
54
+ - Add exact `mathlib@REVISION`, `leancert@REVISION`, and
55
+ `owner/repository@REVISION` package references without permitting floating aliases.
56
+ - Add `ExecutionResult.raise_for_error()` and structured `LeanCheckError` failures.
57
+ - Rewrite the README around the front-facing workflow and expand the standalone
58
+ file, CLI, Python, and routing documentation.
59
+ - Discover pinned local Lake projects from contained Lean files and expose a
60
+ distinct mutable `ProjectEnvironment` API.
61
+ - Preserve project-relative file checks and record content, configuration,
62
+ manifest, and Git project provenance without claiming an environment identity.
63
+ - Add transparent OCI prebuilt-cache lookup with authenticated registry pulls,
64
+ disk-backed blob reuse, strict fallback policy, and explicit `pull` support.
65
+ - Add deterministic OCI publishing through `build-and-push`, with blobs and the
66
+ platform manifest committed before the lock-level index tag.
67
+ - Stream bundle layers and OCI archives through temporary files instead of
68
+ materializing multi-gigabyte package layers in memory.
69
+ - Add deterministic OCI image-layout export and verified, atomic environment import.
70
+ - Verify bundle digests, lock and environment identities, package Git trees,
71
+ archive paths, host compatibility, and a Lean probe before publication.
72
+ - Separate artifact compatibility identity from informational host metadata and
73
+ bump the environment store identity schema.
74
+ - Add verification, decision explanations, semantic context diffs, repeated profiles, and
75
+ bounded matrix execution over ordinary execution results.
76
+ - Add interruptible toolchain installation, Lake resolution, environment builds, matrix checks,
77
+ and project checks with process-group cleanup on cancellation and Ctrl-C.
78
+ - Ship the public JSON schemas in wheel and source distributions and expose `schema_path()`.
79
+ - Add reproducible case-study fixtures, clean-wheel smoke testing, and installed-wheel Lean
80
+ acceptance in CI.
81
+
82
+ ## 0.6.0
83
+
84
+ - Discover packages declared with either `lakefile.toml` or `lakefile.lean`.
85
+ - Translate Lake DSL configurations through the package's exact declared Lean
86
+ toolchain instead of parsing Lean source or guessing package metadata.
87
+
88
+ ## 0.5.0
89
+
90
+ - Add `Environment.execute()` for generic commands such as `lake exe`.
91
+ - Add managed `InteractiveSession` processes with live UTF-8 standard-I/O pipes.
92
+ - Run interactive tools in disposable environment clones with exact provenance.
93
+ - Enforce local timeout, memory, CPU, and bounded-transcript policies for sessions.
94
+ - Gracefully close sessions with stdin EOF before process-group termination.
95
+ - Persist final interactive `ExecutionResult` records and clean up instances.
96
+
97
+ ## 0.4.0
98
+
99
+ - Add `github:owner/repository@tag-or-commit` package references.
100
+ - Discover package identity, root module, and Lean toolchain from Lake projects.
101
+ - Pin convenience references to exact commits before environment resolution.
102
+ - Add one-shot `lean-runtime check FILE --with REFERENCE` execution.
103
+ - Add `Runtime.spec_from_references()`, `resolve_references()`,
104
+ `ensure_references()`, and `Runtime.check(..., packages=[...])`.
105
+ - Detect incompatible discovered toolchains across multi-package requests.
106
+ - Avoid Elan's implicit toolchain installation during installation checks.
107
+
108
+ ## 0.3.0
109
+
110
+ - Add safe multi-file checking and replayable multi-file captures.
111
+ - Add cancellable native asyncio helpers.
112
+ - Add structured lifecycle progress events.
113
+ - Resolve friendly Git tags into exact commit locks.
114
+ - Add installation health, cache status, environment listing, and richer inspection.
115
+ - Add a scheduled real-ecosystem compatibility profile.
116
+ - Store compact, content-verified one-commit source snapshots.
117
+ - Treat direct and transitive package toolchain files as compatibility signals,
118
+ while making the actual selected-toolchain build authoritative.
119
+ - Use execution leases so batch checks can clone concurrently without racing GC.
120
+ - Build imported locked-package roots on demand inside execution workspaces.
121
+ - Add release automation for PyPI trusted publishing.
122
+ - Build and deploy the documentation site through GitHub Pages.
123
+
124
+ ## 0.2.0
125
+
126
+ - Introduce content-addressed environments, exact Git locks, offline reopening,
127
+ execution provenance, captures, aliases, garbage collection, and trusted local
128
+ resource policies.
@@ -4,4 +4,5 @@ recursive-include docs *.md
4
4
  recursive-include examples *.toml
5
5
  recursive-include compatibility *.json *.md *.toml
6
6
  recursive-include scripts *.py
7
+ recursive-include schemas *.json
7
8
  recursive-include tests *.py
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: lean-runtime
3
+ Version: 2.0.0
4
+ Summary: Run Lean 4 proofs from Python or standalone files
5
+ Author: Alejandro Radisic
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/alerad/lean-runtime
8
+ Project-URL: Documentation, https://alerad.github.io/lean-runtime/
9
+ Project-URL: Repository, https://github.com/alerad/lean-runtime.git
10
+ Project-URL: Issues, https://github.com/alerad/lean-runtime/issues
11
+ Project-URL: Changelog, https://github.com/alerad/lean-runtime/blob/main/CHANGELOG.md
12
+ Keywords: lean4,theorem-prover,formal-verification,toolchain
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: tomli>=2; python_version < "3.11"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8; extra == "dev"
27
+ Requires-Dist: ruff>=0.6; extra == "dev"
28
+ Requires-Dist: mypy>=1.10; extra == "dev"
29
+ Requires-Dist: tomli>=2; extra == "dev"
30
+ Requires-Dist: jsonschema>=4.23; extra == "dev"
31
+ Provides-Extra: docs
32
+ Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
33
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
34
+ Dynamic: license-file
35
+
36
+ # Lean Runtime
37
+
38
+ Run Lean proofs from Python or a single `.lean` file—without creating a throwaway
39
+ Lake project or rebuilding the same dependencies on every machine.
40
+
41
+ Lean Runtime discovers the exact Lean environment a project needs and reuses a
42
+ downloadable copy when one is available. It returns structured Lean results
43
+ with a record of the toolchain and dependencies that were actually used.
44
+
45
+ > **Status:** V1 beta. The local backend runs trusted Lean, Lake, and package code;
46
+ > it is an orchestration boundary, not a security sandbox.
47
+
48
+ ## Install
49
+
50
+ ```bash
51
+ python -m pip install lean-runtime
52
+ ```
53
+
54
+ Lean Runtime manages its own Elan installation on macOS and Linux. Windows
55
+ currently requires `LEAN_RUNTIME_ELAN`.
56
+
57
+ ## Run one Lean file
58
+
59
+ Inside an existing pinned Lake project, just pass the file:
60
+
61
+ ```bash
62
+ lean-run MyProject/Main.lean
63
+ ```
64
+
65
+ For a portable standalone file, declare exact dependencies in TOML frontmatter:
66
+
67
+ ```lean
68
+ -- /// lean-runtime
69
+ -- requires = ["mathlib@v4.32.2"]
70
+ -- ///
71
+
72
+ import Mathlib
73
+
74
+ example : 2 + 2 = 4 := by norm_num
75
+ ```
76
+
77
+ ```bash
78
+ lean-run Main.lean
79
+ ```
80
+
81
+ The same context can be supplied from the command line:
82
+
83
+ ```bash
84
+ lean-run Main.lean --with mathlib@v4.32.2
85
+ ```
86
+
87
+ Create an exact lock for CI without changing the file:
88
+
89
+ ```bash
90
+ lean-run Main.lean --with mathlib@v4.32.2 \
91
+ --lock-out environment.lock.json
92
+ lean-run Main.lean --lock environment.lock.json
93
+ ```
94
+
95
+ ## Python
96
+
97
+ Configure an environment once, then use it repeatedly:
98
+
99
+ ```python
100
+ import lean_runtime as lean
101
+
102
+ env = lean.setup(["mathlib@v4.32.2"])
103
+
104
+ result = env.check(
105
+ """
106
+ import Mathlib
107
+ example : 2 + 2 = 4 := by norm_num
108
+ """
109
+ )
110
+ result.raise_for_error()
111
+ ```
112
+
113
+ Batch and asyncio APIs reuse that prepared environment:
114
+
115
+ ```python
116
+ results = env.check_many(generated_proofs, concurrency=8)
117
+ results = await env.check_many_async(generated_proofs, concurrency=20)
118
+ ```
119
+
120
+ Local projects use the same setup pattern while retaining mutable-project
121
+ semantics:
122
+
123
+ ```python
124
+ project = lean.setup(project="./my-project")
125
+ result = project.check_file("./my-project/MyProject/Main.lean")
126
+ ```
127
+
128
+ One-shot helpers are available when setup reuse is unnecessary:
129
+
130
+ ```python
131
+ result = lean.check(source, deps=["mathlib@v4.32.2"])
132
+ result = lean.check_file("./my-project/MyProject/Main.lean")
133
+ ```
134
+
135
+ When you need evidence rather than extra setup, the operations CLI can verify, explain,
136
+ compare, and measure the same exact contexts:
137
+
138
+ ```bash
139
+ lean-runtime verify research-stack --offline
140
+ lean-runtime compare previous.lock.json environment.lock.json
141
+ lean-runtime profile research-stack Main.lean --repeat 5
142
+ lean-runtime matrix compatibility.toml Main.lean
143
+ ```
144
+
145
+ Use `lean-run Main.lean --explain` to inspect context routing without executing Lean, and
146
+ `--timings` to expose preparation versus execution time. Successful ordinary checks remain
147
+ one concise line.
148
+
149
+ Friendly references remain exact: use `mathlib@VERSION`,
150
+ `leancert@VERSION`, `owner/repository@REVISION`, or the explicit
151
+ `github:owner/repository@REVISION` form. Bare floating package names are never
152
+ accepted.
153
+
154
+ ## Share environments
155
+
156
+ A **project** is your ordinary Lake repository. Its **environment** is the exact
157
+ Lean version, dependencies, and build configuration needed to use it. A
158
+ **downloadable environment** is a ready-to-use copy that collaborators and CI
159
+ can fetch instead of rebuilding Mathlib.
160
+
161
+ Environment libraries may be public or private. For example:
162
+
163
+ ```bash
164
+ lean-runtime --library ghcr.io/owner/lean-environments download environment.lock.json
165
+ lean-runtime build-and-publish environment.lock.json \
166
+ --publish-to ghcr.io/owner/lean-environments
167
+ ```
168
+
169
+ For an already-built executable, Lean Runtime can also create a verified
170
+ **ready-to-run program**. It opens without rebuilding the project, can be saved
171
+ as a portable copy, and can be shared through a public or private program
172
+ library. See [Ready-to-run programs](https://github.com/alerad/lean-runtime/blob/main/docs/ready-programs.md).
173
+
174
+ ## Technical details
175
+
176
+ The simple API is backed by exact Git commits and trees, Lake-resolved locks,
177
+ platform-aware content-addressed environments, atomic cross-process builds,
178
+ downloadable environment reuse, replayable provenance, verification, and trusted
179
+ publishers. The libraries use OCI-compatible storage internally, but users do
180
+ not need Docker or container concepts. Advanced protocol details remain in the
181
+ architecture documentation.
182
+
183
+ ## Documentation
184
+
185
+ - [Getting started](https://github.com/alerad/lean-runtime/blob/main/docs/getting-started.md)
186
+ - [Python API](https://github.com/alerad/lean-runtime/blob/main/docs/python-api.md)
187
+ - [`lean-run` and operations CLI](https://github.com/alerad/lean-runtime/blob/main/docs/cli.md)
188
+ - [Managed environments](https://github.com/alerad/lean-runtime/blob/main/docs/environments.md)
189
+ - [Local Lake projects](https://github.com/alerad/lean-runtime/blob/main/docs/local-projects.md)
190
+ - [Portable copies and environment libraries](https://github.com/alerad/lean-runtime/blob/main/docs/portable-copies.md)
191
+ - [Ready-to-run programs](https://github.com/alerad/lean-runtime/blob/main/docs/ready-programs.md)
192
+ - [Architecture](https://github.com/alerad/lean-runtime/blob/main/docs/architecture.md)
193
+ - [Trust and limitations](https://github.com/alerad/lean-runtime/blob/main/docs/trust-and-limitations.md)
194
+ - [V1 release case study](https://github.com/alerad/lean-runtime/blob/main/docs/case-study-v1.md)
195
+
196
+ ## License
197
+
198
+ Apache License 2.0.
@@ -0,0 +1,163 @@
1
+ # Lean Runtime
2
+
3
+ Run Lean proofs from Python or a single `.lean` file—without creating a throwaway
4
+ Lake project or rebuilding the same dependencies on every machine.
5
+
6
+ Lean Runtime discovers the exact Lean environment a project needs and reuses a
7
+ downloadable copy when one is available. It returns structured Lean results
8
+ with a record of the toolchain and dependencies that were actually used.
9
+
10
+ > **Status:** V1 beta. The local backend runs trusted Lean, Lake, and package code;
11
+ > it is an orchestration boundary, not a security sandbox.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ python -m pip install lean-runtime
17
+ ```
18
+
19
+ Lean Runtime manages its own Elan installation on macOS and Linux. Windows
20
+ currently requires `LEAN_RUNTIME_ELAN`.
21
+
22
+ ## Run one Lean file
23
+
24
+ Inside an existing pinned Lake project, just pass the file:
25
+
26
+ ```bash
27
+ lean-run MyProject/Main.lean
28
+ ```
29
+
30
+ For a portable standalone file, declare exact dependencies in TOML frontmatter:
31
+
32
+ ```lean
33
+ -- /// lean-runtime
34
+ -- requires = ["mathlib@v4.32.2"]
35
+ -- ///
36
+
37
+ import Mathlib
38
+
39
+ example : 2 + 2 = 4 := by norm_num
40
+ ```
41
+
42
+ ```bash
43
+ lean-run Main.lean
44
+ ```
45
+
46
+ The same context can be supplied from the command line:
47
+
48
+ ```bash
49
+ lean-run Main.lean --with mathlib@v4.32.2
50
+ ```
51
+
52
+ Create an exact lock for CI without changing the file:
53
+
54
+ ```bash
55
+ lean-run Main.lean --with mathlib@v4.32.2 \
56
+ --lock-out environment.lock.json
57
+ lean-run Main.lean --lock environment.lock.json
58
+ ```
59
+
60
+ ## Python
61
+
62
+ Configure an environment once, then use it repeatedly:
63
+
64
+ ```python
65
+ import lean_runtime as lean
66
+
67
+ env = lean.setup(["mathlib@v4.32.2"])
68
+
69
+ result = env.check(
70
+ """
71
+ import Mathlib
72
+ example : 2 + 2 = 4 := by norm_num
73
+ """
74
+ )
75
+ result.raise_for_error()
76
+ ```
77
+
78
+ Batch and asyncio APIs reuse that prepared environment:
79
+
80
+ ```python
81
+ results = env.check_many(generated_proofs, concurrency=8)
82
+ results = await env.check_many_async(generated_proofs, concurrency=20)
83
+ ```
84
+
85
+ Local projects use the same setup pattern while retaining mutable-project
86
+ semantics:
87
+
88
+ ```python
89
+ project = lean.setup(project="./my-project")
90
+ result = project.check_file("./my-project/MyProject/Main.lean")
91
+ ```
92
+
93
+ One-shot helpers are available when setup reuse is unnecessary:
94
+
95
+ ```python
96
+ result = lean.check(source, deps=["mathlib@v4.32.2"])
97
+ result = lean.check_file("./my-project/MyProject/Main.lean")
98
+ ```
99
+
100
+ When you need evidence rather than extra setup, the operations CLI can verify, explain,
101
+ compare, and measure the same exact contexts:
102
+
103
+ ```bash
104
+ lean-runtime verify research-stack --offline
105
+ lean-runtime compare previous.lock.json environment.lock.json
106
+ lean-runtime profile research-stack Main.lean --repeat 5
107
+ lean-runtime matrix compatibility.toml Main.lean
108
+ ```
109
+
110
+ Use `lean-run Main.lean --explain` to inspect context routing without executing Lean, and
111
+ `--timings` to expose preparation versus execution time. Successful ordinary checks remain
112
+ one concise line.
113
+
114
+ Friendly references remain exact: use `mathlib@VERSION`,
115
+ `leancert@VERSION`, `owner/repository@REVISION`, or the explicit
116
+ `github:owner/repository@REVISION` form. Bare floating package names are never
117
+ accepted.
118
+
119
+ ## Share environments
120
+
121
+ A **project** is your ordinary Lake repository. Its **environment** is the exact
122
+ Lean version, dependencies, and build configuration needed to use it. A
123
+ **downloadable environment** is a ready-to-use copy that collaborators and CI
124
+ can fetch instead of rebuilding Mathlib.
125
+
126
+ Environment libraries may be public or private. For example:
127
+
128
+ ```bash
129
+ lean-runtime --library ghcr.io/owner/lean-environments download environment.lock.json
130
+ lean-runtime build-and-publish environment.lock.json \
131
+ --publish-to ghcr.io/owner/lean-environments
132
+ ```
133
+
134
+ For an already-built executable, Lean Runtime can also create a verified
135
+ **ready-to-run program**. It opens without rebuilding the project, can be saved
136
+ as a portable copy, and can be shared through a public or private program
137
+ library. See [Ready-to-run programs](https://github.com/alerad/lean-runtime/blob/main/docs/ready-programs.md).
138
+
139
+ ## Technical details
140
+
141
+ The simple API is backed by exact Git commits and trees, Lake-resolved locks,
142
+ platform-aware content-addressed environments, atomic cross-process builds,
143
+ downloadable environment reuse, replayable provenance, verification, and trusted
144
+ publishers. The libraries use OCI-compatible storage internally, but users do
145
+ not need Docker or container concepts. Advanced protocol details remain in the
146
+ architecture documentation.
147
+
148
+ ## Documentation
149
+
150
+ - [Getting started](https://github.com/alerad/lean-runtime/blob/main/docs/getting-started.md)
151
+ - [Python API](https://github.com/alerad/lean-runtime/blob/main/docs/python-api.md)
152
+ - [`lean-run` and operations CLI](https://github.com/alerad/lean-runtime/blob/main/docs/cli.md)
153
+ - [Managed environments](https://github.com/alerad/lean-runtime/blob/main/docs/environments.md)
154
+ - [Local Lake projects](https://github.com/alerad/lean-runtime/blob/main/docs/local-projects.md)
155
+ - [Portable copies and environment libraries](https://github.com/alerad/lean-runtime/blob/main/docs/portable-copies.md)
156
+ - [Ready-to-run programs](https://github.com/alerad/lean-runtime/blob/main/docs/ready-programs.md)
157
+ - [Architecture](https://github.com/alerad/lean-runtime/blob/main/docs/architecture.md)
158
+ - [Trust and limitations](https://github.com/alerad/lean-runtime/blob/main/docs/trust-and-limitations.md)
159
+ - [V1 release case study](https://github.com/alerad/lean-runtime/blob/main/docs/case-study-v1.md)
160
+
161
+ ## License
162
+
163
+ Apache License 2.0.
@@ -1,5 +1,16 @@
1
1
  # Architecture
2
2
 
3
+ ## Ready-to-run programs
4
+
5
+ A ready-to-run program is the small result you can open immediately, without
6
+ rebuilding its Lean project first. Lean Runtime verifies its files every time it
7
+ is opened and records the exact source revision and, when known, the environment
8
+ that produced it. Use one for fast service execution. Open the full environment
9
+ when you need kernel replay, custom compilation, or an independent rebuild.
10
+
11
+ Program libraries and portable program copies use OCI-compatible storage under
12
+ the hood. That transport detail does not appear in the ordinary Python API or CLI.
13
+
3
14
  ## Dominant abstraction
4
15
 
5
16
  Lean Runtime is an environment compiler:
@@ -0,0 +1,47 @@
1
+ # V1 release case study
2
+
3
+ The release case study demonstrates the public lifecycle rather than relying on private
4
+ benchmark hooks. It uses a prepared exact Mathlib environment and the committed mixture of
5
+ accepted proofs, elaboration failures, and malformed input.
6
+
7
+ ## Run the evidence harness
8
+
9
+ ```bash
10
+ python scripts/run_v1_case_study.py research-stack \
11
+ --concurrency 1 --concurrency 4 --concurrency 8 --concurrency 20 \
12
+ --repeat 5 --output benchmarks/proof_batch/results.json
13
+ ```
14
+
15
+ The resulting JSON records:
16
+
17
+ - runtime, Python, platform, command, and fixture identity;
18
+ - cache state before and after the workload;
19
+ - raw wall-time samples and min/median/mean/p95/max by concurrency;
20
+ - stable request identity and unique execution identity;
21
+ - bundle size and export/import durations;
22
+ - import into an empty runtime home;
23
+ - offline verification and captured-execution replay.
24
+
25
+ The harness deliberately starts from an already prepared environment. Measure cold source
26
+ preparation separately and state whether local, Lake, and OCI libraries were empty. Do not combine
27
+ cold source builds and warm execution into one headline number.
28
+
29
+ ## Clean-wheel acceptance
30
+
31
+ Build and exercise the artifact users actually install:
32
+
33
+ ```bash
34
+ python -m build
35
+ python scripts/smoke_wheel.py dist/lean_runtime-1.0.0-py3-none-any.whl
36
+ ```
37
+
38
+ Add `--lean` to bootstrap an isolated runtime home and run a real standalone proof. The smoke
39
+ script creates a fresh virtual environment, installs only the wheel, clears ambient Python
40
+ package visibility, checks both console entry points, and reads a packaged v1 schema through
41
+ `lean_runtime.schema_path()`.
42
+
43
+ ## Publishing results
44
+
45
+ Keep the raw JSON beside any summary. Record the exact lock and environment ID, machine and
46
+ filesystem, command line, runtime version, repetition count, and cache state. Timings from noisy
47
+ shared CI are evidence that the workflow completes, not a performance regression gate.
@@ -0,0 +1,122 @@
1
+ # Command-line interface
2
+
3
+ ## `lean-run`
4
+
5
+ The front-facing command checks one file and discovers its context:
6
+
7
+ ```bash
8
+ lean-run Main.lean
9
+ lean-run Main.lean --with mathlib@v4.32.2
10
+ lean-run Main.lean --lock environment.lock.json
11
+ lean-run Main.lean --json
12
+ lean-run Main.lean --explain
13
+ lean-run Main.lean --timings
14
+ ```
15
+
16
+ Use `--lock-out environment.lock.json` with dependencies to retain the exact
17
+ resolved graph. See [Standalone Lean files](standalone-files.md) for frontmatter,
18
+ routing precedence, conflict rules, and output behavior.
19
+
20
+ ## `lean-runtime`
21
+
22
+ All commands accept `--home PATH` before the subcommand to select a store.
23
+
24
+ ## One-shot package workflow
25
+
26
+ ```bash
27
+ lean-runtime check Main.lean \
28
+ --with github:alerad/leancert@v4.32.2.4
29
+ ```
30
+
31
+ `--with` is repeatable. References use
32
+ `mathlib@REVISION`, `OWNER/REPOSITORY@REVISION`, or the explicit
33
+ `github:OWNER/REPOSITORY@REVISION` form. Package discovery reads the root
34
+ `lean-toolchain` and `lakefile.toml`, pins the reference to a full commit, and
35
+ then uses the normal lock and environment pipeline. Multiple discovered
36
+ packages must declare the same toolchain unless `--toolchain` explicitly
37
+ selects the compatibility build.
38
+
39
+ Supporting files work here too:
40
+
41
+ ```bash
42
+ lean-runtime check Main.lean \
43
+ --with github:alerad/leancert@v4.32.2.4 \
44
+ --include Support/Defs.lean
45
+ ```
46
+
47
+ ## Environment workflow
48
+
49
+ ```bash
50
+ lean-runtime prepare environment.toml --output environment.lock.json
51
+ lean-runtime open environment.lock.json --name research-stack
52
+ lean-runtime --library ghcr.io/owner/lean-environments download environment.lock.json
53
+ lean-runtime save-copy research-stack --output research-stack.lean-environment
54
+ lean-runtime --home /tmp/fresh open-copy research-stack.lean-environment --name research-stack
55
+ lean-runtime build-and-publish environment.lock.json --publish-to ghcr.io/owner/lean-environments
56
+ lean-runtime check research-stack Main.lean --json
57
+ lean-runtime inspect research-stack --packages
58
+ lean-runtime environments
59
+ lean-runtime storage
60
+ lean-runtime doctor
61
+ lean-runtime verify research-stack --offline
62
+ lean-runtime compare old.lock.json new.lock.json
63
+ lean-runtime profile research-stack Main.lean --repeat 5
64
+ lean-runtime matrix matrix.toml Main.lean
65
+ lean-runtime clean
66
+ lean-runtime clean --execute
67
+ ```
68
+
69
+ `clean` is a dry run unless `--execute` is supplied.
70
+
71
+ `save-copy` creates a portable environment file. `open-copy` verifies its exact
72
+ identity, package Git trees, computer compatibility, and Lean probe before
73
+ making the environment available. See [Portable copies and environment
74
+ libraries](portable-copies.md) for its trust boundary.
75
+
76
+ ## Replay
77
+
78
+ ```bash
79
+ lean-runtime replay result.execution.json --json
80
+ ```
81
+
82
+ Replay ensures the captured lock, reacquires missing exact sources if network
83
+ is available, and then runs the captured request. An already published
84
+ environment can replay offline.
85
+
86
+ ## Existing projects and core Lean
87
+
88
+ ```bash
89
+ lean-runtime check-file Main.lean --toolchain 4.32.2
90
+ lean-runtime check-file ./existing-project/MyProject/Main.lean
91
+ lean-runtime build ./existing-project MyLibrary
92
+ lean-runtime install 4.32.2
93
+ ```
94
+
95
+ Without `--with`, the environment-aware `check` command requires an environment
96
+ identifier. `check-file` is the direct local-project route. When no
97
+ `--project` or `--toolchain` is supplied, it discovers the nearest directory
98
+ containing a Lake configuration and `lean-toolchain`, then passes the actual
99
+ project-relative file to `lake env lean`.
100
+
101
+ Add supporting source files with repeatable `--include` options:
102
+
103
+ ```bash
104
+ lean-runtime check research-stack Main.lean --include Support/Defs.lean
105
+ ```
106
+
107
+ Resolution and materialization print structured lifecycle progress to stderr.
108
+ Pass global `--quiet` before the subcommand to suppress it.
109
+
110
+ Pass global `--timings` before the subcommand for stable phase timing output. Machine-readable
111
+ execution output uses the versioned `lean-runtime.execution/v1` envelope; the other v1
112
+ schemas and advanced command examples are documented in
113
+ [Verify, understand, compare, and measure](v1-precision.md).
114
+
115
+ Global `--library` is repeatable and `--availability auto|required|local`
116
+ controls whether ready-to-use environments are downloaded or built locally.
117
+ `LEAN_RUNTIME_LIBRARIES` accepts a comma-separated equivalent and
118
+ `LEAN_RUNTIME_AVAILABILITY` sets the default policy.
119
+
120
+ Use global `--publisher_verification required --trusted-publisher ID --trusted-issuer ISSUER`
121
+ to require a verified publisher. `build-and-publish --sign` records the trusted
122
+ publisher using the configured Cosign identity.