fix: arrow congruence in grind (#8280)
This PR the support for arrows in the congruence closure procedure used in `grind`.
This commit is contained in:
parent
575b4786f9
commit
9096eb168d
3 changed files with 14 additions and 5 deletions
|
|
@ -37,6 +37,12 @@ where
|
|||
proof? := proofNew?
|
||||
}
|
||||
|
||||
/--
|
||||
Returns `true` if the parent is relevant for congruence closure.
|
||||
-/
|
||||
private def isCongrRelevant (parent : Expr) : Bool :=
|
||||
parent.isApp || parent.isArrow
|
||||
|
||||
/--
|
||||
Removes `root` parents from the congruence table.
|
||||
This is an auxiliary function performed while merging equivalence classes.
|
||||
|
|
@ -45,7 +51,7 @@ private def removeParents (root : Expr) : GoalM ParentSet := do
|
|||
let parents ← getParents root
|
||||
for parent in parents do
|
||||
-- Recall that we may have `Expr.forallE` in `parents` because of `ForallProp.lean`
|
||||
if (← pure parent.isApp <&&> isCongrRoot parent) then
|
||||
if (← pure (isCongrRelevant parent) <&&> isCongrRoot parent) then
|
||||
trace_goal[grind.debug.parent] "remove: {parent}"
|
||||
modify fun s => { s with congrTable := s.congrTable.erase { e := parent } }
|
||||
return parents
|
||||
|
|
@ -56,7 +62,7 @@ This is an auxiliary function performed while merging equivalence classes.
|
|||
-/
|
||||
private def reinsertParents (parents : ParentSet) : GoalM Unit := do
|
||||
for parent in parents do
|
||||
if (← pure parent.isApp <&&> isCongrRoot parent) then
|
||||
if (← pure (isCongrRelevant parent) <&&> isCongrRoot parent) then
|
||||
trace_goal[grind.debug.parent] "reinsert: {parent}"
|
||||
addCongrTable parent
|
||||
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ def propagateForallPropUp (e : Expr) : GoalM Unit := do
|
|||
where
|
||||
propagateImpliesUp (a b : Expr) : GoalM Unit := do
|
||||
unless (← alreadyInternalized b) do return ()
|
||||
if (← isEqFalse a) then
|
||||
if (← isEqFalse a <&&> isProp b) then
|
||||
-- a = False → (a → b) = True
|
||||
pushEqTrue e <| mkApp3 (mkConst ``Grind.imp_eq_of_eq_false_left) a b (← mkEqFalseProof a)
|
||||
else if (← isEqTrue a) then
|
||||
else if (← isEqTrue a <&&> isProp b) then
|
||||
-- a = True → (a → b) = b
|
||||
pushEq e b <| mkApp3 (mkConst ``Grind.imp_eq_of_eq_true_left) a b (← mkEqTrueProof a)
|
||||
else if (← isEqTrue b) then
|
||||
else if (← isEqTrue b <&&> isProp a) then
|
||||
-- b = True → (a → b) = True
|
||||
pushEqTrue e <| mkApp3 (mkConst ``Grind.imp_eq_of_eq_true_right) a b (← mkEqTrueProof b)
|
||||
else if (← isEqFalse b <&&> isEqTrue e <&&> isProp a) then
|
||||
|
|
|
|||
|
|
@ -47,3 +47,6 @@ example (a b c d e v : Nat) : f v = c → f (g b) = d → a = e → b = e → v
|
|||
-- arrow congruence test
|
||||
example : α = α' → α'' = α' → β' = β → (α → β) = (α'' → β') := by
|
||||
grind
|
||||
|
||||
example (a b c : Nat) (h₁ : a = c) (h₂ : b = c) : (a = b → Nat) = (b = a → Nat) := by
|
||||
grind
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue