blob: b64b4c7ad8ac6a153f2fe68aa21f036ec4a20299 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
------------------------------------------------------------------------
-- Agda Helium
--
-- Some more algebraic structures
-- (not packed up with sets, operations, etc.)
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
open import Relation.Binary.Core using (Rel)
module Helium.Algebra.Structures
{a ℓ} {A : Set a} -- The underlying set
(_≈_ : Rel A ℓ) -- The underlying equality relation
where
open import Algebra.Core
open import Algebra.Definitions _≈_
open import Algebra.Structures _≈_
open import Data.Product using (proj₁; proj₂)
open import Helium.Algebra.Core
open import Helium.Algebra.Definitions _≈_
import Helium.Algebra.Consequences.Setoid as Consequences
open import Level using (_⊔_)
open import Relation.Nullary using (¬_)
record IsAlmostGroup
(_∙_ : Op₂ A) (0# 1# : A) (_⁻¹ : AlmostOp₁ _≈_ 0#) : Set (a ⊔ ℓ) where
field
isMonoid : IsMonoid _∙_ 1#
inverse : AlmostInverse 1# _⁻¹ _∙_
⁻¹-cong : AlmostCongruent₁ _⁻¹
open IsMonoid isMonoid public
infixl 6 _-_
_-_ : AlmostOp₂ _≈_ 0#
x - y≉0 = x ∙ (y≉0 ⁻¹)
inverseˡ : AlmostLeftInverse 1# _⁻¹ _∙_
inverseˡ = proj₁ inverse
inverseʳ : AlmostRightInverse 1# _⁻¹ _∙_
inverseʳ = proj₂ inverse
uniqueˡ-⁻¹ : ∀ x {y} (y≉0 : ¬ y ≈ 0#) → (x ∙ y) ≈ 1# → x ≈ (y≉0 ⁻¹)
uniqueˡ-⁻¹ = Consequences.assoc+id+invʳ⇒invˡ-unique
setoid ∙-cong assoc identity inverseʳ
uniqueʳ-⁻¹ : ∀ {x} (x≉0 : ¬ x ≈ 0#) y → (x ∙ y) ≈ 1# → y ≈ (x≉0 ⁻¹)
uniqueʳ-⁻¹ = Consequences.assoc+id+invˡ⇒invʳ-unique
setoid ∙-cong assoc identity inverseˡ
record IsAlmostAbelianGroup
(∙ : Op₂ A) (0# 1# : A) (⁻¹ : AlmostOp₁ _≈_ 0#) : Set (a ⊔ ℓ) where
field
isAlmostGroup : IsAlmostGroup ∙ 0# 1# ⁻¹
comm : Commutative ∙
open IsAlmostGroup isAlmostGroup
isCommutativeMonoid : IsCommutativeMonoid ∙ 1#
isCommutativeMonoid = record
{ isMonoid = isMonoid
; comm = comm
}
open IsCommutativeMonoid isCommutativeMonoid public
using (isCommutativeMagma; isCommutativeSemigroup)
record IsDivisionRing
(+ _*_ : Op₂ A) (-_ : Op₁ A) (0# 1# : A)
(_⁻¹ : AlmostOp₁ _≈_ 0#) : Set (a ⊔ ℓ) where
field
+-isAbelianGroup : IsAbelianGroup + 0# -_
*-isAlmostGroup : IsAlmostGroup _*_ 0# 1# _⁻¹
distrib : _*_ DistributesOver +
zero : Zero 0# _*_
infixl 7 _/_
_/_ : AlmostOp₂ _≈_ 0#
x / y≉0 = x * (y≉0 ⁻¹)
open IsAbelianGroup +-isAbelianGroup public
renaming
( assoc to +-assoc
; ∙-cong to +-cong
; ∙-congˡ to +-congˡ
; ∙-congʳ to +-congʳ
; identity to +-identity
; identityˡ to +-identityˡ
; identityʳ to +-identityʳ
; inverse to -‿inverse
; inverseˡ to -‿inverseˡ
; inverseʳ to -‿inverseʳ
; ⁻¹-cong to -‿cong
; uniqueˡ-⁻¹ to uniqueˡ‿-
; uniqueʳ-⁻¹ to uniqueʳ‿-
; comm to +-comm
; isMagma to +-isMagma
; isSemigroup to +-isSemigroup
; isMonoid to +-isMonoid
; isCommutativeMagma to +-isCommutativeMagma
; isCommutativeMonoid to +-isCommutativeMonoid
; isCommutativeSemigroup to +-isCommutativeSemigroup
; isGroup to +-isGroup
)
open IsAlmostGroup *-isAlmostGroup public
using (⁻¹-cong; uniqueˡ-⁻¹; uniqueʳ-⁻¹)
renaming
( assoc to *-assoc
; ∙-cong to *-cong
; ∙-congˡ to *-congˡ
; ∙-congʳ to *-congʳ
; identity to *-identity
; identityˡ to *-identityˡ
; identityʳ to *-identityʳ
; inverse to ⁻¹-inverse
; inverseˡ to ⁻¹-inverseˡ
; inverseʳ to ⁻¹-inverseʳ
; isMagma to *-isMagma
; isSemigroup to *-isSemigroup
; isMonoid to *-isMonoid
)
isRing : IsRing + _*_ -_ 0# 1#
isRing = record
{ +-isAbelianGroup = +-isAbelianGroup
; *-isMonoid = *-isMonoid
; distrib = distrib
; zero = zero
}
open IsRing isRing public
using
( distribˡ ; distribʳ ; zeroˡ ; zeroʳ
; isNearSemiring ; isSemiringWithoutOne ; isSemiringWithoutAnnihilatingZero
)
record IsField
(+ * : Op₂ A) (-_ : Op₁ A) (0# 1# : A)
(⁻¹ : AlmostOp₁ _≈_ 0#) : Set (a ⊔ ℓ) where
field
isDivisionRing : IsDivisionRing + * -_ 0# 1# ⁻¹
*-comm : Commutative *
open IsDivisionRing isDivisionRing public
isCommutativeRing : IsCommutativeRing + * -_ 0# 1#
isCommutativeRing = record
{ isRing = isRing
; *-comm = *-comm
}
open IsCommutativeRing isCommutativeRing public
using
( isCommutativeSemiring
; isCommutativeSemiringWithoutOne
; *-isCommutativeMagma
; *-isCommutativeSemigroup
; *-isCommutativeMonoid
)
|