|
| 1 | +------------------------------------------------------------------------ |
| 2 | +-- The Agda standard library |
| 3 | +-- |
| 4 | +-- The composition of morphisms between algebraic structures. |
| 5 | +------------------------------------------------------------------------ |
| 6 | + |
| 7 | +{-# OPTIONS --safe --without-K #-} |
| 8 | + |
| 9 | +module Algebra.Morphism.Construct.Composition where |
| 10 | + |
| 11 | +open import Algebra.Bundles |
| 12 | +open import Algebra.Morphism.Structures |
| 13 | +open import Data.Product |
| 14 | +open import Function.Base using (_∘_) |
| 15 | +import Function.Construct.Composition as Func |
| 16 | +open import Level using (Level) |
| 17 | +open import Relation.Binary.Morphism.Construct.Composition |
| 18 | +open import Relation.Binary.Definitions using (Transitive) |
| 19 | + |
| 20 | +private |
| 21 | + variable |
| 22 | + a b c ℓ₁ ℓ₂ ℓ₃ : Level |
| 23 | + |
| 24 | +------------------------------------------------------------------------ |
| 25 | +-- Magmas |
| 26 | + |
| 27 | +module _ {M₁ : RawMagma a ℓ₁} |
| 28 | + {M₂ : RawMagma b ℓ₂} |
| 29 | + {M₃ : RawMagma c ℓ₃} |
| 30 | + (open RawMagma) |
| 31 | + (≈₃-trans : Transitive (_≈_ M₃)) |
| 32 | + {f : Carrier M₁ → Carrier M₂} |
| 33 | + {g : Carrier M₂ → Carrier M₃} |
| 34 | + where |
| 35 | + |
| 36 | + isMagmaHomomorphism |
| 37 | + : IsMagmaHomomorphism M₁ M₂ f |
| 38 | + → IsMagmaHomomorphism M₂ M₃ g |
| 39 | + → IsMagmaHomomorphism M₁ M₃ (g ∘ f) |
| 40 | + isMagmaHomomorphism f-homo g-homo = record |
| 41 | + { isRelHomomorphism = isRelHomomorphism F.isRelHomomorphism G.isRelHomomorphism |
| 42 | + ; homo = λ x y → ≈₃-trans (G.⟦⟧-cong (F.homo x y)) (G.homo (f x) (f y)) |
| 43 | + } where module F = IsMagmaHomomorphism f-homo; module G = IsMagmaHomomorphism g-homo |
| 44 | + |
| 45 | + isMagmaMonomorphism |
| 46 | + : IsMagmaMonomorphism M₁ M₂ f |
| 47 | + → IsMagmaMonomorphism M₂ M₃ g |
| 48 | + → IsMagmaMonomorphism M₁ M₃ (g ∘ f) |
| 49 | + isMagmaMonomorphism f-mono g-mono = record |
| 50 | + { isMagmaHomomorphism = isMagmaHomomorphism F.isMagmaHomomorphism G.isMagmaHomomorphism |
| 51 | + ; injective = F.injective ∘ G.injective |
| 52 | + } where module F = IsMagmaMonomorphism f-mono; module G = IsMagmaMonomorphism g-mono |
| 53 | + |
| 54 | + isMagmaIsomorphism |
| 55 | + : IsMagmaIsomorphism M₁ M₂ f |
| 56 | + → IsMagmaIsomorphism M₂ M₃ g |
| 57 | + → IsMagmaIsomorphism M₁ M₃ (g ∘ f) |
| 58 | + isMagmaIsomorphism f-iso g-iso = record |
| 59 | + { isMagmaMonomorphism = isMagmaMonomorphism F.isMagmaMonomorphism G.isMagmaMonomorphism |
| 60 | + ; surjective = Func.surjective (_≈_ M₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 61 | + } where module F = IsMagmaIsomorphism f-iso; module G = IsMagmaIsomorphism g-iso |
| 62 | + |
| 63 | + |
| 64 | +------------------------------------------------------------------------ |
| 65 | +-- Monoids |
| 66 | + |
| 67 | +module _ {M₁ : RawMonoid a ℓ₁} |
| 68 | + {M₂ : RawMonoid b ℓ₂} |
| 69 | + {M₃ : RawMonoid c ℓ₃} |
| 70 | + (open RawMonoid) |
| 71 | + (≈₃-trans : Transitive (_≈_ M₃)) |
| 72 | + {f : Carrier M₁ → Carrier M₂} |
| 73 | + {g : Carrier M₂ → Carrier M₃} |
| 74 | + where |
| 75 | + |
| 76 | + isMonoidHomomorphism |
| 77 | + : IsMonoidHomomorphism M₁ M₂ f |
| 78 | + → IsMonoidHomomorphism M₂ M₃ g |
| 79 | + → IsMonoidHomomorphism M₁ M₃ (g ∘ f) |
| 80 | + isMonoidHomomorphism f-homo g-homo = record |
| 81 | + { isMagmaHomomorphism = isMagmaHomomorphism ≈₃-trans F.isMagmaHomomorphism G.isMagmaHomomorphism |
| 82 | + ; ε-homo = ≈₃-trans (G.⟦⟧-cong F.ε-homo) G.ε-homo |
| 83 | + } where module F = IsMonoidHomomorphism f-homo; module G = IsMonoidHomomorphism g-homo |
| 84 | + |
| 85 | + isMonoidMonomorphism |
| 86 | + : IsMonoidMonomorphism M₁ M₂ f |
| 87 | + → IsMonoidMonomorphism M₂ M₃ g |
| 88 | + → IsMonoidMonomorphism M₁ M₃ (g ∘ f) |
| 89 | + isMonoidMonomorphism f-mono g-mono = record |
| 90 | + { isMonoidHomomorphism = isMonoidHomomorphism F.isMonoidHomomorphism G.isMonoidHomomorphism |
| 91 | + ; injective = F.injective ∘ G.injective |
| 92 | + } where module F = IsMonoidMonomorphism f-mono; module G = IsMonoidMonomorphism g-mono |
| 93 | + |
| 94 | + isMonoidIsomorphism |
| 95 | + : IsMonoidIsomorphism M₁ M₂ f |
| 96 | + → IsMonoidIsomorphism M₂ M₃ g |
| 97 | + → IsMonoidIsomorphism M₁ M₃ (g ∘ f) |
| 98 | + isMonoidIsomorphism f-iso g-iso = record |
| 99 | + { isMonoidMonomorphism = isMonoidMonomorphism F.isMonoidMonomorphism G.isMonoidMonomorphism |
| 100 | + ; surjective = Func.surjective (_≈_ M₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 101 | + } where module F = IsMonoidIsomorphism f-iso; module G = IsMonoidIsomorphism g-iso |
| 102 | + |
| 103 | + |
| 104 | +------------------------------------------------------------------------ |
| 105 | +-- Groups |
| 106 | + |
| 107 | +module _ {G₁ : RawGroup a ℓ₁} |
| 108 | + {G₂ : RawGroup b ℓ₂} |
| 109 | + {G₃ : RawGroup c ℓ₃} |
| 110 | + (open RawGroup) |
| 111 | + (≈₃-trans : Transitive (_≈_ G₃)) |
| 112 | + {f : Carrier G₁ → Carrier G₂} |
| 113 | + {g : Carrier G₂ → Carrier G₃} |
| 114 | + where |
| 115 | + |
| 116 | + |
| 117 | + isGroupHomomorphism |
| 118 | + : IsGroupHomomorphism G₁ G₂ f |
| 119 | + → IsGroupHomomorphism G₂ G₃ g |
| 120 | + → IsGroupHomomorphism G₁ G₃ (g ∘ f) |
| 121 | + isGroupHomomorphism f-homo g-homo = record |
| 122 | + { isMonoidHomomorphism = isMonoidHomomorphism ≈₃-trans F.isMonoidHomomorphism G.isMonoidHomomorphism |
| 123 | + ; ⁻¹-homo = λ x → ≈₃-trans (G.⟦⟧-cong (F.⁻¹-homo x)) (G.⁻¹-homo (f x)) |
| 124 | + } where module F = IsGroupHomomorphism f-homo; module G = IsGroupHomomorphism g-homo |
| 125 | + |
| 126 | + isGroupMonomorphism |
| 127 | + : IsGroupMonomorphism G₁ G₂ f |
| 128 | + → IsGroupMonomorphism G₂ G₃ g |
| 129 | + → IsGroupMonomorphism G₁ G₃ (g ∘ f) |
| 130 | + isGroupMonomorphism f-mono g-mono = record |
| 131 | + { isGroupHomomorphism = isGroupHomomorphism F.isGroupHomomorphism G.isGroupHomomorphism |
| 132 | + ; injective = F.injective ∘ G.injective |
| 133 | + } where module F = IsGroupMonomorphism f-mono; module G = IsGroupMonomorphism g-mono |
| 134 | + |
| 135 | + isGroupIsomorphism |
| 136 | + : IsGroupIsomorphism G₁ G₂ f |
| 137 | + → IsGroupIsomorphism G₂ G₃ g |
| 138 | + → IsGroupIsomorphism G₁ G₃ (g ∘ f) |
| 139 | + isGroupIsomorphism f-iso g-iso = record |
| 140 | + { isGroupMonomorphism = isGroupMonomorphism F.isGroupMonomorphism G.isGroupMonomorphism |
| 141 | + ; surjective = Func.surjective (_≈_ G₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 142 | + } where module F = IsGroupIsomorphism f-iso; module G = IsGroupIsomorphism g-iso |
| 143 | + |
| 144 | + |
| 145 | +------------------------------------------------------------------------ |
| 146 | +-- Near semirings |
| 147 | + |
| 148 | +module _ {R₁ : RawNearSemiring a ℓ₁} |
| 149 | + {R₂ : RawNearSemiring b ℓ₂} |
| 150 | + {R₃ : RawNearSemiring c ℓ₃} |
| 151 | + (open RawNearSemiring) |
| 152 | + (≈₃-trans : Transitive (_≈_ R₃)) |
| 153 | + {f : Carrier R₁ → Carrier R₂} |
| 154 | + {g : Carrier R₂ → Carrier R₃} |
| 155 | + where |
| 156 | + |
| 157 | + isNearSemiringHomomorphism |
| 158 | + : IsNearSemiringHomomorphism R₁ R₂ f |
| 159 | + → IsNearSemiringHomomorphism R₂ R₃ g |
| 160 | + → IsNearSemiringHomomorphism R₁ R₃ (g ∘ f) |
| 161 | + isNearSemiringHomomorphism f-homo g-homo = record |
| 162 | + { +-isMonoidHomomorphism = isMonoidHomomorphism ≈₃-trans F.+-isMonoidHomomorphism G.+-isMonoidHomomorphism |
| 163 | + ; *-isMagmaHomomorphism = isMagmaHomomorphism ≈₃-trans F.*-isMagmaHomomorphism G.*-isMagmaHomomorphism |
| 164 | + } where module F = IsNearSemiringHomomorphism f-homo; module G = IsNearSemiringHomomorphism g-homo |
| 165 | + |
| 166 | + isNearSemiringMonomorphism |
| 167 | + : IsNearSemiringMonomorphism R₁ R₂ f |
| 168 | + → IsNearSemiringMonomorphism R₂ R₃ g |
| 169 | + → IsNearSemiringMonomorphism R₁ R₃ (g ∘ f) |
| 170 | + isNearSemiringMonomorphism f-mono g-mono = record |
| 171 | + { isNearSemiringHomomorphism = isNearSemiringHomomorphism F.isNearSemiringHomomorphism G.isNearSemiringHomomorphism |
| 172 | + ; injective = F.injective ∘ G.injective |
| 173 | + } where module F = IsNearSemiringMonomorphism f-mono; module G = IsNearSemiringMonomorphism g-mono |
| 174 | + |
| 175 | + isNearSemiringIsomorphism |
| 176 | + : IsNearSemiringIsomorphism R₁ R₂ f |
| 177 | + → IsNearSemiringIsomorphism R₂ R₃ g |
| 178 | + → IsNearSemiringIsomorphism R₁ R₃ (g ∘ f) |
| 179 | + isNearSemiringIsomorphism f-iso g-iso = record |
| 180 | + { isNearSemiringMonomorphism = isNearSemiringMonomorphism F.isNearSemiringMonomorphism G.isNearSemiringMonomorphism |
| 181 | + ; surjective = Func.surjective (_≈_ R₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 182 | + } where module F = IsNearSemiringIsomorphism f-iso; module G = IsNearSemiringIsomorphism g-iso |
| 183 | + |
| 184 | + |
| 185 | +------------------------------------------------------------------------ |
| 186 | +-- Semirings |
| 187 | + |
| 188 | +module _ |
| 189 | + {R₁ : RawSemiring a ℓ₁} |
| 190 | + {R₂ : RawSemiring b ℓ₂} |
| 191 | + {R₃ : RawSemiring c ℓ₃} |
| 192 | + (open RawSemiring) |
| 193 | + (≈₃-trans : Transitive (_≈_ R₃)) |
| 194 | + {f : Carrier R₁ → Carrier R₂} |
| 195 | + {g : Carrier R₂ → Carrier R₃} |
| 196 | + where |
| 197 | + |
| 198 | + |
| 199 | + isSemiringHomomorphism |
| 200 | + : IsSemiringHomomorphism R₁ R₂ f |
| 201 | + → IsSemiringHomomorphism R₂ R₃ g |
| 202 | + → IsSemiringHomomorphism R₁ R₃ (g ∘ f) |
| 203 | + isSemiringHomomorphism f-homo g-homo = record |
| 204 | + { +-isMonoidHomomorphism = isMonoidHomomorphism ≈₃-trans F.+-isMonoidHomomorphism G.+-isMonoidHomomorphism |
| 205 | + ; *-isMonoidHomomorphism = isMonoidHomomorphism ≈₃-trans F.*-isMonoidHomomorphism G.*-isMonoidHomomorphism |
| 206 | + } where module F = IsSemiringHomomorphism f-homo; module G = IsSemiringHomomorphism g-homo |
| 207 | + |
| 208 | + isSemiringMonomorphism |
| 209 | + : IsSemiringMonomorphism R₁ R₂ f |
| 210 | + → IsSemiringMonomorphism R₂ R₃ g |
| 211 | + → IsSemiringMonomorphism R₁ R₃ (g ∘ f) |
| 212 | + isSemiringMonomorphism f-mono g-mono = record |
| 213 | + { isSemiringHomomorphism = isSemiringHomomorphism F.isSemiringHomomorphism G.isSemiringHomomorphism |
| 214 | + ; injective = F.injective ∘ G.injective |
| 215 | + } where module F = IsSemiringMonomorphism f-mono; module G = IsSemiringMonomorphism g-mono |
| 216 | + |
| 217 | + isSemiringIsomorphism |
| 218 | + : IsSemiringIsomorphism R₁ R₂ f |
| 219 | + → IsSemiringIsomorphism R₂ R₃ g |
| 220 | + → IsSemiringIsomorphism R₁ R₃ (g ∘ f) |
| 221 | + isSemiringIsomorphism f-iso g-iso = record |
| 222 | + { isSemiringMonomorphism = isSemiringMonomorphism F.isSemiringMonomorphism G.isSemiringMonomorphism |
| 223 | + ; surjective = Func.surjective (_≈_ R₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 224 | + } where module F = IsSemiringIsomorphism f-iso; module G = IsSemiringIsomorphism g-iso |
| 225 | + |
| 226 | + |
| 227 | +------------------------------------------------------------------------ |
| 228 | +-- Rings |
| 229 | + |
| 230 | +module _ {R₁ : RawRing a ℓ₁} |
| 231 | + {R₂ : RawRing b ℓ₂} |
| 232 | + {R₃ : RawRing c ℓ₃} |
| 233 | + (open RawRing) |
| 234 | + (≈₃-trans : Transitive (_≈_ R₃)) |
| 235 | + {f : Carrier R₁ → Carrier R₂} |
| 236 | + {g : Carrier R₂ → Carrier R₃} |
| 237 | + where |
| 238 | + |
| 239 | + |
| 240 | + isRingHomomorphism |
| 241 | + : IsRingHomomorphism R₁ R₂ f |
| 242 | + → IsRingHomomorphism R₂ R₃ g |
| 243 | + → IsRingHomomorphism R₁ R₃ (g ∘ f) |
| 244 | + isRingHomomorphism f-homo g-homo = record |
| 245 | + { +-isGroupHomomorphism = isGroupHomomorphism ≈₃-trans F.+-isGroupHomomorphism G.+-isGroupHomomorphism |
| 246 | + ; *-isMonoidHomomorphism = isMonoidHomomorphism ≈₃-trans F.*-isMonoidHomomorphism G.*-isMonoidHomomorphism |
| 247 | + } where module F = IsRingHomomorphism f-homo; module G = IsRingHomomorphism g-homo |
| 248 | + |
| 249 | + isRingMonomorphism |
| 250 | + : IsRingMonomorphism R₁ R₂ f |
| 251 | + → IsRingMonomorphism R₂ R₃ g |
| 252 | + → IsRingMonomorphism R₁ R₃ (g ∘ f) |
| 253 | + isRingMonomorphism f-mono g-mono = record |
| 254 | + { isRingHomomorphism = isRingHomomorphism F.isRingHomomorphism G.isRingHomomorphism |
| 255 | + ; injective = F.injective ∘ G.injective |
| 256 | + } where module F = IsRingMonomorphism f-mono; module G = IsRingMonomorphism g-mono |
| 257 | + |
| 258 | + isRingIsomorphism |
| 259 | + : IsRingIsomorphism R₁ R₂ f |
| 260 | + → IsRingIsomorphism R₂ R₃ g |
| 261 | + → IsRingIsomorphism R₁ R₃ (g ∘ f) |
| 262 | + isRingIsomorphism f-iso g-iso = record |
| 263 | + { isRingMonomorphism = isRingMonomorphism F.isRingMonomorphism G.isRingMonomorphism |
| 264 | + ; surjective = Func.surjective (_≈_ R₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 265 | + } where module F = IsRingIsomorphism f-iso; module G = IsRingIsomorphism g-iso |
| 266 | + |
| 267 | + |
| 268 | +------------------------------------------------------------------------ |
| 269 | +-- Lattices |
| 270 | + |
| 271 | +module _ {L₁ : RawLattice a ℓ₁} |
| 272 | + {L₂ : RawLattice b ℓ₂} |
| 273 | + {L₃ : RawLattice c ℓ₃} |
| 274 | + (open RawLattice) |
| 275 | + (≈₃-trans : Transitive (_≈_ L₃)) |
| 276 | + {f : Carrier L₁ → Carrier L₂} |
| 277 | + {g : Carrier L₂ → Carrier L₃} |
| 278 | + where |
| 279 | + |
| 280 | + isLatticeHomomorphism |
| 281 | + : IsLatticeHomomorphism L₁ L₂ f |
| 282 | + → IsLatticeHomomorphism L₂ L₃ g |
| 283 | + → IsLatticeHomomorphism L₁ L₃ (g ∘ f) |
| 284 | + isLatticeHomomorphism f-homo g-homo = record |
| 285 | + { ∧-isMagmaHomomorphism = isMagmaHomomorphism ≈₃-trans F.∧-isMagmaHomomorphism G.∧-isMagmaHomomorphism |
| 286 | + ; ∨-isMagmaHomomorphism = isMagmaHomomorphism ≈₃-trans F.∨-isMagmaHomomorphism G.∨-isMagmaHomomorphism |
| 287 | + } where module F = IsLatticeHomomorphism f-homo; module G = IsLatticeHomomorphism g-homo |
| 288 | + |
| 289 | + isLatticeMonomorphism |
| 290 | + : IsLatticeMonomorphism L₁ L₂ f |
| 291 | + → IsLatticeMonomorphism L₂ L₃ g |
| 292 | + → IsLatticeMonomorphism L₁ L₃ (g ∘ f) |
| 293 | + isLatticeMonomorphism f-mono g-mono = record |
| 294 | + { isLatticeHomomorphism = isLatticeHomomorphism F.isLatticeHomomorphism G.isLatticeHomomorphism |
| 295 | + ; injective = F.injective ∘ G.injective |
| 296 | + } where module F = IsLatticeMonomorphism f-mono; module G = IsLatticeMonomorphism g-mono |
| 297 | + |
| 298 | + isLatticeIsomorphism |
| 299 | + : IsLatticeIsomorphism L₁ L₂ f |
| 300 | + → IsLatticeIsomorphism L₂ L₃ g |
| 301 | + → IsLatticeIsomorphism L₁ L₃ (g ∘ f) |
| 302 | + isLatticeIsomorphism f-iso g-iso = record |
| 303 | + { isLatticeMonomorphism = isLatticeMonomorphism F.isLatticeMonomorphism G.isLatticeMonomorphism |
| 304 | + ; surjective = Func.surjective (_≈_ L₁) _ _ ≈₃-trans G.⟦⟧-cong F.surjective G.surjective |
| 305 | + } where module F = IsLatticeIsomorphism f-iso; module G = IsLatticeIsomorphism g-iso |
0 commit comments