| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Some algebraic structures defined over some other structure |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Algebra.Module.Structures where |
| 10 |
|
| 11 |
open import Algebra.Bundles |
| 12 |
using (Semiring; Ring; CommutativeSemiring; CommutativeRing) |
| 13 |
open import Algebra.Core using (Op₁; Op₂) |
| 14 |
open import Algebra.Module.Core using (Opₗ; Opᵣ) |
| 15 |
import Algebra.Definitions as Defs |
| 16 |
open import Algebra.Module.Definitions |
| 17 |
using (module LeftDefs; module RightDefs; module BiDefs |
| 18 |
; module SimultaneousBiDefs) |
| 19 |
open import Algebra.Structures using (IsCommutativeMonoid; IsAbelianGroup) |
| 20 |
open import Data.Product.Base using (_,_; proj₁; proj₂) |
| 21 |
open import Level using (Level; _⊔_) |
| 22 |
open import Relation.Binary.Core using (Rel) |
| 23 |
open import Relation.Binary.Bundles using (Setoid) |
| 24 |
open import Relation.Binary.Structures using (IsEquivalence) |
| 25 |
|
| 26 |
|
| 27 |
private |
| 28 |
variable |
| 29 |
m ℓm r ℓr s ℓs : Level |
| 30 |
M : Set m |
| 31 |
|
| 32 |
module _ (semiring : Semiring r ℓr) (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) |
| 33 |
where |
| 34 |
|
| 35 |
open Semiring semiring renaming (Carrier to R) |
| 36 |
|
| 37 |
record IsPreleftSemimodule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 38 |
open LeftDefs R ≈ᴹ |
| 39 |
field |
| 40 |
*ₗ-cong : Congruent _≈_ *ₗ |
| 41 |
*ₗ-zeroˡ : LeftZero 0# 0ᴹ *ₗ |
| 42 |
*ₗ-distribʳ : *ₗ DistributesOverʳ _+_ ⟶ +ᴹ |
| 43 |
*ₗ-identityˡ : LeftIdentity 1# *ₗ |
| 44 |
*ₗ-assoc : Associative _*_ *ₗ |
| 45 |
*ₗ-zeroʳ : RightZero 0ᴹ *ₗ |
| 46 |
*ₗ-distribˡ : *ₗ DistributesOverˡ +ᴹ |
| 47 |
|
| 48 |
record IsLeftSemimodule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 49 |
open LeftDefs R ≈ᴹ |
| 50 |
field |
| 51 |
+ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ |
| 52 |
isPreleftSemimodule : IsPreleftSemimodule *ₗ |
| 53 |
|
| 54 |
open IsPreleftSemimodule isPreleftSemimodule public |
| 55 |
|
| 56 |
open IsCommutativeMonoid +ᴹ-isCommutativeMonoid public |
| 57 |
using () renaming |
| 58 |
( assoc to +ᴹ-assoc |
| 59 |
; comm to +ᴹ-comm |
| 60 |
; identity to +ᴹ-identity |
| 61 |
; identityʳ to +ᴹ-identityʳ |
| 62 |
; identityˡ to +ᴹ-identityˡ |
| 63 |
; isEquivalence to ≈ᴹ-isEquivalence |
| 64 |
; isMagma to +ᴹ-isMagma |
| 65 |
; isMonoid to +ᴹ-isMonoid |
| 66 |
; isPartialEquivalence to ≈ᴹ-isPartialEquivalence |
| 67 |
; isSemigroup to +ᴹ-isSemigroup |
| 68 |
; refl to ≈ᴹ-refl |
| 69 |
; reflexive to ≈ᴹ-reflexive |
| 70 |
; setoid to ≈ᴹ-setoid |
| 71 |
; sym to ≈ᴹ-sym |
| 72 |
; trans to ≈ᴹ-trans |
| 73 |
; ∙-cong to +ᴹ-cong |
| 74 |
; ∙-congʳ to +ᴹ-congʳ |
| 75 |
; ∙-congˡ to +ᴹ-congˡ |
| 76 |
) |
| 77 |
|
| 78 |
*ₗ-congˡ : LeftCongruent *ₗ |
| 79 |
*ₗ-congˡ mm = *ₗ-cong refl mm |
| 80 |
|
| 81 |
*ₗ-congʳ : RightCongruent _≈_ *ₗ |
| 82 |
*ₗ-congʳ xx = *ₗ-cong xx ≈ᴹ-refl |
| 83 |
|
| 84 |
record IsPrerightSemimodule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 85 |
open RightDefs R ≈ᴹ |
| 86 |
field |
| 87 |
*ᵣ-cong : Congruent _≈_ *ᵣ |
| 88 |
*ᵣ-zeroʳ : RightZero 0# 0ᴹ *ᵣ |
| 89 |
*ᵣ-distribˡ : *ᵣ DistributesOverˡ _+_ ⟶ +ᴹ |
| 90 |
*ᵣ-identityʳ : RightIdentity 1# *ᵣ |
| 91 |
*ᵣ-assoc : Associative _*_ *ᵣ |
| 92 |
*ᵣ-zeroˡ : LeftZero 0ᴹ *ᵣ |
| 93 |
*ᵣ-distribʳ : *ᵣ DistributesOverʳ +ᴹ |
| 94 |
|
| 95 |
record IsRightSemimodule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 96 |
open RightDefs R ≈ᴹ |
| 97 |
field |
| 98 |
+ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ |
| 99 |
isPrerightSemimodule : IsPrerightSemimodule *ᵣ |
| 100 |
|
| 101 |
open IsPrerightSemimodule isPrerightSemimodule public |
| 102 |
|
| 103 |
open IsCommutativeMonoid +ᴹ-isCommutativeMonoid public |
| 104 |
using () renaming |
| 105 |
( assoc to +ᴹ-assoc |
| 106 |
; comm to +ᴹ-comm |
| 107 |
; identity to +ᴹ-identity |
| 108 |
; identityʳ to +ᴹ-identityʳ |
| 109 |
; identityˡ to +ᴹ-identityˡ |
| 110 |
; isEquivalence to ≈ᴹ-isEquivalence |
| 111 |
; isMagma to +ᴹ-isMagma |
| 112 |
; isMonoid to +ᴹ-isMonoid |
| 113 |
; isPartialEquivalence to ≈ᴹ-isPartialEquivalence |
| 114 |
; isSemigroup to +ᴹ-isSemigroup |
| 115 |
; refl to ≈ᴹ-refl |
| 116 |
; reflexive to ≈ᴹ-reflexive |
| 117 |
; setoid to ≈ᴹ-setoid |
| 118 |
; sym to ≈ᴹ-sym |
| 119 |
; trans to ≈ᴹ-trans |
| 120 |
; ∙-cong to +ᴹ-cong |
| 121 |
; ∙-congʳ to +ᴹ-congʳ |
| 122 |
; ∙-congˡ to +ᴹ-congˡ |
| 123 |
) |
| 124 |
|
| 125 |
*ᵣ-congˡ : LeftCongruent _≈_ *ᵣ |
| 126 |
*ᵣ-congˡ xx = *ᵣ-cong ≈ᴹ-refl xx |
| 127 |
|
| 128 |
*ᵣ-congʳ : RightCongruent *ᵣ |
| 129 |
*ᵣ-congʳ mm = *ᵣ-cong mm refl |
| 130 |
|
| 131 |
module _ (R-semiring : Semiring r ℓr) (S-semiring : Semiring s ℓs) |
| 132 |
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) |
| 133 |
where |
| 134 |
|
| 135 |
open Semiring R-semiring using () renaming (Carrier to R) |
| 136 |
open Semiring S-semiring using () renaming (Carrier to S) |
| 137 |
|
| 138 |
record IsBisemimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ S M) |
| 139 |
: Set (r ⊔ s ⊔ m ⊔ ℓr ⊔ ℓs ⊔ ℓm) where |
| 140 |
open BiDefs R S ≈ᴹ |
| 141 |
field |
| 142 |
+ᴹ-isCommutativeMonoid : IsCommutativeMonoid ≈ᴹ +ᴹ 0ᴹ |
| 143 |
isPreleftSemimodule : IsPreleftSemimodule R-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ |
| 144 |
isPrerightSemimodule : IsPrerightSemimodule S-semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ |
| 145 |
*ₗ-*ᵣ-assoc : Associative *ₗ *ᵣ |
| 146 |
|
| 147 |
isLeftSemimodule : IsLeftSemimodule R-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ |
| 148 |
isLeftSemimodule = record |
| 149 |
{ +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid |
| 150 |
; isPreleftSemimodule = isPreleftSemimodule |
| 151 |
} |
| 152 |
|
| 153 |
isRightSemimodule : IsRightSemimodule S-semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ |
| 154 |
isRightSemimodule = record |
| 155 |
{ +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid |
| 156 |
; isPrerightSemimodule = isPrerightSemimodule |
| 157 |
} |
| 158 |
|
| 159 |
open IsLeftSemimodule isLeftSemimodule public |
| 160 |
hiding (+ᴹ-isCommutativeMonoid; isPreleftSemimodule) |
| 161 |
open IsPrerightSemimodule isPrerightSemimodule public |
| 162 |
open IsRightSemimodule isRightSemimodule public |
| 163 |
using (*ᵣ-congˡ; *ᵣ-congʳ) |
| 164 |
|
| 165 |
module _ (commutativeSemiring : CommutativeSemiring r ℓr) |
| 166 |
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) |
| 167 |
where |
| 168 |
|
| 169 |
open CommutativeSemiring commutativeSemiring renaming (Carrier to R) |
| 170 |
|
| 171 |
-- An R-semimodule is an R-R-bisemimodule where R is commutative. |
| 172 |
-- We enforce that *ₗ and *ᵣ coincide up to mathematical equality, though it |
| 173 |
-- may be that they do not coincide up to definitional equality. |
| 174 |
|
| 175 |
open SimultaneousBiDefs R ≈ᴹ |
| 176 |
|
| 177 |
record IsSemimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ R M) |
| 178 |
: Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 179 |
field |
| 180 |
isBisemimodule : IsBisemimodule semiring semiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ |
| 181 |
*ₗ-*ᵣ-coincident : Coincident *ₗ *ᵣ |
| 182 |
|
| 183 |
open IsBisemimodule isBisemimodule public |
| 184 |
|
| 185 |
|
| 186 |
module _ (ring : Ring r ℓr) |
| 187 |
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M) |
| 188 |
where |
| 189 |
|
| 190 |
open Ring ring renaming (Carrier to R) |
| 191 |
|
| 192 |
record IsLeftModule (*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 193 |
open Defs ≈ᴹ |
| 194 |
field |
| 195 |
isLeftSemimodule : IsLeftSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ₗ |
| 196 |
-ᴹ‿cong : Congruent₁ -ᴹ |
| 197 |
-ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ |
| 198 |
|
| 199 |
open IsLeftSemimodule isLeftSemimodule public |
| 200 |
|
| 201 |
+ᴹ-isAbelianGroup : IsAbelianGroup ≈ᴹ +ᴹ 0ᴹ -ᴹ |
| 202 |
+ᴹ-isAbelianGroup = record |
| 203 |
{ isGroup = record |
| 204 |
{ isMonoid = +ᴹ-isMonoid |
| 205 |
; inverse = -ᴹ‿inverse |
| 206 |
; ⁻¹-cong = -ᴹ‿cong |
| 207 |
} |
| 208 |
; comm = +ᴹ-comm |
| 209 |
} |
| 210 |
|
| 211 |
open IsAbelianGroup +ᴹ-isAbelianGroup public |
| 212 |
using () renaming |
| 213 |
( isGroup to +ᴹ-isGroup |
| 214 |
; inverseˡ to -ᴹ‿inverseˡ |
| 215 |
; inverseʳ to -ᴹ‿inverseʳ |
| 216 |
; uniqueˡ-⁻¹ to uniqueˡ‿-ᴹ |
| 217 |
; uniqueʳ-⁻¹ to uniqueʳ‿-ᴹ |
| 218 |
) |
| 219 |
{-# WARNING_ON_USAGE uniqueˡ‿-ᴹ |
| 220 |
"Warning: uniqueˡ‿-ᴹ was deprecated in v2.3. |
| 221 |
Please use Algebra.Module.Properties.LeftModule.inverseˡ-uniqueᴹ instead." |
| 222 |
#-} |
| 223 |
{-# WARNING_ON_USAGE uniqueʳ‿-ᴹ |
| 224 |
"Warning: uniqueʳ‿-ᴹ was deprecated in v2.3. |
| 225 |
Please use Algebra.Module.Properties.LeftModule.inverseʳ-uniqueᴹ instead." |
| 226 |
#-} |
| 227 |
|
| 228 |
|
| 229 |
record IsRightModule (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 230 |
open Defs ≈ᴹ |
| 231 |
field |
| 232 |
isRightSemimodule : IsRightSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ |
| 233 |
-ᴹ‿cong : Congruent₁ -ᴹ |
| 234 |
-ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ |
| 235 |
|
| 236 |
open IsRightSemimodule isRightSemimodule public |
| 237 |
|
| 238 |
+ᴹ-isAbelianGroup : IsAbelianGroup ≈ᴹ +ᴹ 0ᴹ -ᴹ |
| 239 |
+ᴹ-isAbelianGroup = record |
| 240 |
{ isGroup = record |
| 241 |
{ isMonoid = +ᴹ-isMonoid |
| 242 |
; inverse = -ᴹ‿inverse |
| 243 |
; ⁻¹-cong = -ᴹ‿cong |
| 244 |
} |
| 245 |
; comm = +ᴹ-comm |
| 246 |
} |
| 247 |
|
| 248 |
open IsAbelianGroup +ᴹ-isAbelianGroup public |
| 249 |
using () renaming |
| 250 |
( isGroup to +ᴹ-isGroup |
| 251 |
; inverseˡ to -ᴹ‿inverseˡ |
| 252 |
; inverseʳ to -ᴹ‿inverseʳ |
| 253 |
; uniqueˡ-⁻¹ to uniqueˡ‿-ᴹ |
| 254 |
; uniqueʳ-⁻¹ to uniqueʳ‿-ᴹ |
| 255 |
) |
| 256 |
{-# WARNING_ON_USAGE uniqueˡ‿-ᴹ |
| 257 |
"Warning: uniqueˡ‿-ᴹ was deprecated in v2.3. |
| 258 |
Please use Algebra.Module.Properties.RightModule.inverseˡ-uniqueᴹ instead." |
| 259 |
#-} |
| 260 |
{-# WARNING_ON_USAGE uniqueʳ‿-ᴹ |
| 261 |
"Warning: uniqueʳ‿-ᴹ was deprecated in v2.3. |
| 262 |
Please use Algebra.Module.Properties.RightModule.inverseʳ-uniqueᴹ instead." |
| 263 |
#-} |
| 264 |
|
| 265 |
|
| 266 |
module _ (R-ring : Ring r ℓr) (S-ring : Ring s ℓs) |
| 267 |
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M) |
| 268 |
where |
| 269 |
|
| 270 |
open Ring R-ring renaming (Carrier to R; semiring to R-semiring) |
| 271 |
open Ring S-ring renaming (Carrier to S; semiring to S-semiring) |
| 272 |
|
| 273 |
record IsBimodule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ S M) |
| 274 |
: Set (r ⊔ s ⊔ m ⊔ ℓr ⊔ ℓs ⊔ ℓm) where |
| 275 |
open Defs ≈ᴹ |
| 276 |
field |
| 277 |
isBisemimodule : IsBisemimodule R-semiring S-semiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ |
| 278 |
-ᴹ‿cong : Congruent₁ -ᴹ |
| 279 |
-ᴹ‿inverse : Inverse 0ᴹ -ᴹ +ᴹ |
| 280 |
|
| 281 |
open IsBisemimodule isBisemimodule public |
| 282 |
|
| 283 |
isLeftModule : IsLeftModule R-ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ |
| 284 |
isLeftModule = record |
| 285 |
{ isLeftSemimodule = isLeftSemimodule |
| 286 |
; -ᴹ‿cong = -ᴹ‿cong |
| 287 |
; -ᴹ‿inverse = -ᴹ‿inverse |
| 288 |
} |
| 289 |
|
| 290 |
open IsLeftModule isLeftModule public |
| 291 |
using ( +ᴹ-isAbelianGroup; +ᴹ-isGroup; -ᴹ‿inverseˡ; -ᴹ‿inverseʳ |
| 292 |
; uniqueˡ‿-ᴹ; uniqueʳ‿-ᴹ) |
| 293 |
|
| 294 |
isRightModule : IsRightModule S-ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ᵣ |
| 295 |
isRightModule = record |
| 296 |
{ isRightSemimodule = isRightSemimodule |
| 297 |
; -ᴹ‿cong = -ᴹ‿cong |
| 298 |
; -ᴹ‿inverse = -ᴹ‿inverse |
| 299 |
} |
| 300 |
|
| 301 |
module _ (commutativeRing : CommutativeRing r ℓr) |
| 302 |
(≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M) |
| 303 |
where |
| 304 |
|
| 305 |
open CommutativeRing commutativeRing renaming (Carrier to R) |
| 306 |
|
| 307 |
-- An R-module is an R-R-bimodule where R is commutative. |
| 308 |
-- We enforce that *ₗ and *ᵣ coincide up to mathematical equality, though it |
| 309 |
-- may be that they do not coincide up to definitional equality. |
| 310 |
|
| 311 |
open SimultaneousBiDefs R ≈ᴹ |
| 312 |
|
| 313 |
record IsModule (*ₗ : Opₗ R M) (*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 314 |
field |
| 315 |
isBimodule : IsBimodule ring ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ *ᵣ |
| 316 |
*ₗ-*ᵣ-coincident : Coincident *ₗ *ᵣ |
| 317 |
|
| 318 |
open IsBimodule isBimodule public |
| 319 |
|
| 320 |
isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ *ₗ *ᵣ |
| 321 |
isSemimodule = record { isBisemimodule = isBisemimodule; *ₗ-*ᵣ-coincident = *ₗ-*ᵣ-coincident } |