File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ import Lean.PremiseSelection
2+
3+ -- A custom function that simp doesn't know about
4+ def myCustomAdd (x y : Nat) : Nat := x + y
5+
6+ -- A helper lemma about our custom function
7+ theorem myCustomAdd_comm (x y : Nat) : myCustomAdd x y = myCustomAdd y x := by
8+ simp [myCustomAdd, Nat.add_comm]
9+
10+ -- Set up a premise selector that suggests our helper theorem
11+ set_premise_selector (fun _ _ => pure #[{ name := `myCustomAdd_comm, score := 1 .0 }])
12+
13+ -- Test that regular simp? fails without the premise
14+ example (a b : Nat) : myCustomAdd a b = myCustomAdd b a := by
15+ fail_if_success simp?
16+ exact myCustomAdd_comm a b
17+
18+ -- Test that simp? +suggestions succeeds by using the selected premise
19+ /--
20+ info: Try this:
21+ [ apply ] simp only [ myCustomAdd_comm ]
22+ -/
23+ #guard_msgs in
24+ example (a b : Nat) : myCustomAdd a b = myCustomAdd b a := by
25+ simp? +suggestions
You can’t perform that action at this time.
0 commit comments