This PR fixes a panic in `grind` where `sreifyCore?` could encounter power subterms not yet internalized in the E-graph during nested propagation. The ring reifier (`reifyCore?`) already had a defensive `alreadyInternalized` check before creating variables, but the semiring reifier (`sreifyCore?`) was missing this guard. When `propagatePower` decomposed `a ^ (b₁ + b₂)` into `a^b₁ * a^b₂` and the resulting terms triggered further propagation, the semiring reifier could be called on subterms not yet in the E-graph, causing `markTerm` to fail. Closes #12428 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
14 lines
400 B
Text
14 lines
400 B
Text
import Std.Do
|
|
|
|
-- `grind` should not panic on this example (issue #12428).
|
|
-- The bug was that `sreifyCore?` could encounter power subterms
|
|
-- not yet internalized in the E-graph during nested propagation.
|
|
example
|
|
(n x' y : Nat)
|
|
(pref : List Nat)
|
|
(cur : Nat)
|
|
(suff : List Nat)
|
|
(h : List.range' 0 n 1 = pref ++ cur :: suff) :
|
|
y ^ x' * n ^ x' = x' ^ n := by
|
|
fail_if_success grind
|
|
sorry
|