Debian Codegraph @

src/Algebra/Module/Bundles.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Definitions of algebraic structures defined over some other
5 -- structure, like modules and vector spaces
6 --
7 -- Terminology of bundles:
8 -- * There are both *semimodules* and *modules*.
9 -- - For M an R-semimodule, R is a semiring, and M forms a commutative
10 -- monoid.
11 -- - For M an R-module, R is a ring, and M forms an Abelian group.
12 -- * There are all four of *left modules*, *right modules*, *bimodules*,
13 -- and *modules*.
14 -- - Left modules have a left-scaling operation.
15 -- - Right modules have a right-scaling operation.
16 -- - Bimodules have two sorts of scalars. Left-scaling handles one and
17 -- right-scaling handles the other. Left-scaling and right-scaling
18 -- are furthermore compatible.
19 -- - Modules are bimodules with a single sort of scalars and scalar
20 -- multiplication must also be commutative. Left-scaling and
21 -- right-scaling coincide.
22 ------------------------------------------------------------------------
23
24 {-# OPTIONS --cubical-compatible --safe #-}
25
26 module Algebra.Module.Bundles where
27
28 open import Algebra.Bundles
29 using (Semiring; Ring; CommutativeSemiring; CommutativeRing
30 ; CommutativeMonoid; AbelianGroup)
31 open import Algebra.Core using (Op₁; Op₂)
32 open import Algebra.Definitions using (Involutive)
33 import Algebra.Module.Bundles.Raw as Raw
34 open import Algebra.Module.Core using (Opₗ; Opᵣ)
35 open import Algebra.Module.Structures
36 using (IsLeftSemimodule; IsRightSemimodule; IsBisemimodule
37 ; IsSemimodule; IsLeftModule; IsRightModule; IsModule; IsBimodule)
38 open import Algebra.Module.Definitions
39 open import Function.Base using (flip)
40 open import Level using (Level; _⊔_; suc)
41 open import Relation.Binary.Core using (Rel)
42 import Relation.Binary.Reasoning.Setoid as ≈-Reasoning
43
44 private
45 variable
46 r ℓr s ℓs : Level
47
48 ------------------------------------------------------------------------
49 -- Re-export definitions of 'raw' bundles
50
51 open Raw public
52 using ( RawLeftSemimodule; RawLeftModule
53 ; RawRightSemimodule; RawRightModule
54 ; RawBisemimodule; RawBimodule
55 ; RawSemimodule; RawModule
56 )
57
58 ------------------------------------------------------------------------
59 -- Left modules
60 ------------------------------------------------------------------------
61
62 record LeftSemimodule (semiring : Semiring r ℓr) m ℓm
63 : Set (r ⊔ ℓr ⊔ suc (m ⊔ ℓm)) where
64 open Semiring semiring
65
66 infixr 7 _*ₗ_
67 infixl 6 _+ᴹ_
68 infix 4 _≈ᴹ_
69
70 field
71 Carrierᴹ : Set m
72 _≈ᴹ_ : Rel Carrierᴹ ℓm
73 _+ᴹ_ : Op₂ Carrierᴹ
74 _*ₗ_ : Opₗ Carrier Carrierᴹ
75 0ᴹ : Carrierᴹ
76 isLeftSemimodule : IsLeftSemimodule semiring _≈ᴹ_ _+ᴹ_ 0ᴹ _*ₗ_
77
78 open IsLeftSemimodule isLeftSemimodule public
79
80 +ᴹ-commutativeMonoid : CommutativeMonoid m ℓm
81 +ᴹ-commutativeMonoid = record
82 { isCommutativeMonoid = +ᴹ-isCommutativeMonoid
83 }
84
85 open CommutativeMonoid +ᴹ-commutativeMonoid public
86 using () renaming
87 ( monoid to +ᴹ-monoid
88 ; semigroup to +ᴹ-semigroup
89 ; magma to +ᴹ-magma
90 ; rawMagma to +ᴹ-rawMagma
91 ; rawMonoid to +ᴹ-rawMonoid
92 ; _≉_ to _≉ᴹ_
93 )
94
95 rawLeftSemimodule : RawLeftSemimodule Carrier m ℓm
96 rawLeftSemimodule = record
97 { _≈ᴹ_ = _≈ᴹ_
98 ; _+ᴹ_ = _+ᴹ_
99 ; _*ₗ_ = _*ₗ_
100 ; 0ᴹ = 0ᴹ
101 }
102
103 record LeftModule (ring : Ring r ℓr) m ℓm : Set (r ⊔ ℓr ⊔ suc (m ⊔ ℓm)) where
104 open Ring ring
105
106 infixr 8 -ᴹ_
107 infixr 7 _*ₗ_
108 infixl 6 _+ᴹ_
109 infix 4 _≈ᴹ_
110
111 field
112 Carrierᴹ : Set m
113 _≈ᴹ_ : Rel Carrierᴹ ℓm
114 _+ᴹ_ : Op₂ Carrierᴹ
115 _*ₗ_ : Opₗ Carrier Carrierᴹ
116 0ᴹ : Carrierᴹ
117 -ᴹ_ : Op₁ Carrierᴹ
118 isLeftModule : IsLeftModule ring _≈ᴹ_ _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_
119
120 open IsLeftModule isLeftModule public
121
122 leftSemimodule : LeftSemimodule semiring m ℓm
123 leftSemimodule = record { isLeftSemimodule = isLeftSemimodule }
124
125 open LeftSemimodule leftSemimodule public
126 using ( +ᴹ-commutativeMonoid; +ᴹ-monoid; +ᴹ-semigroup; +ᴹ-magma
127 ; +ᴹ-rawMagma; +ᴹ-rawMonoid; rawLeftSemimodule; _≉ᴹ_)
128
129 +ᴹ-abelianGroup : AbelianGroup m ℓm
130 +ᴹ-abelianGroup = record { isAbelianGroup = +ᴹ-isAbelianGroup }
131
132 open AbelianGroup +ᴹ-abelianGroup public
133 using () renaming (group to +ᴹ-group; rawGroup to +ᴹ-rawGroup)
134
135 rawLeftModule : RawLeftModule Carrier m ℓm
136 rawLeftModule = record
137 { _≈ᴹ_ = _≈ᴹ_
138 ; _+ᴹ_ = _+ᴹ_
139 ; _*ₗ_ = _*ₗ_
140 ; 0ᴹ = 0ᴹ
141 ; -ᴹ_ = -ᴹ_
142 }
143
144 ------------------------------------------------------------------------
145 -- Right modules
146 ------------------------------------------------------------------------
147
148 record RightSemimodule (semiring : Semiring r ℓr) m ℓm
149 : Set (r ⊔ ℓr ⊔ suc (m ⊔ ℓm)) where
150 open Semiring semiring
151
152 infixl 7 _*ᵣ_
153 infixl 6 _+ᴹ_
154 infix 4 _≈ᴹ_
155
156 field
157 Carrierᴹ : Set m
158 _≈ᴹ_ : Rel Carrierᴹ ℓm
159 _+ᴹ_ : Op₂ Carrierᴹ
160 _*ᵣ_ : Opᵣ Carrier Carrierᴹ
161 0ᴹ : Carrierᴹ
162 isRightSemimodule : IsRightSemimodule semiring _≈ᴹ_ _+ᴹ_ 0ᴹ _*ᵣ_
163
164 open IsRightSemimodule isRightSemimodule public
165
166 +ᴹ-commutativeMonoid : CommutativeMonoid m ℓm
167 +ᴹ-commutativeMonoid = record
168 { isCommutativeMonoid = +ᴹ-isCommutativeMonoid
169 }
170
171 open CommutativeMonoid +ᴹ-commutativeMonoid public
172 using () renaming
173 ( monoid to +ᴹ-monoid
174 ; semigroup to +ᴹ-semigroup
175 ; magma to +ᴹ-magma
176 ; rawMagma to +ᴹ-rawMagma
177 ; rawMonoid to +ᴹ-rawMonoid
178 ; _≉_ to _≉ᴹ_
179 )
180
181 rawRightSemimodule : RawRightSemimodule Carrier m ℓm
182 rawRightSemimodule = record
183 { _≈ᴹ_ = _≈ᴹ_
184 ; _+ᴹ_ = _+ᴹ_
185 ; _*ᵣ_ = _*ᵣ_
186 ; 0ᴹ = 0ᴹ
187 }
188
189 record RightModule (ring : Ring r ℓr) m ℓm : Set (r ⊔ ℓr ⊔ suc (m ⊔ ℓm)) where
190 open Ring ring
191
192 infixr 8 -ᴹ_
193 infixl 7 _*ᵣ_
194 infixl 6 _+ᴹ_
195 infix 4 _≈ᴹ_
196
197 field
198 Carrierᴹ : Set m
199 _≈ᴹ_ : Rel Carrierᴹ ℓm
200 _+ᴹ_ : Op₂ Carrierᴹ
201 _*ᵣ_ : Opᵣ Carrier Carrierᴹ
202 0ᴹ : Carrierᴹ
203 -ᴹ_ : Op₁ Carrierᴹ
204 isRightModule : IsRightModule ring _≈ᴹ_ _+ᴹ_ 0ᴹ -ᴹ_ _*ᵣ_
205
206 open IsRightModule isRightModule public
207
208 rightSemimodule : RightSemimodule semiring m ℓm
209 rightSemimodule = record { isRightSemimodule = isRightSemimodule }
210
211 open RightSemimodule rightSemimodule public
212 using ( +ᴹ-commutativeMonoid; +ᴹ-monoid; +ᴹ-semigroup; +ᴹ-magma
213 ; +ᴹ-rawMagma; +ᴹ-rawMonoid; rawRightSemimodule; _≉ᴹ_)
214
215 +ᴹ-abelianGroup : AbelianGroup m ℓm
216 +ᴹ-abelianGroup = record { isAbelianGroup = +ᴹ-isAbelianGroup }
217
218 open AbelianGroup +ᴹ-abelianGroup public
219 using () renaming (group to +ᴹ-group; rawGroup to +ᴹ-rawGroup)
220
221 rawRightModule : RawRightModule Carrier m ℓm
222 rawRightModule = record
223 { _≈ᴹ_ = _≈ᴹ_
224 ; _+ᴹ_ = _+ᴹ_
225 ; _*ᵣ_ = _*ᵣ_
226 ; 0ᴹ = 0ᴹ
227 ; -ᴹ_ = -ᴹ_
228 }
229
230 ------------------------------------------------------------------------
231 -- Bimodules
232 ------------------------------------------------------------------------
233
234 record Bisemimodule (R-semiring : Semiring r ℓr) (S-semiring : Semiring s ℓs)
235 m ℓm : Set (r ⊔ s ⊔ ℓr ⊔ ℓs ⊔ suc (m ⊔ ℓm)) where
236 private
237 module R = Semiring R-semiring
238 module S = Semiring S-semiring
239
240 infixr 7 _*ₗ_
241 infixl 7 _*ᵣ_
242 infixl 6 _+ᴹ_
243 infix 4 _≈ᴹ_
244
245 field
246 Carrierᴹ : Set m
247 _≈ᴹ_ : Rel Carrierᴹ ℓm
248 _+ᴹ_ : Op₂ Carrierᴹ
249 _*ₗ_ : Opₗ R.Carrier Carrierᴹ
250 _*ᵣ_ : Opᵣ S.Carrier Carrierᴹ
251 0ᴹ : Carrierᴹ
252 isBisemimodule : IsBisemimodule R-semiring S-semiring _≈ᴹ_ _+ᴹ_ 0ᴹ _*ₗ_ _*ᵣ_
253
254 open IsBisemimodule isBisemimodule public
255
256 leftSemimodule : LeftSemimodule R-semiring m ℓm
257 leftSemimodule = record { isLeftSemimodule = isLeftSemimodule }
258
259 rightSemimodule : RightSemimodule S-semiring m ℓm
260 rightSemimodule = record { isRightSemimodule = isRightSemimodule }
261
262 open LeftSemimodule leftSemimodule public
263 using ( +ᴹ-commutativeMonoid; +ᴹ-monoid; +ᴹ-semigroup; +ᴹ-magma; +ᴹ-rawMagma
264 ; +ᴹ-rawMonoid; rawLeftSemimodule; _≉ᴹ_)
265
266 open RightSemimodule rightSemimodule public
267 using ( rawRightSemimodule )
268
269 rawBisemimodule : RawBisemimodule R.Carrier S.Carrier m ℓm
270 rawBisemimodule = record
271 { _≈ᴹ_ = _≈ᴹ_
272 ; _+ᴹ_ = _+ᴹ_
273 ; _*ₗ_ = _*ₗ_
274 ; _*ᵣ_ = _*ᵣ_
275 ; 0ᴹ = 0ᴹ
276 }
277
278 record Bimodule (R-ring : Ring r ℓr) (S-ring : Ring s ℓs) m ℓm
279 : Set (r ⊔ s ⊔ ℓr ⊔ ℓs ⊔ suc (m ⊔ ℓm)) where
280 private
281 module R = Ring R-ring
282 module S = Ring S-ring
283
284 infix 8 -ᴹ_
285 infixr 7 _*ₗ_
286 infixl 7 _*ᵣ_
287 infixl 6 _+ᴹ_
288 infix 4 _≈ᴹ_
289
290 field
291 Carrierᴹ : Set m
292 _≈ᴹ_ : Rel Carrierᴹ ℓm
293 _+ᴹ_ : Op₂ Carrierᴹ
294 _*ₗ_ : Opₗ R.Carrier Carrierᴹ
295 _*ᵣ_ : Opᵣ S.Carrier Carrierᴹ
296 0ᴹ : Carrierᴹ
297 -ᴹ_ : Op₁ Carrierᴹ
298 isBimodule : IsBimodule R-ring S-ring _≈ᴹ_ _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ _*ᵣ_
299
300 open IsBimodule isBimodule public
301
302 leftModule : LeftModule R-ring m ℓm
303 leftModule = record { isLeftModule = isLeftModule }
304
305 rightModule : RightModule S-ring m ℓm
306 rightModule = record { isRightModule = isRightModule }
307
308 open LeftModule leftModule public
309 using ( +ᴹ-abelianGroup; +ᴹ-commutativeMonoid; +ᴹ-group; +ᴹ-monoid
310 ; +ᴹ-semigroup; +ᴹ-magma; +ᴹ-rawMagma; +ᴹ-rawMonoid; +ᴹ-rawGroup
311 ; rawLeftSemimodule; rawLeftModule; _≉ᴹ_)
312
313 open RightModule rightModule public
314 using ( rawRightSemimodule; rawRightModule )
315
316 bisemimodule : Bisemimodule R.semiring S.semiring m ℓm
317 bisemimodule = record { isBisemimodule = isBisemimodule }
318
319 open Bisemimodule bisemimodule public
320 using (leftSemimodule; rightSemimodule; rawBisemimodule)
321
322 rawBimodule : RawBimodule R.Carrier S.Carrier m ℓm
323 rawBimodule = record
324 { _≈ᴹ_ = _≈ᴹ_
325 ; _+ᴹ_ = _+ᴹ_
326 ; _*ₗ_ = _*ₗ_
327 ; _*ᵣ_ = _*ᵣ_
328 ; 0ᴹ = 0ᴹ
329 ; -ᴹ_ = -ᴹ_
330 }
331
332 ------------------------------------------------------------------------
333 -- Modules over commutative structures
334 ------------------------------------------------------------------------
335
336 record Semimodule (commutativeSemiring : CommutativeSemiring r ℓr) m ℓm
337 : Set (r ⊔ ℓr ⊔ suc (m ⊔ ℓm)) where
338 open CommutativeSemiring commutativeSemiring
339
340 infixr 7 _*ₗ_
341 infixl 7 _*ᵣ_
342 infixl 6 _+ᴹ_
343 infix 4 _≈ᴹ_
344
345 field
346 Carrierᴹ : Set m
347 _≈ᴹ_ : Rel Carrierᴹ ℓm
348 _+ᴹ_ : Op₂ Carrierᴹ
349 _*ₗ_ : Opₗ Carrier Carrierᴹ
350 _*ᵣ_ : Opᵣ Carrier Carrierᴹ
351 0ᴹ : Carrierᴹ
352 isSemimodule : IsSemimodule commutativeSemiring _≈ᴹ_ _+ᴹ_ 0ᴹ _*ₗ_ _*ᵣ_
353
354 open IsSemimodule isSemimodule public
355
356 private
357 module L = LeftDefs Carrier _≈ᴹ_
358 module R = RightDefs Carrier _≈ᴹ_
359
360 bisemimodule : Bisemimodule semiring semiring m ℓm
361 bisemimodule = record { isBisemimodule = isBisemimodule }
362
363 open Bisemimodule bisemimodule public
364 using ( leftSemimodule; rightSemimodule
365 ; +ᴹ-commutativeMonoid; +ᴹ-monoid; +ᴹ-semigroup; +ᴹ-magma
366 ; +ᴹ-rawMagma; +ᴹ-rawMonoid; rawLeftSemimodule; rawRightSemimodule
367 ; rawBisemimodule; _≉ᴹ_
368 )
369
370 open ≈-Reasoning ≈ᴹ-setoid
371
372 *ₗ-comm : L.Commutative _*ₗ_
373 *ₗ-comm x y m = begin
374 x *ₗ y *ₗ m ≈⟨ ≈ᴹ-sym (*ₗ-assoc x y m) ⟩
375 (x * y) *ₗ m ≈⟨ *ₗ-cong (*-comm _ _) ≈ᴹ-refl ⟩
376 (y * x) *ₗ m ≈⟨ *ₗ-assoc y x m ⟩
377 y *ₗ x *ₗ m ∎
378
379 *ᵣ-comm : R.Commutative _*ᵣ_
380 *ᵣ-comm m x y = begin
381 m *ᵣ x *ᵣ y ≈⟨ *ᵣ-assoc m x y ⟩
382 m *ᵣ (x * y) ≈⟨ *ᵣ-cong ≈ᴹ-refl (*-comm _ _) ⟩
383 m *ᵣ (y * x) ≈⟨ ≈ᴹ-sym (*ᵣ-assoc m y x) ⟩
384 m *ᵣ y *ᵣ x ∎
385
386 rawSemimodule : RawSemimodule Carrier m ℓm
387 rawSemimodule = rawBisemimodule
388
389 record Module (commutativeRing : CommutativeRing r ℓr) m ℓm
390 : Set (r ⊔ ℓr ⊔ suc (m ⊔ ℓm)) where
391 open CommutativeRing commutativeRing
392
393 infixr 8 -ᴹ_
394 infixr 7 _*ₗ_
395 infixl 7 _*ᵣ_
396 infixl 6 _+ᴹ_
397 infix 4 _≈ᴹ_
398
399 field
400 Carrierᴹ : Set m
401 _≈ᴹ_ : Rel Carrierᴹ ℓm
402 _+ᴹ_ : Op₂ Carrierᴹ
403 _*ₗ_ : Opₗ Carrier Carrierᴹ
404 _*ᵣ_ : Opᵣ Carrier Carrierᴹ
405 0ᴹ : Carrierᴹ
406 -ᴹ_ : Op₁ Carrierᴹ
407 isModule : IsModule commutativeRing _≈ᴹ_ _+ᴹ_ 0ᴹ -ᴹ_ _*ₗ_ _*ᵣ_
408
409 open IsModule isModule public
410
411 bimodule : Bimodule ring ring m ℓm
412 bimodule = record { isBimodule = isBimodule }
413
414 open Bimodule bimodule public
415 using ( leftModule; rightModule; leftSemimodule; rightSemimodule
416 ; +ᴹ-abelianGroup; +ᴹ-group; +ᴹ-commutativeMonoid; +ᴹ-monoid
417 ; +ᴹ-semigroup; +ᴹ-magma ; +ᴹ-rawMonoid; +ᴹ-rawMagma
418 ; +ᴹ-rawGroup; rawLeftSemimodule; rawLeftModule; rawRightSemimodule
419 ; rawRightModule; rawBisemimodule; rawBimodule; _≉ᴹ_)
420
421 semimodule : Semimodule commutativeSemiring m ℓm
422 semimodule = record { isSemimodule = isSemimodule }
423
424 open Semimodule semimodule public using (*ₗ-comm; *ᵣ-comm; rawSemimodule)
425
426 rawModule : RawModule Carrier m ℓm
427 rawModule = rawBimodule