fix: consistent term order in linear integer normalization (#7560)
This PR ensures that we use the same ordering to normalize linear `Int` terms and relations. This change affects `simp +arith` and `grind` normalizer. This consistency is important in the cutsat procedure. We want to avoid a situation where the cutsat state contains both "atoms": - `「(NatCast.natCast x + NatCast.natCast y) % 8」` - `「(NatCast.natCast y + NatCast.natCast x) % 8」` This was happening because we were using different orderings for (nested) terms and relations (`=`, `<=`).
This commit is contained in:
parent
134d11f1a3
commit
389537cf0e
2 changed files with 13 additions and 1 deletions
|
|
@ -211,7 +211,7 @@ def toLinearExpr (e : Expr) : MetaM (Int.Linear.Expr × Array Expr) := do
|
|||
if atoms.size == 1 then
|
||||
return (e, atoms)
|
||||
else
|
||||
let (atoms, perm) := sortExprs atoms
|
||||
let (atoms, perm) := sortExprs atoms (lt := false)
|
||||
let e := e.applyPerm perm
|
||||
return (e, atoms)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,3 +30,15 @@ example (x y : Nat) :
|
|||
|
||||
example (i : Nat) : i < 330 → 7 ∣ (660 + i) * (1319 - i) → 1319 - i < 1979 := by
|
||||
grind
|
||||
|
||||
example (x y : Nat) (_ : 2 ≤ x) (_ : x ≤ 3) (_ : 2 ≤ y) (_ : y ≤ 3) :
|
||||
4 ≤ (x + y) % 8 ∧ (x + y) % 8 ≤ 6 := by
|
||||
grind
|
||||
|
||||
example (x y : Nat) (_ : 2 ≤ x) (_ : x ≤ 3) (_ : 2 ≤ y) (_ : y ≤ 3) :
|
||||
4 ≤ (y + x) % 8 ∧ (x + y) % 8 ≤ 6 := by
|
||||
grind
|
||||
|
||||
example (x y : Nat) (_ : 2 ≤ x) (_ : x ≤ 3) (_ : 2 ≤ y) (_ : y ≤ 3) :
|
||||
4 ≤ (y + x) % 8 ∧ (y + x) % 8 ≤ 6 := by
|
||||
grind
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue