Debian Codegraph @

src/Algebra/Structures.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Some algebraic structures (not packed up with sets, operations, etc.)
5 ------------------------------------------------------------------------
6
7 -- The contents of this module should be accessed via `Algebra`, unless
8 -- you want to parameterise it via the equality relation.
9
10 {-# OPTIONS --cubical-compatible --safe #-}
11
12 open import Relation.Binary.Core using (Rel)
13 open import Relation.Binary.Bundles using (Setoid)
14 open import Relation.Binary.Structures using (IsEquivalence)
15
16 module Algebra.Structures
17 {a ℓ} {A : Set a} -- The underlying set
18 (_≈_ : Rel A ℓ) -- The underlying equality relation
19 where
20
21 -- The file is divided into sections depending on the arities of the
22 -- components of the algebraic structure.
23
24 open import Algebra.Core using (Op₁; Op₂)
25 open import Algebra.Definitions _≈_
26 import Algebra.Consequences.Setoid as Consequences
27 open import Data.Product.Base using (_,_; proj₁; proj₂)
28 open import Level using (_⊔_)
29
30 ------------------------------------------------------------------------
31 -- Structures with 1 unary operation & 1 element
32 ------------------------------------------------------------------------
33
34 record IsSuccessorSet (suc# : Op₁ A) (zero# : A) : Set (a ⊔ ℓ) where
35 field
36 isEquivalence : IsEquivalence _≈_
37 suc#-cong : Congruent₁ suc#
38
39 open IsEquivalence isEquivalence public
40
41 setoid : Setoid a ℓ
42 setoid = record { isEquivalence = isEquivalence }
43
44 ------------------------------------------------------------------------
45 -- Structures with 1 binary operation
46 ------------------------------------------------------------------------
47
48 record IsMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
49 field
50 isEquivalence : IsEquivalence _≈_
51 ∙-cong : Congruent₂ ∙
52
53 open IsEquivalence isEquivalence public
54
55 setoid : Setoid a ℓ
56 setoid = record { isEquivalence = isEquivalence }
57
58 open Consequences.Congruence setoid ∙-cong public
59
60 record IsCommutativeMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
61 field
62 isMagma : IsMagma ∙
63 comm : Commutative ∙
64
65 open IsMagma isMagma public
66
67 record IsIdempotentMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
68 field
69 isMagma : IsMagma ∙
70 idem : Idempotent ∙
71
72 open IsMagma isMagma public
73
74 record IsAlternativeMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
75 field
76 isMagma : IsMagma ∙
77 alter : Alternative ∙
78
79 open IsMagma isMagma public
80
81 alternativeˡ : LeftAlternative ∙
82 alternativeˡ = proj₁ alter
83
84 alternativeʳ : RightAlternative ∙
85 alternativeʳ = proj₂ alter
86
87 record IsFlexibleMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
88 field
89 isMagma : IsMagma ∙
90 flex : Flexible ∙
91
92 open IsMagma isMagma public
93
94 record IsMedialMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
95 field
96 isMagma : IsMagma ∙
97 medial : Medial ∙
98
99 open IsMagma isMagma public
100
101 record IsSemimedialMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
102 field
103 isMagma : IsMagma ∙
104 semiMedial : Semimedial ∙
105
106 open IsMagma isMagma public
107
108 semimedialˡ : LeftSemimedial ∙
109 semimedialˡ = proj₁ semiMedial
110
111 semimedialʳ : RightSemimedial ∙
112 semimedialʳ = proj₂ semiMedial
113
114 record IsSelectiveMagma (∙ : Op₂ A) : Set (a ⊔ ℓ) where
115 field
116 isMagma : IsMagma ∙
117 sel : Selective ∙
118
119 open IsMagma isMagma public
120
121
122 record IsSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where
123 field
124 isMagma : IsMagma ∙
125 assoc : Associative ∙
126
127 open IsMagma isMagma public
128
129
130 record IsBand (∙ : Op₂ A) : Set (a ⊔ ℓ) where
131 field
132 isSemigroup : IsSemigroup ∙
133 idem : Idempotent ∙
134
135 open IsSemigroup isSemigroup public
136
137
138 record IsCommutativeSemigroup (∙ : Op₂ A) : Set (a ⊔ ℓ) where
139 field
140 isSemigroup : IsSemigroup ∙
141 comm : Commutative ∙
142
143 open IsSemigroup isSemigroup public
144
145 isCommutativeMagma : IsCommutativeMagma ∙
146 isCommutativeMagma = record
147 { isMagma = isMagma
148 ; comm = comm
149 }
150
151
152 record IsCommutativeBand (∙ : Op₂ A) : Set (a ⊔ ℓ) where
153 field
154 isBand : IsBand ∙
155 comm : Commutative ∙
156
157 open IsBand isBand public
158
159 isCommutativeSemigroup : IsCommutativeSemigroup ∙
160 isCommutativeSemigroup = record { isSemigroup = isSemigroup ; comm = comm }
161
162 open IsCommutativeSemigroup isCommutativeSemigroup public
163 using (isCommutativeMagma)
164
165 ------------------------------------------------------------------------
166 -- Structures with 1 binary operation & 1 element
167 ------------------------------------------------------------------------
168
169 record IsUnitalMagma (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
170 field
171 isMagma : IsMagma ∙
172 identity : Identity ε ∙
173
174 open IsMagma isMagma public
175
176 identityˡ : LeftIdentity ε ∙
177 identityˡ = proj₁ identity
178
179 identityʳ : RightIdentity ε ∙
180 identityʳ = proj₂ identity
181
182
183 record IsMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
184 field
185 isSemigroup : IsSemigroup ∙
186 identity : Identity ε ∙
187
188 open IsSemigroup isSemigroup public
189
190 identityˡ : LeftIdentity ε ∙
191 identityˡ = proj₁ identity
192
193 identityʳ : RightIdentity ε ∙
194 identityʳ = proj₂ identity
195
196 isUnitalMagma : IsUnitalMagma ∙ ε
197 isUnitalMagma = record
198 { isMagma = isMagma
199 ; identity = identity
200 }
201
202
203 record IsCommutativeMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
204 field
205 isMonoid : IsMonoid ∙ ε
206 comm : Commutative ∙
207
208 open IsMonoid isMonoid public
209
210 isCommutativeSemigroup : IsCommutativeSemigroup ∙
211 isCommutativeSemigroup = record
212 { isSemigroup = isSemigroup
213 ; comm = comm
214 }
215
216 open IsCommutativeSemigroup isCommutativeSemigroup public
217 using (isCommutativeMagma)
218
219
220 record IsIdempotentMonoid (∙ : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
221 field
222 isMonoid : IsMonoid ∙ ε
223 idem : Idempotent ∙
224
225 open IsMonoid isMonoid public
226
227 isBand : IsBand ∙
228 isBand = record { isSemigroup = isSemigroup ; idem = idem }
229
230
231 record IsIdempotentCommutativeMonoid (∙ : Op₂ A)
232 (ε : A) : Set (a ⊔ ℓ) where
233 field
234 isCommutativeMonoid : IsCommutativeMonoid ∙ ε
235 idem : Idempotent ∙
236
237 open IsCommutativeMonoid isCommutativeMonoid public
238
239 isIdempotentMonoid : IsIdempotentMonoid ∙ ε
240 isIdempotentMonoid = record { isMonoid = isMonoid ; idem = idem }
241
242 open IsIdempotentMonoid isIdempotentMonoid public
243 using (isBand)
244
245 isCommutativeBand : IsCommutativeBand ∙
246 isCommutativeBand = record { isBand = isBand ; comm = comm }
247
248 ------------------------------------------------------------------------
249 -- Structures with 1 binary operation, 1 unary operation & 1 element
250 ------------------------------------------------------------------------
251
252 record IsInvertibleMagma (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where
253 field
254 isMagma : IsMagma _∙_
255 inverse : Inverse ε _⁻¹ _∙_
256 ⁻¹-cong : Congruent₁ _⁻¹
257
258 open IsMagma isMagma public
259
260 inverseˡ : LeftInverse ε _⁻¹ _∙_
261 inverseˡ = proj₁ inverse
262
263 inverseʳ : RightInverse ε _⁻¹ _∙_
264 inverseʳ = proj₂ inverse
265
266
267 record IsInvertibleUnitalMagma (_∙_ : Op₂ A) (ε : A) (⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where
268 field
269 isInvertibleMagma : IsInvertibleMagma _∙_ ε ⁻¹
270 identity : Identity ε _∙_
271
272 open IsInvertibleMagma isInvertibleMagma public
273
274 identityˡ : LeftIdentity ε _∙_
275 identityˡ = proj₁ identity
276
277 identityʳ : RightIdentity ε _∙_
278 identityʳ = proj₂ identity
279
280 isUnitalMagma : IsUnitalMagma _∙_ ε
281 isUnitalMagma = record
282 { isMagma = isMagma
283 ; identity = identity
284 }
285
286
287 record IsGroup (_∙_ : Op₂ A) (ε : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where
288 field
289 isMonoid : IsMonoid _∙_ ε
290 inverse : Inverse ε _⁻¹ _∙_
291 ⁻¹-cong : Congruent₁ _⁻¹
292
293 open IsMonoid isMonoid public
294
295 infixr 6 _\\_
296 _\\_ : Op₂ A
297 x \\ y = (x ⁻¹) ∙ y
298
299 infixl 6 _//_
300 _//_ : Op₂ A
301 x // y = x ∙ (y ⁻¹)
302
303 -- Deprecated.
304 infixl 6 _-_
305 _-_ : Op₂ A
306 _-_ = _//_
307 {-# WARNING_ON_USAGE _-_
308 "Warning: _-_ was deprecated in v2.1.
309 Please use _//_ instead. "
310 #-}
311
312 inverseˡ : LeftInverse ε _⁻¹ _∙_
313 inverseˡ = proj₁ inverse
314
315 inverseʳ : RightInverse ε _⁻¹ _∙_
316 inverseʳ = proj₂ inverse
317
318 uniqueˡ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → x ≈ (y ⁻¹)
319 uniqueˡ-⁻¹ = Consequences.assoc∧id∧invʳ⇒invˡ-unique
320 setoid ∙-cong assoc identity inverseʳ
321 {-# WARNING_ON_USAGE uniqueˡ-⁻¹
322 "Warning: uniqueˡ-⁻¹ was deprecated in v2.3.
323 Please use Algebra.Properties.Group.inverseˡ-unique instead. "
324 #-}
325
326 uniqueʳ-⁻¹ : ∀ x y → (x ∙ y) ≈ ε → y ≈ (x ⁻¹)
327 uniqueʳ-⁻¹ = Consequences.assoc∧id∧invˡ⇒invʳ-unique
328 setoid ∙-cong assoc identity inverseˡ
329 {-# WARNING_ON_USAGE uniqueʳ-⁻¹
330 "Warning: uniqueʳ-⁻¹ was deprecated in v2.3.
331 Please use Algebra.Properties.Group.inverseʳ-unique instead. "
332 #-}
333
334 isInvertibleMagma : IsInvertibleMagma _∙_ ε _⁻¹
335 isInvertibleMagma = record
336 { isMagma = isMagma
337 ; inverse = inverse
338 ; ⁻¹-cong = ⁻¹-cong
339 }
340
341 isInvertibleUnitalMagma : IsInvertibleUnitalMagma _∙_ ε _⁻¹
342 isInvertibleUnitalMagma = record
343 { isInvertibleMagma = isInvertibleMagma
344 ; identity = identity
345 }
346
347
348 record IsAbelianGroup (∙ : Op₂ A)
349 (ε : A) (⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where
350 field
351 isGroup : IsGroup ∙ ε ⁻¹
352 comm : Commutative ∙
353
354 open IsGroup isGroup public renaming (_//_ to _-_) hiding (_\\_; _-_)
355
356 isCommutativeMonoid : IsCommutativeMonoid ∙ ε
357 isCommutativeMonoid = record
358 { isMonoid = isMonoid
359 ; comm = comm
360 }
361
362 open IsCommutativeMonoid isCommutativeMonoid public
363 using (isCommutativeMagma; isCommutativeSemigroup)
364
365
366 ------------------------------------------------------------------------
367 -- Structures with 2 binary operations & 1 element
368 ------------------------------------------------------------------------
369
370 record IsNearSemiring (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where
371 field
372 +-isMonoid : IsMonoid + 0#
373 *-cong : Congruent₂ *
374 *-assoc : Associative *
375 distribʳ : * DistributesOverʳ +
376 zeroˡ : LeftZero 0# *
377
378 open IsMonoid +-isMonoid public
379 renaming
380 ( assoc to +-assoc
381 ; ∙-cong to +-cong
382 ; ∙-congˡ to +-congˡ
383 ; ∙-congʳ to +-congʳ
384 ; identity to +-identity
385 ; identityˡ to +-identityˡ
386 ; identityʳ to +-identityʳ
387 ; isMagma to +-isMagma
388 ; isUnitalMagma to +-isUnitalMagma
389 ; isSemigroup to +-isSemigroup
390 )
391
392 *-isMagma : IsMagma *
393 *-isMagma = record
394 { isEquivalence = isEquivalence
395 ; ∙-cong = *-cong
396 }
397
398 *-isSemigroup : IsSemigroup *
399 *-isSemigroup = record
400 { isMagma = *-isMagma
401 ; assoc = *-assoc
402 }
403
404 open IsMagma *-isMagma public
405 using ()
406 renaming
407 ( ∙-congˡ to *-congˡ
408 ; ∙-congʳ to *-congʳ
409 )
410
411
412 record IsSemiringWithoutOne (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where
413 field
414 +-isCommutativeMonoid : IsCommutativeMonoid + 0#
415 *-cong : Congruent₂ *
416 *-assoc : Associative *
417 distrib : * DistributesOver +
418 zero : Zero 0# *
419
420 open IsCommutativeMonoid +-isCommutativeMonoid public
421 using (setoid; isEquivalence)
422 renaming
423 ( ∙-cong to +-cong
424 ; ∙-congˡ to +-congˡ
425 ; ∙-congʳ to +-congʳ
426 ; assoc to +-assoc
427 ; identity to +-identity
428 ; identityˡ to +-identityˡ
429 ; identityʳ to +-identityʳ
430 ; comm to +-comm
431 ; isMonoid to +-isMonoid
432 ; isCommutativeMagma to +-isCommutativeMagma
433 ; isCommutativeSemigroup to +-isCommutativeSemigroup
434 )
435
436 open IsEquivalence isEquivalence public
437
438 *-isMagma : IsMagma *
439 *-isMagma = record
440 { isEquivalence = isEquivalence
441 ; ∙-cong = *-cong
442 }
443
444 *-isSemigroup : IsSemigroup *
445 *-isSemigroup = record
446 { isMagma = *-isMagma
447 ; assoc = *-assoc
448 }
449
450 open IsMagma *-isMagma public
451 using ()
452 renaming
453 ( ∙-congˡ to *-congˡ
454 ; ∙-congʳ to *-congʳ
455 )
456
457 distribˡ : * DistributesOverˡ +
458 distribˡ = proj₁ distrib
459
460 distribʳ : * DistributesOverʳ +
461 distribʳ = proj₂ distrib
462
463 zeroˡ : LeftZero 0# *
464 zeroˡ = proj₁ zero
465
466 zeroʳ : RightZero 0# *
467 zeroʳ = proj₂ zero
468
469 isNearSemiring : IsNearSemiring + * 0#
470 isNearSemiring = record
471 { +-isMonoid = +-isMonoid
472 ; *-cong = *-cong
473 ; *-assoc = *-assoc
474 ; distribʳ = proj₂ distrib
475 ; zeroˡ = zeroˡ
476 }
477
478 record IsCommutativeSemiringWithoutOne
479 (+ * : Op₂ A) (0# : A) : Set (a ⊔ ℓ) where
480 field
481 isSemiringWithoutOne : IsSemiringWithoutOne + * 0#
482 *-comm : Commutative *
483
484 open IsSemiringWithoutOne isSemiringWithoutOne public
485
486 *-isCommutativeSemigroup : IsCommutativeSemigroup *
487 *-isCommutativeSemigroup = record
488 { isSemigroup = *-isSemigroup
489 ; comm = *-comm
490 }
491
492 open IsCommutativeSemigroup *-isCommutativeSemigroup public
493 using () renaming (isCommutativeMagma to *-isCommutativeMagma)
494
495 ------------------------------------------------------------------------
496 -- Structures with 2 binary operations & 2 elements
497 ------------------------------------------------------------------------
498
499 record IsSemiringWithoutAnnihilatingZero (+ * : Op₂ A)
500 (0# 1# : A) : Set (a ⊔ ℓ) where
501 field
502 -- Note that these structures do have an additive unit, but this
503 -- unit does not necessarily annihilate multiplication.
504 +-isCommutativeMonoid : IsCommutativeMonoid + 0#
505 *-cong : Congruent₂ *
506 *-assoc : Associative *
507 *-identity : Identity 1# *
508 distrib : * DistributesOver +
509
510 distribˡ : * DistributesOverˡ +
511 distribˡ = proj₁ distrib
512
513 distribʳ : * DistributesOverʳ +
514 distribʳ = proj₂ distrib
515
516 open IsCommutativeMonoid +-isCommutativeMonoid public
517 renaming
518 ( assoc to +-assoc
519 ; ∙-cong to +-cong
520 ; ∙-congˡ to +-congˡ
521 ; ∙-congʳ to +-congʳ
522 ; identity to +-identity
523 ; identityˡ to +-identityˡ
524 ; identityʳ to +-identityʳ
525 ; comm to +-comm
526 ; isMagma to +-isMagma
527 ; isSemigroup to +-isSemigroup
528 ; isMonoid to +-isMonoid
529 ; isUnitalMagma to +-isUnitalMagma
530 ; isCommutativeMagma to +-isCommutativeMagma
531 ; isCommutativeSemigroup to +-isCommutativeSemigroup
532 )
533
534 *-isMagma : IsMagma *
535 *-isMagma = record
536 { isEquivalence = isEquivalence
537 ; ∙-cong = *-cong
538 }
539
540 *-isSemigroup : IsSemigroup *
541 *-isSemigroup = record
542 { isMagma = *-isMagma
543 ; assoc = *-assoc
544 }
545
546 *-isMonoid : IsMonoid * 1#
547 *-isMonoid = record
548 { isSemigroup = *-isSemigroup
549 ; identity = *-identity
550 }
551
552 open IsMonoid *-isMonoid public
553 using ()
554 renaming
555 ( ∙-congˡ to *-congˡ
556 ; ∙-congʳ to *-congʳ
557 ; identityˡ to *-identityˡ
558 ; identityʳ to *-identityʳ
559 )
560
561
562 record IsSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where
563 field
564 isSemiringWithoutAnnihilatingZero :
565 IsSemiringWithoutAnnihilatingZero + * 0# 1#
566 zero : Zero 0# *
567
568 open IsSemiringWithoutAnnihilatingZero
569 isSemiringWithoutAnnihilatingZero public
570
571 isSemiringWithoutOne : IsSemiringWithoutOne + * 0#
572 isSemiringWithoutOne = record
573 { +-isCommutativeMonoid = +-isCommutativeMonoid
574 ; *-cong = *-cong
575 ; *-assoc = *-assoc
576 ; distrib = distrib
577 ; zero = zero
578 }
579
580 open IsSemiringWithoutOne isSemiringWithoutOne public
581 using
582 ( isNearSemiring
583 ; zeroˡ
584 ; zeroʳ
585 )
586
587
588 record IsCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where
589 field
590 isSemiring : IsSemiring + * 0# 1#
591 *-comm : Commutative *
592
593 open IsSemiring isSemiring public
594
595 isCommutativeSemiringWithoutOne :
596 IsCommutativeSemiringWithoutOne + * 0#
597 isCommutativeSemiringWithoutOne = record
598 { isSemiringWithoutOne = isSemiringWithoutOne
599 ; *-comm = *-comm
600 }
601
602 open IsCommutativeSemiringWithoutOne isCommutativeSemiringWithoutOne public
603 using
604 ( *-isCommutativeMagma
605 ; *-isCommutativeSemigroup
606 )
607
608 *-isCommutativeMonoid : IsCommutativeMonoid * 1#
609 *-isCommutativeMonoid = record
610 { isMonoid = *-isMonoid
611 ; comm = *-comm
612 }
613
614
615 record IsCancellativeCommutativeSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where
616 field
617 isCommutativeSemiring : IsCommutativeSemiring + * 0# 1#
618 *-cancelˡ-nonZero : AlmostLeftCancellative 0# *
619
620 open IsCommutativeSemiring isCommutativeSemiring public
621
622 *-cancelʳ-nonZero : AlmostRightCancellative 0# *
623 *-cancelʳ-nonZero = Consequences.comm∧almostCancelˡ⇒almostCancelʳ setoid
624 *-comm *-cancelˡ-nonZero
625
626 record IsIdempotentSemiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where
627 field
628 isSemiring : IsSemiring + * 0# 1#
629 +-idem : Idempotent +
630
631 open IsSemiring isSemiring public
632
633 +-isIdempotentCommutativeMonoid : IsIdempotentCommutativeMonoid + 0#
634 +-isIdempotentCommutativeMonoid = record
635 { isCommutativeMonoid = +-isCommutativeMonoid
636 ; idem = +-idem
637 }
638
639 open IsIdempotentCommutativeMonoid +-isIdempotentCommutativeMonoid public
640 using ()
641 renaming ( isCommutativeBand to +-isCommutativeBand
642 ; isBand to +-isBand
643 ; isIdempotentMonoid to +-isIdempotentMonoid
644 )
645
646
647 record IsKleeneAlgebra (+ * : Op₂ A) (⋆ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where
648 field
649 isIdempotentSemiring : IsIdempotentSemiring + * 0# 1#
650 starExpansive : StarExpansive 1# + * ⋆
651 starDestructive : StarDestructive + * ⋆
652
653 open IsIdempotentSemiring isIdempotentSemiring public
654
655 starExpansiveˡ : StarLeftExpansive 1# + * ⋆
656 starExpansiveˡ = proj₁ starExpansive
657
658 starExpansiveʳ : StarRightExpansive 1# + * ⋆
659 starExpansiveʳ = proj₂ starExpansive
660
661 starDestructiveˡ : StarLeftDestructive + * ⋆
662 starDestructiveˡ = proj₁ starDestructive
663
664 starDestructiveʳ : StarRightDestructive + * ⋆
665 starDestructiveʳ = proj₂ starDestructive
666
667 record IsQuasiring (+ * : Op₂ A) (0# 1# : A) : Set (a ⊔ ℓ) where
668 field
669 +-isMonoid : IsMonoid + 0#
670 *-cong : Congruent₂ *
671 *-assoc : Associative *
672 *-identity : Identity 1# *
673 distrib : * DistributesOver +
674 zero : Zero 0# *
675
676 open IsMonoid +-isMonoid public
677 renaming
678 ( assoc to +-assoc
679 ; ∙-cong to +-cong
680 ; ∙-congˡ to +-congˡ
681 ; ∙-congʳ to +-congʳ
682 ; identity to +-identity
683 ; identityˡ to +-identityˡ
684 ; identityʳ to +-identityʳ
685 ; isMagma to +-isMagma
686 ; isUnitalMagma to +-isUnitalMagma
687 ; isSemigroup to +-isSemigroup
688 )
689
690 distribˡ : * DistributesOverˡ +
691 distribˡ = proj₁ distrib
692
693 distribʳ : * DistributesOverʳ +
694 distribʳ = proj₂ distrib
695
696 zeroˡ : LeftZero 0# *
697 zeroˡ = proj₁ zero
698
699 zeroʳ : RightZero 0# *
700 zeroʳ = proj₂ zero
701
702 identityˡ : LeftIdentity 1# *
703 identityˡ = proj₁ *-identity
704
705 identityʳ : RightIdentity 1# *
706 identityʳ = proj₂ *-identity
707
708 *-isMagma : IsMagma *
709 *-isMagma = record
710 { isEquivalence = isEquivalence
711 ; ∙-cong = *-cong
712 }
713
714 *-isSemigroup : IsSemigroup *
715 *-isSemigroup = record
716 { isMagma = *-isMagma
717 ; assoc = *-assoc
718 }
719
720 *-isMonoid : IsMonoid * 1#
721 *-isMonoid = record
722 { isSemigroup = *-isSemigroup
723 ; identity = *-identity
724 }
725
726 open IsMonoid *-isMonoid public
727 using ()
728 renaming
729 ( ∙-congˡ to *-congˡ
730 ; ∙-congʳ to *-congʳ
731 ; identityˡ to *-identityˡ
732 ; identityʳ to *-identityʳ
733 )
734
735 ------------------------------------------------------------------------
736 -- Structures with 2 binary operations, 1 unary operation & 1 element
737 ------------------------------------------------------------------------
738
739 record IsRingWithoutOne (+ * : Op₂ A) (-_ : Op₁ A) (0# : A) : Set (a ⊔ ℓ) where
740 field
741 +-isAbelianGroup : IsAbelianGroup + 0# -_
742 *-cong : Congruent₂ *
743 *-assoc : Associative *
744 distrib : * DistributesOver +
745
746 open IsAbelianGroup +-isAbelianGroup public
747 renaming
748 ( assoc to +-assoc
749 ; ∙-cong to +-cong
750 ; ∙-congˡ to +-congˡ
751 ; ∙-congʳ to +-congʳ
752 ; identity to +-identity
753 ; identityˡ to +-identityˡ
754 ; identityʳ to +-identityʳ
755 ; inverse to -‿inverse
756 ; inverseˡ to -‿inverseˡ
757 ; inverseʳ to -‿inverseʳ
758 ; ⁻¹-cong to -‿cong
759 ; comm to +-comm
760 ; isMagma to +-isMagma
761 ; isSemigroup to +-isSemigroup
762 ; isMonoid to +-isMonoid
763 ; isUnitalMagma to +-isUnitalMagma
764 ; isCommutativeMagma to +-isCommutativeMagma
765 ; isCommutativeMonoid to +-isCommutativeMonoid
766 ; isCommutativeSemigroup to +-isCommutativeSemigroup
767 ; isInvertibleMagma to +-isInvertibleMagma
768 ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma
769 ; isGroup to +-isGroup
770 )
771
772 distribˡ : * DistributesOverˡ +
773 distribˡ = proj₁ distrib
774
775 distribʳ : * DistributesOverʳ +
776 distribʳ = proj₂ distrib
777
778 zeroˡ : LeftZero 0# *
779 zeroˡ = Consequences.assoc∧distribʳ∧idʳ∧invʳ⇒zeˡ setoid
780 +-cong *-cong +-assoc distribʳ +-identityʳ -‿inverseʳ
781
782 zeroʳ : RightZero 0# *
783 zeroʳ = Consequences.assoc∧distribˡ∧idʳ∧invʳ⇒zeʳ setoid
784 +-cong *-cong +-assoc distribˡ +-identityʳ -‿inverseʳ
785
786 zero : Zero 0# *
787 zero = zeroˡ , zeroʳ
788
789 isNearSemiring : IsNearSemiring + * 0#
790 isNearSemiring = record
791 { +-isMonoid = +-isMonoid
792 ; *-cong = *-cong
793 ; *-assoc = *-assoc
794 ; distribʳ = distribʳ
795 ; zeroˡ = zeroˡ
796 }
797
798 open IsNearSemiring isNearSemiring public
799 using (*-isMagma; *-isSemigroup; *-congˡ; *-congʳ)
800
801 ------------------------------------------------------------------------
802 -- Structures with 2 binary operations, 1 unary operation & 2 elements
803 ------------------------------------------------------------------------
804
805 record IsNonAssociativeRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where
806 field
807 +-isAbelianGroup : IsAbelianGroup + 0# -_
808 *-cong : Congruent₂ *
809 *-identity : Identity 1# *
810 distrib : * DistributesOver +
811 zero : Zero 0# *
812
813 open IsAbelianGroup +-isAbelianGroup public
814 renaming
815 ( assoc to +-assoc
816 ; ∙-cong to +-cong
817 ; ∙-congˡ to +-congˡ
818 ; ∙-congʳ to +-congʳ
819 ; identity to +-identity
820 ; identityˡ to +-identityˡ
821 ; identityʳ to +-identityʳ
822 ; inverse to -‿inverse
823 ; inverseˡ to -‿inverseˡ
824 ; inverseʳ to -‿inverseʳ
825 ; ⁻¹-cong to -‿cong
826 ; comm to +-comm
827 ; isMagma to +-isMagma
828 ; isSemigroup to +-isSemigroup
829 ; isMonoid to +-isMonoid
830 ; isUnitalMagma to +-isUnitalMagma
831 ; isCommutativeMagma to +-isCommutativeMagma
832 ; isCommutativeMonoid to +-isCommutativeMonoid
833 ; isCommutativeSemigroup to +-isCommutativeSemigroup
834 ; isInvertibleMagma to +-isInvertibleMagma
835 ; isInvertibleUnitalMagma to +-isInvertibleUnitalMagma
836 ; isGroup to +-isGroup
837 )
838
839 zeroˡ : LeftZero 0# *
840 zeroˡ = proj₁ zero
841
842 zeroʳ : RightZero 0# *
843 zeroʳ = proj₂ zero
844
845 distribˡ : * DistributesOverˡ +
846 distribˡ = proj₁ distrib
847
848 distribʳ : * DistributesOverʳ +
849 distribʳ = proj₂ distrib
850
851 *-isMagma : IsMagma *
852 *-isMagma = record
853 { isEquivalence = isEquivalence
854 ; ∙-cong = *-cong
855 }
856
857 *-identityˡ : LeftIdentity 1# *
858 *-identityˡ = proj₁ *-identity
859
860 *-identityʳ : RightIdentity 1# *
861 *-identityʳ = proj₂ *-identity
862
863 *-isUnitalMagma : IsUnitalMagma * 1#
864 *-isUnitalMagma = record
865 { isMagma = *-isMagma
866 ; identity = *-identity
867 }
868
869 open IsUnitalMagma *-isUnitalMagma public
870 using ()
871 renaming
872 ( ∙-congˡ to *-congˡ
873 ; ∙-congʳ to *-congʳ
874 )
875
876 record IsNearring (+ * : Op₂ A) (0# 1# : A) (_⁻¹ : Op₁ A) : Set (a ⊔ ℓ) where
877 field
878 isQuasiring : IsQuasiring + * 0# 1#
879 +-inverse : Inverse 0# _⁻¹ +
880 ⁻¹-cong : Congruent₁ _⁻¹
881
882 open IsQuasiring isQuasiring public
883
884 +-inverseˡ : LeftInverse 0# _⁻¹ +
885 +-inverseˡ = proj₁ +-inverse
886
887 +-inverseʳ : RightInverse 0# _⁻¹ +
888 +-inverseʳ = proj₂ +-inverse
889
890 record IsRing (+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where
891 field
892 +-isAbelianGroup : IsAbelianGroup + 0# -_
893 *-cong : Congruent₂ *
894 *-assoc : Associative *
895 *-identity : Identity 1# *
896 distrib : * DistributesOver +
897
898 isRingWithoutOne : IsRingWithoutOne + * -_ 0#
899 isRingWithoutOne = record
900 { +-isAbelianGroup = +-isAbelianGroup
901 ; *-cong = *-cong
902 ; *-assoc = *-assoc
903 ; distrib = distrib
904 }
905
906 open IsRingWithoutOne isRingWithoutOne public
907 hiding (+-isAbelianGroup; *-cong; *-assoc; distrib)
908
909 *-isMonoid : IsMonoid * 1#
910 *-isMonoid = record
911 { isSemigroup = *-isSemigroup
912 ; identity = *-identity
913 }
914
915 open IsMonoid *-isMonoid public
916 using ()
917 renaming
918 ( identityˡ to *-identityˡ
919 ; identityʳ to *-identityʳ
920 )
921
922 isSemiringWithoutAnnihilatingZero
923 : IsSemiringWithoutAnnihilatingZero + * 0# 1#
924 isSemiringWithoutAnnihilatingZero = record
925 { +-isCommutativeMonoid = +-isCommutativeMonoid
926 ; *-cong = *-cong
927 ; *-assoc = *-assoc
928 ; *-identity = *-identity
929 ; distrib = distrib
930 }
931
932 isSemiring : IsSemiring + * 0# 1#
933 isSemiring = record
934 { isSemiringWithoutAnnihilatingZero =
935 isSemiringWithoutAnnihilatingZero
936 ; zero = zero
937 }
938
939 open IsSemiring isSemiring public
940 using (isSemiringWithoutOne)
941
942
943 record IsCommutativeRing
944 (+ * : Op₂ A) (- : Op₁ A) (0# 1# : A) : Set (a ⊔ ℓ) where
945 field
946 isRing : IsRing + * - 0# 1#
947 *-comm : Commutative *
948
949 open IsRing isRing public
950
951 isCommutativeSemiring : IsCommutativeSemiring + * 0# 1#
952 isCommutativeSemiring = record
953 { isSemiring = isSemiring
954 ; *-comm = *-comm
955 }
956
957 open IsCommutativeSemiring isCommutativeSemiring public
958 using
959 ( isCommutativeSemiringWithoutOne
960 ; *-isCommutativeMagma
961 ; *-isCommutativeSemigroup
962 ; *-isCommutativeMonoid
963 )
964
965 ------------------------------------------------------------------------
966 -- Structures with 3 binary operations
967 ------------------------------------------------------------------------
968
969 record IsQuasigroup (∙ \\ // : Op₂ A) : Set (a ⊔ ℓ) where
970 field
971 isMagma : IsMagma ∙
972 \\-cong : Congruent₂ \\
973 //-cong : Congruent₂ //
974 leftDivides : LeftDivides ∙ \\
975 rightDivides : RightDivides ∙ //
976
977 open IsMagma isMagma public
978
979 \\-congˡ : LeftCongruent \\
980 \\-congˡ y≈z = \\-cong refl y≈z
981
982 \\-congʳ : RightCongruent \\
983 \\-congʳ y≈z = \\-cong y≈z refl
984
985 //-congˡ : LeftCongruent //
986 //-congˡ y≈z = //-cong refl y≈z
987
988 //-congʳ : RightCongruent //
989 //-congʳ y≈z = //-cong y≈z refl
990
991 leftDividesˡ : LeftDividesˡ ∙ \\
992 leftDividesˡ = proj₁ leftDivides
993
994 leftDividesʳ : LeftDividesʳ ∙ \\
995 leftDividesʳ = proj₂ leftDivides
996
997 rightDividesˡ : RightDividesˡ ∙ //
998 rightDividesˡ = proj₁ rightDivides
999
1000 rightDividesʳ : RightDividesʳ ∙ //
1001 rightDividesʳ = proj₂ rightDivides
1002
1003
1004 record IsLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
1005 field
1006 isQuasigroup : IsQuasigroup ∙ \\ //
1007 identity : Identity ε ∙
1008
1009 open IsQuasigroup isQuasigroup public
1010
1011 identityˡ : LeftIdentity ε ∙
1012 identityˡ = proj₁ identity
1013
1014 identityʳ : RightIdentity ε ∙
1015 identityʳ = proj₂ identity
1016
1017 record IsLeftBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
1018 field
1019 isLoop : IsLoop ∙ \\ // ε
1020 leftBol : LeftBol ∙
1021
1022 open IsLoop isLoop public
1023
1024 record IsRightBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
1025 field
1026 isLoop : IsLoop ∙ \\ // ε
1027 rightBol : RightBol ∙
1028
1029 open IsLoop isLoop public
1030
1031 record IsMoufangLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
1032 field
1033 isLeftBolLoop : IsLeftBolLoop ∙ \\ // ε
1034 rightBol : RightBol ∙
1035 identical : Identical ∙
1036
1037 open IsLeftBolLoop isLeftBolLoop public
1038
1039 record IsMiddleBolLoop (∙ \\ // : Op₂ A) (ε : A) : Set (a ⊔ ℓ) where
1040 field
1041 isLoop : IsLoop ∙ \\ // ε
1042 middleBol : MiddleBol ∙ \\ //
1043
1044 open IsLoop isLoop public