-
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: canonicalizer diagnostics (#6662)
This PR improves the canonicalizer used in the `grind` tactic and the diagnostics it produces. It also adds a new configuration option, `canonHeartbeats`, to address (some of) the issues. Here is an example illustrating the new diagnostics, where we intentionally create a problem by using a very small number of heartbeats. <img width="1173" alt="image" src="https://github.com/user-attachments/assets/484005c8-dcaa-4164-8fbf-617864ed7350" />
- Loading branch information
1 parent
af4a7d7
commit 3a6c5cf
Showing
6 changed files
with
155 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import Lean.Meta.Match.MatcherInfo | |
import Lean.Meta.Match.MatchEqsExt | ||
import Lean.Meta.Tactic.Grind.Types | ||
import Lean.Meta.Tactic.Grind.Util | ||
import Lean.Meta.Tactic.Grind.Canon | ||
import Lean.Meta.Tactic.Grind.Arith.Internalize | ||
|
||
namespace Lean.Meta.Grind | ||
|
@@ -98,13 +99,16 @@ 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 () | ||
|
||
private def preprocessGroundPattern (e : Expr) : GoalM Expr := do | ||
shareCommon (← canon (← normalizeLevels (← unfoldReducible e))) | ||
|
||
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))) | ||
let e ← preprocessGroundPattern e | ||
internalize e generation none | ||
return mkGroundPattern e | ||
else pattern.withApp fun f args => do | ||
|
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.