Skip to content

Adaptations for Lean 4.35 - #47

Draft
Kha wants to merge 2 commits into
digama0:arenafrom
Kha:size-reduce
Draft

Kha wants to merge 2 commits into
digama0:arenafrom
Kha:size-reduce

Conversation

@Kha

@Kha Kha commented Sep 9, 2026

Copy link
Copy Markdown

This PR contains two changes necessary for bundling lean4lean in Lean 4.35 (leanprover/lean4#15048):

  • adapt to recent primitive/kernel changes
  • shrink executable size by reducing imports/options. The size is further reduce on the Lean side through special linking options.

Pinned against Lean nightly until rc1 is out.

Kha and others added 2 commits September 9, 2026 13:40
The binary is 231 MB, nearly all of it the statically linked Lean library rather than `lean4lean`'s own code. Two changes bring it to 119 MB with no behavioural change.

`supportInterpreter` exports every symbol in the executable, which stops `--gc-sections` from dropping anything. The checker replays declarations through the kernel and never interprets Lean source, so it does not need the interpreter.

`Lean4Lean/Level.lean` is the only module in the executable's import closure that imports all of `Lean`; it needs only `Lean.Level`. Narrowing it also unblocks a further reduction to roughly 12 MB via `-linitialize_minimal`, once the pinned toolchain is new enough to ship `libinitialize_minimal.a` (leanprover/lean4#14936, first released in v4.35.0).

Checked against v4.33.1 by replaying `Init.Data.List.Basic` from oleans (711 declarations) and by parsing a 10 MB export file through `--import`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPPJuXrRxwXgsWEAqM62dd
Bumps `lean-toolchain` to `nightly-2026-09-06`, with `batteries` on `nightly-testing` and `lean4export` on `master`.

`Decidable` is no longer a `class inductive` with `isTrue`/`isFalse` constructors; it is a structure with a `decide : Bool` field and a `reflects_decide : decide.Reflects p` proof, and `Nat.decLe`, `Nat.decEq` and friends now take that shape. Two changes bring `Primitive.lean`'s reflection layer back in line.

`Reflection.toDec` builds `⟨b, _⟩` directly, so its `decide` field is literally the reflecting `Bool`. Structure eta and proof irrelevance then match it against the real instances, which the old `dite` form could not: a `dite` on an abstract condition has no `decide` field to project.

`Condition.decide` uses the `Decidable.decide` projection instead of `ite _ true false`. Those coincided when `ite` eliminated the `Decidable` inductive directly, but `ite` now goes through `dite`, leaving a `Bool.casesOn` on an abstract `decide` that does not reduce.

The reflection proof deliberately uses only `Bool.noConfusion` and `▸`, mirroring `Nat.decLe`'s own proof: the primitive check runs while replaying the primitive itself, so it may only mention constants in that primitive's dependency closure. `Eq.symm` and `Eq.trans` are not.

Also drops `reduceNative` and its three call sites. Kernel native reduction is gone, so `Lean.reduceBool` and `Lean.reduceNat` no longer exist; the hook only ever returned `none` or threw on those two constants.

Checked by replaying `Init.Data.List.Basic` into a fresh environment (5558 declarations, which exercises every primitive) and through `--import` on a 10 MB export file (4866 declarations), including an export produced by a different Lean build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPPJuXrRxwXgsWEAqM62dd
miguelangelorocha pushed a commit to iggue/lean4 that referenced this pull request Sep 10, 2026
…leanprover#15048)

This PR bundles the `lean4lean` external checker with release
toolchains, so it can be used as an independent checker without a
separate install.

Bundles digama0/lean4lean#47, an updated version
of the kernel arena branch

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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