fix: minor issues in grind (#10339)

This PR fixes a few minor issues and applies a few cleanups.
This commit is contained in:
Leonardo de Moura 2025-09-10 19:54:36 -07:00 committed by GitHub
parent b7520e7232
commit a4a2bfa426
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 11 deletions

View file

@ -497,8 +497,6 @@ def check : GoalM Bool := do profileitM Exception "grind ac" (← getOptions) do
let r ← ACM.run opId checkStruct
progress := progress || r
if (← isInconsistent) then return true
if progress then
processNewFacts
return progress
finally
checkInvariants

View file

@ -229,7 +229,7 @@ where
}
propagateBeta lams₁ fns₁
propagateBeta lams₂ fns₂
let todo ← Solvers.mergeTerms rhsRoot lhsRoot
let toPropagateSolvers ← Solvers.mergeTerms rhsRoot lhsRoot
resetParentsOf lhsRoot.self
copyParentsTo parents rhsNode.root
unless (← isInconsistent) do
@ -240,7 +240,7 @@ where
for e in toPropagateDown do
propagateDown e
propagateUnitConstFuns lams₁ lams₂
todo.propagate
toPropagateSolvers.propagate
updateRoots (lhs : Expr) (rootNew : Expr) : GoalM Unit := do
let isFalseRoot ← isFalseExpr rootNew
traverseEqc lhs fun n => do

View file

@ -585,17 +585,11 @@ private structure Context where
private abbrev M := ReaderT Context StateRefT State MetaM
/-- Helper declaration for finding bootstrapping issues. See `isCandidateSymbol`. -/
private abbrev badForPatterns := [``Eq, ``HEq, ``Iff, ``And, ``Or, ``Not]
private def isCandidateSymbol (declName : Name) (root : Bool) : M Bool := do
let ctx ← read
let prio := ctx.symPrios.getPrio declName
-- Priority 0 are never considered, they are treated as forbidden
if prio == 0 then return false
-- Remark: uncomment the following code to fix bootstrapping issues
-- if declName ∈ badForPatterns then
-- throwError "INSERT `import Init.Grind.Tactics`, otherwise a pattern containing `{.ofConstName declName}` will be used, prio: {prio}"
-- If it is the root symbol, then we check whether `prio ≥ minPrio`
if root then
return prio ≥ ctx.minPrio

View file

@ -1085,7 +1085,15 @@ For each equality `b = c` in `parents`, executes `k b c` IF
for parent in parents do
let_expr Eq _ b c := parent | continue
if (← isEqFalse parent) then
k b c
if (← isEqv b c) then
/-
Remark: if `b` and `c` are already in the same equivalence class,
there is an inconsistency in the TODO queue already, and we can interrupt
propagation
-/
return ()
else
k b c
/-- Returns `true` is `e` is the root of its congruence class. -/
def isCongrRoot (e : Expr) : GoalM Bool := do
@ -1485,6 +1493,8 @@ def Solvers.checkInvariants : GoalM Unit := do
def Solvers.check : GoalM Bool := do
let mut result := false
for ext in (← solverExtensionsRef.get) do
if (← isInconsistent) then
return true
if (← ext.check) then
result := true
if result then