Skip to content

fix: restore sharing for discharged hypothesis proofs that occur in the result in Sym.simp - #14424

Merged
leodemoura merged 3 commits into
masterfrom
sym_discharge_leak
Jul 16, 2026
Merged

fix: restore sharing for discharged hypothesis proofs that occur in the result in Sym.simp#14424
leodemoura merged 3 commits into
masterfrom
sym_discharge_leak

Conversation

@leodemoura

Copy link
Copy Markdown
Member

This PR fixes a maximal-sharing violation in Sym.simp: when a conditional rewrite discharged a hypothesis that occurs in the theorem's right-hand side., the discharger-provided proof was spliced into the resulting term without restoring maximal sharing, violating the SymM sharing invariant (detected by sym.debug). Dischargers are not required to return maximally shared proofs. This issue was reported by @hargoniX

Theorem now stores rhsVarMask, a bitmask computed once at theorem construction that records which theorem variables occur in the right-hand side. During rewriting, Theorem.rewrite applies shareCommon to a discharged hypothesis proof only when the corresponding bit is set, i.e., only when the proof becomes part of the resulting term.

@leodemoura leodemoura added the changelog-tactics User facing tactics label Jul 16, 2026
@leodemoura
leodemoura enabled auto-merge July 16, 2026 22:24
@leodemoura
leodemoura added this pull request to the merge queue Jul 16, 2026
@leodemoura

Copy link
Copy Markdown
Member Author

!bench

Merged via the queue into master with commit 0c8d331 Jul 16, 2026
21 of 22 checks passed
@leanprover-radar

leanprover-radar commented Jul 16, 2026

Copy link
Copy Markdown

Benchmark results for afb4f7d against 94b4a6e are in. No significant results found. @leodemoura

  • 🟥 build//instructions: +1.4G (+0.01%)

Medium changes (1✅, 1🟥)

  • compiled/incr_header_save//instructions: -921.5M (-14.21%)
  • 🟥 elab/bv_decide_mod//maxrss: +167MiB (+9.15%)

Small changes (3🟥)

  • 🟥 build/module/Lean.Meta.Sym.Simp.Rewrite//instructions: +163.3M (+7.28%) (reduced significance based on *//lines)
  • 🟥 build/module/Lean.Meta.Sym.Simp.Theorems//instructions: +90.0M (+3.48%) (reduced significance based on *//lines)
  • 🟥 lake/inundation/startup//maxrss: +5MiB (+4.46%)

robsimmons pushed a commit that referenced this pull request Jul 29, 2026
…he result in `Sym.simp` (#14424)

This PR fixes a maximal-sharing violation in `Sym.simp`: when a
conditional rewrite discharged a hypothesis that occurs in the theorem's
right-hand side., the discharger-provided proof was spliced into the
resulting term without restoring maximal sharing, violating the `SymM`
sharing invariant (detected by `sym.debug`). Dischargers are not
required to return maximally shared proofs. This issue was reported by
@hargoniX

`Theorem` now stores `rhsVarMask`, a bitmask computed once at theorem
construction that records which theorem variables occur in the
right-hand side. During rewriting, `Theorem.rewrite` applies
`shareCommon` to a discharged hypothesis proof only when the
corresponding bit is set, i.e., only when the proof becomes part of the
resulting term.
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.

2 participants