fix: grind AC invariant (#13614)
This PR fixes the invariant in `grind` AC. equations in the todo queue are not fully simplified.
This commit is contained in:
parent
030397785c
commit
fe3c7394fd
2 changed files with 20 additions and 8 deletions
|
|
@ -22,29 +22,34 @@ def checkVars : ACM Unit := do
|
|||
num := num + 1
|
||||
assert! s.vars.size == num
|
||||
|
||||
def checkSeq (s : AC.Seq) : ACM Unit := do
|
||||
/-
|
||||
**Note**: Elements in the todo queue are not fully simplified.
|
||||
Recall that we only (fully) simplify them when adding them to the basis.
|
||||
-/
|
||||
def checkSeq (s : AC.Seq) (simplified : Bool) : ACM Unit := do
|
||||
if (← isCommutative) then
|
||||
assert! s.isSorted
|
||||
if (← hasNeutral) then
|
||||
assert! !s.contains 0 || s == .var 0
|
||||
if (← isIdempotent) then
|
||||
assert! s.noAdjacentDuplicates
|
||||
if simplified then
|
||||
if (← isIdempotent) then
|
||||
assert! s.noAdjacentDuplicates
|
||||
|
||||
def checkLhsRhs (lhs rhs : AC.Seq) : ACM Unit := do
|
||||
checkSeq lhs; checkSeq rhs
|
||||
def checkLhsRhs (lhs rhs : AC.Seq) (simplified : Bool) : ACM Unit := do
|
||||
checkSeq lhs simplified; checkSeq rhs simplified
|
||||
|
||||
def checkBasis : ACM Unit := do
|
||||
for c in (← getStruct).basis do
|
||||
assert! compare c.lhs c.rhs == .gt
|
||||
checkLhsRhs c.lhs c.rhs
|
||||
checkLhsRhs c.lhs c.rhs (simplified := true)
|
||||
|
||||
def checkQueue : ACM Unit := do
|
||||
for c in (← getStruct).queue do
|
||||
checkLhsRhs c.lhs c.rhs
|
||||
checkLhsRhs c.lhs c.rhs (simplified := false)
|
||||
|
||||
def checkDiseqs : ACM Unit := do
|
||||
for c in (← getStruct).diseqs do
|
||||
checkLhsRhs c.lhs c.rhs
|
||||
checkLhsRhs c.lhs c.rhs (simplified := true)
|
||||
|
||||
def checkStructInvs : ACM Unit := do
|
||||
checkVars
|
||||
|
|
|
|||
7
tests/elab/grind_ac_inv_issue.lean
Normal file
7
tests/elab/grind_ac_inv_issue.lean
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
public section
|
||||
|
||||
namespace List
|
||||
|
||||
set_option grind.debug true in
|
||||
theorem take_eq_self_iff (x : List α) {n : Nat} : x.take n = x → x.length ≤ n := by
|
||||
grind
|
||||
Loading…
Add table
Reference in a new issue