Skip to content

feat: restrict simpa using h close to reducible transparency#13636

Open
kim-em wants to merge 1 commit intoleanprover:masterfrom
kim-em:simpa-reducible-impl
Open

feat: restrict simpa using h close to reducible transparency#13636
kim-em wants to merge 1 commit intoleanprover:masterfrom
kim-em:simpa-reducible-impl

Conversation

@kim-em
Copy link
Copy Markdown
Collaborator

@kim-em kim-em commented May 5, 2026

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.checkedAssigncheckTypesAndAssign) 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 simpa can do without the broader behaviour change of also using h as a simp lemma. The PR is branched from nightly-with-mathlib so Mathlib breakage data can be gathered via the existing nightly-testing infrastructure.

🤖 Prepared with Claude Code

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>
@kim-em kim-em requested a review from digama0 as a code owner May 5, 2026 03:44
@kim-em kim-em added the changelog-tactics User facing tactics label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant