Skip to content

[Add] Consequences of identity for monoids #2692

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

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4828f10
Adds reasonig combinator for semigroup
jmougeot Apr 1, 2025
93c9976
Adds reasonig combinator for semigroup
jmougeot Apr 1, 2025
e885711
Adds reasonig combinator for semigroup
jmougeot Apr 1, 2025
3c38b3c
Adds reasonig combinator for semigroup
jmougeot Apr 1, 2025
cd399f7
Add some more missing reasoning combinators
jmougeot Apr 1, 2025
3f79f75
add module Extends
jmougeot Apr 1, 2025
6b9e442
rename SemiGroup to Semigroup
jmougeot Apr 1, 2025
a3a3181
fix-whitespace
jmougeot Apr 1, 2025
f8c8533
Update CHANGELOG.md
jmougeot Apr 2, 2025
19ec1eb
New names
jmougeot Apr 3, 2025
52eaa44
improve syntx
jmougeot Apr 3, 2025
ee3ac5d
fix-whitespace
jmougeot Apr 3, 2025
5d47f4c
Name changes
jmougeot Apr 7, 2025
f4c1245
Names change
jmougeot Apr 7, 2025
9f0a376
Space
jmougeot Apr 7, 2025
3a8d81f
Proof of assoc with PUshes and Pulles
jmougeot Apr 8, 2025
1c13577
Proof of assoc with PUshes and Pulles
jmougeot Apr 8, 2025
79311ae
white space
jmougeot Apr 9, 2025
cc934ca
Update src/Algebra/Properties/Semigroup/Reasoning.agda
jmougeot Apr 10, 2025
17a8964
Reasoning to Semigroup and explicit variables
jmougeot Apr 11, 2025
899099c
Update CHANGELOG.md
jmougeot Apr 14, 2025
4129eed
Add reasonining combinators for monoids
jmougeot Apr 1, 2025
0ab87a6
chore: move imports around in Algebra.Definitions
jmougeot Apr 1, 2025
8eb8a69
Syntax modification
jmougeot Apr 1, 2025
fbf8920
rebase
jmougeot Apr 14, 2025
eb543a8
update semigroup
jmougeot Apr 8, 2025
b742f6f
One line proof
jmougeot Apr 9, 2025
08d797c
move importation
jmougeot Apr 10, 2025
490a28c
fix-whitespace
jmougeot Apr 10, 2025
a34b4b5
Add reasonining combinators for monoids
jmougeot Apr 1, 2025
41696ed
chore: move imports around in Algebra.Definitions
jmougeot Apr 1, 2025
ff966fe
Syntax modification
jmougeot Apr 1, 2025
3cbb91b
rebase
jmougeot Apr 11, 2025
29b22d6
move importation
jmougeot Apr 10, 2025
7cd4230
fix-whitespace
jmougeot Apr 10, 2025
acb6467
explicit varaibles
jmougeot Apr 14, 2025
4b38e08
used of semigroup propreties
jmougeot Apr 14, 2025
64d12ad
update
jmougeot Apr 16, 2025
b0179f5
Update CHANGELOG.md
JacquesCarette Apr 21, 2025
dab0763
merge and proof refactoring
jmougeot Jul 3, 2025
7185d5f
Changelog update
jmougeot Jul 3, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ New modules
Additions to existing modules
-----------------------------

* In `Algebra.Properties.Monoid` adding consequences for identity for monoids

* In `Algebra.Properties.Semigroup` adding consequences for associativity for semigroups

* In `Algebra.Consequences.Base`:
```agda
module Congruence (_≈_ : Rel A ℓ) (cong : Congruent₂ _≈_ _∙_) (refl : Reflexive _≈_)
Expand Down
70 changes: 70 additions & 0 deletions src/Algebra/Properties/Monoid.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- Equational reasoning for monoids
-- (Utilities for identity and cancellation reasoning, extending semigroup reasoning)
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}

open import Algebra.Bundles using (Monoid)
open import Function using (_∘_)

module Algebra.Properties.Monoid {o ℓ} (M : Monoid o ℓ) where

open Monoid M
using (Carrier; _∙_; _≈_; setoid; isMagma; semigroup; ε; sym; identityˡ
; identityʳ ; ∙-cong; refl; assoc; ∙-congˡ; ∙-congʳ; trans)
open import Relation.Binary.Reasoning.Setoid setoid

open import Algebra.Properties.Semigroup semigroup public

private
variable
a b c d : Carrier

id-unique : ∀ a → (∀ b → b ∙ a ≈ b) → a ≈ ε
id-unique a b∙a≈b = trans (sym (identityˡ a)) (b∙a≈b ε)

id-comm : ∀ a → a ∙ ε ≈ ε ∙ a
id-comm a = trans (identityʳ a) (sym (identityˡ a))

id-comm-sym : ∀ a → ε ∙ a ≈ a ∙ ε
id-comm-sym = sym ∘ id-comm

module _ (a≈ε : a ≈ ε) where
elimʳ : ∀ b → b ∙ a ≈ b
elimʳ = trans (∙-congˡ a≈ε) ∘ identityʳ

elimˡ : ∀ b → a ∙ b ≈ b
elimˡ = trans (∙-congʳ a≈ε) ∘ identityˡ

introʳ : ∀ b → b ≈ b ∙ a
introʳ = sym ∘ elimʳ

introˡ : ∀ b → b ≈ a ∙ b
introˡ = sym ∘ elimˡ

introcenter : ∀ c → b ∙ c ≈ b ∙ (a ∙ c)
introcenter c = trans (∙-congˡ (sym (identityˡ c))) (∙-congˡ (∙-congʳ (sym a≈ε)))

module _ (inv : a ∙ c ≈ ε) where

cancelʳ : ∀ b → (b ∙ a) ∙ c ≈ b
cancelʳ b = trans (uv≈w⇒xu∙v≈xw inv b) (identityʳ b)

cancelˡ : ∀ b → a ∙ (c ∙ b) ≈ b
cancelˡ b = trans (uv≈w⇒u∙vx≈wx inv b) (identityˡ b)

insertˡ : ∀ b → b ≈ a ∙ (c ∙ b)
insertˡ = sym ∘ cancelˡ

insertʳ : ∀ b → b ≈ (b ∙ a) ∙ c
insertʳ = sym ∘ cancelʳ

cancelInner : ∀ b d → (b ∙ a) ∙ (c ∙ d) ≈ b ∙ d
cancelInner b d = trans (uv≈w⇒xu∙vy≈x∙wy inv b d) (∙-congˡ (identityˡ d))

insertInner : ∀ b d → b ∙ d ≈ (b ∙ a) ∙ (c ∙ d)
insertInner = λ b d → sym (cancelInner b d)