Skip to content

Support Lean 4.35 and loading compiled proof projects - #15

Draft
kiranandcode wants to merge 4 commits into
bump-lean-v4.34.1from
codex/lean-4.35-newton
Draft

kiranandcode wants to merge 4 commits into
bump-lean-v4.34.1from
codex/lean-4.35-newton

Conversation

@kiranandcode

Copy link
Copy Markdown
Collaborator

Lean 4.35 projects cannot use the current bridge: its toolchain differs, and decideProp assumes the old inductive representation of Decidable. This upgrades the toolchains, pins Pantograph's Lean 4.35 revision, and reads the new Boolean field when deciding propositions.

The kernel example loads an existing project's compiled modules using its Lake search path. It supports declaration types and axiom inspection without linking the inspected project's native libraries or Mathlib:static.

This draft is stacked on #14. Regex has no compatible release yet: plain first lake build fails in SparseSet.Bijection with a grind panic. The explicit scripts/prepare_lean435.py bootstrap checks the exact source SHA-256 and applies a proof-only workaround before building. It is idempotent, rejects unexpected source, and runs in CI. There is no automatic update hook. Remove this workaround when upstream provides a compatible revision.

Validation on AWS Linux, Lean 4.35.0:

  • Root library, TestLib shared library, and KernelBridge shared library build.
  • 1,325 pytest tests pass, including the existing true/false decision tests and standalone bundled-library tests.
  • Ruff checks/format and mypy pass.
  • Regex preparation tested from pristine source and repeated for idempotence.
  • KernelBridge loads VerifyNumericalAnalysis's compiled Mathlib/Newton modules. Newton step semantics, convergence, and rewrite equivalence declarations report only Classical.choice, Quot.sound, and propext; a tactic goal also succeeds.

macOS and sanitizer checks remain for CI. The six existing examples have updated toolchains/locks but were not individually rebuilt. Native evaluation of arbitrary imported projects may require their native libraries; declaration inspection does not.

kiranandcode and others added 4 commits August 10, 2026 18:57
* Harden C bridge; add stub, wheel, and type-check tooling

- GIL: acquire around every CPython-touching bridge entry via a
  cleanup-attribute WITH_GIL macro (releases on all return paths).
- Remove dead lean_types.py + manual m_rc helpers; route library.py
  through lean_dec. Replace magic IO.Error tag constants with
  lean_is_string. Clear stale worktree/autosave/pyc; fix README count.
- stubgen: generate .pyi from the registry (mypy-clean).
- packaging: vendor the dylib closure + lean.h into a py3-none wheel
  that loads with no toolchain present.
- registry: TypeRepr drives both the stub annotation and a runtime
  predicate (matches/check); opt-in set_argument_typechecking.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Fix lint: ruff format, drop unused import, mypy None-guard

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Harden C bridge; add stub, wheel, and type-check tooling

- GIL: acquire around every CPython-touching bridge entry via a
  cleanup-attribute WITH_GIL macro (releases on all return paths).
- Remove dead lean_types.py + manual m_rc helpers; route library.py
  through lean_dec. Replace magic IO.Error tag constants with
  lean_is_string. Clear stale worktree/autosave/pyc; fix README count.
- stubgen: generate .pyi from the registry (mypy-clean).
- packaging: vendor the dylib closure + lean.h into a py3-none wheel
  that loads with no toolchain present.
- registry: TypeRepr drives both the stub annotation and a runtime
  predicate (matches/check); opt-in set_argument_typechecking.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Fix lint: ruff format, drop unused import, mypy None-guard

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Bump Lean toolchain v4.29.1 -> v4.34.1

- lean-toolchain (root, tests/lean, examples/*) -> v4.34.1
- Regex v4.29.0 -> v4.34.0-rc1; Pantograph dev -> 92d4818
- Kernel.declAxioms: use public Lean.collectAxioms (CollectAxioms.collect
  is now private)
- Kernel.envUnpickle/goalUnpickle: re-enable initializer execution, since
  withImporting now clears the flag after each import
- Z3 datatypes: compileDecls the inductive before mkCtorIdx etc.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Main's tree equals the old base (bump-lean-v4.34.1); conflicts in the
toolchain and lake manifests take this branch's Lean 4.35 versions.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant