Debian Codegraph @

src/Algebra/Module/Construct/DirectProduct.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- This module constructs the biproduct of two R-modules, and similar
5 -- for weaker module-like structures.
6 -- The intended universal property is that the biproduct is both a
7 -- product and a coproduct in the category of R-modules.
8 ------------------------------------------------------------------------
9
10 {-# OPTIONS --cubical-compatible --safe #-}
11
12 module Algebra.Module.Construct.DirectProduct where
13
14 open import Algebra.Bundles
15 open import Algebra.Construct.DirectProduct using (commutativeMonoid)
16 open import Algebra.Module.Bundles
17 open import Data.Product.Base using (map; zip; _,_; proj₁; proj₂)
18 open import Data.Product.Relation.Binary.Pointwise.NonDependent
19 using (Pointwise)
20 open import Level using (Level; _⊔_)
21
22 private
23 variable
24 r s ℓr ℓs m m′ ℓm ℓm′ : Level
25
26 ------------------------------------------------------------------------
27 -- Raw bundles
28
29 rawLeftSemimodule : {R : Set r} →
30 RawLeftSemimodule R m ℓm →
31 RawLeftSemimodule R m′ ℓm′ →
32 RawLeftSemimodule R (m ⊔ m′) (ℓm ⊔ ℓm′)
33 rawLeftSemimodule M N = record
34 { _≈ᴹ_ = Pointwise M._≈ᴹ_ N._≈ᴹ_
35 ; _+ᴹ_ = zip M._+ᴹ_ N._+ᴹ_
36 ; _*ₗ_ = λ r → map (r M.*ₗ_) (r N.*ₗ_)
37 ; 0ᴹ = M.0ᴹ , N.0ᴹ
38 } where module M = RawLeftSemimodule M; module N = RawLeftSemimodule N
39
40 rawLeftModule : {R : Set r} →
41 RawLeftModule R m ℓm →
42 RawLeftModule R m′ ℓm′ →
43 RawLeftModule R (m ⊔ m′) (ℓm ⊔ ℓm′)
44 rawLeftModule M N = record
45 { RawLeftSemimodule (rawLeftSemimodule M.rawLeftSemimodule N.rawLeftSemimodule)
46 ; -ᴹ_ = map M.-ᴹ_ N.-ᴹ_
47 } where module M = RawLeftModule M; module N = RawLeftModule N
48
49
50 rawRightSemimodule : {R : Set r} →
51 RawRightSemimodule R m ℓm →
52 RawRightSemimodule R m′ ℓm′ →
53 RawRightSemimodule R (m ⊔ m′) (ℓm ⊔ ℓm′)
54 rawRightSemimodule M N = record
55 { _≈ᴹ_ = Pointwise M._≈ᴹ_ N._≈ᴹ_
56 ; _+ᴹ_ = zip M._+ᴹ_ N._+ᴹ_
57 ; _*ᵣ_ = λ mn r → map (M._*ᵣ r) (N._*ᵣ r) mn
58 ; 0ᴹ = M.0ᴹ , N.0ᴹ
59 } where module M = RawRightSemimodule M; module N = RawRightSemimodule N
60
61 rawRightModule : {R : Set r} →
62 RawRightModule R m ℓm →
63 RawRightModule R m′ ℓm′ →
64 RawRightModule R (m ⊔ m′) (ℓm ⊔ ℓm′)
65 rawRightModule M N = record
66 { RawRightSemimodule (rawRightSemimodule M.rawRightSemimodule N.rawRightSemimodule)
67 ; -ᴹ_ = map M.-ᴹ_ N.-ᴹ_
68 } where module M = RawRightModule M; module N = RawRightModule N
69
70 rawBisemimodule : {R : Set r} {S : Set s} →
71 RawBisemimodule R S m ℓm →
72 RawBisemimodule R S m′ ℓm′ →
73 RawBisemimodule R S (m ⊔ m′) (ℓm ⊔ ℓm′)
74 rawBisemimodule M N = record
75 { _≈ᴹ_ = Pointwise M._≈ᴹ_ N._≈ᴹ_
76 ; _+ᴹ_ = zip M._+ᴹ_ N._+ᴹ_
77 ; _*ₗ_ = λ r → map (r M.*ₗ_) (r N.*ₗ_)
78 ; _*ᵣ_ = λ mn r → map (M._*ᵣ r) (N._*ᵣ r) mn
79 ; 0ᴹ = M.0ᴹ , N.0ᴹ
80 } where module M = RawBisemimodule M; module N = RawBisemimodule N
81
82 rawBimodule : {R : Set r} {S : Set s} →
83 RawBimodule R S m ℓm →
84 RawBimodule R S m′ ℓm′ →
85 RawBimodule R S (m ⊔ m′) (ℓm ⊔ ℓm′)
86 rawBimodule M N = record
87 { RawBisemimodule (rawBisemimodule M.rawBisemimodule N.rawBisemimodule)
88 ; -ᴹ_ = map M.-ᴹ_ N.-ᴹ_
89 } where module M = RawBimodule M; module N = RawBimodule N
90
91 rawSemimodule : {R : Set r} →
92 RawSemimodule R m ℓm →
93 RawSemimodule R m′ ℓm′ →
94 RawSemimodule R (m ⊔ m′) (ℓm ⊔ ℓm′)
95 rawSemimodule M N = rawBisemimodule M N
96
97 rawModule : {R : Set r} →
98 RawModule R m ℓm →
99 RawModule R m′ ℓm′ →
100 RawModule R (m ⊔ m′) (ℓm ⊔ ℓm′)
101 rawModule M N = rawBimodule M N
102
103 ------------------------------------------------------------------------
104 -- Bundles
105
106 leftSemimodule : {R : Semiring r ℓr} →
107 LeftSemimodule R m ℓm →
108 LeftSemimodule R m′ ℓm′ →
109 LeftSemimodule R (m ⊔ m′) (ℓm ⊔ ℓm′)
110 leftSemimodule M N = record
111 { _*ₗ_ = λ r → map (r M.*ₗ_) (r N.*ₗ_)
112 ; isLeftSemimodule = record
113 { +ᴹ-isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid
114 (commutativeMonoid M.+ᴹ-commutativeMonoid N.+ᴹ-commutativeMonoid)
115 ; isPreleftSemimodule = record
116 { *ₗ-cong = λ where rr (mm , nn) → M.*ₗ-cong rr mm , N.*ₗ-cong rr nn
117 ; *ₗ-zeroˡ = λ where (m , n) → M.*ₗ-zeroˡ m , N.*ₗ-zeroˡ n
118 ; *ₗ-distribʳ = λ where
119 (m , n) x y → M.*ₗ-distribʳ m x y , N.*ₗ-distribʳ n x y
120 ; *ₗ-identityˡ = λ where (m , n) → M.*ₗ-identityˡ m , N.*ₗ-identityˡ n
121 ; *ₗ-assoc = λ where x y (m , n) → M.*ₗ-assoc x y m , N.*ₗ-assoc x y n
122 ; *ₗ-zeroʳ = λ x → M.*ₗ-zeroʳ x , N.*ₗ-zeroʳ x
123 ; *ₗ-distribˡ = λ where
124 x (m , n) (m′ , n′) → M.*ₗ-distribˡ x m m′ , N.*ₗ-distribˡ x n n′
125 }
126 }
127 } where module M = LeftSemimodule M; module N = LeftSemimodule N
128
129 rightSemimodule : {R : Semiring r ℓr} →
130 RightSemimodule R m ℓm →
131 RightSemimodule R m′ ℓm′ →
132 RightSemimodule R (m ⊔ m′) (ℓm ⊔ ℓm′)
133 rightSemimodule M N = record
134 { _*ᵣ_ = λ mn r → map (M._*ᵣ r) (N._*ᵣ r) mn
135 ; isRightSemimodule = record
136 { +ᴹ-isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid
137 (commutativeMonoid M.+ᴹ-commutativeMonoid N.+ᴹ-commutativeMonoid)
138 ; isPrerightSemimodule = record
139 { *ᵣ-cong = λ where (mm , nn) rr → M.*ᵣ-cong mm rr , N.*ᵣ-cong nn rr
140 ; *ᵣ-zeroʳ = λ where (m , n) → M.*ᵣ-zeroʳ m , N.*ᵣ-zeroʳ n
141 ; *ᵣ-distribˡ = λ where
142 (m , n) x y → M.*ᵣ-distribˡ m x y , N.*ᵣ-distribˡ n x y
143 ; *ᵣ-identityʳ = λ where (m , n) → M.*ᵣ-identityʳ m , N.*ᵣ-identityʳ n
144 ; *ᵣ-assoc = λ where
145 (m , n) x y → M.*ᵣ-assoc m x y , N.*ᵣ-assoc n x y
146 ; *ᵣ-zeroˡ = λ x → M.*ᵣ-zeroˡ x , N.*ᵣ-zeroˡ x
147 ; *ᵣ-distribʳ = λ where
148 x (m , n) (m′ , n′) → M.*ᵣ-distribʳ x m m′ , N.*ᵣ-distribʳ x n n′
149 }
150 }
151 } where module M = RightSemimodule M; module N = RightSemimodule N
152
153 bisemimodule : {R : Semiring r ℓr} {S : Semiring s ℓs} →
154 Bisemimodule R S m ℓm →
155 Bisemimodule R S m′ ℓm′ →
156 Bisemimodule R S (m ⊔ m′) (ℓm ⊔ ℓm′)
157 bisemimodule M N = record
158 { isBisemimodule = record
159 { +ᴹ-isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid
160 (commutativeMonoid M.+ᴹ-commutativeMonoid N.+ᴹ-commutativeMonoid)
161 ; isPreleftSemimodule = LeftSemimodule.isPreleftSemimodule
162 (leftSemimodule M.leftSemimodule N.leftSemimodule)
163 ; isPrerightSemimodule = RightSemimodule.isPrerightSemimodule
164 (rightSemimodule M.rightSemimodule N.rightSemimodule)
165 ; *ₗ-*ᵣ-assoc = λ where
166 x (m , n) y → M.*ₗ-*ᵣ-assoc x m y , N.*ₗ-*ᵣ-assoc x n y
167 }
168 } where module M = Bisemimodule M; module N = Bisemimodule N
169
170 semimodule : {R : CommutativeSemiring r ℓr} →
171 Semimodule R m ℓm →
172 Semimodule R m′ ℓm′ →
173 Semimodule R (m ⊔ m′) (ℓm ⊔ ℓm′)
174 semimodule M N = record
175 { isSemimodule = record
176 { isBisemimodule = Bisemimodule.isBisemimodule
177 (bisemimodule M.bisemimodule N.bisemimodule)
178 ; *ₗ-*ᵣ-coincident = λ x m → M.*ₗ-*ᵣ-coincident x (proj₁ m) , N.*ₗ-*ᵣ-coincident x (proj₂ m)
179 }
180 } where module M = Semimodule M; module N = Semimodule N
181
182 leftModule : {R : Ring r ℓr} →
183 LeftModule R m ℓm →
184 LeftModule R m′ ℓm′ →
185 LeftModule R (m ⊔ m′) (ℓm ⊔ ℓm′)
186 leftModule M N = record
187 { -ᴹ_ = map M.-ᴹ_ N.-ᴹ_
188 ; isLeftModule = record
189 { isLeftSemimodule = LeftSemimodule.isLeftSemimodule
190 (leftSemimodule M.leftSemimodule N.leftSemimodule)
191 ; -ᴹ‿cong = λ where (mm , nn) → M.-ᴹ‿cong mm , N.-ᴹ‿cong nn
192 ; -ᴹ‿inverse = λ where
193 .proj₁ (m , n) → M.-ᴹ‿inverseˡ m , N.-ᴹ‿inverseˡ n
194 .proj₂ (m , n) → M.-ᴹ‿inverseʳ m , N.-ᴹ‿inverseʳ n
195 }
196 } where module M = LeftModule M; module N = LeftModule N
197
198 rightModule : {R : Ring r ℓr} →
199 RightModule R m ℓm →
200 RightModule R m′ ℓm′ →
201 RightModule R (m ⊔ m′) (ℓm ⊔ ℓm′)
202 rightModule M N = record
203 { -ᴹ_ = map M.-ᴹ_ N.-ᴹ_
204 ; isRightModule = record
205 { isRightSemimodule = RightSemimodule.isRightSemimodule
206 (rightSemimodule M.rightSemimodule N.rightSemimodule)
207 ; -ᴹ‿cong = λ where (mm , nn) → M.-ᴹ‿cong mm , N.-ᴹ‿cong nn
208 ; -ᴹ‿inverse = λ where
209 .proj₁ (m , n) → M.-ᴹ‿inverseˡ m , N.-ᴹ‿inverseˡ n
210 .proj₂ (m , n) → M.-ᴹ‿inverseʳ m , N.-ᴹ‿inverseʳ n
211 }
212 } where module M = RightModule M; module N = RightModule N
213
214 bimodule : {R : Ring r ℓr} {S : Ring s ℓs} →
215 Bimodule R S m ℓm →
216 Bimodule R S m′ ℓm′ →
217 Bimodule R S (m ⊔ m′) (ℓm ⊔ ℓm′)
218 bimodule M N = record
219 { -ᴹ_ = map M.-ᴹ_ N.-ᴹ_
220 ; isBimodule = record
221 { isBisemimodule = Bisemimodule.isBisemimodule
222 (bisemimodule M.bisemimodule N.bisemimodule)
223 ; -ᴹ‿cong = λ where (mm , nn) → M.-ᴹ‿cong mm , N.-ᴹ‿cong nn
224 ; -ᴹ‿inverse = λ where
225 .proj₁ (m , n) → M.-ᴹ‿inverseˡ m , N.-ᴹ‿inverseˡ n
226 .proj₂ (m , n) → M.-ᴹ‿inverseʳ m , N.-ᴹ‿inverseʳ n
227 }
228 } where module M = Bimodule M; module N = Bimodule N
229
230 ⟨module⟩ : {R : CommutativeRing r ℓr} →
231 Module R m ℓm →
232 Module R m′ ℓm′ →
233 Module R (m ⊔ m′) (ℓm ⊔ ℓm′)
234 ⟨module⟩ M N = record
235 { isModule = record
236 { isBimodule = Bimodule.isBimodule (bimodule M.bimodule N.bimodule)
237 ; *ₗ-*ᵣ-coincident = λ x m → M.*ₗ-*ᵣ-coincident x (proj₁ m) , N.*ₗ-*ᵣ-coincident x (proj₂ m)
238 }
239 } where module M = Module M; module N = Module N