-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: binderNameHint in congr (#7053)
This PR makes `simp` heed the `binderNameHint` also in the assumptions of congruence rules. Fixes #7052.
- Loading branch information
Showing
4 changed files
with
78 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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 |