Skip to content

Remove Mathlib dependency to shrink the compiled binary - #44

Merged
chriseth merged 2 commits into
powdr-labs:mainfrom
chris-ai1:remove-mathlib
Aug 5, 2026
Merged

Remove Mathlib dependency to shrink the compiled binary#44
chriseth merged 2 commits into
powdr-labs:mainfrom
chris-ai1:remove-mathlib

Conversation

@chris-ai1

Copy link
Copy Markdown
Contributor

Linking the yul-semantics executable currently compiles + links native object code for every transitively imported Mathlib module (~8500 C files), which dominates both CI time and binary size. The library's actual footprint in Mathlib is tiny, so we remove the dependency:

  1. YulSemantics/Adequacy.lean — drop import Mathlib.Data.Nat.Basic; nothing from it is used (omega/simp are core).
  2. YulSemantics/Dialect/EVM.lean — drop import Mathlib.Tactic.SplitIfs; replace the single split_ifs at h1 h2 with core split at ....
  3. YulSemantics/Equiv.lean — drop import Mathlib.Data.List.Forall2; define a local Forall₂ inductive with the imp lemma (the only Mathlib API used).
  4. YulSemantics/FibExample.lean — drop import Mathlib.Data.Nat.Fib.Basic; define a local fib with a fib_add_two defining equation and state the theorems against it.
  5. lakefile.toml — replace require mathlib with a direct require batteries (small, pure-Lean), kept only for the batteries/runLinter lint driver and the nolint attribute used in YulSemantics/Dialect.lean. Regenerate lake-manifest.json.
  6. .github/workflows/lean_action_ci.yml — set use-mathlib-cache to false.

Each step keeps lake build green; verified locally before push.

chris-ai1 and others added 2 commits August 4, 2026 12:23
Linking the `yul-semantics` executable currently compiles + links native
object code for every transitively imported Mathlib module (~8500 C
files), which dominates both CI time and binary size. The library's
actual footprint in Mathlib is tiny, so we remove the dependency:

1. YulSemantics/Adequacy.lean — drop `import Mathlib.Data.Nat.Basic`;
   nothing from it is used (omega/simp are core).
2. YulSemantics/Dialect/EVM.lean — drop `import Mathlib.Tactic.SplitIfs`;
   replace the single `split_ifs at h1 h2` with core `split at ...`.
3. YulSemantics/Equiv.lean — drop `import Mathlib.Data.List.Forall2`;
   define a local `Forall₂` inductive with the `imp` lemma (the only
   Mathlib API used).
4. YulSemantics/FibExample.lean — drop `import Mathlib.Data.Nat.Fib.Basic`;
   define a local `fib` with a `fib_add_two` defining equation and state
   the theorems against it.
5. lakefile.toml — replace `require mathlib` with a direct
   `require batteries` (small, pure-Lean), kept only for the
   `batteries/runLinter` lint driver and the `nolint` attribute used in
   YulSemantics/Dialect.lean. Regenerate lake-manifest.json.
6. .github/workflows/lean_action_ci.yml — set use-mathlib-cache to false.

Each step keeps `lake build` green; verified locally before push.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Implements the plan from the previous commit:

* Adequacy.lean: drop the unused `Mathlib.Data.Nat.Basic` import; spell
  the two `le_rfl` uses as core `Nat.le_refl`.
* Dialect/EVM.lean: drop `Mathlib.Tactic.SplitIfs`; replace the single
  `split_ifs at h1 h2` with core `repeat1' (first | split at h1 | split
  at h2)`.
* Equiv.lean: drop `Mathlib.Data.List.Forall2`; add a local `Forall₂`
  inductive with the `imp` lemma (all the file used).
* FibExample.lean: drop `Mathlib.Data.Nat.Fib.Basic`; add a local `fib`
  and `fib_add_two`, and state the theorems against them.
* lakefile.toml: require batteries v4.31.0 directly (only for the
  `batteries/runLinter` lint driver and the `nolint` attribute used in
  Dialect.lean) instead of mathlib. The manifest shrinks from 9 packages
  to 1.
* CI: no Mathlib cache step; Batteries builds from source in minutes.
* README/DESIGN/docstrings updated accordingly.

Verified: `lake build`, `lake lint`, and `lake build yul-semantics` all
succeed from a clean checkout; the placeholder exe runs. The linked
executable is 114M unstripped / 76M stripped, and no longer pulls any
Mathlib object code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chris-ai1 chris-ai1 changed the title Plan: remove the Mathlib dependency to shrink the compiled binary Remove Mathlib dependency to shrink the compiled binary Aug 4, 2026
@chriseth
chriseth merged commit 852d3ca into powdr-labs:main Aug 5, 2026
1 check passed
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.

2 participants