| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Some theory for commutative semigroup |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Algebra.Bundles using (CommutativeSemigroup) |
| 10 |
|
| 11 |
module Algebra.Properties.CommutativeSemigroup |
| 12 |
{a ℓ} (CS : CommutativeSemigroup a ℓ) |
| 13 |
where |
| 14 |
|
| 15 |
open CommutativeSemigroup CS |
| 16 |
open import Algebra.Definitions _≈_ |
| 17 |
open import Relation.Binary.Reasoning.Setoid setoid |
| 18 |
open import Data.Product.Base using (_,_) |
| 19 |
|
| 20 |
------------------------------------------------------------------------ |
| 21 |
-- Re-export the contents of semigroup |
| 22 |
|
| 23 |
open import Algebra.Properties.Semigroup semigroup public |
| 24 |
|
| 25 |
------------------------------------------------------------------------ |
| 26 |
-- Properties |
| 27 |
|
| 28 |
interchange : Interchangable _∙_ _∙_ |
| 29 |
interchange a b c d = begin |
| 30 |
(a ∙ b) ∙ (c ∙ d) ≈⟨ assoc a b (c ∙ d) ⟩ |
| 31 |
a ∙ (b ∙ (c ∙ d)) ≈⟨ ∙-congˡ (assoc b c d) ⟨ |
| 32 |
a ∙ ((b ∙ c) ∙ d) ≈⟨ ∙-congˡ (∙-congʳ (comm b c)) ⟩ |
| 33 |
a ∙ ((c ∙ b) ∙ d) ≈⟨ ∙-congˡ (assoc c b d) ⟩ |
| 34 |
a ∙ (c ∙ (b ∙ d)) ≈⟨ assoc a c (b ∙ d) ⟨ |
| 35 |
(a ∙ c) ∙ (b ∙ d) ∎ |
| 36 |
|
| 37 |
------------------------------------------------------------------------ |
| 38 |
-- Permutation laws for _∙_ for three factors. |
| 39 |
|
| 40 |
-- There are five nontrivial permutations. |
| 41 |
|
| 42 |
------------------------------------------------------------------------ |
| 43 |
-- Partitions (1,1). |
| 44 |
|
| 45 |
x∙yz≈y∙xz : ∀ x y z → x ∙ (y ∙ z) ≈ y ∙ (x ∙ z) |
| 46 |
x∙yz≈y∙xz x y z = begin |
| 47 |
x ∙ (y ∙ z) ≈⟨ sym (assoc x y z) ⟩ |
| 48 |
(x ∙ y) ∙ z ≈⟨ ∙-congʳ (comm x y) ⟩ |
| 49 |
(y ∙ x) ∙ z ≈⟨ assoc y x z ⟩ |
| 50 |
y ∙ (x ∙ z) ∎ |
| 51 |
|
| 52 |
x∙yz≈z∙yx : ∀ x y z → x ∙ (y ∙ z) ≈ z ∙ (y ∙ x) |
| 53 |
x∙yz≈z∙yx x y z = begin |
| 54 |
x ∙ (y ∙ z) ≈⟨ ∙-congˡ (comm y z) ⟩ |
| 55 |
x ∙ (z ∙ y) ≈⟨ x∙yz≈y∙xz x z y ⟩ |
| 56 |
z ∙ (x ∙ y) ≈⟨ ∙-congˡ (comm x y) ⟩ |
| 57 |
z ∙ (y ∙ x) ∎ |
| 58 |
|
| 59 |
x∙yz≈x∙zy : ∀ x y z → x ∙ (y ∙ z) ≈ x ∙ (z ∙ y) |
| 60 |
x∙yz≈x∙zy _ y z = ∙-congˡ (comm y z) |
| 61 |
|
| 62 |
x∙yz≈y∙zx : ∀ x y z → x ∙ (y ∙ z) ≈ y ∙ (z ∙ x) |
| 63 |
x∙yz≈y∙zx x y z = begin |
| 64 |
x ∙ (y ∙ z) ≈⟨ comm x _ ⟩ |
| 65 |
(y ∙ z) ∙ x ≈⟨ assoc y z x ⟩ |
| 66 |
y ∙ (z ∙ x) ∎ |
| 67 |
|
| 68 |
x∙yz≈z∙xy : ∀ x y z → x ∙ (y ∙ z) ≈ z ∙ (x ∙ y) |
| 69 |
x∙yz≈z∙xy x y z = begin |
| 70 |
x ∙ (y ∙ z) ≈⟨ sym (assoc x y z) ⟩ |
| 71 |
(x ∙ y) ∙ z ≈⟨ comm _ z ⟩ |
| 72 |
z ∙ (x ∙ y) ∎ |
| 73 |
|
| 74 |
------------------------------------------------------------------------ |
| 75 |
-- Partitions (1,2). |
| 76 |
|
| 77 |
-- These permutation laws are proved by composing the proofs for |
| 78 |
-- partitions (1,1) with \p → trans p (sym (assoc _ _ _)). |
| 79 |
|
| 80 |
x∙yz≈yx∙z : ∀ x y z → x ∙ (y ∙ z) ≈ (y ∙ x) ∙ z |
| 81 |
x∙yz≈yx∙z x y z = trans (x∙yz≈y∙xz x y z) (sym (assoc y x z)) |
| 82 |
|
| 83 |
x∙yz≈zy∙x : ∀ x y z → x ∙ (y ∙ z) ≈ (z ∙ y) ∙ x |
| 84 |
x∙yz≈zy∙x x y z = trans (x∙yz≈z∙yx x y z) (sym (assoc z y x)) |
| 85 |
|
| 86 |
x∙yz≈xz∙y : ∀ x y z → x ∙ (y ∙ z) ≈ (x ∙ z) ∙ y |
| 87 |
x∙yz≈xz∙y x y z = trans (x∙yz≈x∙zy x y z) (sym (assoc x z y)) |
| 88 |
|
| 89 |
x∙yz≈yz∙x : ∀ x y z → x ∙ (y ∙ z) ≈ (y ∙ z) ∙ x |
| 90 |
x∙yz≈yz∙x x y z = trans (x∙yz≈y∙zx _ _ _) (sym (assoc y z x)) |
| 91 |
|
| 92 |
x∙yz≈zx∙y : ∀ x y z → x ∙ (y ∙ z) ≈ (z ∙ x) ∙ y |
| 93 |
x∙yz≈zx∙y x y z = trans (x∙yz≈z∙xy x y z) (sym (assoc z x y)) |
| 94 |
|
| 95 |
------------------------------------------------------------------------ |
| 96 |
-- Partitions (2,1). |
| 97 |
|
| 98 |
-- Their laws are proved by composing proofs for partitions (1,1) with |
| 99 |
-- trans (assoc x y z). |
| 100 |
|
| 101 |
xy∙z≈y∙xz : ∀ x y z → (x ∙ y) ∙ z ≈ y ∙ (x ∙ z) |
| 102 |
xy∙z≈y∙xz x y z = trans (assoc x y z) (x∙yz≈y∙xz x y z) |
| 103 |
|
| 104 |
xy∙z≈z∙yx : ∀ x y z → (x ∙ y) ∙ z ≈ z ∙ (y ∙ x) |
| 105 |
xy∙z≈z∙yx x y z = trans (assoc x y z) (x∙yz≈z∙yx x y z) |
| 106 |
|
| 107 |
xy∙z≈x∙zy : ∀ x y z → (x ∙ y) ∙ z ≈ x ∙ (z ∙ y) |
| 108 |
xy∙z≈x∙zy x y z = trans (assoc x y z) (x∙yz≈x∙zy x y z) |
| 109 |
|
| 110 |
xy∙z≈y∙zx : ∀ x y z → (x ∙ y) ∙ z ≈ y ∙ (z ∙ x) |
| 111 |
xy∙z≈y∙zx x y z = trans (assoc x y z) (x∙yz≈y∙zx x y z) |
| 112 |
|
| 113 |
xy∙z≈z∙xy : ∀ x y z → (x ∙ y) ∙ z ≈ z ∙ (x ∙ y) |
| 114 |
xy∙z≈z∙xy x y z = trans (assoc x y z) (x∙yz≈z∙xy x y z) |
| 115 |
|
| 116 |
------------------------------------------------------------------------ |
| 117 |
-- Partitions (2,2). |
| 118 |
|
| 119 |
-- These proofs are by composing with the proofs for (2,1). |
| 120 |
|
| 121 |
xy∙z≈yx∙z : ∀ x y z → (x ∙ y) ∙ z ≈ (y ∙ x) ∙ z |
| 122 |
xy∙z≈yx∙z x y z = trans (xy∙z≈y∙xz _ _ _) (sym (assoc y x z)) |
| 123 |
|
| 124 |
xy∙z≈zy∙x : ∀ x y z → (x ∙ y) ∙ z ≈ (z ∙ y) ∙ x |
| 125 |
xy∙z≈zy∙x x y z = trans (xy∙z≈z∙yx x y z) (sym (assoc z y x)) |
| 126 |
|
| 127 |
xy∙z≈xz∙y : ∀ x y z → (x ∙ y) ∙ z ≈ (x ∙ z) ∙ y |
| 128 |
xy∙z≈xz∙y x y z = trans (xy∙z≈x∙zy x y z) (sym (assoc x z y)) |
| 129 |
|
| 130 |
xy∙z≈yz∙x : ∀ x y z → (x ∙ y) ∙ z ≈ (y ∙ z) ∙ x |
| 131 |
xy∙z≈yz∙x x y z = trans (xy∙z≈y∙zx x y z) (sym (assoc y z x)) |
| 132 |
|
| 133 |
xy∙z≈zx∙y : ∀ x y z → (x ∙ y) ∙ z ≈ (z ∙ x) ∙ y |
| 134 |
xy∙z≈zx∙y x y z = trans (xy∙z≈z∙xy x y z) (sym (assoc z x y)) |
| 135 |
|
| 136 |
------------------------------------------------------------------------ |
| 137 |
-- commutative semigroup has Jordan identity |
| 138 |
|
| 139 |
xy∙xx≈x∙yxx : ∀ x y → (x ∙ y) ∙ (x ∙ x) ≈ x ∙ (y ∙ (x ∙ x)) |
| 140 |
xy∙xx≈x∙yxx x y = assoc x y ((x ∙ x)) |
| 141 |
|
| 142 |
------------------------------------------------------------------------ |
| 143 |
-- commutative semigroup is left/right/middle semiMedial |
| 144 |
|
| 145 |
semimedialˡ : LeftSemimedial _∙_ |
| 146 |
semimedialˡ x y z = begin |
| 147 |
(x ∙ x) ∙ (y ∙ z) ≈⟨ assoc x x (y ∙ z) ⟩ |
| 148 |
x ∙ (x ∙ (y ∙ z)) ≈⟨ ∙-congˡ (sym (assoc x y z)) ⟩ |
| 149 |
x ∙ ((x ∙ y) ∙ z) ≈⟨ ∙-congˡ (∙-congʳ (comm x y)) ⟩ |
| 150 |
x ∙ ((y ∙ x) ∙ z) ≈⟨ ∙-congˡ (assoc y x z) ⟩ |
| 151 |
x ∙ (y ∙ (x ∙ z)) ≈⟨ sym (assoc x y ((x ∙ z))) ⟩ |
| 152 |
(x ∙ y) ∙ (x ∙ z) ∎ |
| 153 |
|
| 154 |
semimedialʳ : RightSemimedial _∙_ |
| 155 |
semimedialʳ x y z = begin |
| 156 |
(y ∙ z) ∙ (x ∙ x) ≈⟨ assoc y z (x ∙ x) ⟩ |
| 157 |
y ∙ (z ∙ (x ∙ x)) ≈⟨ ∙-congˡ (sym (assoc z x x)) ⟩ |
| 158 |
y ∙ ((z ∙ x) ∙ x) ≈⟨ ∙-congˡ (∙-congʳ (comm z x)) ⟩ |
| 159 |
y ∙ ((x ∙ z) ∙ x) ≈⟨ ∙-congˡ (assoc x z x) ⟩ |
| 160 |
y ∙ (x ∙ (z ∙ x)) ≈⟨ sym (assoc y x ((z ∙ x))) ⟩ |
| 161 |
(y ∙ x) ∙ (z ∙ x) ∎ |
| 162 |
|
| 163 |
middleSemimedial : ∀ x y z → (x ∙ y) ∙ (z ∙ x) ≈ (x ∙ z) ∙ (y ∙ x) |
| 164 |
middleSemimedial x y z = begin |
| 165 |
(x ∙ y) ∙ (z ∙ x) ≈⟨ assoc x y ((z ∙ x)) ⟩ |
| 166 |
x ∙ (y ∙ (z ∙ x)) ≈⟨ ∙-congˡ (sym (assoc y z x)) ⟩ |
| 167 |
x ∙ ((y ∙ z) ∙ x) ≈⟨ ∙-congˡ (∙-congʳ (comm y z)) ⟩ |
| 168 |
x ∙ ((z ∙ y) ∙ x) ≈⟨ ∙-congˡ ( assoc z y x) ⟩ |
| 169 |
x ∙ (z ∙ (y ∙ x)) ≈⟨ sym (assoc x z ((y ∙ x))) ⟩ |
| 170 |
(x ∙ z) ∙ (y ∙ x) ∎ |
| 171 |
|
| 172 |
semimedial : Semimedial _∙_ |
| 173 |
semimedial = semimedialˡ , semimedialʳ |