Classical.Theories.Semigroup¶
The equational theory of semigroups¶
This is the Classical.Theories.Semigroup module of the Agda Universal Algebra Library.
This is the first concrete equational theory module in the Classical/
tree, and as such this file's prose is normative for every subsequent
Classical/Theories/X.lagda.md (Monoid in M3-6, Group in M3-6, Lattice in M3-7,
Ring in M3-8). See ADR-002 v2 ยง3, ยง4
for the design rationale.
The shape established here is:
- An index type
Eq-<Structure> : Typeโ a small named enum whose constructors correspond one-to-one with the defining equations of<Structure>'s theory. For semigroups the index is the singleton enumEq-Semigroupwith sole constructorassoc. Single-equation theories use a singleton enum rather than degenerating the index toโค; the named constructor pays for itself in error-message readability and in symmetry with multi-equation theories landing later. - A theory function
Th-<Structure> : Eq-<Structure> โ Term (Fin n) ร Term (Fin n)composed from the generic equation builders ofClassical.Equations(M3-2) applied to the operation symbols ofSig-<Structure>. The codomain is spelled in its long form rather than abbreviated to_, per the meta-resolution-pitfall note in ADR-002 v2 ยง4. - The variable carrier is
Fin nfor the smallestnthat suffices, per ADR-002 v2 ยง2. Associativity needs three distinct variables, son = 3and the variable patterns at use sites are0F,1F,2FfromData.Fin.Patterns.
Since semigroups share the magma signature Sig-Magma โ semigroups are precisely
those magmas whose binary operation is associative โ there is no Sig-Semigroup.
The variable carrier Fin 3 and the magma signature Sig-Magma together fully
parameterize the equation builder Associative from Classical.Equations.
The index of equations¶
Semigroup's theory has exactly one equation, associativity. The singleton enum
Eq-Semigroup names it.
data Eq-Semigroup : Type where assoc : Eq-Semigroup
The theory map¶
Th-Semigroup sends the sole equation constructor assoc to the associativity
term-pair built by the generic Associative builder from
Classical.Equations. The arity-conformance evidence refl typechecks
because ar-Magma โ-Op reduces definitionally to Fin 2 โ this is what the
Classical/Signatures/Magma arity-function-by-direct-pattern-matching convention
buys us.
Th-Semigroup : Eq-Semigroup โ Term (Fin 3) ร Term (Fin 3) Th-Semigroup assoc = Associative โ-Op refl 0F 1F 2F
Unfolded, Th-Semigroup assoc is the pair ((โ 0F โ โ 1F) โ โ 2F , โ 0F โ (โ 1F โ โ 2F))
of Sig-Magma-terms over the variable carrier Fin 3 โ the left-associated and
right-associated three-fold product, respectively.