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 52 commits into
base: master
Choose a base branch
from

Conversation

jmougeot
Copy link
Contributor

Introduce reasoning combinators for monoids.

This PR is intended to focus on the Monoid.Reasoning filr as the discussion regarding the Semigroup.reasonig file is in the PR : #2688

I went with the names from agda-categories since they seemed to make sense.

@jamesmckinna
Copy link
Contributor

jamesmckinna commented Apr 10, 2025

Probably the 'best' thing to do is to mark this as blocked (on #2688 ), otherwise you'll end up with merge conflicts when that PR gets merged, and indeed to start afresh with this PR being on a branch based on jmougeot/semigroup (or else: rebase this one against that branch). That keeps both the locality of each PR smaller, but also the (sequential) dependency between them.

@jamesmckinna jamesmckinna added addition status: blocked-by-issue Progress on this issue or PR is blocked by another issue. labels Apr 10, 2025
@jamesmckinna jamesmckinna added this to the v2.3 milestone Apr 10, 2025

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

open import Algebra.Structures using (IsMagma)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with #2688 there's no need to make this explicit, it's even an abstraction failure/violation to do so

@jamesmckinna
Copy link
Contributor

Suggest corresponding title change for the PR in the spirit of that for #2688 ...

@jmougeot jmougeot changed the title [Add] reasoning combinators monoids [Add] Consequences of identity for monoids Apr 10, 2025
@jmougeot jmougeot changed the title [Add] Consequences of identity for monoids [Add] Consequences of identity for monoids Apr 10, 2025
uv≈wx⇒u∙vy≈w∙xy y = trans (uv≈w⇒u∙vx≈wx uv≈wx y) (assoc w x y)

uv≈wx⇒yu∙vz≈yw∙xz : ∀ y z → (y ∙ u) ∙ (v ∙ z) ≈ (y ∙ w) ∙ (x ∙ z)
uv≈wx⇒yu∙vz≈yw∙xz y z = trans (uv≈w⇒xu∙v≈xw (uv≈wx⇒u∙vy≈w∙xy z) y)(sym (assoc y w (x ∙ z)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space

Suggested change
uv≈wx⇒yu∙vz≈yw∙xz y z = trans (uv≈w⇒xu∙v≈xw (uv≈wx⇒u∙vy≈w∙xy z) y)(sym (assoc y w (x ∙ z)))
uv≈wx⇒yu∙vz≈yw∙xz y z = trans (uv≈w⇒xu∙v≈xw (uv≈wx⇒u∙vy≈w∙xy z) y) (sym (assoc y w (x ∙ z)))

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

module _ {a b : Carrier} (a≈ε : a ≈ ε) where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the variable block above means you don't need {a b : Carrier} anymore

elimˡ b = trans (∙-congʳ a≈ε) (identityˡ b)

introʳ : ∀ b → b ≈ b ∙ a
introʳ b = sym (elimʳ b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eta-reduce, here and next

introˡ b = sym (elimˡ b)

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should use a superscript m (for 'middle') or c (for, indeed, 'center') instead of spelling it out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta: a good general point that, besides 'left' and 'right' (modulo collective mutual misunderstanding/inconsistency about what such conventions might even mean #2654 ), we don't have good heuristics about super-/sub-scripts and their intended semantics. I think I'd be happy with or ... but nervous about establishing a precedent without further thought/discussion?

CHANGELOG.md Outdated
@@ -123,7 +123,7 @@ New modules

* `Data.Sign.Show` to show a sign

Additions to existing modules
* `Algebra.Properties.Semigroup` adding consequences for associatvity for semigroups
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you need to revert this change.
The lemmas added to Algebra.Properties.Semigroup should each be added in an Agda code block under this line moved to be a sub-heading underneath this section heading...


open import Algebra.Bundles using (Monoid)

module Algebra.Properties.Monoid.Reasoning {o ℓ} (M : Monoid o ℓ) where
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As usual: these lemmas belong in Algebra.Properties.Monoid, not in a separate module as you have it.

By all means do initial development in that style before raising a PR, or else mark it as DRAFT (and hence not ready-for-review) but once you do raise the PR/ask for review, we do need it to be compatible both with the existing stdlib hierarchy/structure, but also with the style-guide, or else we will expend a lot of extra reviewing energy on things which should have been fixed ahead of time.

JacquesCarette and others added 2 commits April 21, 2025 13:30
Co-authored-by: jamesmckinna <[email protected]>
Co-authored-by: jamesmckinna <[email protected]>
module _ (inv : a ∙ c ≈ ε) where

cancelʳ : ∀ b → (b ∙ a) ∙ c ≈ b
cancelʳ b = trans (assoc b a c) (trans (∙-congˡ inv) (identityʳ b))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm quite sure this can be done in 2 steps via one of the Semigroup combinators. Same for on the left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition status: blocked-by-issue Progress on this issue or PR is blocked by another issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants