Skip to content

Commit 885c8b7

Browse files
committed
chore(Algebra/Module/Equiv): clean and golf (#15151)
1 parent 624027c commit 885c8b7

File tree

2 files changed

+41
-48
lines changed

2 files changed

+41
-48
lines changed

Mathlib/Algebra/Module/Equiv/Basic.lean

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def restrictScalars (f : M ≃ₗ[S] M₂) : M ≃ₗ[R] M₂ :=
4949
right_inv := f.right_inv }
5050

5151
theorem restrictScalars_injective :
52-
Function.Injective (restrictScalars R : (M ≃ₗ[S] M₂) → M ≃ₗ[R] M₂) := fun _ _ h =>
52+
Function.Injective (restrictScalars R : (M ≃ₗ[S] M₂) → M ≃ₗ[R] M₂) := fun _ _ h
5353
ext (LinearEquiv.congr_fun h : _)
5454

5555
@[simp]
@@ -61,12 +61,12 @@ end RestrictScalars
6161

6262
theorem _root_.Module.End_isUnit_iff [Module R M] (f : Module.End R M) :
6363
IsUnit f ↔ Function.Bijective f :=
64-
fun h =>
64+
fun h
6565
Function.bijective_iff_has_inverse.mpr <|
6666
⟨h.unit.inv,
6767
⟨Module.End_isUnit_inv_apply_apply_of_isUnit h,
6868
Module.End_isUnit_apply_inv_apply_of_isUnit h⟩⟩,
69-
fun H =>
69+
fun H
7070
let e : M ≃ₗ[R] M := { f, Equiv.ofBijective f H with }
7171
⟨⟨_, e.symm, LinearMap.ext e.right_inv, LinearMap.ext e.left_inv⟩, rfl⟩⟩
7272

@@ -79,8 +79,8 @@ instance automorphismGroup : Group (M ≃ₗ[R] M) where
7979
one := LinearEquiv.refl R M
8080
inv f := f.symm
8181
mul_assoc f g h := rfl
82-
mul_one f := ext fun x => rfl
83-
one_mul f := ext fun x => rfl
82+
mul_one f := ext fun x rfl
83+
one_mul f := ext fun x rfl
8484
mul_left_inv f := ext <| f.left_inv
8585

8686
@[simp]
@@ -91,7 +91,7 @@ lemma coe_toLinearMap_one : (↑(1 : M ≃ₗ[R] M) : M →ₗ[R] M) = LinearMap
9191

9292
@[simp]
9393
lemma coe_toLinearMap_mul {e₁ e₂ : M ≃ₗ[R] M} :
94-
(↑(e₁ * e₂) : M →ₗ[R] M) = (e₁ : M →ₗ[R] M) * (e₂ : M →ₗ[R] M) := by
94+
(↑(e₁ * e₂) : M →ₗ[R] M) = (e₁ : M →ₗ[R] M) * (e₂ : M →ₗ[R] M) :=
9595
rfl
9696

9797
theorem coe_pow (e : M ≃ₗ[R] M) (n : ℕ) : ⇑(e ^ n) = e^[n] := hom_coe_pow _ rfl (fun _ _ ↦ rfl) _ _
@@ -122,7 +122,7 @@ protected theorem smul_def (f : M ≃ₗ[R] M) (a : M) : f • a = f a :=
122122

123123
/-- `LinearEquiv.applyDistribMulAction` is faithful. -/
124124
instance apply_faithfulSMul : FaithfulSMul (M ≃ₗ[R] M) M :=
125-
⟨@fun _ _ => LinearEquiv.ext⟩
125+
⟨@fun _ _ LinearEquiv.ext⟩
126126

127127
instance apply_smulCommClass : SMulCommClass R (M ≃ₗ[R] M) M where
128128
smul_comm r e m := (e.map_smul r m).symm
@@ -141,10 +141,10 @@ variable [Module R M] [Module R M₂] [Subsingleton M] [Subsingleton M₂]
141141
@[simps]
142142
def ofSubsingleton : M ≃ₗ[R] M₂ :=
143143
{ (0 : M →ₗ[R] M₂) with
144-
toFun := fun _ => 0
145-
invFun := fun _ => 0
146-
left_inv := fun _ => Subsingleton.elim _ _
147-
right_inv := fun _ => Subsingleton.elim _ _ }
144+
toFun := fun _ 0
145+
invFun := fun _ 0
146+
left_inv := fun _ Subsingleton.elim _ _
147+
right_inv := fun _ Subsingleton.elim _ _ }
148148

