Skip to content

feat: cbv on arrays using a tree data structure - #14732

Draft
Rob23oba wants to merge 3 commits into
leanprover:masterfrom
Rob23oba:cbv-tree-array
Draft

feat: cbv on arrays using a tree data structure#14732
Rob23oba wants to merge 3 commits into
leanprover:masterfrom
Rob23oba:cbv-tree-array

Conversation

@Rob23oba

Copy link
Copy Markdown
Contributor

This PR adds special support for many Array operations in cbv by rewriting them to operations on Lean.Sym.PartialBlock, a tree data structure.

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 10, 2026
@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-08-08 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-08-10 09:53:54)

@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Aug 10, 2026

end ArrayBuilderCtx

builtin_cbv_simproc ↓ simpPartialToArray (PartialBlock.toArray _) := fun e => do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you achieve this with cbv_opaque annotation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does cbv_opaque prevent it from visiting subexpressions?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it only prevents from unfolding the function body.

@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Aug 10, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 10, 2026

Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request Aug 10, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Aug 10, 2026
@wkrozowski

Copy link
Copy Markdown
Contributor

!bench

@leanprover-radar

leanprover-radar commented Aug 11, 2026

Copy link
Copy Markdown

Benchmark results for 11f991c against 87e7204 are in. There are significant results. @wkrozowski

  • 🟥 build//instructions: +21.4G (+0.18%)

Large changes (1🟥)

  • 🟥 size/Init/.olean//bytes: +614kiB (+0.63%)

Medium changes (1✅)

  • build/profile/grind dsimp//wall-clock: -3ms (-44.12%)

Small changes (1✅, 11🟥)

  • 🟥 build/module/Init.Data.Bool//instructions: +33.9M (+0.78%)
  • 🟥 build/module/Init.Sym//instructions: +24.6M (+4.68%) (reduced significance based on *//lines)
  • build/module/Lean.Elab.PreDefinition//instructions: -17.3M (-1.83%)
  • 🟥 build/module/Lean.Meta.Tactic.Cbv.BuiltinCbvSimprocs.Array//instructions: +15.6G (+1074.19%) (reduced significance based on *//lines)
  • 🟥 size/Init/.olean.private//bytes: +843kiB (+0.33%)
  • 🟥 size/all/.c//lines: +29.1k (+0.24%)
  • 🟥 size/all/.ilean//bytes: +214kiB (+0.25%)
  • 🟥 size/all/.ir//bytes: +828kiB (+0.23%)
  • 🟥 size/all/.olean.private//bytes: +3MiB (+0.22%)
  • 🟥 size/compile/.out//bytes: +7MiB (+0.25%)
  • 🟥 size/libleanshared.so//bytes: +537kiB (+0.24%)
  • 🟥 vcgen/PurePrecond/400/vcgen//wall-clock: +3ms (+9.24%)

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

Labels

builds-mathlib CI has verified that Mathlib builds against this PR mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants