lean4-htt/tests/lean/run/binderNameHint_congr.lean
Joachim Breitner a833afa935
feat: binderNameHint in congr (#7053)
This PR makes `simp` heed the `binderNameHint` also in the assumptions
of congruence rules. Fixes #7052.
2025-02-13 09:38:42 +00:00

61 lines
1.4 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

section no_congr
/--
error: tactic 'fail' failed
xs : List Nat
⊢ xs = List.map (fun y => 1 + y) xs
-/
#guard_msgs in
example : xs = List.map (fun y => 1 + (y + 1 - 1)) xs := by
simp
fail
end no_congr
section with_congr
/--
info: List.map_congr_left.{u_1, u_2} {α✝ : Type u_1} {l : List α✝} {α✝¹ : Type u_2} {f g : α✝ → α✝¹}
(h : ∀ (a : α✝), a ∈ l → f a = g a) : List.map f l = List.map g l
-/
#guard_msgs in
#check List.map_congr_left
attribute [local congr] List.map_congr_left
/--
error: tactic 'fail' failed
xs : List Nat
⊢ xs = List.map (fun a => 1 + a) xs
-/
#guard_msgs in
example : xs = List.map (fun y => 1 + (y + 1 - 1)) xs := by
simp -- NB: Changes variable name!
fail
end with_congr
section with_congr_hint
-- Trying to use the binderNameHint on a congruence rule
theorem List.map_congr_left'' {f g : α → β}
(h : ∀ (a : α), a ∈ l → binderNameHint a f (f a) = g a) :
List.map f l = List.map g l := List.map_congr_left h
attribute [local congr] List.map_congr_left''
-- set_option trace.Debug.Meta.Tactic.simp true
-- set_option pp.instantiateMVars false
-- set_option trace.Debug.Meta.Tactic.simp.congr true
/--
error: tactic 'fail' failed
xs : List Nat
⊢ xs = List.map (fun y => 1 + y) xs
-/
#guard_msgs in
example : xs = List.map (fun y => 1 + (y + 1 - 1)) xs := by
simp
fail
end with_congr_hint