Skip to content

Commit 66b1e30

Browse files
committed
chore: ext lemma for DirectSum (#20600)
1 parent b85c65b commit 66b1e30

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

Mathlib/Algebra/DirectSum/Basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ end AddCommGroup
9090

9191
variable [∀ i, AddCommMonoid (β i)]
9292

93+
@[ext] theorem ext {x y : DirectSum ι β} (w : ∀ i, x i = y i) : x = y :=
94+
DFunLike.ext _ _ w
95+
9396
@[simp]
9497
theorem zero_apply (i : ι) : (0 : ⨁ i, β i) i = 0 :=
9598
rfl

Mathlib/Algebra/DirectSum/Module.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,14 @@ variable {ι M}
182182
theorem apply_eq_component (f : ⨁ i, M i) (i : ι) : f i = component R ι M i f := rfl
183183

184184
-- Note(kmill): `@[ext]` cannot prove `ext_iff` because `R` is not determined by `f` or `g`.
185-
@[ext (iff := false)]
186-
theorem ext {f g : ⨁ i, M i} (h : ∀ i, component R ι M i f = component R ι M i g) : f = g :=
185+
-- This is not useful as an `@[ext]` lemma as the `ext` tactic can not infer `R`.
186+
theorem ext_component {f g : ⨁ i, M i} (h : ∀ i, component R ι M i f = component R ι M i g) :
187+
f = g :=
187188
DFinsupp.ext h
188189

189-
theorem ext_iff {f g : ⨁ i, M i} : f = g ↔ ∀ i, component R ι M i f = component R ι M i g :=
190-
fun h _ ↦ by rw [h], ext R⟩
190+
theorem ext_component_iff {f g : ⨁ i, M i} :
191+
f = g ↔ ∀ i, component R ι M i f = component R ι M i g :=
192+
fun h _ ↦ by rw [h], ext_component R⟩
191193

192194
@[simp]
193195
theorem lof_apply [DecidableEq ι] (i : ι) (b : M i) : ((lof R ι M i) b) i = b :=

Mathlib/Algebra/DirectSum/Ring.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private theorem mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) := by
235235
simpa only [coe_comp, Function.comp_apply, AddMonoidHom.compHom_apply_apply, flip_apply,
236236
AddMonoidHom.flipHom_apply]
237237
using DFunLike.congr_fun (DFunLike.congr_fun (DFunLike.congr_fun this a) b) c
238-
ext ai ax bi bx ci cx
238+
ext ai ax bi bx ci cx : 6
239239
dsimp only [coe_comp, Function.comp_apply, AddMonoidHom.compHom_apply_apply, flip_apply,
240240
AddMonoidHom.flipHom_apply]
241241
simp_rw [mulHom_of_of]

Mathlib/Algebra/Lie/DirectSum.lean

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ variable [∀ i, LieRingModule L (M i)] [∀ i, LieModule R L (M i)]
4343
instance : LieRingModule L (⨁ i, M i) where
4444
bracket x m := m.mapRange (fun _ m' => ⁅x, m'⁆) fun _ => lie_zero x
4545
add_lie x y m := by
46-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
46+
ext
4747
simp only [mapRange_apply, add_apply, add_lie]
4848
lie_add x m n := by
49-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
49+
ext
5050
simp only [mapRange_apply, add_apply, lie_add]
5151
leibniz_lie x y m := by
52-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
52+
ext
5353
simp only [mapRange_apply, lie_lie, add_apply, sub_add_cancel]
5454

5555
@[simp]
@@ -58,10 +58,10 @@ theorem lie_module_bracket_apply (x : L) (m : ⨁ i, M i) (i : ι) : ⁅x, m⁆
5858

5959
instance : LieModule R L (⨁ i, M i) where
6060
smul_lie t x m := by
61-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext i`
61+
ext
6262
simp only [smul_lie, lie_module_bracket_apply, smul_apply]
6363
lie_smul t x m := by
64-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext i`
64+
ext
6565
simp only [lie_smul, lie_module_bracket_apply, smul_apply]
6666

