-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: literals, lower and upper bounds in the offset constraint modul…
…e within `grind` (#6648) This PR adds support for numerals, lower & upper bounds to the offset constraint module in the `grind` tactic. `grind` can now solve examples such as: ``` example (f : Nat → Nat) : f 2 = a → b ≤ 1 → b ≥ 1 → c = b + 1 → f c = a := by grind ``` In the example above, the literal `2` and the lower&upper bounds, `b ≤ 1` and `b ≥ 1`, are now processed by offset constraint module.
- Loading branch information
1 parent
f95d810
commit 8d69909
Showing
11 changed files
with
172 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,16 +98,14 @@ private def pushCastHEqs (e : Expr) : GoalM Unit := do | |
| [email protected] α a motive b h v => pushHEq e v (mkApp6 (mkConst ``Grind.eqRecOn_heq f.constLevels!) α a motive b h v) | ||
| _ => return () | ||
|
||
def noParent := mkBVar 0 | ||
|
||
mutual | ||
/-- Internalizes the nested ground terms in the given pattern. -/ | ||
private partial def internalizePattern (pattern : Expr) (generation : Nat) : GoalM Expr := do | ||
if pattern.isBVar || isPatternDontCare pattern then | ||
return pattern | ||
else if let some e := groundPattern? pattern then | ||
let e ← shareCommon (← canon (← normalizeLevels (← unfoldReducible e))) | ||
internalize e generation | ||
internalize e generation none | ||
return mkGroundPattern e | ||
else pattern.withApp fun f args => do | ||
return mkAppN f (← args.mapM (internalizePattern · generation)) | ||
|
@@ -148,7 +146,7 @@ private partial def activateTheoremPatterns (fName : Name) (generation : Nat) : | |
trace_goal[grind.ematch] "reinsert `{thm.origin.key}`" | ||
modify fun s => { s with thmMap := s.thmMap.insert thm } | ||
|
||
partial def internalize (e : Expr) (generation : Nat) (parent : Expr := noParent) : GoalM Unit := do | ||
partial def internalize (e : Expr) (generation : Nat) (parent? : Option Expr := none) : GoalM Unit := do | ||
if (← alreadyInternalized e) then return () | ||
trace_goal[grind.internalize] "{e}" | ||
match e with | ||
|
@@ -176,6 +174,7 @@ partial def internalize (e : Expr) (generation : Nat) (parent : Expr := noParent | |
if (← isLitValue e) then | ||
-- We do not want to internalize the components of a literal value. | ||
mkENode e generation | ||
Arith.internalize e parent? | ||
else e.withApp fun f args => do | ||
checkAndAddSplitCandidate e | ||
pushCastHEqs e | ||
|
@@ -199,7 +198,7 @@ partial def internalize (e : Expr) (generation : Nat) (parent : Expr := noParent | |
mkENode e generation | ||
addCongrTable e | ||
updateAppMap e | ||
Arith.internalize e parent | ||
Arith.internalize e parent? | ||
propagateUp e | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.