Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit d709ed6

Browse files
eric-wieserdigama0
andcommitted
feat(algebra/direct_sum*): relax a lot of constraints to add_comm_monoid (#3537)
Co-authored-by: Mario Carneiro <di.gama@gmail.com>
1 parent f83468d commit d709ed6

File tree

3 files changed

+44
-29
lines changed

3 files changed

+44
-29
lines changed

src/algebra/direct_limit.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ span_induction ((quotient.mk_eq_zero _).1 H)
156156
subst hxy,
157157
split,
158158
{ intros i0 hi0,
159-
rw [dfinsupp.mem_support_iff, dfinsupp.sub_apply, ← direct_sum.single_eq_lof,
159+
rw [dfinsupp.mem_support_iff, direct_sum.sub_apply, ← direct_sum.single_eq_lof,
160160
← direct_sum.single_eq_lof, dfinsupp.single_apply, dfinsupp.single_apply] at hi0,
161161
split_ifs at hi0 with hi hj hj, { rwa hi at hik }, { rwa hi at hik }, { rwa hj at hjk },
162162
exfalso, apply hi0, rw sub_zero },

src/algebra/direct_sum.lean

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,34 @@ open_locale big_operators
2525

2626
universes u v w u₁
2727

28-
variables (ι : Type v) [dec_ι : decidable_eq ι] (β : ι → Type w) [Π i, add_comm_group (β i)]
28+
variables (ι : Type v) [dec_ι : decidable_eq ι] (β : ι → Type w)
2929

30-
/-- `direct_sum β` is the direct sum of a family of additive commutative groups `β i`.
30+
/-- `direct_sum β` is the direct sum of a family of additive commutative monoids `β i`.
3131
3232
Note: `open_locale direct_sum` will enable the notation `⨁ i, β i` for `direct_sum β`. -/
33-
@[derive [has_coe_to_fun, add_comm_group, inhabited]]
34-
def direct_sum : Type* := Π₀ i, β i
33+
@[derive [has_coe_to_fun, add_comm_monoid, inhabited]]
34+
def direct_sum [Π i, add_comm_monoid (β i)] : Type* := Π₀ i, β i
3535

3636
localized "notation `⨁` binders `, ` r:(scoped f, direct_sum _ f) := r" in direct_sum
3737

3838
namespace direct_sum
3939

4040
variables {ι}
4141

42+
section add_comm_group
43+
44+
variables [Π i, add_comm_group (β i)]
45+
46+
instance : add_comm_group (direct_sum ι β) := dfinsupp.add_comm_group
47+
48+
variables {β}
49+
@[simp] lemma sub_apply (g₁ g₂ : ⨁ i, β i) (i : ι) : (g₁ - g₂) i = g₁ i - g₂ i :=
50+
dfinsupp.sub_apply _ _ _
51+
52+
end add_comm_group
53+
54+
variables [Π i, add_comm_monoid (β i)]
55+
4256
@[simp] lemma zero_apply (i : ι) : (0 : ⨁ i, β i) i = 0 := rfl
4357

4458
variables {β}
@@ -80,13 +94,13 @@ begin
8094
solve_by_elim
8195
end
8296

83-
variables {γ : Type u₁} [add_comm_group γ]
97+
variables {γ : Type u₁} [add_comm_monoid γ]
8498
variables (φ : Π i, β i →+ γ)
8599

86100
variables (φ)
87-
/-- `to_group φ` is the natural homomorphism from `⨁ i, β i` to `γ`
101+
/-- `to_add_monoid φ` is the natural homomorphism from `⨁ i, β i` to `γ`
88102
induced by a family `φ` of homomorphisms `β i → γ`. -/
89-
def to_group : (⨁ i, β i) →+ γ :=
103+
def to_add_monoid : (⨁ i, β i) →+ γ :=
90104
{ to_fun := (λ f,
91105
quotient.lift_on f (λ x, ∑ i in x.2.to_finset, φ i (x.1 i)) $ λ x y H,
92106
begin
@@ -121,17 +135,17 @@ def to_group : (⨁ i, β i) →+ γ :=
121135
map_zero' := rfl
122136
}
123137

124-
@[simp] lemma to_group_of (i) (x : β i) : to_group φ (of β i x) = φ i x :=
138+
@[simp] lemma to_add_monoid_of (i) (x : β i) : to_add_monoid φ (of β i x) = φ i x :=
125139
(add_zero _).trans $ congr_arg (φ i) $ show (if H : i ∈ ({i} : finset _) then x else 0) = x,
126140
from dif_pos $ finset.mem_singleton_self i
127141

128142
variables (ψ : (⨁ i, β i) →+ γ)
129143

130-
theorem to_group.unique (f : ⨁ i, β i) :
131-
ψ f = to_group (λ i, ψ.comp (of β i)) f :=
144+
theorem to_add_monoid.unique (f : ⨁ i, β i) :
145+
ψ f = to_add_monoid (λ i, ψ.comp (of β i)) f :=
132146
direct_sum.induction_on f
133147
(by rw [add_monoid_hom.map_zero, add_monoid_hom.map_zero])
134-
(λ i x, by rw [to_group_of, add_monoid_hom.comp_apply])
148+
(λ i x, by rw [to_add_monoid_of, add_monoid_hom.comp_apply])
135149
(λ x y ihx ihy, by rw [add_monoid_hom.map_add, add_monoid_hom.map_add, ihx, ihy])
136150

137151
variables (β)
@@ -140,21 +154,21 @@ where `h : S ⊆ T`. -/
140154
-- TODO: generalize this to remove the assumption `S ⊆ T`.
141155
def set_to_set (S T : set ι) (H : S ⊆ T) :
142156
(⨁ (i : S), β i) →+ (⨁ (i : T), β i) :=
143-
to_group $ λ i, of (λ (i : subtype T), β i) ⟨↑i, H i.prop⟩
157+
to_add_monoid $ λ i, of (λ (i : subtype T), β i) ⟨↑i, H i.prop⟩
144158
variables {β}
145159

146160
omit dec_ι
147161

148162
/-- The natural equivalence between `⨁ _ : ι, M` and `M` when `unique ι`. -/
149-
protected def id (M : Type v) (ι : Type* := punit) [add_comm_group M] [unique ι] :
163+
protected def id (M : Type v) (ι : Type* := punit) [add_comm_monoid M] [unique ι] :
150164
(⨁ (_ : ι), M) ≃+ M :=
151-
{ to_fun := direct_sum.to_group (λ _, add_monoid_hom.id M),
165+
{ to_fun := direct_sum.to_add_monoid (λ _, add_monoid_hom.id M),
152166
inv_fun := of (λ _, M) (default ι),
153167
left_inv := λ x, direct_sum.induction_on x
154168
(by rw [add_monoid_hom.map_zero, add_monoid_hom.map_zero])
155-
(λ p x, by rw [unique.default_eq p, to_group_of]; refl)
169+
(λ p x, by rw [unique.default_eq p, to_add_monoid_of]; refl)
156170
(λ x y ihx ihy, by rw [add_monoid_hom.map_add, add_monoid_hom.map_add, ihx, ihy]),
157-
right_inv := λ x, to_group_of _ _ _,
158-
..direct_sum.to_group (λ _, add_monoid_hom.id M) }
171+
right_inv := λ x, to_add_monoid_of _ _ _,
172+
..direct_sum.to_add_monoid (λ _, add_monoid_hom.id M) }
159173

160174
end direct_sum

src/linear_algebra/direct_sum_module.lean

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ universes u v w u₁
2828

2929
variables (R : Type u) [semiring R]
3030
variables (ι : Type v) [dec_ι : decidable_eq ι] (M : ι → Type w)
31-
variables [Π i, add_comm_group (M i)] [Π i, semimodule R (M i)]
31+
variables [Π i, add_comm_monoid (M i)] [Π i, semimodule R (M i)]
3232
include R
3333

3434
namespace direct_sum
3535
open_locale direct_sum
3636

3737
variables {R ι M}
3838

39-
instance : semimodule R (⨁ i, M i) := @dfinsupp.to_semimodule ι M _ _ _ _
39+
instance : semimodule R (⨁ i, M i) := dfinsupp.to_semimodule
4040

41-
@[simp] lemma smul_apply (b : R) (v : ⨁ i, M i) (i : ι) :
41+
lemma smul_apply (b : R) (v : ⨁ i, M i) (i : ι) :
4242
(b • v) i = b • (v i) := dfinsupp.smul_apply _ _ _
4343

4444
include dec_ι
@@ -68,36 +68,36 @@ variables {R}
6868
lemma support_smul [Π (i : ι) (x : M i), decidable (x ≠ 0)]
6969
(c : R) (v : ⨁ i, M i) : (c • v).support ⊆ v.support := dfinsupp.support_smul _ _
7070

71-
variables {N : Type u₁} [add_comm_group N] [semimodule R N]
71+
variables {N : Type u₁} [add_comm_monoid N] [semimodule R N]
7272
variables (φ : Π i, M i →ₗ[R] N)
7373

7474
variables (R ι N φ)
7575
/-- The linear map constructed using the universal property of the coproduct. -/
7676
def to_module : (⨁ i, M i) →ₗ[R] N :=
77-
{ to_fun := to_group (λ i, (φ i).to_add_monoid_hom),
78-
map_add' := (to_group (λ i, (φ i).to_add_monoid_hom)).map_add,
77+
{ to_fun := to_add_monoid (λ i, (φ i).to_add_monoid_hom),
78+
map_add' := (to_add_monoid (λ i, (φ i).to_add_monoid_hom)).map_add,
7979
map_smul' := λ c x, direct_sum.induction_on x
8080
(by rw [smul_zero, add_monoid_hom.map_zero, smul_zero])
8181
(λ i x,
82-
by rw [← of_smul, to_group_of, to_group_of, linear_map.to_add_monoid_hom_coe,
82+
by rw [← of_smul, to_add_monoid_of, to_add_monoid_of, linear_map.to_add_monoid_hom_coe,
8383
linear_map.map_smul])
8484
(λ x y ihx ihy,
8585
by rw [smul_add, add_monoid_hom.map_add, ihx, ihy, add_monoid_hom.map_add, smul_add]),
86-
..(to_group (λ i, (φ i).to_add_monoid_hom))}
86+
..(to_add_monoid (λ i, (φ i).to_add_monoid_hom))}
8787

8888
variables {ι N φ}
8989

9090
/-- The map constructed using the universal property gives back the original maps when
9191
restricted to each component. -/
9292
@[simp] lemma to_module_lof (i) (x : M i) : to_module R ι N φ (lof R ι M i x) = φ i x :=
93-
to_group_of (λ i, (φ i).to_add_monoid_hom) i x
93+
to_add_monoid_of (λ i, (φ i).to_add_monoid_hom) i x
9494

9595
variables (ψ : (⨁ i, M i) →ₗ[R] N)
9696

9797
/-- Every linear map from a direct sum agrees with the one obtained by applying
9898
the universal property to each of its components. -/
9999
theorem to_module.unique (f : ⨁ i, M i) : ψ f = to_module R ι N (λ i, ψ.comp $ lof R ι M i) f :=
100-
to_group.unique ψ.to_add_monoid_hom f
100+
to_add_monoid.unique ψ.to_add_monoid_hom f
101101

102102
variables {ψ} {ψ' : (⨁ i, M i) →ₗ[R] N}
103103

@@ -117,7 +117,8 @@ omit dec_ι
117117

118118
/-- The natural linear equivalence between `⨁ _ : ι, M` and `M` when `unique ι`. -/
119119
-- TODO: generalize this to arbitrary index type `ι` with `unique ι`
120-
protected def lid (M : Type v) (ι : Type* := punit) [add_comm_group M] [semimodule R M] [unique ι] :
120+
protected def lid (M : Type v) (ι : Type* := punit) [add_comm_monoid M] [semimodule R M]
121+
[unique ι] :
121122
(⨁ (_ : ι), M) ≃ₗ M :=
122123
{ .. direct_sum.id M ι,
123124
.. to_module R ι M (λ i, linear_map.id) }

0 commit comments

Comments
 (0)