149149
@[simp]
150150
theorem ofSubsingleton_self : ofSubsingleton M M = refl R M := by
@@ -217,15 +217,14 @@ theorem coe_toLinearEquiv_symm (h : ∀ (c : R) (x), e (c • x) = c • e x) :
217217
/-- An additive equivalence between commutative additive monoids is a linear equivalence between
218218
ℕ-modules -/
219219
def toNatLinearEquiv : M ≃ₗ[ℕ] M₂ :=
220-
e.toLinearEquiv fun c a => by rw [map_nsmul]
220+
e.toLinearEquiv fun c a by rw [map_nsmul]
221221

222222
@[simp]
223223
theorem coe_toNatLinearEquiv : ⇑e.toNatLinearEquiv = e :=
224224
rfl
225225

226226
@[simp]
227-
theorem toNatLinearEquiv_toAddEquiv : ↑e.toNatLinearEquiv = e := by
228-
ext
227+
theorem toNatLinearEquiv_toAddEquiv : ↑e.toNatLinearEquiv = e :=
229228
rfl
230229

231230
@[simp]
@@ -256,7 +255,7 @@ variable (e : M ≃+ M₂)
256255
/-- An additive equivalence between commutative additive groups is a linear
257256
equivalence between ℤ-modules -/
258257
def toIntLinearEquiv : M ≃ₗ[ℤ] M₂ :=
259-
e.toLinearEquiv fun c a => e.toAddMonoidHom.map_zsmul a c
258+
e.toLinearEquiv fun c a e.toAddMonoidHom.map_zsmul a c
260259

261260
@[simp]
262261
theorem coe_toIntLinearEquiv : ⇑e.toIntLinearEquiv = e :=
@@ -305,12 +304,12 @@ See note [bundled maps over different rings].
305304
@[simps]
306305
def ringLmapEquivSelf [Module S M] [SMulCommClass R S M] : (R →ₗ[R] M) ≃ₗ[S] M :=
307306
{ applyₗ' S (1 : R) with
308-
toFun := fun f => f 1
307+
toFun := fun f f 1
309308
invFun := smulRight (1 : R →ₗ[R] R)
310-
left_inv := fun f => by
309+
left_inv := fun f by
311310
ext
312311
simp only [coe_smulRight, one_apply, smul_eq_mul, ← map_smul f, mul_one]
313-
right_inv := fun x => by simp }
312+
right_inv := fun x by simp }
314313

315314
end LinearMap
316315

