Debian Codegraph @

src/Algebra/Construct/DirectProduct.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Instances of algebraic structures made by taking two other instances
5 -- A and B, and having elements of the new instance be pairs |A| × |B|.
6 -- In mathematics, this would usually be written A × B or A ⊕ B.
7 --
8 -- From semigroups up, these new instances are products of the relevant
9 -- category. For structures with commutative addition (commutative
10 -- monoids, Abelian groups, semirings, rings), the direct product is
11 -- also the coproduct, making it a biproduct.
12 ------------------------------------------------------------------------
13
14 {-# OPTIONS --cubical-compatible --safe #-}
15
16 module Algebra.Construct.DirectProduct where
17
18 open import Algebra
19 open import Data.Product.Base using (_×_; zip; _,_; map; _<*>_; uncurry)
20 open import Data.Product.Relation.Binary.Pointwise.NonDependent
21 open import Level using (Level; _⊔_)
22
23 private
24 variable
25 a b ℓ₁ ℓ₂ : Level
26
27 ------------------------------------------------------------------------
28 -- Raw bundles
29
30 rawMagma : RawMagma a ℓ₁ → RawMagma b ℓ₂ → RawMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
31 rawMagma M N = record
32 { Carrier = M.Carrier × N.Carrier
33 ; _≈_ = Pointwise M._≈_ N._≈_
34 ; _∙_ = zip M._∙_ N._∙_
35 } where module M = RawMagma M; module N = RawMagma N
36
37 rawMonoid : RawMonoid a ℓ₁ → RawMonoid b ℓ₂ → RawMonoid (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
38 rawMonoid M N = record
39 { Carrier = M.Carrier × N.Carrier
40 ; _≈_ = Pointwise M._≈_ N._≈_
41 ; _∙_ = zip M._∙_ N._∙_
42 ; ε = M.ε , N.ε
43 } where module M = RawMonoid M; module N = RawMonoid N
44
45 rawGroup : RawGroup a ℓ₁ → RawGroup b ℓ₂ → RawGroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
46 rawGroup G H = record
47 { Carrier = G.Carrier × H.Carrier
48 ; _≈_ = Pointwise G._≈_ H._≈_
49 ; _∙_ = zip G._∙_ H._∙_
50 ; ε = G.ε , H.ε
51 ; _⁻¹ = map G._⁻¹ H._⁻¹
52 } where module G = RawGroup G; module H = RawGroup H
53
54 rawSemiring : RawSemiring a ℓ₁ → RawSemiring b ℓ₂ → RawSemiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
55 rawSemiring R S = record
56 { Carrier = R.Carrier × S.Carrier
57 ; _≈_ = Pointwise R._≈_ S._≈_
58 ; _+_ = zip R._+_ S._+_
59 ; _*_ = zip R._*_ S._*_
60 ; 0# = R.0# , S.0#
61 ; 1# = R.1# , S.1#
62 } where module R = RawSemiring R; module S = RawSemiring S
63
64 rawRingWithoutOne : RawRingWithoutOne a ℓ₁ → RawRingWithoutOne b ℓ₂ → RawRingWithoutOne (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
65 rawRingWithoutOne R S = record
66 { Carrier = R.Carrier × S.Carrier
67 ; _≈_ = Pointwise R._≈_ S._≈_
68 ; _+_ = zip R._+_ S._+_
69 ; _*_ = zip R._*_ S._*_
70 ; -_ = map R.-_ S.-_
71 ; 0# = R.0# , S.0#
72 } where module R = RawRingWithoutOne R; module S = RawRingWithoutOne S
73
74 rawRing : RawRing a ℓ₁ → RawRing b ℓ₂ → RawRing (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
75 rawRing R S = record
76 { Carrier = R.Carrier × S.Carrier
77 ; _≈_ = Pointwise R._≈_ S._≈_
78 ; _+_ = zip R._+_ S._+_
79 ; _*_ = zip R._*_ S._*_
80 ; -_ = map R.-_ S.-_
81 ; 0# = R.0# , S.0#
82 ; 1# = R.1# , S.1#
83 } where module R = RawRing R; module S = RawRing S
84
85 rawQuasigroup : RawQuasigroup a ℓ₁ → RawQuasigroup b ℓ₂ → RawQuasigroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
86 rawQuasigroup M N = record
87 { Carrier = M.Carrier × N.Carrier
88 ; _≈_ = Pointwise M._≈_ N._≈_
89 ; _∙_ = zip M._∙_ N._∙_
90 ; _\\_ = zip M._\\_ N._\\_
91 ; _//_ = zip M._//_ N._//_
92 } where module M = RawQuasigroup M; module N = RawQuasigroup N
93
94 rawLoop : RawLoop a ℓ₁ → RawLoop b ℓ₂ → RawLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
95 rawLoop M N = record
96 { Carrier = M.Carrier × N.Carrier
97 ; _≈_ = Pointwise M._≈_ N._≈_
98 ; _∙_ = zip M._∙_ N._∙_
99 ; _\\_ = zip M._\\_ N._\\_
100 ; _//_ = zip M._//_ N._//_
101 ; ε = M.ε , N.ε
102 } where module M = RawLoop M; module N = RawLoop N
103
104 ------------------------------------------------------------------------
105 -- Bundles
106
107 magma : Magma a ℓ₁ → Magma b ℓ₂ → Magma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
108 magma M N = record
109 { Carrier = M.Carrier × N.Carrier
110 ; _≈_ = Pointwise M._≈_ N._≈_
111 ; _∙_ = zip M._∙_ N._∙_
112 ; isMagma = record
113 { isEquivalence = ×-isEquivalence M.isEquivalence N.isEquivalence
114 ; ∙-cong = zip M.∙-cong N.∙-cong
115 }
116 } where module M = Magma M; module N = Magma N
117
118 idempotentMagma : IdempotentMagma a ℓ₁ → IdempotentMagma b ℓ₂ → IdempotentMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
119 idempotentMagma G H = record
120 { isIdempotentMagma = record
121 { isMagma = Magma.isMagma (magma G.magma H.magma)
122 ; idem = λ x → (G.idem , H.idem) <*> x
123 }
124 } where module G = IdempotentMagma G; module H = IdempotentMagma H
125
126 alternativeMagma : AlternativeMagma a ℓ₁ → AlternativeMagma b ℓ₂ → AlternativeMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
127 alternativeMagma G H = record
128 { isAlternativeMagma = record
129 { isMagma = Magma.isMagma (magma G.magma H.magma)
130 ; alter = (λ x y → G.alternativeˡ , H.alternativeˡ <*> x <*> y)
131 , (λ x y → G.alternativeʳ , H.alternativeʳ <*> x <*> y)
132 }
133 } where module G = AlternativeMagma G; module H = AlternativeMagma H
134
135 flexibleMagma : FlexibleMagma a ℓ₁ → FlexibleMagma b ℓ₂ → FlexibleMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
136 flexibleMagma G H = record
137 { isFlexibleMagma = record
138 { isMagma = Magma.isMagma (magma G.magma H.magma)
139 ; flex = λ x y → (G.flex , H.flex) <*> x <*> y
140 }
141 } where module G = FlexibleMagma G; module H = FlexibleMagma H
142
143 medialMagma : MedialMagma a ℓ₁ → MedialMagma b ℓ₂ → MedialMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
144 medialMagma G H = record
145 { isMedialMagma = record
146 { isMagma = Magma.isMagma (magma G.magma H.magma)
147 ; medial = λ x y u z → (G.medial , H.medial) <*> x <*> y <*> u <*> z
148 }
149 } where module G = MedialMagma G; module H = MedialMagma H
150
151 semimedialMagma : SemimedialMagma a ℓ₁ → SemimedialMagma b ℓ₂ → SemimedialMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
152 semimedialMagma G H = record
153 { isSemimedialMagma = record
154 { isMagma = Magma.isMagma (magma G.magma H.magma)
155 ; semiMedial = (λ x y z → G.semimedialˡ , H.semimedialˡ <*> x <*> y <*> z)
156 , ((λ x y z → G.semimedialʳ , H.semimedialʳ <*> x <*> y <*> z))
157 }
158 } where module G = SemimedialMagma G; module H = SemimedialMagma H
159
160 semigroup : Semigroup a ℓ₁ → Semigroup b ℓ₂ → Semigroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
161 semigroup G H = record
162 { isSemigroup = record
163 { isMagma = Magma.isMagma (magma G.magma H.magma)
164 ; assoc = λ x y z → (G.assoc , H.assoc) <*> x <*> y <*> z
165 }
166 } where module G = Semigroup G; module H = Semigroup H
167
168 band : Band a ℓ₁ → Band b ℓ₂ → Band (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
169 band B C = record
170 { isBand = record
171 { isSemigroup = Semigroup.isSemigroup (semigroup B.semigroup C.semigroup)
172 ; idem = λ x → (B.idem , C.idem) <*> x
173 }
174 } where module B = Band B; module C = Band C
175
176 commutativeSemigroup : CommutativeSemigroup a ℓ₁ → CommutativeSemigroup b ℓ₂ →
177 CommutativeSemigroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
178 commutativeSemigroup G H = record
179 { isCommutativeSemigroup = record
180 { isSemigroup = Semigroup.isSemigroup (semigroup G.semigroup H.semigroup)
181 ; comm = λ x y → (G.comm , H.comm) <*> x <*> y
182 }
183 } where module G = CommutativeSemigroup G; module H = CommutativeSemigroup H
184
185 unitalMagma : UnitalMagma a ℓ₁ → UnitalMagma b ℓ₂ → UnitalMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
186 unitalMagma M N = record
187 { ε = M.ε , N.ε
188 ; isUnitalMagma = record
189 { isMagma = Magma.isMagma (magma M.magma N.magma)
190 ; identity = (M.identityˡ , N.identityˡ <*>_)
191 , (M.identityʳ , N.identityʳ <*>_)
192 }
193 } where module M = UnitalMagma M; module N = UnitalMagma N
194
195 monoid : Monoid a ℓ₁ → Monoid b ℓ₂ → Monoid (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
196 monoid M N = record
197 { ε = M.ε , N.ε
198 ; isMonoid = record
199 { isSemigroup = Semigroup.isSemigroup (semigroup M.semigroup N.semigroup)
200 ; identity = (M.identityˡ , N.identityˡ <*>_)
201 , (M.identityʳ , N.identityʳ <*>_)
202 }
203 } where module M = Monoid M; module N = Monoid N
204
205 commutativeMonoid : CommutativeMonoid a ℓ₁ → CommutativeMonoid b ℓ₂ →
206 CommutativeMonoid (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
207 commutativeMonoid M N = record
208 { isCommutativeMonoid = record
209 { isMonoid = Monoid.isMonoid (monoid M.monoid N.monoid)
210 ; comm = λ x y → (M.comm , N.comm) <*> x <*> y
211 }
212 } where module M = CommutativeMonoid M; module N = CommutativeMonoid N
213
214 idempotentCommutativeMonoid :
215 IdempotentCommutativeMonoid a ℓ₁ → IdempotentCommutativeMonoid b ℓ₂ →
216 IdempotentCommutativeMonoid (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
217 idempotentCommutativeMonoid M N = record
218 { isIdempotentCommutativeMonoid = record
219 { isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid
220 (commutativeMonoid M.commutativeMonoid N.commutativeMonoid)
221 ; idem = λ x → (M.idem , N.idem) <*> x
222 }
223 }
224 where
225 module M = IdempotentCommutativeMonoid M
226 module N = IdempotentCommutativeMonoid N
227
228 invertibleMagma : InvertibleMagma a ℓ₁ → InvertibleMagma b ℓ₂ → InvertibleMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
229 invertibleMagma M N = record
230 { _⁻¹ = map M._⁻¹ N._⁻¹
231 ; isInvertibleMagma = record
232 { isMagma = Magma.isMagma (magma M.magma N.magma)
233 ; inverse = (λ x → (M.inverseˡ , N.inverseˡ) <*> x)
234 , (λ x → (M.inverseʳ , N.inverseʳ) <*> x)
235 ; ⁻¹-cong = map M.⁻¹-cong N.⁻¹-cong
236 }
237 } where module M = InvertibleMagma M; module N = InvertibleMagma N
238
239 invertibleUnitalMagma : InvertibleUnitalMagma a ℓ₁ → InvertibleUnitalMagma b ℓ₂ → InvertibleUnitalMagma (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
240 invertibleUnitalMagma M N = record
241 { ε = M.ε , N.ε
242 ; isInvertibleUnitalMagma = record
243 { isInvertibleMagma = InvertibleMagma.isInvertibleMagma (invertibleMagma M.invertibleMagma N.invertibleMagma)
244 ; identity = (M.identityˡ , N.identityˡ <*>_)
245 , (M.identityʳ , N.identityʳ <*>_)
246 }
247 } where module M = InvertibleUnitalMagma M; module N = InvertibleUnitalMagma N
248
249 group : Group a ℓ₁ → Group b ℓ₂ → Group (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
250 group G H = record
251 { _⁻¹ = map G._⁻¹ H._⁻¹
252 ; isGroup = record
253 { isMonoid = Monoid.isMonoid (monoid G.monoid H.monoid)
254 ; inverse = (λ x → (G.inverseˡ , H.inverseˡ) <*> x)
255 , (λ x → (G.inverseʳ , H.inverseʳ) <*> x)
256 ; ⁻¹-cong = map G.⁻¹-cong H.⁻¹-cong
257 }
258 } where module G = Group G; module H = Group H
259
260 abelianGroup : AbelianGroup a ℓ₁ → AbelianGroup b ℓ₂ →
261 AbelianGroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
262 abelianGroup G H = record
263 { isAbelianGroup = record
264 { isGroup = Group.isGroup (group G.group H.group)
265 ; comm = λ x y → (G.comm , H.comm) <*> x <*> y
266 }
267 } where module G = AbelianGroup G; module H = AbelianGroup H
268
269 semiringWithoutAnnihilatingZero : SemiringWithoutAnnihilatingZero a ℓ₁ →
270 SemiringWithoutAnnihilatingZero b ℓ₂ →
271 SemiringWithoutAnnihilatingZero (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
272 semiringWithoutAnnihilatingZero R S = record
273 { isSemiringWithoutAnnihilatingZero = record
274 { +-isCommutativeMonoid = CommutativeMonoid.isCommutativeMonoid
275 (commutativeMonoid R.+-commutativeMonoid
276 S.+-commutativeMonoid)
277 ; *-cong = zip R.*-cong S.*-cong
278 ; *-assoc = λ x y z → (R.*-assoc , S.*-assoc) <*> x <*> y <*> z
279 ; *-identity = (R.*-identityˡ , S.*-identityˡ <*>_)
280 , (R.*-identityʳ , S.*-identityʳ <*>_)
281 ; distrib = (λ x y z → (R.distribˡ , S.distribˡ) <*> x <*> y <*> z)
282 , (λ x y z → (R.distribʳ , S.distribʳ) <*> x <*> y <*> z)
283 }
284 } where module R = SemiringWithoutAnnihilatingZero R
285 module S = SemiringWithoutAnnihilatingZero S
286
287 semiring : Semiring a ℓ₁ → Semiring b ℓ₂ → Semiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
288 semiring R S = record
289 { isSemiring = record
290 { isSemiringWithoutAnnihilatingZero =
291 SemiringWithoutAnnihilatingZero.isSemiringWithoutAnnihilatingZero U
292 ; zero = uncurry (λ x y → R.zeroˡ x , S.zeroˡ y)
293 , uncurry (λ x y → R.zeroʳ x , S.zeroʳ y)
294 }
295 }
296 where
297 module R = Semiring R
298 module S = Semiring S
299 U = semiringWithoutAnnihilatingZero R.semiringWithoutAnnihilatingZero
300 S.semiringWithoutAnnihilatingZero
301
302 commutativeSemiring : CommutativeSemiring a ℓ₁ → CommutativeSemiring b ℓ₂ →
303 CommutativeSemiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
304 commutativeSemiring R S = record
305 { isCommutativeSemiring = record
306 { isSemiring = Semiring.isSemiring (semiring R.semiring S.semiring)
307 ; *-comm = λ x y → (R.*-comm , S.*-comm) <*> x <*> y
308 }
309 } where module R = CommutativeSemiring R; module S = CommutativeSemiring S
310
311 idempotentSemiring : IdempotentSemiring a ℓ₁ → IdempotentSemiring b ℓ₂ → IdempotentSemiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
312 idempotentSemiring K L = record
313 { isIdempotentSemiring = record
314 { isSemiring = Semiring.isSemiring (semiring K.semiring L.semiring)
315 ; +-idem = λ x → (K.+-idem , L.+-idem) <*> x
316 }
317 } where module K = IdempotentSemiring K; module L = IdempotentSemiring L
318
319 kleeneAlgebra : KleeneAlgebra a ℓ₁ → KleeneAlgebra b ℓ₂ → KleeneAlgebra (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
320 kleeneAlgebra K L = record
321 { isKleeneAlgebra = record
322 { isIdempotentSemiring = IdempotentSemiring.isIdempotentSemiring (idempotentSemiring K.idempotentSemiring L.idempotentSemiring)
323 ; starExpansive = (λ x → (K.starExpansiveˡ , L.starExpansiveˡ) <*> x)
324 , (λ x → (K.starExpansiveʳ , L.starExpansiveʳ) <*> x)
325 ; starDestructive = (λ a b x x₁ → (K.starDestructiveˡ , L.starDestructiveˡ) <*> a <*> b <*> x <*> x₁)
326 , (λ a b x x₁ → (K.starDestructiveʳ , L.starDestructiveʳ) <*> a <*> b <*> x <*> x₁)
327 }
328 } where module K = KleeneAlgebra K; module L = KleeneAlgebra L
329
330 ringWithoutOne : RingWithoutOne a ℓ₁ → RingWithoutOne b ℓ₂ → RingWithoutOne (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
331 ringWithoutOne R S = record
332 { isRingWithoutOne = record
333 { +-isAbelianGroup = AbelianGroup.isAbelianGroup ((abelianGroup R.+-abelianGroup S.+-abelianGroup))
334 ; *-cong = Semigroup.∙-cong (semigroup R.*-semigroup S.*-semigroup)
335 ; *-assoc = Semigroup.assoc (semigroup R.*-semigroup S.*-semigroup)
336 ; distrib = (λ x y z → (R.distribˡ , S.distribˡ) <*> x <*> y <*> z)
337 , (λ x y z → (R.distribʳ , S.distribʳ) <*> x <*> y <*> z)
338 }
339
340 } where module R = RingWithoutOne R; module S = RingWithoutOne S
341
342 nonAssociativeRing : NonAssociativeRing a ℓ₁ → NonAssociativeRing b ℓ₂ → NonAssociativeRing (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
343 nonAssociativeRing R S = record
344 { isNonAssociativeRing = record
345 { +-isAbelianGroup = AbelianGroup.isAbelianGroup ((abelianGroup R.+-abelianGroup S.+-abelianGroup))
346 ; *-cong = UnitalMagma.∙-cong (unitalMagma R.*-unitalMagma S.*-unitalMagma)
347 ; *-identity = UnitalMagma.identity (unitalMagma R.*-unitalMagma S.*-unitalMagma)
348 ; distrib = (λ x y z → (R.distribˡ , S.distribˡ) <*> x <*> y <*> z)
349 , (λ x y z → (R.distribʳ , S.distribʳ) <*> x <*> y <*> z)
350 ; zero = uncurry (λ x y → R.zeroˡ x , S.zeroˡ y)
351 , uncurry (λ x y → R.zeroʳ x , S.zeroʳ y)
352 }
353
354 } where module R = NonAssociativeRing R; module S = NonAssociativeRing S
355
356 quasiring : Quasiring a ℓ₁ → Quasiring b ℓ₂ → Quasiring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
357 quasiring R S = record
358 { isQuasiring = record
359 { +-isMonoid = Monoid.isMonoid ((monoid R.+-monoid S.+-monoid))
360 ; *-cong = Monoid.∙-cong (monoid R.*-monoid S.*-monoid)
361 ; *-assoc = Monoid.assoc (monoid R.*-monoid S.*-monoid)
362 ; *-identity = Monoid.identity ((monoid R.*-monoid S.*-monoid))
363 ; distrib = (λ x y z → (R.distribˡ , S.distribˡ) <*> x <*> y <*> z)
364 , (λ x y z → (R.distribʳ , S.distribʳ) <*> x <*> y <*> z)
365 ; zero = uncurry (λ x y → R.zeroˡ x , S.zeroˡ y)
366 , uncurry (λ x y → R.zeroʳ x , S.zeroʳ y)
367 }
368
369 } where module R = Quasiring R; module S = Quasiring S
370
371 nearring : Nearring a ℓ₁ → Nearring b ℓ₂ → Nearring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
372 nearring R S = record
373 { isNearring = record
374 { isQuasiring = Quasiring.isQuasiring (quasiring R.quasiring S.quasiring)
375 ; +-inverse = (λ x → (R.+-inverseˡ , S.+-inverseˡ) <*> x)
376 , (λ x → (R.+-inverseʳ , S.+-inverseʳ) <*> x)
377 ; ⁻¹-cong = map R.⁻¹-cong S.⁻¹-cong
378 }
379 } where module R = Nearring R; module S = Nearring S
380
381 ring : Ring a ℓ₁ → Ring b ℓ₂ → Ring (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
382 ring R S = record
383 { -_ = uncurry (λ x y → R.-_ x , S.-_ y)
384 ; isRing = record
385 { +-isAbelianGroup = AbelianGroup.isAbelianGroup A
386 ; *-cong = Semiring.*-cong Semi
387 ; *-assoc = Semiring.*-assoc Semi
388 ; *-identity = Semiring.*-identity Semi
389 ; distrib = Semiring.distrib Semi
390 }
391 }
392 where
393 module R = Ring R
394 module S = Ring S
395 Semi = semiring R.semiring S.semiring
396 A = abelianGroup R.+-abelianGroup S.+-abelianGroup
397
398 commutativeRing : CommutativeRing a ℓ₁ → CommutativeRing b ℓ₂ →
399 CommutativeRing (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
400 commutativeRing R S = record
401 { isCommutativeRing = record
402 { isRing = Ring.isRing (ring R.ring S.ring)
403 ; *-comm = λ x y → (R.*-comm , S.*-comm) <*> x <*> y
404 }
405 } where module R = CommutativeRing R; module S = CommutativeRing S
406
407 quasigroup : Quasigroup a ℓ₁ → Quasigroup b ℓ₂ → Quasigroup (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
408 quasigroup M N = record
409 { _\\_ = zip M._\\_ N._\\_
410 ; _//_ = zip M._//_ N._//_
411 ; isQuasigroup = record
412 { isMagma = Magma.isMagma (magma M.magma N.magma)
413 ; \\-cong = zip M.\\-cong N.\\-cong
414 ; //-cong = zip M.//-cong N.//-cong
415 ; leftDivides = (λ x y → M.leftDividesˡ , N.leftDividesˡ <*> x <*> y) , (λ x y → M.leftDividesʳ , N.leftDividesʳ <*> x <*> y)
416 ; rightDivides = (λ x y → M.rightDividesˡ , N.rightDividesˡ <*> x <*> y) , (λ x y → M.rightDividesʳ , N.rightDividesʳ <*> x <*> y)
417 }
418 } where module M = Quasigroup M; module N = Quasigroup N
419
420 loop : Loop a ℓ₁ → Loop b ℓ₂ → Loop (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
421 loop M N = record
422 { ε = M.ε , N.ε
423 ; isLoop = record
424 { isQuasigroup = Quasigroup.isQuasigroup (quasigroup M.quasigroup N.quasigroup)
425 ; identity = (M.identityˡ , N.identityˡ <*>_)
426 , (M.identityʳ , N.identityʳ <*>_)
427 }
428 } where module M = Loop M; module N = Loop N
429
430 leftBolLoop : LeftBolLoop a ℓ₁ → LeftBolLoop b ℓ₂ → LeftBolLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
431 leftBolLoop M N = record
432 { isLeftBolLoop = record
433 { isLoop = Loop.isLoop (loop M.loop N.loop)
434 ; leftBol = λ x y z → M.leftBol , N.leftBol <*> x <*> y <*> z
435 }
436 } where module M = LeftBolLoop M; module N = LeftBolLoop N
437
438 rightBolLoop : RightBolLoop a ℓ₁ → RightBolLoop b ℓ₂ → RightBolLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
439 rightBolLoop M N = record
440 { isRightBolLoop = record
441 { isLoop = Loop.isLoop (loop M.loop N.loop)
442 ; rightBol = λ x y z → M.rightBol , N.rightBol <*> x <*> y <*> z
443 }
444 } where module M = RightBolLoop M; module N = RightBolLoop N
445
446 middleBolLoop : MiddleBolLoop a ℓ₁ → MiddleBolLoop b ℓ₂ → MiddleBolLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
447 middleBolLoop M N = record
448 { isMiddleBolLoop = record
449 { isLoop = Loop.isLoop (loop M.loop N.loop)
450 ; middleBol = λ x y z → M.middleBol , N.middleBol <*> x <*> y <*> z
451 }
452 } where module M = MiddleBolLoop M; module N = MiddleBolLoop N
453
454 moufangLoop : MoufangLoop a ℓ₁ → MoufangLoop b ℓ₂ → MoufangLoop (a ⊔ b) (ℓ₁ ⊔ ℓ₂)
455 moufangLoop M N = record
456 { isMoufangLoop = record
457 { isLeftBolLoop = LeftBolLoop.isLeftBolLoop (leftBolLoop M.leftBolLoop N.leftBolLoop)
458 ; rightBol = λ x y z → M.rightBol , N.rightBol <*> x <*> y <*> z
459 ; identical = λ x y z → M.identical , N.identical <*> x <*> y <*> z
460 }
461 } where module M = MoufangLoop M; module N = MoufangLoop N