fix: redundant information in the offset constraint module (#6734)

This PR ensures there are no redundant entries in the offset constraint
model produced by `grind`
This commit is contained in:
Leonardo de Moura 2025-01-21 14:19:24 -08:00 committed by GitHub
parent c9a03c7613
commit 3881f21df1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View file

@ -39,7 +39,7 @@ def mkModel (goal : Goal) : MetaM (Array (Expr × Nat)) := do
We should not include the assignment for auxiliary offset terms since
they do not provide any additional information.
-/
if (isNatOffset? e).isNone && isNatNum? e != some 0 then
if !(← isLitValue e) && (isNatOffset? e).isNone && isNatNum? e != some 0 then
r := r.push (e, val)
return r

View file

@ -121,6 +121,7 @@ private def ppOffset : M Unit := do
let nodes := s.nodes
if nodes.isEmpty then return ()
let model ← Arith.Offset.mkModel goal
if model.isEmpty then return ()
let mut ms := #[]
for (e, val) in model do
ms := ms.push <| .trace { cls := `assign } m!"{e} := {val}" #[]

View file

@ -325,3 +325,28 @@ example (x y : S) : x.a = y.a → y.b = x.b → x = y := by
example (x : S) : x.a = 10 → false ≠ x.b → x = { a := 10, b := true } := by
grind
-- In the following test, we should not display `10 := 10` and `20 := 20` in the
-- assignment produced by the offset module
/--
error: `grind` failed
case grind
a : Nat
b : Bool
a✝¹ : (if b = true then 10 else 20) = a
a✝ : b = true
⊢ False
[grind] Diagnostics
[facts] Asserted facts
[prop] (if b = true then 10 else 20) = a
[prop] b = true
[eqc] True propositions
[prop] b = true
[eqc] Equivalence classes
[eqc] {a, if b = true then 10 else 20, 10}
[eqc] {b, true}
-/
#guard_msgs (error) in
example (b : Bool) : (if b then 10 else 20) = a → b = true → False := by
grind