feat: use explicit allowlist instead of transparency bump in whnfMatcher#13363
Draft
nomeata wants to merge 18 commits intonightly-with-mathlibfrom
Draft
feat: use explicit allowlist instead of transparency bump in whnfMatcher#13363nomeata wants to merge 18 commits intonightly-with-mathlibfrom
nomeata wants to merge 18 commits intonightly-with-mathlibfrom
Conversation
Previously, `whnfMatcher` would increase the transparency from `.reducible` to `.instances` when reducing match expressions. This caused surprising over-unfolding when `implicit_reducible` definitions appeared in match discriminants, as reported in the discussion around `whnfMatcher`'s TODO comment. This PR removes the `withTransparency .instances` call so that `whnfMatcher` now runs at the ambient transparency. To ensure match discriminants involving class projections (e.g. `OfNat.ofNat`, `NatCast.natCast`, `Pure.pure`) still reduce to expose constructors, `canUnfoldAtMatcher` now allows unfolding any class projection (`projInfo.fromClass`). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
Reference manual CI status:
|
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 10, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Apr 10, 2026
|
Mathlib CI status (docs):
|
…fMatcher` Replace the `implicitReducible` and `fromClass` checks in `canUnfoldAtMatcher` with an explicit allowlist of class projections and instances. Delegate to `canUnfoldDefault` first so that `withCanUnfoldPred` does not accidentally block sub-calls at different transparencies. This ensures that marking more definitions as `implicit_reducible` in the future will not silently change which terms get unfolded in match discriminants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 13, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Apr 13, 2026
|
Mathlib CI status (docs):
|
Remove entries that are not needed for tests or stage 2 to pass: Std.Stream.next?, MonadStateOf.get, MonadState.get, Bind.bind, Ord.compare, LT.lt, LE.le, HAppend.hAppend, Append.append, GetElem?.getElem?, BEq.beq, HSub.hSub, Sub.sub, HMod.hMod, Mod.mod. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove: instDecidableEqBool, instBEqOfDecidableEq, String.decEq, List.hasDecEq, Char.ofNat, Char.ofNatAux. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…` allowlist Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Nat.add → instAddNat → instHAdd chain is not needed because these definitions are already handled by canUnfoldDefault or matchPattern attributes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eeded Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use `Nat.decEq` (which is reducible) directly instead of the generic `decEq` (which is semireducible) when comparing constructor indices in derived BEq instances. This removes the need for `decEq`, `instDecidableEqNat`, and `Nat.decEq` in the `canUnfoldAtMatcher` allowlist. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The `unfold` tactic no longer over-unfolds `2 * x` to `Nat.mul 2 x` in match discriminants. Update `unfold1` test expected output accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 13, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Apr 13, 2026
|
Mathlib CI status (docs):
|
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 13, 2026
…` allowlist Without Pure.pure, the mvcgenTutorial test needs an explicit `dsimp only [pure]` before `grind`. Without the Nat.mul chain, `unfold isEven` no longer reduces the match on `2 * (x + 1)` in unfold1, but the proof still works by definitional equality. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add explicit `Least?.least?` to the `simp` calls in the five PRange Nat lemmas that need it to unfold `least?` to `some 0`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…owlist Add explicit `UpwardEnumerable.succ?` to the `simp` calls in the two PRange Int lemmas that need it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `Fin.getElem_fin` to the `simp` calls in BVDecide's RupAddResult proofs so that `units[j]` (Fin indexing) is normalized to `units[↑j]` (Nat indexing), allowing the induction hypotheses to match before `clearUnit` unfolds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
.instances in whnfMatcher
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 13, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Apr 13, 2026
|
Mathlib CI status (docs):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces the transparency bump from
.reducibleto.instancesinwhnfMatcherwith an explicit, minimal allowlist incanUnfoldAtMatcher. Previously,whnfMatcherwould unfold allimplicitReducibledefinitions and allfromClassprojections when reducing match discriminants. This made it impossible to mark definitions asimplicit_reduciblewithout silently affecting match reduction behavior.The new
canUnfoldAtMatcherdelegates tocanUnfoldDefaultfirst (respecting the ambient transparency), then allows unfolding ofmatch_pattern-attributed definitions, and finally checks a small explicit allowlist:OfNat.ofNat(for numeric literals) andNatCast.natCast(for↑mcoercions, pervasive in Int proofs).All other definitions that were previously unfolded via the blanket
implicitReducible/fromClasschecks have been removed from the allowlist after verifying they are not needed, or the proofs that depended on them have been updated:RupAddResultproofs: addFin.getElem_finto normalize Fin-indexed array access beforeclearUnitunfoldsNatLemmas/IntLemmas: add explicitLeast?.least?andUpwardEnumerable.succ?tosimpcallsmvcgenTutorialtest: addpuretodsimp onlycallunfold1test: update expected output (match discriminant no longer over-unfolds)TakeDropproof: uselength, drop_succ_consinstead ofdropNat.decEqinstead of genericdecEq(extracted to separate PR refactor: use Nat.decEq in derived BEq instances #13390)