Skip to content

Commit 54a8de2

Browse files
committed
chore: syntactically generalise symm_mk (#37748)
1 parent 834e516 commit 54a8de2

14 files changed

Lines changed: 39 additions & 53 deletions

File tree

Mathlib/Algebra/Algebra/Equiv.lean

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,11 @@ theorem mk_coe' (e : A₁ ≃ₐ[R] A₂) (f h₁ h₂ h₃ h₄ h₅) :
278278
(⟨⟨f, e, h₁, h₂⟩, h₃, h₄, h₅⟩ : A₂ ≃ₐ[R] A₁) = e.symm :=
279279
symm_bijective.injective <| ext fun _ => rfl
280280

281-
/-- Auxiliary definition to avoid looping in `dsimp` with `AlgEquiv.symm_mk`. -/
282-
protected def symm_mk.aux (f f') (h₁ h₂ h₃ h₄ h₅) :=
283-
(⟨⟨f, f', h₁, h₂⟩, h₃, h₄, h₅⟩ : A₁ ≃ₐ[R] A₂).symm
284-
285281
@[simp]
286-
theorem symm_mk (f f') (h₁ h₂ h₃ h₄ h₅) :
287-
(⟨⟨f, f', h₁, h₂⟩, h₃, h₄, h₅⟩ : A₁ ≃ₐ[R] A₂).symm =
288-
{ symm_mk.aux f f' h₁ h₂ h₃ h₄ h₅ with
289-
toFun := f'
290-
invFun := f } :=
282+
theorem symm_mk (e : A₁ ≃ A₂) (h₁ h₂ h₃) : dsimp%
283+
(mk e h₁ h₂ h₃ : A₁ ≃ₐ[R] A₂).symm =
284+
{ (mk e h₁ h₂ h₃ : A₁ ≃ₐ[R] A₂).symm with
285+
toEquiv := e.symm } :=
291286
rfl
292287

293288
@[simp]

Mathlib/Algebra/Module/Equiv/Defs.lean

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,12 @@ theorem mk_coe' (f h₁ h₂ h₃ h₄) :
528528
(LinearEquiv.mk ⟨⟨f, h₁⟩, h₂⟩ (⇑e) h₃ h₄ : M₂ ≃ₛₗ[σ'] M) = e.symm :=
529529
symm_bijective.injective <| ext fun _ ↦ rfl
530530

531-
/-- Auxiliary definition to avoid looping in `dsimp` with `LinearEquiv.symm_mk`. -/
532-
protected def symm_mk.aux (f h₁ h₂ h₃ h₄) := (⟨⟨⟨e, h₁⟩, h₂⟩, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm
533-
534531
@[simp]
535-
theorem symm_mk (f h₁ h₂ h₃ h₄) :
536-
(⟨⟨⟨e, h₁⟩, h₂⟩, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm =
537-
{ symm_mk.aux e f h₁ h₂ h₃ h₄ with
538-
toFun := f
539-
invFun := e } :=
532+
theorem symm_mk (toLinearMap invFun h₁ h₂) : dsimp%
533+
(mk toLinearMap invFun h₁ h₂ : M ≃ₛₗ[σ] M₂).symm =
534+
{ (mk toLinearMap invFun h₁ h₂ : M ≃ₛₗ[σ] M₂).symm with
535+
toFun := invFun
536+
invFun := toLinearMap } :=
540537
rfl
541538

542539
/-- For a more powerful version, see `coe_symm_mk'`. -/

Mathlib/Algebra/Ring/Equiv.lean

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public import Mathlib.Algebra.Ring.Hom.Defs
1313
public import Mathlib.Logic.Equiv.Set
1414
public import Mathlib.Util.Delaborators
1515

16+
import Mathlib.Tactic.DSimpPercent
17+
1618
/-!
1719
# (Semi)ring equivs
1820
@@ -264,15 +266,11 @@ theorem mk_coe' (e : R ≃+* S) (f h₁ h₂ h₃ h₄) :
264266
(⟨⟨f, ⇑e, h₁, h₂⟩, h₃, h₄⟩ : S ≃+* R) = e.symm :=
265267
symm_bijective.injective <| ext fun _ => rfl
266268

267-
/-- Auxiliary definition to avoid looping in `dsimp` with `RingEquiv.symm_mk`. -/
268-
protected def symm_mk.aux (f : R → S) (g h₁ h₂ h₃ h₄) := (mk ⟨f, g, h₁, h₂⟩ h₃ h₄).symm
269-
270269
@[simp]
271-
theorem symm_mk (f : R → S) (g h₁ h₂ h₃ h₄) :
272-
(mk ⟨f, g, h₁, h₂⟩ h₃ h₄).symm =
273-
{ symm_mk.aux f g h₁ h₂ h₃ h₄ with
274-
toFun := g
275-
invFun := f } :=
270+
theorem symm_mk (e : R ≃ S) (h₁ h₂) : dsimp%
271+
(mk e h₁ h₂).symm =
272+
{ (mk e h₁ h₂).symm with
273+
toEquiv := e.symm } :=
276274
rfl
277275

278276
@[simp]

Mathlib/Algebra/Star/StarAlgHom.lean

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -767,16 +767,11 @@ theorem coe_mk (e h) : ⇑(⟨e, h⟩ : A ≃⋆ₐ[R] B) = e := rfl
767767
theorem mk_coe (e : A ≃⋆ₐ[R] B) (e' h₁ h₂ h₃ h₄ h₅ h₆) :
768768
(⟨⟨⟨⟨e, e', h₁, h₂⟩, h₃, h₄⟩, h₅⟩, h₆⟩ : A ≃⋆ₐ[R] B) = e := ext fun _ => rfl
769769

770-
/-- Auxiliary definition to avoid looping in `dsimp` with `StarAlgEquiv.symm_mk`. -/
771-
protected def symm_mk.aux (f f') (h₁ h₂ h₃ h₄ h₅ h₆) :=
772-
(⟨⟨⟨⟨f, f', h₁, h₂⟩, h₃, h₄⟩, h₅⟩, h₆⟩ : A ≃⋆ₐ[R] B).symm
773-
774770
@[simp]
775-
theorem symm_mk (f f') (h₁ h₂ h₃ h₄ h₅ h₆) :
776-
(⟨⟨⟨⟨f, f', h₁, h₂⟩, h₃, h₄⟩, h₅⟩, h₆⟩ : A ≃⋆ₐ[R] B).symm =
777-
{ symm_mk.aux f f' h₁ h₂ h₃ h₄ h₅ h₆ with
778-
toFun := f'
779-
invFun := f } :=
771+
theorem symm_mk (e : A ≃⋆+* B) (h₁) : dsimp%
772+
(⟨e, h₁⟩ : A ≃⋆ₐ[R] B).symm =
773+
{ (⟨e, h₁⟩ : A ≃⋆ₐ[R] B).symm with
774+
toStarRingEquiv := e.symm } :=
780775
rfl
781776

782777
@[simp]

Mathlib/Algebra/Star/StarRingHom.lean

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,11 @@ theorem symm_bijective : Function.Bijective (symm : (A ≃⋆+* B) → B ≃⋆+
369369
theorem mk_coe (e : A ≃⋆+* B) (e' h₁ h₂ h₃ h₄ h₅) :
370370
(⟨⟨⟨e, e', h₁, h₂⟩, h₃, h₄⟩, h₅⟩ : A ≃⋆+* B) = e := ext fun _ => rfl
371371

372-
/-- Auxiliary definition to avoid looping in `dsimp` with `StarRingEquiv.symm_mk`. -/
373-
protected def symm_mk.aux (f f') (h₁ h₂ h₃ h₄ h₅) :=
374-
(⟨⟨⟨f, f', h₁, h₂⟩, h₃, h₄⟩, h₅⟩ : A ≃⋆+* B).symm
375-
376372
@[simp]
377-
theorem symm_mk (f f') (h₁ h₂ h₃ h₄ h₅) :
378-
(⟨⟨⟨f, f', h₁, h₂⟩, h₃, h₄⟩, h₅⟩ : A ≃⋆+* B).symm =
379-
{ symm_mk.aux f f' h₁ h₂ h₃ h₄ h₅ with
380-
toFun := f'
381-
invFun := f } :=
373+
theorem symm_mk (e : A ≃+* B) (h₁) : dsimp%
374+
(⟨e, h₁⟩ : A ≃⋆+* B).symm =
375+
{ (⟨e, h₁⟩ : A ≃⋆+* B).symm with
376+
toRingEquiv := e.symm } :=
382377
rfl
383378

384379
@[simp]

Mathlib/AlgebraicGeometry/Spec.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ theorem localRingHom_comp_stalkIso {R S : CommRingCat.{u}} (f : R ⟶ S) (p : Pr
227227
(stalkIso R (PrimeSpectrum.comap f.hom p)).toCommRingCatIso.symm.eq_inv_comp.mp <|
228228
(stalkIso S p).toCommRingCatIso.symm.comp_inv_eq.mpr <| CommRingCat.hom_ext <|
229229
Localization.localRingHom_unique _ _ _ (PrimeSpectrum.comap_asIdeal _ _) fun x => by
230-
dsimp
230+
dsimp [-RingEquiv.symm_mk]
231231
simp only [AlgEquiv.commutes, RingEquiv.symm_apply_eq, AlgEquiv.coe_ringEquiv]
232232
exact stalkMap_toStalk_apply f p x
233233

Mathlib/Logic/Equiv/Defs.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ theorem left_inv' (e : α ≃ β) : Function.LeftInverse e.symm e := e.left_inv
156156
/-- Restatement of `Equiv.right_inv` in terms of `Function.RightInverse`. -/
157157
theorem right_inv' (e : α ≃ β) : Function.RightInverse e.symm e := e.right_inv
158158

159+
@[simp] lemma symm_mk (f : α → β) (g hl hr) : (mk f g hl hr).symm = mk g f hr hl := rfl
160+
159161
/-- Composition of equivalences `e₁ : α ≃ β` and `e₂ : β ≃ γ`. -/
160162
@[trans]
161163
protected def trans (e₁ : α ≃ β) (e₂ : β ≃ γ) : α ≃ γ :=

Mathlib/RingTheory/AdjoinRoot.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def mapAlgEquiv (f : S ≃ₐ[R] T) (p : S[X]) (q : T[X]) (h : Associated (p.map
431431
-- FIXME: Coercion hell. See https://github.com/leanprover-community/mathlib4/issues/31365.
432432
have : (RingHomClass.toRingHom f.toRingEquiv.symm).comp (RingHomClass.toRingHom f) =
433433
.id S := by ext; exact f.symm_apply_apply _
434-
simpa [Polynomial.map_map, this] using map_dvd f.symm.toRingHom h.dvd)
434+
simpa [Polynomial.map_map, -RingEquiv.symm_mk, this] using map_dvd f.symm.toRingHom h.dvd)
435435
(by ext <;> simp) (by ext <;> simp)
436436

437437
@[simp] lemma coe_mapAlgEquiv (f : S ≃ₐ[R] T) (p : S[X]) (q : T[X]) (h) :
@@ -442,7 +442,8 @@ def mapAlgEquiv (f : S ≃ₐ[R] T) (p : S[X]) (q : T[X]) (h : Associated (p.map
442442
-- FIXME: Coercion hell. See https://github.com/leanprover-community/mathlib4/issues/31365.
443443
have : (RingHomClass.toRingHom f.toRingEquiv.symm).comp (RingHomClass.toRingHom f) =
444444
.id S := by ext; exact f.symm_apply_apply _
445-
simpa [Polynomial.map_map, this] using associated_map_map f.symm.toRingHom h.symm) := rfl
445+
simpa [Polynomial.map_map, -RingEquiv.symm_mk, this]
446+
using associated_map_map f.symm.toRingHom h.symm) := rfl
446447

447448
variable (R) in
448449
/-- The canonical algebraic homomorphism from `AdjoinRoot f` to `AdjoinRoot g`, where

Mathlib/RingTheory/DedekindDomain/Different.lean

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,9 @@ theorem not_dvd_differentIdeal_of_isCoprime_of_isSeparable
822822
simpa [LinearMap.ext_iff] using Algebra.trace_ne_zero (A ⧸ p) (B ⧸ P)
823823
obtain ⟨y, hy⟩ := Ideal.Quotient.mk_surjective (e.symm (x, 0))
824824
refine not_dvd_differentIdeal_of_intTrace_not_mem A P Q hP y ?_ ?_
825-
· simpa [e, Ideal.Quotient.eq_zero_iff_mem] using congr((e $hy).2)
825+
· have := congr((e $hy).2)
826+
simp at this
827+
simpa [e, Ideal.Quotient.eq_zero_iff_mem] using this
826828
· rw [← Ideal.Quotient.eq_zero_iff_mem, ← Algebra.trace_quotient_eq_of_isDedekindDomain,
827829
hy, Algebra.trace_eq_of_algEquiv, Algebra.trace_prod_apply]
828830
simpa

Mathlib/RingTheory/LaurentSeries.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,6 @@ equivalence: it goes from `K⸨X⸩` to `RatFuncAdicCompl K` -/
10271027
abbrev LaurentSeriesRingEquiv : K⸨X⸩ ≃+* RatFuncAdicCompl K :=
10281028
(ratfuncAdicComplRingEquiv K).symm
10291029

1030-
@[simp]
10311030
lemma LaurentSeriesRingEquiv_def (f : K⟦X⟧) :
10321031
(LaurentSeriesRingEquiv K) f = (LaurentSeriesPkg K).compare ratfuncAdicComplPkg (f : K⸨X⸩) :=
10331032
rfl

0 commit comments

Comments
 (0)