feat: restrict simpa using h close to reducible transparency#13636
Open
kim-em wants to merge 1 commit intoleanprover:masterfrom
Open
feat: restrict simpa using h close to reducible transparency#13636kim-em wants to merge 1 commit intoleanprover:masterfrom
simpa using h close to reducible transparency#13636kim-em wants to merge 1 commit intoleanprover:masterfrom
Conversation
This PR makes `simpa using h` require the simplified `h` and the simplified goal to match at reducible transparency, rather than at the ambient (default/semireducible) transparency used previously. This makes `simpa using h` more predictable: it no longer succeeds via incidental β/δ-reduction at the closing step, so adding new `simp` lemmas is less likely to silently break unrelated `simpa` calls. The new behaviour is gated by a backward-compat option `backward.simpa.using.reducibleClose` (defaulting to `true`); set it to `false` per-call, per-section, or globally to restore the previous behaviour. Two existing in-tree tests (`getElemV.lean`, `scopeCacheProofs.lean`) relied on the old behaviour; they are annotated with the option and an explanatory comment so the breakage is visible. The change wraps only the precondition `isDefEq` check inside `Lean.Elab.Tactic.Simpa.evalSimpa`. The downstream metavariable-assignment check (`MVarId.checkedAssign` → `checkTypesAndAssign`) still escalates transparency internally, but the reducible-transparency precondition strictly dominates it, so the escalation is benign. Motivated by Floris's Zulip thread on `simpa` code quality: https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Mathlib.20code.20quality.3A.20simpa Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 makes
simpa using hrequire the simplifiedhand the simplified goal to match at reducible transparency, rather than at the ambient (default/semireducible) transparency used previously. This makessimpa using hmore predictable: it no longer succeeds via incidental β/δ-reduction at the closing step, so adding newsimplemmas is less likely to silently break unrelatedsimpacalls.The new behaviour is gated by a backward-compat option
backward.simpa.using.reducibleClose(defaulting totrue); set it tofalseper-call, per-section, or globally to restore the previous behaviour. Two existing in-tree tests (getElemV.lean,scopeCacheProofs.lean) relied on the old behaviour; they are annotated with the option and an explanatory comment so the breakage is visible.The change wraps only the precondition
isDefEqcheck insideLean.Elab.Tactic.Simpa.evalSimpa. The downstream metavariable-assignment check (MVarId.checkedAssign→checkTypesAndAssign) still escalates transparency internally, but the reducible-transparency precondition strictly dominates it, so the escalation is benign.This addresses Jovan's point (1) of the proposal in https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Mathlib.20code.20quality.3A.20simpa, narrowing what
simpacan do without the broader behaviour change of also usinghas a simp lemma. The PR is branched fromnightly-with-mathlibso Mathlib breakage data can be gathered via the existing nightly-testing infrastructure.🤖 Prepared with Claude Code