diff --git a/src/Init/Grind/Config.lean b/src/Init/Grind/Config.lean index 12e8ec2006..2df1e30dac 100644 --- a/src/Init/Grind/Config.lean +++ b/src/Init/Grind/Config.lean @@ -35,6 +35,11 @@ structure Config where The input goal terms have generation 0. When we instantiate a theorem using a term from generation `n`, the new terms have generation `n+1`. Thus, this parameter limits the length of an instantiation chain. -/ gen : Nat := 8 + /-- + Maximum term generation for local theorems (e.g., hypotheses). + See `gen`. + -/ + genLocal : Nat := 8 /-- Maximum number of theorem instances generated using E-matching in a proof search tree branch. -/ instances : Nat := 1000 /-- If `matchEqs` is `true`, `grind` uses `match`-equations as E-matching theorems. -/ diff --git a/src/Lean/Meta/Tactic/Grind/EMatch.lean b/src/Lean/Meta/Tactic/Grind/EMatch.lean index 917a2bfb32..ee75170c3c 100644 --- a/src/Lean/Meta/Tactic/Grind/EMatch.lean +++ b/src/Lean/Meta/Tactic/Grind/EMatch.lean @@ -272,6 +272,14 @@ private def assignGenInfo? (genInfo? : Option GenPatternInfo) (c : Choice) (x : let c ← saveSource c x genInfo.assign? c x +/-- +Return the maximum generation allowed for the current theorem. +-/ +private def getMaxGeneration : M Nat := do + match (← read).thm.origin with + | .stx .. | .decl _ => return (← getConfig).gen + | _ => return (← getConfig).genLocal + /-- Matches pattern `p` with term `e` with respect to choice `c`. We traverse the equivalence class of `e` looking for applications compatible with `p`.