Examples.Classical.Semigroup¶
Worked example: (β, +) as a semigroup¶
This is the Examples.Classical.Semigroup module of the Agda Universal Algebra Library.
The natural numbers under addition form the canonical first semigroup to exhibit,
mirroring the magma example in Examples.Classical.Magma. Beyond demonstrating
that the M3-4 deliverable type-checks, this module is the home for all future
semigroup-specific worked examples: alternative semigroups on β, finite semigroups,
the free semigroup over a generating set, semigroups that fail to be monoids, and so on.
Subsequent additions should land here rather than alongside the core structure file.
The semigroup (β, +)¶
We build (β, +) directly from stdlib's +-assoc. The eqsToSemigroup constructor
demands an associativity proof of exactly the shape
β a b c β (a + b) + c β‘ a + (b + c), which is the type of +-assoc up to the
definitional equality Associative _+_ = β x y z β (x + y) + z β‘ x + (y + z).
β-semigroup : Semigroup β-semigroup = eqsToSemigroup β _+_ +-assoc open Polymorphic.Semigroup-Op β-semigroup using ( _β_ )
Acceptance checks¶
β-Op interpreted in β-semigroup reduces definitionally to _+_: no opacity
from the eqsToSemigroup construction, from the factoring through
opsToMagma, or from the Curryβ wrapping in the inherited named accessor;
discharged by refl.
β-is-+-sg : β (a b : β) β a β b β‘ a + b β-is-+-sg a b = refl
The forgetful image of β-semigroup is the magma β-magma on the nose.
This holds because eqsToSemigroup is implemented as opsToMagma _Β·_ , <proof>,
so semigroupβmagma (eqsToSemigroup β _+_ +-assoc) reduces to opsToMagma β _+_,
which is exactly the definition of β-magma; discharged by refl.
forgetful-agrees : Polymorphic.semigroupβmagma β-semigroup β‘ β-magma forgetful-agrees = refl
The bundle bridge round-trips on β-semigroup pointwise. Both directions reduce
by pair a b 0F β a and pair a b 1F β b, so propositional refl discharges the
obligation at the curried form (per
ADR-002 v2 Β§6.
open Polymorphic.Semigroup-Op βͺ β¨ β-semigroup β©Λ’α΅ β«Λ’α΅ using () renaming ( _β_ to _Β·_ ) roundtrip-β-sg : β (a b : β) β a Β· b β‘ a + b roundtrip-β-sg a b = refl