forked from agda/agda-stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStructures.agda
294 lines (240 loc) · 10.5 KB
/
Structures.agda
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some algebraic structures defined over some other structure
------------------------------------------------------------------------
{-# OPTIONS --cubical-compatible --safe #-}
open import Relation.Binary using (Rel; Setoid; IsEquivalence)
module Algebra.Module.Structures where
open import Algebra.Bundles
open import Algebra.Core
open import Algebra.Module.Core
import Algebra.Definitions as Defs
open import Algebra.Module.Definitions
open import Algebra.Structures
open import Data.Product.Base using (_,_; proj₁; proj₂)
open import Level using (Level; _⊔_)
private
variable
m ℓm r ℓr s ℓs : Level
M : Set m
module _ (semiring : Semiring r ℓr) (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M)
where
open Semiring semiring renaming (Carrier to R)
record IsPreleftSemimodule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
open LeftDefs R ≈ᴹ
field
*ₗ-cong : Congruent _≈_ *ₗ
*ₗ-zeroˡ : LeftZero 0# 0ᴹ *ₗ
*ₗ-distribʳ : *ₗ DistributesOverʳ _+_ ⟶ +ᴹ
*ₗ-identityˡ : LeftIdentity 1# *ₗ
*ₗ-assoc : Associative _*_ *ₗ
*ₗ-zeroʳ : RightZero 0ᴹ *ₗ
*ₗ-distribˡ : *ₗ DistributesOverˡ +ᴹ
record IsLeftSemimodule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
open LeftDefs R ≈ᴹ
field
+ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ
isPreleftSemimodule : IsPreleftSemimodule *ₗ
open IsPreleftSemimodule isPreleftSemimodule public
open IsCommutativeMonoid +ᴹ-isCommutativeMonoid public
using () renaming
( assoc to +ᴹ-assoc
; comm to +ᴹ-comm
; identity to +ᴹ-identity
; identityʳ to +ᴹ-identityʳ
; identityˡ to +ᴹ-identityˡ
; isEquivalence to ≈ᴹ-isEquivalence
; isMagma to +ᴹ-isMagma
; isMonoid to +ᴹ-isMonoid
; isPartialEquivalence to ≈ᴹ-isPartialEquivalence
; isSemigroup to +ᴹ-isSemigroup
; refl to ≈ᴹ-refl
; reflexive to ≈ᴹ-reflexive
; setoid to ≈ᴹ-setoid
; sym to ≈ᴹ-sym
; trans to ≈ᴹ-trans
; ∙-cong to +ᴹ-cong
; ∙-congʳ to +ᴹ-congʳ
; ∙-congˡ to +ᴹ-congˡ
)
*ₗ-congˡ : LeftCongruent *ₗ
*ₗ-congˡ mm = *ₗ-cong refl mm
*ₗ-congʳ : RightCongruent _≈_ *ₗ
*ₗ-congʳ xx = *ₗ-cong xx ≈ᴹ-refl
record IsPrerightSemimodule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
open RightDefs R ≈ᴹ
field
*ᵣ-cong : Congruent _≈_ *ᵣ
*ᵣ-zeroʳ : RightZero 0# 0ᴹ *ᵣ
*ᵣ-distribˡ : *ᵣ DistributesOverˡ _+_ ⟶ +ᴹ
*ᵣ-identityʳ : RightIdentity 1# *ᵣ
*ᵣ-assoc : Associative _*_ *ᵣ
*ᵣ-zeroˡ : LeftZero 0ᴹ *ᵣ
*ᵣ-distribʳ : *ᵣ DistributesOverʳ +ᴹ
record IsRightSemimodule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
open RightDefs R ≈ᴹ
field
+ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ
isPrerightSemimodule : IsPrerightSemimodule *ᵣ
open IsPrerightSemimodule isPrerightSemimodule public
open IsCommutativeMonoid +ᴹ-isCommutativeMonoid public
using () renaming
( assoc to +ᴹ-assoc
; comm to +ᴹ-comm
; identity to +ᴹ-identity
; identityʳ to +ᴹ-identityʳ
; identityˡ to +ᴹ-identityˡ
; isEquivalence to ≈ᴹ-isEquivalence
; isMagma to +ᴹ-isMagma
; isMonoid to +ᴹ-isMonoid
; isPartialEquivalence to ≈ᴹ-isPartialEquivalence
; isSemigroup to +ᴹ-isSemigroup
; refl to ≈ᴹ-refl
; reflexive to ≈ᴹ-reflexive
; setoid to ≈ᴹ-setoid
; sym to ≈ᴹ-sym
; trans to ≈ᴹ-trans
; ∙-cong to +ᴹ-cong
; ∙-congʳ to +ᴹ-congʳ
; ∙-congˡ to +ᴹ-congˡ
)
*ᵣ-congˡ : LeftCongruent _≈_ *ᵣ
*ᵣ-congˡ xx = *ᵣ-cong ≈ᴹ-refl xx
*ᵣ-congʳ : RightCongruent *ᵣ
*ᵣ-congʳ mm = *ᵣ-cong mm refl
module _ (R-semiring : Semiring r ℓr) (S-semiring : Semiring s ℓs)
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M)
where
open Semiring R-semiring using () renaming (Carrier to R)
open Semiring S-semiring using () renaming (Carrier to S)
record IsBisemimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ S M)
: Set (r ⊔ s ⊔ m ⊔ ℓr ⊔ ℓs ⊔ ℓm) where
open BiDefs R S ≈ᴹ
field
+ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ
isPreleftSemimodule : IsPreleftSemimodule R-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ
isPrerightSemimodule : IsPrerightSemimodule S-semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ
*ₗ-*ᵣ-assoc : Associative *ₗ *ᵣ
isLeftSemimodule : IsLeftSemimodule R-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ
isLeftSemimodule = record
{ +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid
; isPreleftSemimodule = isPreleftSemimodule
}
isRightSemimodule : IsRightSemimodule S-semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ
isRightSemimodule = record
{ +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid
; isPrerightSemimodule = isPrerightSemimodule
}
open IsLeftSemimodule isLeftSemimodule public
hiding (+ᴹ-isCommutativeMonoid; isPreleftSemimodule)
open IsPrerightSemimodule isPrerightSemimodule public
open IsRightSemimodule isRightSemimodule public
using (*ᵣ-congˡ; *ᵣ-congʳ)
module _ (commutativeSemiring : CommutativeSemiring r ℓr)
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M)
where
open CommutativeSemiring commutativeSemiring renaming (Carrier to R)
-- An R-semimodule is an R-R-bisemimodule where R is commutative.
-- This means that *ₗ and *ᵣ coincide up to mathematical equality,
-- though it may be that they do not coincide up to definitional
-- equality.
record IsSemimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ R M)
: Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
field
isBisemimodule : IsBisemimodule semiring semiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ
open IsBisemimodule isBisemimodule public
module _ (ring : Ring r ℓr)
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M)
where
open Ring ring renaming (Carrier to R)
record IsLeftModule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
open Defs ≈ᴹ
field
isLeftSemimodule : IsLeftSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ₗ
-ᴹ‿cong : Congruent₁ -ᴹ
-ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ
open IsLeftSemimodule isLeftSemimodule public
+ᴹ-isAbelianGroup : IsAbelianGroup ≈ᴹ +ᴹ 0ᴹ -ᴹ
+ᴹ-isAbelianGroup = record
{ isGroup = record
{ isMonoid = +ᴹ-isMonoid
; inverse = -ᴹ‿inverse
; ⁻¹-cong = -ᴹ‿cong
}
; comm = +ᴹ-comm
}
open IsAbelianGroup +ᴹ-isAbelianGroup public
using () renaming
( isGroup to +ᴹ-isGroup
; inverseˡ to -ᴹ‿inverseˡ
; inverseʳ to -ᴹ‿inverseʳ
; uniqueˡ-⁻¹ to uniqueˡ‿-ᴹ
; uniqueʳ-⁻¹ to uniqueʳ‿-ᴹ
)
record IsRightModule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
open Defs ≈ᴹ
field
isRightSemimodule : IsRightSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ
-ᴹ‿cong : Congruent₁ -ᴹ
-ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ
open IsRightSemimodule isRightSemimodule public
+ᴹ-isAbelianGroup : IsAbelianGroup ≈ᴹ +ᴹ 0ᴹ -ᴹ
+ᴹ-isAbelianGroup = record
{ isGroup = record
{ isMonoid = +ᴹ-isMonoid
; inverse = -ᴹ‿inverse
; ⁻¹-cong = -ᴹ‿cong
}
; comm = +ᴹ-comm
}
open IsAbelianGroup +ᴹ-isAbelianGroup public
using () renaming
( isGroup to +ᴹ-isGroup
; inverseˡ to -ᴹ‿inverseˡ
; inverseʳ to -ᴹ‿inverseʳ
; uniqueˡ-⁻¹ to uniqueˡ‿-ᴹ
; uniqueʳ-⁻¹ to uniqueʳ‿-ᴹ
)
module _ (R-ring : Ring r ℓr) (S-ring : Ring s ℓs)
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M)
where
open Ring R-ring renaming (Carrier to R; semiring to R-semiring)
open Ring S-ring renaming (Carrier to S; semiring to S-semiring)
record IsBimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ S M)
: Set (r ⊔ s ⊔ m ⊔ ℓr ⊔ ℓs ⊔ ℓm) where
open Defs ≈ᴹ
field
isBisemimodule : IsBisemimodule R-semiring S-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ
-ᴹ‿cong : Congruent₁ -ᴹ
-ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ
open IsBisemimodule isBisemimodule public
isLeftModule : IsLeftModule R-ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ
isLeftModule = record
{ isLeftSemimodule = isLeftSemimodule
; -ᴹ‿cong = -ᴹ‿cong
; -ᴹ‿inverse = -ᴹ‿inverse
}
open IsLeftModule isLeftModule public
using ( +ᴹ-isAbelianGroup; +ᴹ-isGroup; -ᴹ‿inverseˡ; -ᴹ‿inverseʳ
; uniqueˡ‿-ᴹ; uniqueʳ‿-ᴹ)
isRightModule : IsRightModule S-ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ᵣ
isRightModule = record
{ isRightSemimodule = isRightSemimodule
; -ᴹ‿cong = -ᴹ‿cong
; -ᴹ‿inverse = -ᴹ‿inverse
}
module _ (commutativeRing : CommutativeRing r ℓr)
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M)
where
open CommutativeRing commutativeRing renaming (Carrier to R)
-- An R-module is an R-R-bimodule where R is commutative.
-- This means that *ₗ and *ᵣ coincide up to mathematical equality,
-- though it may be that they do not coincide up to definitional
-- equality.
record IsModule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where
field
isBimodule : IsBimodule ring ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ *ᵣ
open IsBimodule isBimodule public
isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ
isSemimodule = record { isBisemimodule = isBisemimodule }