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

Commit bad4f97

Browse files
feat(algebra/direct_sum): Add ⨁ notation (#3473)
This uses the unicode character "n-ary circled plus operator", which seems to be the usual symbol for this operation Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
1 parent 289d17c commit bad4f97

File tree

3 files changed

+47
-29
lines changed

3 files changed

+47
-29
lines changed

src/algebra/direct_sum.lean

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@ Copyright (c) 2019 Kenny Lau. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Kenny Lau
55
6-
Direct sum of abelian groups, indexed by a discrete type.
76
-/
87
import data.dfinsupp
98

9+
/-!
10+
# Direct sum
11+
12+
This file defines the direct sum of abelian groups, indexed by a discrete type.
13+
14+
## Notation
15+
16+
`⨁ i, β i` is the n-ary direct sum `direct_sum`.
17+
This notation is in the `direct_sum` locale, accessible after `open_locale direct_sum`.
18+
19+
## References
20+
21+
* https://en.wikipedia.org/wiki/Direct_sum
22+
-/
23+
1024
open_locale big_operators
1125

1226
universes u v w u₁
@@ -15,20 +29,22 @@ variables (ι : Type v) [decidable_eq ι] (β : ι → Type w) [Π i, add_comm_g
1529

1630
def direct_sum : Type* := Π₀ i, β i
1731

32+
localized "notation `⨁` binders `, ` r:(scoped f, direct_sum _ f) := r" in direct_sum
33+
1834
namespace direct_sum
1935

2036
variables {ι β}
2137

22-
instance : add_comm_group (direct_sum ι β) :=
38+
instance : add_comm_group (⨁ i, β i) :=
2339
dfinsupp.add_comm_group
2440

25-
instance : inhabited (direct_sum ι β) := ⟨0
41+
instance : inhabited (⨁ i, β i) := ⟨0
2642

2743
variables β
28-
def mk : Π s : finset ι, (Π i : (↑s : set ι), β i.1) → direct_sum ι β :=
44+
def mk : Π s : finset ι, (Π i : (↑s : set ι), β i.1) → ⨁ i, β i :=
2945
dfinsupp.mk
3046

31-
def of : Π i : ι, β i → direct_sum ι β :=
47+
def of : Π i : ι, β i → ⨁ i, β i :=
3248
dfinsupp.single
3349
variables {β}
3450

@@ -69,8 +85,8 @@ theorem of_injective (i : ι) : function.injective (of β i) :=
6985
λ x y H, congr_fun (mk_injective _ H) ⟨i, by simp⟩
7086

7187
@[elab_as_eliminator]
72-
protected theorem induction_on {C : direct_sum ι βProp}
73-
(x : direct_sum ι β) (H_zero : C 0)
88+
protected theorem induction_on {C : (⨁ i, β i)Prop}
89+
(x : ⨁ i, β i) (H_zero : C 0)
7490
(H_basic : ∀ (i : ι) (x : β i), C (of β i x))
7591
(H_plus : ∀ x y, C x → C y → C (x + y)) : C x :=
7692
begin
@@ -83,7 +99,7 @@ variables {γ : Type u₁} [add_comm_group γ]
8399
variables (φ : Π i, β i → γ) [Π i, is_add_group_hom (φ i)]
84100

85101
variables (φ)
86-
def to_group (f : direct_sum ι β) : γ :=
102+
def to_group (f : ⨁ i, β i) : γ :=
87103
quotient.lift_on f (λ x, ∑ i in x.2.to_finset, φ i (x.1 i)) $ λ x y H,
88104
begin
89105
have H1 : x.2.to_finset ∩ y.2.to_finset ⊆ x.2.to_finset, from finset.inter_subset_left _ _,
@@ -135,9 +151,9 @@ is_add_group_hom.map_sub _ x y
135151
(add_zero _).trans $ congr_arg (φ i) $ show (if H : i ∈ ({i} : finset _) then x else 0) = x,
136152
from dif_pos $ finset.mem_singleton_self i
137153

138-
variables (ψ : direct_sum ι β → γ) [is_add_group_hom ψ]
154+
variables (ψ : (⨁ i, β i) → γ) [is_add_group_hom ψ]
139155

140-
theorem to_group.unique (f : direct_sum ι β) :
156+
theorem to_group.unique (f : ⨁ i, β i) :
141157
ψ f = @to_group _ _ _ _ _ _ (λ i, ψ ∘ of β i) (λ i, is_add_group_hom.comp (of β i) ψ) f :=
142158
by haveI : ∀ i, is_add_group_hom (ψ ∘ of β i) := (λ _, is_add_group_hom.comp _ _); exact
143159
direct_sum.induction_on f
@@ -147,14 +163,14 @@ direct_sum.induction_on f
147163

148164
variables (β)
149165
def set_to_set (S T : set ι) (H : S ⊆ T) :
150-
direct_sum S (β ∘ subtype.val) → direct_sum T (β ∘ subtype.val) :=
166+
(⨁ (i : S), β i) → (⨁ (i : T), β i) :=
151167
to_group $ λ i, of (β ∘ @subtype.val _ T) ⟨i.1, H i.2
152168
variables {β}
153169

154170
instance (S T : set ι) (H : S ⊆ T) : is_add_group_hom (set_to_set β S T H) :=
155171
to_group.is_add_group_hom
156172

157-
protected def id (M : Type v) [add_comm_group M] : direct_sum punit (λ _, M) ≃ M :=
173+
protected def id (M : Type v) [add_comm_group M] : (⨁ (_ : punit), M) ≃ M :=
158174
{ to_fun := direct_sum.to_group (λ _, id),
159175
inv_fun := of (λ _, M) punit.star,
160176
left_inv := λ x, direct_sum.induction_on x
@@ -163,7 +179,7 @@ protected def id (M : Type v) [add_comm_group M] : direct_sum punit (λ _, M)
163179
(λ x y ihx ihy, by rw [to_group_add, of_add, ihx, ihy]),
164180
right_inv := λ x, to_group_of _ _ _ }
165181

166-
instance : has_coe_to_fun (direct_sum ι β) :=
182+
instance : has_coe_to_fun (⨁ i, β i) :=
167183
dfinsupp.has_coe_to_fun
168184

169185
end direct_sum

src/linear_algebra/direct_sum/tensor_product.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ section ring
1111
namespace tensor_product
1212

1313
open_locale tensor_product
14+
open_locale direct_sum
1415
open linear_map
1516

1617
variables (R : Type*) [comm_ring R]
@@ -20,10 +21,10 @@ variables (M₁ : ι₁ → Type*) (M₂ : ι₂ → Type*)
2021
variables [Π i₁, add_comm_group (M₁ i₁)] [Π i₂, add_comm_group (M₂ i₂)]
2122
variables [Π i₁, module R (M₁ i₁)] [Π i₂, module R (M₂ i₂)]
2223

23-
/-- The linear equivalence `( i₁, M₁ i₁) ⊗ ( i₂, M₂ i₂) ≃ ( i₁, i₂, M₁ i₁ ⊗ M₂ i₂)`, i.e.
24+
/-- The linear equivalence `( i₁, M₁ i₁) ⊗ ( i₂, M₂ i₂) ≃ ( i₁, i₂, M₁ i₁ ⊗ M₂ i₂)`, i.e.
2425
"tensor product distributes over direct sum". -/
2526
def direct_sum :
26-
direct_sum ι₁ M₁ ⊗[R] direct_sum ι₂ M₂ ≃ₗ[R] direct_sum (ι₁ × ι₂) (λ i, M₁ i.1 ⊗[R] M₂ i.2) :=
27+
(⨁ i₁, M₁ i₁) ⊗[R] (⨁ i₂, M₂ i₂) ≃ₗ[R] (⨁ (i : ι₁ × ι₂), M₁ i.1 ⊗[R] M₂ i.2) :=
2728
begin
2829
refine linear_equiv.of_linear
2930
(lift $ direct_sum.to_module R _ _ $ λ i₁, flip $ direct_sum.to_module R _ _ $ λ i₂,

src/linear_algebra/direct_sum_module.lean

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ variables [Π i, add_comm_group (M i)] [Π i, semimodule R (M i)]
3232
include R
3333

3434
namespace direct_sum
35+
open_locale direct_sum
3536

3637
variables {R ι M}
3738

38-
instance : semimodule R (direct_sum ι M) := dfinsupp.to_semimodule
39+
instance : semimodule R (⨁ i, M i) := dfinsupp.to_semimodule
3940

4041
variables R ι M
4142
/-- Create the direct sum given a family `M` of `R` semimodules indexed over `ι`. -/
42-
def lmk : Π s : finset ι, (Π i : (↑s : set ι), M i.val) →ₗ[R] direct_sum ι M :=
43+
def lmk : Π s : finset ι, (Π i : (↑s : set ι), M i.val) →ₗ[R] (⨁ i, M i) :=
4344
dfinsupp.lmk M R
4445

4546
/-- Inclusion of each component into the direct sum. -/
46-
def lof : Π i : ι, M i →ₗ[R] direct_sum ι M :=
47+
def lof : Π i : ι, M i →ₗ[R] (⨁ i, M i) :=
4748
dfinsupp.lsingle M R
4849
variables {ι M}
4950

@@ -63,7 +64,7 @@ variables (φ : Π i, M i →ₗ[R] N)
6364

6465
variables (ι N φ)
6566
/-- The linear map constructed using the universal property of the coproduct. -/
66-
def to_module : direct_sum ι M →ₗ[R] N :=
67+
def to_module : (⨁ i, M i) →ₗ[R] N :=
6768
{ to_fun := to_group (λ i, φ i),
6869
map_add' := to_group_add _,
6970
map_smul' := λ c x, direct_sum.induction_on x
@@ -78,16 +79,16 @@ restricted to each component. -/
7879
@[simp] lemma to_module_lof (i) (x : M i) : to_module R ι N φ (lof R ι M i x) = φ i x :=
7980
to_group_of (λ i, φ i) i x
8081

81-
variables (ψ : direct_sum ι M →ₗ[R] N)
82+
variables (ψ : (⨁ i, M i) →ₗ[R] N)
8283

8384
/-- Every linear map from a direct sum agrees with the one obtained by applying
8485
the universal property to each of its components. -/
85-
theorem to_module.unique (f : direct_sum ι M) : ψ f = to_module R ι N (λ i, ψ.comp $ lof R ι M i) f :=
86+
theorem to_module.unique (f : ⨁ i, M i) : ψ f = to_module R ι N (λ i, ψ.comp $ lof R ι M i) f :=
8687
to_group.unique ψ f
8788

88-
variables {ψ} {ψ' : direct_sum ι M →ₗ[R] N}
89+
variables {ψ} {ψ' : (⨁ i, M i) →ₗ[R] N}
8990

90-
theorem to_module.ext (H : ∀ i, ψ.comp (lof R ι M i) = ψ'.comp (lof R ι M i)) (f : direct_sum ι M) :
91+
theorem to_module.ext (H : ∀ i, ψ.comp (lof R ι M i) = ψ'.comp (lof R ι M i)) (f : ⨁ i, M i) :
9192
ψ f = ψ' f :=
9293
by rw [to_module.unique R ψ, to_module.unique R ψ', funext H]
9394

@@ -96,17 +97,17 @@ The inclusion of a subset of the direct summands
9697
into a larger subset of the direct summands, as a linear map.
9798
-/
9899
def lset_to_set (S T : set ι) (H : S ⊆ T) :
99-
direct_sum S (M ∘ subtype.val) →ₗ direct_sum T (M ∘ subtype.val) :=
100+
(⨁ (i : S), M i) →ₗ (⨁ (i : T), M i) :=
100101
to_module R _ _ $ λ i, lof R T (M ∘ @subtype.val _ T) ⟨i.1, H i.2
101102

102103
protected def lid (M : Type v) [add_comm_group M] [semimodule R M] :
103-
direct_sum punit (λ _, M) ≃ₗ M :=
104+
(⨁ (_ : punit), M) ≃ₗ M :=
104105
{ .. direct_sum.id M,
105106
.. to_module R punit M (λ i, linear_map.id) }
106107

107108
variables (ι M)
108109
/-- The projection map onto one component, as a linear map. -/
109-
def component (i : ι) : direct_sum ι M →ₗ[R] M i :=
110+
def component (i : ι) : (⨁ i, M i) →ₗ[R] M i :=
110111
{ to_fun := λ f, f i,
111112
map_add' := λ _ _, dfinsupp.add_apply,
112113
map_smul' := λ _ _, dfinsupp.smul_apply }
@@ -115,7 +116,7 @@ variables {ι M}
115116
@[simp] lemma lof_apply (i : ι) (b : M i) : ((lof R ι M i) b) i = b :=
116117
by rw [lof, dfinsupp.lsingle_apply, dfinsupp.single_apply, dif_pos rfl]
117118

118-
lemma apply_eq_component (f : direct_sum ι M) (i : ι) :
119+
lemma apply_eq_component (f : ⨁ i, M i) (i : ι) :
119120
f i = component R ι M i f := rfl
120121

121122
@[simp] lemma component.lof_self (i : ι) (b : M i) :
@@ -127,11 +128,11 @@ lemma component.of (i j : ι) (b : M j) :
127128
if h : j = i then eq.rec_on h b else 0 :=
128129
dfinsupp.single_apply
129130

130-
@[ext] lemma ext {f g : direct_sum ι M}
131+
@[ext] lemma ext {f g : ⨁ i, M i}
131132
(h : ∀ i, component R ι M i f = component R ι M i g) : f = g :=
132133
dfinsupp.ext h
133134

134-
lemma ext_iff {f g : direct_sum ι M} : f = g ↔
135+
lemma ext_iff {f g : ⨁ i, M i} : f = g ↔
135136
∀ i, component R ι M i f = component R ι M i g :=
136137
⟨λ h _, by rw h, ext R⟩
137138

0 commit comments

Comments
 (0)