6767
variable (R ι L M)
@@ -70,7 +70,7 @@ variable (R ι L M)
7070
def lieModuleOf [DecidableEq ι] (j : ι) : M j →ₗ⁅R,L⁆ ⨁ i, M i :=
7171
{ lof R ι M j with
7272
map_lie' := fun {x m} => by
73-
refine DFinsupp.ext fun i => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext i`
73+
ext i
7474
by_cases h : j = i
7575
· rw [← h]; simp
7676
· -- This used to be the end of the proof before https://github.com/leanprover/lean4/pull/2644
@@ -98,16 +98,16 @@ instance lieRing : LieRing (⨁ i, L i) :=
9898
{ (inferInstance : AddCommGroup _) with
9999
bracket := zipWith (fun _ => fun x y => ⁅x, y⁆) fun _ => lie_zero 0
100100
add_lie := fun x y z => by
101-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
101+
ext
102102
simp only [zipWith_apply, add_apply, add_lie]
103103
lie_add := fun x y z => by
104-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
104+
ext
105105
simp only [zipWith_apply, add_apply, lie_add]
106106
lie_self := fun x => by
107-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
107+
ext
108108
simp only [zipWith_apply, add_apply, lie_self, zero_apply]
109109
leibniz_lie := fun x y z => by
110-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
110+
ext
111111
simp only [sub_apply, zipWith_apply, add_apply, zero_apply]
112112
apply leibniz_lie }
113113

@@ -121,7 +121,7 @@ theorem lie_of_same [DecidableEq ι] {i : ι} (x y : L i) :
121121

122122
theorem lie_of_of_ne [DecidableEq ι] {i j : ι} (hij : i ≠ j) (x : L i) (y : L j) :
123123
⁅of L i x, of L j y⁆ = 0 := by
124-
refine DFinsupp.ext fun k => ?_
124+
ext k
125125
rw [bracket_apply]
126126
obtain rfl | hik := Decidable.eq_or_ne i k
127127
· rw [of_eq_of_ne _ _ _ hij.symm, lie_zero, zero_apply]
@@ -137,7 +137,7 @@ theorem lie_of [DecidableEq ι] {i j : ι} (x : L i) (y : L j) :
137137
instance lieAlgebra : LieAlgebra R (⨁ i, L i) :=
138138
{ (inferInstance : Module R _) with
139139
lie_smul := fun c x y => by
140-
refine DFinsupp.ext fun _ => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext`
140+
ext
141141
simp only [zipWith_apply, smul_apply, bracket_apply, lie_smul] }
142142

143143
variable (R ι)
@@ -148,7 +148,7 @@ def lieAlgebraOf [DecidableEq ι] (j : ι) : L j →ₗ⁅R⁆ ⨁ i, L i :=
148148
{ lof R ι L j with
149149
toFun := of L j
150150
map_lie' := fun {x y} => by
151-
refine DFinsupp.ext fun i => ?_ -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): Originally `ext i`
151+
ext i
152152
by_cases h : j = i
153153
· rw [← h]
154154
-- This used to be the end of the proof before https://github.com/leanprover/lean4/pull/2644

Mathlib/RingTheory/AdicCompletion/Functoriality.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ theorem sumInv_apply (x : AdicCompletion I (⨁ j, M j)) (j : ι) :
287287
variable [DecidableEq ι]
288288

289289
theorem sumInv_comp_sum : sumInv I M ∘ₗ sum I M = LinearMap.id := by
290-
ext j x
291-
apply DirectSum.ext (AdicCompletion I R) (fun i ↦ ?_)
290+
ext j x : 2
291+
apply DirectSum.ext_component (AdicCompletion I R) (fun i ↦ ?_)
292292
ext n
293293
simp only [LinearMap.coe_comp, Function.comp_apply, sum_lof, map_mk, component_sumInv,
294294
mk_apply_coe, AdicCauchySequence.map_apply_coe, Submodule.mkQ_apply, LinearMap.id_comp]

Mathlib/RingTheory/Flat/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ instance directSum (ι : Type v) (M : ι → Type w) [(i : ι) → AddCommGroup
195195
by_cases h₂ : j = i
196196
· subst j; simp
197197
· simp [h₂]
198-
intro a ha; rw [DirectSum.ext_iff R]; intro i
198+
intro a ha; rw [DirectSum.ext_component_iff R]; intro i
199199
have f := LinearMap.congr_arg (f := (π i)) ha
200200
erw [LinearMap.congr_fun (h₁ i) a] at f
201201
rw [(map_zero (π i) : (π i) 0 = (0 : M i))] at f

0 commit comments

Comments
 (0)