Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

middle four exchange law in a Setoid: definition and consequences #1953

Merged
merged 7 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,15 @@ Other minor changes

* Added new proofs to `Algebra.Consequences.Setoid`:
```agda
comm+assoc⇒middleFour : Congruent₂ _•_ → Commutative _•_ → Associative _•_ →
_•_ MiddleFourExchange _•_
identity+middleFour⇒assoc : Congruent₂ _•_ → Identity e _•_ →
_•_ MiddleFourExchange _•_ →
Associative _•_
identity+middleFour⇒comm : Congruent₂ _•_ → Identity e _+_ →
_•_ MiddleFourExchange _+_ →
Commutative _•_

involutive⇒surjective : Involutive f → Surjective f
selfInverse⇒involutive : SelfInverse f → Involutive f
selfInverse⇒congruent : SelfInverse f → Congruent f
Expand Down Expand Up @@ -1666,6 +1675,8 @@ Other minor changes

* Added new definition to `Algebra.Definitions`:
```agda
_MiddleFourExchange_ : Op₂ A → Op₂ A → Set _

SelfInverse : Op₁ A → Set _

LeftDividesˡ : Op₂ A → Op₂ A → Set _
Expand Down
21 changes: 19 additions & 2 deletions src/Algebra/Consequences/Propositional.agda
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import Algebra.Consequences.Setoid (setoid A) as Base

open Base public
hiding
( assoc+distribʳ+idʳ+invʳ⇒zeˡ
( comm+assoc⇒middleFour
; identity+middleFour⇒assoc
; identity+middleFour⇒comm
; assoc+distribʳ+idʳ+invʳ⇒zeˡ
; assoc+distribˡ+idʳ+invʳ⇒zeʳ
; assoc+id+invʳ⇒invˡ-unique
; assoc+id+invˡ⇒invʳ-unique
Expand Down Expand Up @@ -83,13 +86,27 @@ module _ {_•_ _◦_ : Op₂ A} (•-comm : Commutative _•_) where
comm⇒sym[distribˡ] = Base.comm⇒sym[distribˡ] (cong₂ _◦_) •-comm

------------------------------------------------------------------------
-- Selectivity
-- Selectivity and Middle-Four Exchange

module _ {_•_ : Op₂ A} where

sel⇒idem : Selective _•_ → Idempotent _•_
sel⇒idem = Base.sel⇒idem _≡_

comm+assoc⇒middleFour : Commutative _•_ → Associative _•_ →
_•_ MiddleFourExchange _•_
comm+assoc⇒middleFour = Base.comm+assoc⇒middleFour (cong₂ _•_)

identity+middleFour⇒assoc : {e : A} → Identity e _•_ →
_•_ MiddleFourExchange _•_ →
Associative _•_
identity+middleFour⇒assoc = Base.identity+middleFour⇒assoc (cong₂ _•_)

identity+middleFour⇒comm : {_+_ : Op₂ A} {e : A} → Identity e _+_ →
_•_ MiddleFourExchange _+_ →
Commutative _•_
identity+middleFour⇒comm = Base.identity+middleFour⇒comm (cong₂ _•_)

------------------------------------------------------------------------
-- Without Loss of Generality

Expand Down
34 changes: 34 additions & 0 deletions src/Algebra/Consequences/Setoid.agda
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,40 @@ open import Relation.Unary using (Pred)

open import Algebra.Consequences.Base public

------------------------------------------------------------------------
-- Congruence and MiddleFourExchange

module _ {_•_ : Op₂ A} (cong : Congruent₂ _•_) where

comm+assoc⇒middleFour : Commutative _•_ → Associative _•_ →
_•_ MiddleFourExchange _•_
comm+assoc⇒middleFour comm assoc w x y z = begin
(w • x) • (y • z) ≈⟨ assoc w x (y • z) ⟩
w • (x • (y • z)) ≈⟨ cong refl (sym (assoc x y z)) ⟩
w • ((x • y) • z) ≈⟨ cong refl (cong (comm x y) refl) ⟩
w • ((y • x) • z) ≈⟨ cong refl (assoc y x z) ⟩
w • (y • (x • z)) ≈⟨ sym (assoc w y (x • z)) ⟩
(w • y) • (x • z) ∎

identity+middleFour⇒assoc : {e : A} → Identity e _•_ →
_•_ MiddleFourExchange _•_ →
Associative _•_
identity+middleFour⇒assoc {e} (identityˡ , identityʳ) middleFour x y z = begin
(x • y) • z ≈⟨ cong refl (sym (identityˡ z)) ⟩
(x • y) • (e • z) ≈⟨ middleFour x y e z ⟩
(x • e) • (y • z) ≈⟨ cong (identityʳ x) refl ⟩
x • (y • z) ∎

identity+middleFour⇒comm : {_+_ : Op₂ A} {e : A} → Identity e _+_ →
_•_ MiddleFourExchange _+_ →
Commutative _•_
identity+middleFour⇒comm {_+_} {e} (identityˡ , identityʳ) middleFour x y
= begin
x • y ≈⟨ sym (cong (identityˡ x) (identityʳ y)) ⟩
(e + x) • (y + e) ≈⟨ middleFour e x y e ⟩
(e + y) • (x + e) ≈⟨ cong (identityˡ y) (identityʳ x) ⟩
y • x ∎

------------------------------------------------------------------------
-- Involutive/SelfInverse functions

Expand Down
4 changes: 4 additions & 0 deletions src/Algebra/Definitions.agda
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ _*_ DistributesOverʳ _+_ =
_DistributesOver_ : Op₂ A → Op₂ A → Set _
* DistributesOver + = (* DistributesOverˡ +) × (* DistributesOverʳ +)

_MiddleFourExchange_ : Op₂ A → Op₂ A → Set _
_*_ MiddleFourExchange _+_ =
∀ w x y z → ((w + x) * (y + z)) ≈ ((w + y) * (x + z))

_IdempotentOn_ : Op₂ A → A → Set _
_∙_ IdempotentOn x = (x ∙ x) ≈ x

Expand Down