Skip to content

Commit

Permalink
chore: check whether declaration is a theorem or not
Browse files Browse the repository at this point in the history
  • Loading branch information
leodemoura committed Dec 29, 2024
1 parent a0f73c3 commit 83bb6be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Lean/Meta/Tactic/Grind/TheoremPatterns.lean
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ def main (patterns : List Expr) : MetaM (List Expr × List HeadIndex) := do
end NormalizePattern

def addTheoremPattern (declName : Name) (numParams : Nat) (patterns : List Expr) : MetaM Unit := do
let cinfo ← getConstInfo declName
let us := cinfo.levelParams.map mkLevelParam
let .thmInfo info ← getConstInfo declName
| throwError "`{declName}` is not a theorem, you cannot assign patterns to non-theorems for the `grind` tactic"
let us := info.levelParams.map mkLevelParam
let proof := mkConst declName us
let (patterns, symbols) ← NormalizePattern.main patterns
trace[grind.pattern] "{declName}: {patterns.map ppPattern}"
Expand Down
8 changes: 8 additions & 0 deletions tests/lean/run/grind_pattern1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ info: [grind.pattern] List.mem_concat_self: [@Membership.mem #2 ? ? (@HAppend.hA
-/
#guard_msgs in
grind_pattern List.mem_concat_self => a ∈ xs ++ [a]

def foo (x : Nat) := x + x

/--
error: `foo` is not a theorem, you cannot assign patterns to non-theorems for the `grind` tactic
-/
#guard_msgs in
grind_pattern foo => x + x

0 comments on commit 83bb6be

Please sign in to comment.