Skip to content

fix: expose Array equality for kernel reduction - #14270

Draft
kim-em wants to merge 1 commit into
leanprover:masterfrom
kim-em:expose-array-instdecidableeqimpl
Draft

fix: expose Array equality for kernel reduction#14270
kim-em wants to merge 1 commit into
leanprover:masterfrom
kim-em:expose-array-instdecidableeqimpl

Conversation

@kim-em

@kim-em kim-em commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

This PR lets decide and rfl reduce nonempty Array equality in the kernel across module boundaries.

Array.instDecidableEq delegates its nonempty case to Array.instDecidableEqImpl, which was opaque downstream. That implementation evaluates Array.isEqv and Array.isEqvAux, so expose the full reduction closure. Regression coverage includes equal and unequal nonempty arrays and decide +kernel.

The original broader PR was split into this fix, the Vector DecidableEq fix in #14988, and the Array.ofFn fix in #14989.

@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 Jul 4, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Jul 4, 2026

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 061fa50bfb1eb555654ee704754d30aef51b0521 --onto 41b2fe837a74f3d3449816e58dd6219eac034ff7. You can force Mathlib CI using the force-mathlib-ci label. (2026-07-04 11:58:32)
  • ✅ Mathlib branch lean-pr-testing-14270 has successfully built against this PR. (2026-07-28 13:43:17) View Log
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-09-01 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-09-01 14:14:56)

@leanprover-bot

leanprover-bot commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 061fa50bfb1eb555654ee704754d30aef51b0521 --onto e281ba87c2c967b1662ee28bd201046956d0494a. You can force reference manual CI using the force-manual-ci label. (2026-07-04 11:58:34)
  • ✅ Reference manual branch lean-pr-testing-14270 has successfully built against this PR. (2026-07-28 12:28:55) View Log
  • 🟡 Reference manual branch lean-pr-testing-14270 build against this PR didn't complete normally. (2026-07-28 12:29:40) View Log
  • ✅ Reference manual branch lean-pr-testing-14270 has successfully built against this PR. (2026-07-28 12:48:00) View Log
  • 🟡 Reference manual branch lean-pr-testing-14270 build against this PR didn't complete normally. (2026-07-28 12:49:46) View Log

kim-em added a commit to kim-em/hex-dev that referenced this pull request Jul 4, 2026
)

* refactor(bz): migrate HexBerlekampZassenhaus to the module system

Migrate the executable Berlekamp-Zassenhaus library onto the Lean 4 module
system (module / public import / public section), the prerequisite for
splitting the 19k-line Basic.lean monolith.

Works around two lean4 module-system reduction bugs found in the process:
- Array.instDecidableEqImpl is not @[expose], so decide/rfl over Array
  equality does not reduce in the kernel under the module system for
  nonempty arrays. Worked around with import all Init.Data.Array.DecidableEq
  (keeping the efficient Array instance); upstream fix in leanprover/lean4#14270.
- Array.back? does not reduce under the module system; reimplement
  DensePoly.leadingCoeff as coeffs.getD (size - 1) 0 (equal, reducible).

Adds public meta imports for the #guards, the backward.{proofsInPublic,
privateInPublic} options, @[expose] on the executable defs exported defeq
proofs reduce through, and de-privatises the leaked GcdLaws Rat instance.
No runtime performance regression (only leadingCoeff's compiled body
changes, equal-or-faster; DecidableEq unchanged).

See progress/20260704T000000Z_bz-module-migration-phase1a.md.

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

* fix(bench): repair leadingCoeff Monic proofs in bench/conformance drivers

The DensePoly.leadingCoeff reimplementation (coeffs.getD (size-1) 0 instead
of coeffs.back?.getD 0) broke the monic-witness proofs in the bench exe and
emit-fixture drivers, which the module-migration commit missed because a
plain `lake build` does not build the bench/conformance sub-projects (CI
does). Rewrite the `change ...back?.getD 0 = 1` proofs to close the
getD form via Array.getElem_push.

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

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kim-em kim-em reopened this Jul 28, 2026
@kim-em
kim-em force-pushed the expose-array-instdecidableeqimpl branch from 2beb9e7 to a79caf6 Compare July 28, 2026 08:07
@kim-em kim-em changed the title fix: expose Array.instDecidableEqImpl so Array DecidableEq reduces under the module system fix: kernel reduction of Array/derived DecidableEq and Array.ofFn under the module system Jul 28, 2026
@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 Jul 28, 2026
@leanprover-bot leanprover-bot added the builds-manual CI has verified that the Lean Language Reference builds against this PR label Jul 28, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request Jul 28, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jul 28, 2026
leanprover-bot added a commit to leanprover/reference-manual that referenced this pull request Jul 28, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Jul 28, 2026
Expose the implementation and its isEqv reduction closure so decide and rfl over nonempty Array equality reduce across module boundaries.
@kim-em
kim-em force-pushed the expose-array-instdecidableeqimpl branch from 50541c4 to 81cf4b0 Compare September 1, 2026 13:49
@kim-em kim-em changed the title fix: kernel reduction of Array/derived DecidableEq and Array.ofFn under the module system fix: expose Array equality for kernel reduction Sep 1, 2026
@kim-em kim-em added the changelog-language Language features and metaprograms label Sep 1, 2026
leanprover-bot added a commit to leanprover/reference-manual that referenced this pull request Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-manual CI has verified that the Lean Language Reference builds against this PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms 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.

2 participants