@@ -323,10 +322,10 @@ def addMonoidHomLequivNat {A B : Type*} (R : Type*) [Semiring R] [AddCommMonoid
323322
where
324323
toFun := AddMonoidHom.toNatLinearMap
325324
invFun := LinearMap.toAddMonoidHom
326-
map_add' := by intros; ext; rfl
327-
map_smul' := by intros; ext; rfl
328-
left_inv := by intro f; ext; rfl
329-
right_inv := by intro f; ext; rfl
325+
map_add' _ _ := rfl
326+
map_smul' _ _ := rfl
327+
left_inv _ := rfl
328+
right_inv _ := rfl
330329

331330
/--
332331
The `R`-linear equivalence between additive morphisms `A →+ B` and `ℤ`-linear morphisms `A →ₗ[ℤ] B`.
@@ -337,17 +336,17 @@ def addMonoidHomLequivInt {A B : Type*} (R : Type*) [Semiring R] [AddCommGroup A
337336
where
338337
toFun := AddMonoidHom.toIntLinearMap
339338
invFun := LinearMap.toAddMonoidHom
340-
map_add' := by intros; ext; rfl
341-
map_smul' := by intros; ext; rfl
342-
left_inv := by intro f; ext; rfl
343-
right_inv := by intro f; ext; rfl
339+
map_add' _ _ := rfl
340+
map_smul' _ _ := rfl
341+
left_inv _ := rfl
342+
right_inv _ := rfl
344343

345344
/-- Ring equivalence between additive group endomorphisms of an `AddCommGroup` `A` and
346345
`ℤ`-module endomorphisms of `A.` -/
347346
@[simps] def addMonoidEndRingEquivInt (A : Type*) [AddCommGroup A] :
348347
AddMonoid.End A ≃+* Module.End ℤ A :=
349348
{ addMonoidHomLequivInt (B := A) ℤ with
350-
map_mul' := fun _ _ => rfl }
349+
map_mul' := fun _ _ rfl }
351350

352351
namespace LinearEquiv
353352

@@ -391,7 +390,6 @@ instance : Unique (M ≃ₛₗ[σ₁₂] M₂) where
391390
uniq _ := toLinearMap_injective (Subsingleton.elim _ _)
392391
default := 0
393392

394-
395393
end Module
396394

397395
instance uniqueOfSubsingleton [Subsingleton R] [Subsingleton R₂] : Unique (M ≃ₛₗ[σ₁₂] M₂) := by
@@ -411,12 +409,8 @@ variable (V V₂ R)
411409
Differs from `TensorProduct.curry`. -/
412410
protected def curry : (V × V₂ → R) ≃ₗ[R] V → V₂ → R :=
413411
{ Equiv.curry _ _ _ with
414-
map_add' := fun _ _ => by
415-
ext
416-
rfl
417-
map_smul' := fun _ _ => by
418-
ext
419-
rfl }
412+
map_add' := fun _ _ ↦ rfl
413+
map_smul' := fun _ _ ↦ rfl }
420414

421415
@[simp]
422416
theorem coe_curry : ⇑(LinearEquiv.curry R V V₂) = curry :=
@@ -501,7 +495,7 @@ linear isomorphism between the two function spaces. -/
501495
def arrowCongr {R M₁ M₂ M₂₁ M₂₂ : Sort _} [CommSemiring R] [AddCommMonoid M₁] [AddCommMonoid M₂]
502496
[AddCommMonoid M₂₁] [AddCommMonoid M₂₂] [Module R M₁] [Module R M₂] [Module R M₂₁]
503497
[Module R M₂₂] (e₁ : M₁ ≃ₗ[R] M₂) (e₂ : M₂₁ ≃ₗ[R] M₂₂) : (M₁ →ₗ[R] M₂₁) ≃ₗ[R] M₂ →ₗ[R] M₂₂ where
504-
toFun := fun f : M₁ →ₗ[R] M₂₁ => (e₂ : M₂₁ →ₗ[R] M₂₂).comp <| f.comp (e₁.symm : M₂ →ₗ[R] M₁)
498+
toFun := fun f : M₁ →ₗ[R] M₂₁ (e₂ : M₂₁ →ₗ[R] M₂₂).comp <| f.comp (e₁.symm : M₂ →ₗ[R] M₁)
505499
invFun f := (e₂.symm : M₂₂ →ₗ[R] M₂₁).comp <| f.comp (e₁ : M₁ →ₗ[R] M₂)
506500
left_inv f := by
507501
ext x
@@ -571,8 +565,7 @@ theorem conj_comp (e : M ≃ₗ[R] M₂) (f g : Module.End R M) :
571565
arrowCongr_comp e e e f g
572566

573567
theorem conj_trans (e₁ : M ≃ₗ[R] M₂) (e₂ : M₂ ≃ₗ[R] M₃) :
574-
e₁.conj.trans e₂.conj = (e₁.trans e₂).conj := by
575-
ext f x
568+
e₁.conj.trans e₂.conj = (e₁.trans e₂).conj :=
576569
rfl
577570

578571
@[simp]
@@ -652,7 +645,7 @@ theorem funLeft_surjective_of_injective (f : m → n) (hf : Injective f) :
652645
Surjective (funLeft R M f) := by
653646
classical
654647
intro g
655-
refine ⟨fun x => if h : ∃ y, f y = x then g h.choose else 0, ?_⟩
648+
refine ⟨fun x if h : ∃ y, f y = x then g h.choose else 0, ?_⟩
656649
ext
657650
dsimp only [funLeft_apply]
658651
split_ifs with w
@@ -677,10 +670,10 @@ open LinearMap
677670
construct a linear equivalence `(n → M) ≃ₗ[R] (m → M)` -/
678671
def funCongrLeft (e : m ≃ n) : (n → M) ≃ₗ[R] m → M :=
679672
LinearEquiv.ofLinear (funLeft R M e) (funLeft R M e.symm)
680-
(LinearMap.ext fun x =>
681-
funext fun i => by rw [id_apply, ← funLeft_comp, Equiv.symm_comp_self, LinearMap.funLeft_id])
682-
(LinearMap.ext fun x =>
683-
funext fun i => by rw [id_apply, ← funLeft_comp, Equiv.self_comp_symm, LinearMap.funLeft_id])
673+
(LinearMap.ext fun x
674+
funext fun i by rw [id_apply, ← funLeft_comp, Equiv.symm_comp_self, LinearMap.funLeft_id])
675+
(LinearMap.ext fun x
676+
funext fun i by rw [id_apply, ← funLeft_comp, Equiv.self_comp_symm, LinearMap.funLeft_id])
684677

685678
@[simp]
686679
theorem funCongrLeft_apply (e : m ≃ n) (x : n → M) : funCongrLeft R M e x = funLeft R M e x :=

Mathlib/Algebra/Module/Equiv/Defs.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ instance : Coe (M ≃ₛₗ[σ] M₂) (M →ₛₗ[σ] M₂) :=
147147

148148
-- This exists for compatibility, previously `≃ₗ[R]` extended `≃` instead of `≃+`.
149149
/-- The equivalence of types underlying a linear equivalence. -/
150-
def toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂ := fun f => f.toAddEquiv.toEquiv
150+
def toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂ := fun f f.toAddEquiv.toEquiv
151151

152152
theorem toEquiv_injective : Function.Injective (toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂) :=
153-
fun ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ h =>
153+
fun ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ h
154154
(LinearEquiv.mk.injEq _ _ _ _ _ _ _ _).mpr
155155
⟨LinearMap.ext (congr_fun (Equiv.mk.inj h).1), (Equiv.mk.inj h).2
156156

@@ -159,7 +159,7 @@ theorem toEquiv_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : e₁.toEquiv = e₂.toE
159159
toEquiv_injective.eq_iff
160160

161161
theorem toLinearMap_injective : Injective (toLinearMap : (M ≃ₛₗ[σ] M₂) → M →ₛₗ[σ] M₂) :=
162-
fun _ _ H => toEquiv_injective <| Equiv.ext <| LinearMap.congr_fun H
162+
fun _ _ H toEquiv_injective <| Equiv.ext <| LinearMap.congr_fun H
163163

164164
@[simp, norm_cast]
165165
theorem toLinearMap_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : (↑e₁ : M →ₛₗ[σ] M₂) = e₂ ↔ e₁ = e₂ :=
@@ -260,7 +260,7 @@ def symm (e : M ≃ₛₗ[σ] M₂) : M₂ ≃ₛₗ[σ'] M :=
260260
e.toEquiv.symm with
261261
toFun := e.toLinearMap.inverse e.invFun e.left_inv e.right_inv
262262
invFun := e.toEquiv.symm.invFun
263-
map_smul' := fun r x => by dsimp only; rw [map_smulₛₗ] }
263+
map_smul' := fun r x by dsimp only; rw [map_smulₛₗ] }
264264

265265
-- Porting note: this is new
266266
/-- See Note [custom simps projection] -/
@@ -431,7 +431,7 @@ theorem comp_coe [Module R M] [Module R M₂] [Module R M₃] (f : M ≃ₗ[R] M
431431

432432
@[simp]
433433
theorem mk_coe (f h₁ h₂) : (LinearEquiv.mk e f h₁ h₂ : M ≃ₛₗ[σ] M₂) = e :=
434-
ext fun _ => rfl
434+
ext fun _ rfl
435435

436436
protected theorem map_add (a b : M) : e (a + b) = e a + e b :=
437437
map_add e a b
@@ -463,7 +463,7 @@ theorem symm_bijective [Module R M] [Module S M₂] [RingHomInvPair σ' σ] [Rin
463463
@[simp]
464464
theorem mk_coe' (f h₁ h₂ h₃ h₄) :
465465
(LinearEquiv.mk ⟨⟨f, h₁⟩, h₂⟩ (⇑e) h₃ h₄ : M₂ ≃ₛₗ[σ'] M) = e.symm :=
466-
symm_bijective.injective <| ext fun _ => rfl
466+
symm_bijective.injective <| ext fun _ rfl
467467

468468
/-- Auxilliary definition to avoid looping in `dsimp` with `LinearEquiv.symm_mk`. -/
469469
protected def symm_mk.aux (f h₁ h₂ h₃ h₄) := (⟨⟨⟨e, h₁⟩, h₂⟩, f, h₃, h₄⟩ : M ≃ₛₗ[σ] M₂).symm

0 commit comments

Comments
 (0)