| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- This module provides alternative ways of providing instances of |
| 5 |
-- structures in the Algebra.Module hierarchy. |
| 6 |
------------------------------------------------------------------------ |
| 7 |
|
| 8 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 9 |
|
| 10 |
open import Relation.Binary.Core using (Rel) |
| 11 |
open import Relation.Binary.Bundles using (Setoid) |
| 12 |
open import Relation.Binary.Structures using (IsEquivalence) |
| 13 |
|
| 14 |
module Algebra.Module.Structures.Biased where |
| 15 |
|
| 16 |
open import Algebra.Bundles |
| 17 |
using (Semiring; Ring; CommutativeSemiring; CommutativeRing) |
| 18 |
open import Algebra.Core using (Op₁; Op₂) |
| 19 |
open import Algebra.Module.Core using (Opₗ; Opᵣ) |
| 20 |
open import Algebra.Module.Consequences |
| 21 |
open import Algebra.Module.Structures |
| 22 |
using (IsLeftSemimodule; IsRightSemimodule; IsBisemimodule; |
| 23 |
IsSemimodule; IsLeftModule; IsRightModule; IsModule) |
| 24 |
open import Function.Base using (flip) |
| 25 |
open import Level using (Level; _⊔_) |
| 26 |
|
| 27 |
private |
| 28 |
variable |
| 29 |
m ℓm r ℓr s ℓs : Level |
| 30 |
M : Set m |
| 31 |
|
| 32 |
module _ (commutativeSemiring : CommutativeSemiring r ℓr) where |
| 33 |
open CommutativeSemiring commutativeSemiring renaming (Carrier to R) |
| 34 |
|
| 35 |
-- A left semimodule over a commutative semiring is already a semimodule. |
| 36 |
|
| 37 |
record IsSemimoduleFromLeft (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) |
| 38 |
(*ₗ : Opₗ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 39 |
field |
| 40 |
isLeftSemimodule : IsLeftSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ₗ |
| 41 |
|
| 42 |
open IsLeftSemimodule isLeftSemimodule |
| 43 |
|
| 44 |
isBisemimodule : IsBisemimodule semiring semiring ≈ᴹ +ᴹ 0ᴹ *ₗ (flip *ₗ) |
| 45 |
isBisemimodule = record |
| 46 |
{ +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid |
| 47 |
; isPreleftSemimodule = isPreleftSemimodule |
| 48 |
; isPrerightSemimodule = record |
| 49 |
{ *ᵣ-cong = flip *ₗ-cong |
| 50 |
; *ᵣ-zeroʳ = *ₗ-zeroˡ |
| 51 |
; *ᵣ-distribˡ = *ₗ-distribʳ |
| 52 |
; *ᵣ-identityʳ = *ₗ-identityˡ |
| 53 |
; *ᵣ-assoc = |
| 54 |
*ₗ-assoc∧comm⇒*ᵣ-assoc _≈_ ≈ᴹ-setoid *ₗ-congʳ *ₗ-assoc *-comm |
| 55 |
; *ᵣ-zeroˡ = *ₗ-zeroʳ |
| 56 |
; *ᵣ-distribʳ = *ₗ-distribˡ |
| 57 |
} |
| 58 |
; *ₗ-*ᵣ-assoc = |
| 59 |
*ₗ-assoc∧comm⇒*ₗ-*ᵣ-assoc _≈_ ≈ᴹ-setoid *ₗ-congʳ *ₗ-assoc *-comm |
| 60 |
} |
| 61 |
|
| 62 |
isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ *ₗ (flip *ₗ) |
| 63 |
isSemimodule = record |
| 64 |
{ isBisemimodule = isBisemimodule |
| 65 |
; *ₗ-*ᵣ-coincident = λ _ _ → ≈ᴹ-refl |
| 66 |
} |
| 67 |
|
| 68 |
-- Similarly, a right semimodule over a commutative semiring |
| 69 |
-- is already a semimodule. |
| 70 |
|
| 71 |
record IsSemimoduleFromRight (≈ᴹ : Rel {m} M ℓm) (+ᴹ : Op₂ M) (0ᴹ : M) |
| 72 |
(*ᵣ : Opᵣ R M) : Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 73 |
field |
| 74 |
isRightSemimodule : IsRightSemimodule semiring ≈ᴹ +ᴹ 0ᴹ *ᵣ |
| 75 |
|
| 76 |
open IsRightSemimodule isRightSemimodule |
| 77 |
|
| 78 |
isBisemimodule : IsBisemimodule semiring semiring ≈ᴹ +ᴹ 0ᴹ (flip *ᵣ) *ᵣ |
| 79 |
isBisemimodule = record |
| 80 |
{ +ᴹ-isCommutativeMonoid = +ᴹ-isCommutativeMonoid |
| 81 |
; isPreleftSemimodule = record |
| 82 |
{ *ₗ-cong = flip *ᵣ-cong |
| 83 |
; *ₗ-zeroˡ = *ᵣ-zeroʳ |
| 84 |
; *ₗ-distribʳ = *ᵣ-distribˡ |
| 85 |
; *ₗ-identityˡ = *ᵣ-identityʳ |
| 86 |
; *ₗ-assoc = |
| 87 |
*ᵣ-assoc∧comm⇒*ₗ-assoc _≈_ ≈ᴹ-setoid *ᵣ-congˡ *ᵣ-assoc *-comm |
| 88 |
; *ₗ-zeroʳ = *ᵣ-zeroˡ |
| 89 |
; *ₗ-distribˡ = *ᵣ-distribʳ |
| 90 |
} |
| 91 |
; isPrerightSemimodule = isPrerightSemimodule |
| 92 |
; *ₗ-*ᵣ-assoc = |
| 93 |
*ᵣ-assoc∧comm⇒*ₗ-*ᵣ-assoc _≈_ ≈ᴹ-setoid *ᵣ-congˡ *ᵣ-assoc *-comm |
| 94 |
} |
| 95 |
|
| 96 |
isSemimodule : IsSemimodule commutativeSemiring ≈ᴹ +ᴹ 0ᴹ (flip *ᵣ) *ᵣ |
| 97 |
isSemimodule = record |
| 98 |
{ isBisemimodule = isBisemimodule |
| 99 |
; *ₗ-*ᵣ-coincident = λ _ _ → ≈ᴹ-refl |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
module _ (commutativeRing : CommutativeRing r ℓr) where |
| 104 |
open CommutativeRing commutativeRing renaming (Carrier to R) |
| 105 |
|
| 106 |
-- A left module over a commutative ring is already a module. |
| 107 |
|
| 108 |
record IsModuleFromLeft (≈ᴹ : Rel {m} M ℓm) |
| 109 |
(+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M) (*ₗ : Opₗ R M) |
| 110 |
: Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 111 |
field |
| 112 |
isLeftModule : IsLeftModule ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ |
| 113 |
|
| 114 |
open IsLeftModule isLeftModule |
| 115 |
|
| 116 |
isModule : IsModule commutativeRing ≈ᴹ +ᴹ 0ᴹ -ᴹ *ₗ (flip *ₗ) |
| 117 |
isModule = record |
| 118 |
{ isBimodule = record |
| 119 |
{ isBisemimodule = IsSemimoduleFromLeft.isBisemimodule |
| 120 |
{commutativeSemiring = commutativeSemiring} |
| 121 |
(record { isLeftSemimodule = isLeftSemimodule }) |
| 122 |
; -ᴹ‿cong = -ᴹ‿cong |
| 123 |
; -ᴹ‿inverse = -ᴹ‿inverse |
| 124 |
} |
| 125 |
; *ₗ-*ᵣ-coincident = λ _ _ → ≈ᴹ-refl |
| 126 |
} |
| 127 |
|
| 128 |
-- Similarly, a right module over a commutative ring is already a module. |
| 129 |
|
| 130 |
record IsModuleFromRight (≈ᴹ : Rel {m} M ℓm) |
| 131 |
(+ᴹ : Op₂ M) (0ᴹ : M) (-ᴹ : Op₁ M) (*ᵣ : Opᵣ R M) |
| 132 |
: Set (r ⊔ m ⊔ ℓr ⊔ ℓm) where |
| 133 |
field |
| 134 |
isRightModule : IsRightModule ring ≈ᴹ +ᴹ 0ᴹ -ᴹ *ᵣ |
| 135 |
|
| 136 |
open IsRightModule isRightModule |
| 137 |
|
| 138 |
isModule : IsModule commutativeRing ≈ᴹ +ᴹ 0ᴹ -ᴹ (flip *ᵣ) *ᵣ |
| 139 |
isModule = record |
| 140 |
{ isBimodule = record |
| 141 |
{ isBisemimodule = IsSemimoduleFromRight.isBisemimodule |
| 142 |
{commutativeSemiring = commutativeSemiring} |
| 143 |
(record { isRightSemimodule = isRightSemimodule }) |
| 144 |
; -ᴹ‿cong = -ᴹ‿cong |
| 145 |
; -ᴹ‿inverse = -ᴹ‿inverse |
| 146 |
} |
| 147 |
; *ₗ-*ᵣ-coincident = λ _ _ → ≈ᴹ-refl |
| 148 |
} |