Skip to content

Commit dc60430

Browse files
committed
feat(Order/Antisymmetrization): support AntisymmRel in gcongr_forward (#28514)
This PR adds support for `AntisymmRel` in `gcongr_forward`, so that we can `grw` using the `AntisymmRel (· ≤ ·)` relation. Requested in [#mathlib4 > Announcement: New `grw` tactic @ 💬](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Announcement.3A.20New.20.60grw.60.20tactic/near/534752659)
1 parent 0bb58c2 commit dc60430

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

Mathlib/Order/Antisymmetrization.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ theorem antisymmRel_iff_eq [IsRefl α r] [IsAntisymm α r] : AntisymmRel r a b
8484

8585
alias ⟨AntisymmRel.eq, _⟩ := antisymmRel_iff_eq
8686

87+
namespace Mathlib.Tactic.GCongr
88+
89+
variable {α : Type*} {a b : α} {r : α → α → Prop}
90+
91+
lemma AntisymmRel.left (h : AntisymmRel r a b) : r a b := h.1
92+
lemma AntisymmRel.right (h : AntisymmRel r a b) : r b a := h.2
93+
94+
/-- See if the term is `AntisymmRel r a b` and the goal is `r a b`. -/
95+
@[gcongr_forward] def exactAntisymmRelLeft : ForwardExt where
96+
eval h goal := do goal.assignIfDefEq (← Lean.Meta.mkAppM ``AntisymmRel.left #[h])
97+
98+
/-- See if the term is `AntisymmRel r a b` and the goal is `r b a`. -/
99+
@[gcongr_forward] def exactAntisymmRelRight : ForwardExt where
100+
eval h goal := do goal.assignIfDefEq (← Lean.Meta.mkAppM ``AntisymmRel.right #[h])
101+
102+
end Mathlib.Tactic.GCongr
103+
87104
end Relation
88105

89106
section LE

MathlibTest/GRewrite.lean

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Sebastian Zimmer, Mario Carneiro, Heather Macbeth, Jovan Gerbscheid
55
-/
66
import Mathlib.Data.Int.ModEq
7+
import Mathlib.Order.Antisymmetrization
78
import Mathlib.Tactic.GRewrite
89
import Mathlib.Tactic.GCongr
910
import Mathlib.Tactic.NormNum
@@ -320,3 +321,22 @@ example (h : a ≡ b [ZMOD n]) : a ^ 2 ≡ b ^ 2 [ZMOD n] := by
320321
example (h₁ : a ∣ b) (h₂ : b ∣ a * d) : a ∣ b * d := by
321322
grw [h₁] at h₂ ⊢
322323
exact h₂
324+
325+
namespace AntiSymmRelTest
326+
327+
variable {α : Type u} [Preorder α] {a b : α}
328+
329+
local infix:50 " ≈ " => AntisymmRel (· ≤ ·)
330+
331+
axiom f : α → α
332+
333+
@[gcongr]
334+
axiom f_congr' : a ≤ b → f a ≤ f b
335+
336+
example (h : a ≈ b) : f a ≤ f b := by
337+
grw [h]
338+
339+
example (h : b ≈ a) : f a ≤ f b := by
340+
grw [h]
341+
342+
end AntiSymmRelTest

0 commit comments

Comments
 (0)