Examples.Classical.Magma¶
Worked example: (โ, +) as a magma¶
This is the Examples.Classical.Magma module of the Agda Universal Algebra Library.
The natural numbers under addition form the canonical first magma to exhibit.
Beyond demonstrating that the M3-3 deliverable type-checks, this module is the
home for all future magma-specific worked examples: alternative magmas on โ
(under multiplication, under truncated subtraction), small finite magmas as Cayley
tables, free magmas over a generating set, magmas that fail to be semigroups,
and so on. Subsequent additions should land here rather than alongside the
core structure file.
The magma (โ, +)¶
โ-magma : Magma โ-magma = opsToMagma โ _+_ open Polymorphic.Magma-Op โ-magma using ( _โ_ )
Acceptance checks¶
โ-Op interpreted in โ-magma reduces definitionally to _+_: no opacity from
the opsToMagma construction, no opacity from the Curryโ wrapping in the named
accessor. Discharged by refl.
โ-is-+-ma : โ (a b : โ) โ a โ b โก a + b โ-is-+-ma a b = refl
The bundle bridge round-trips on โ-magma 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.Magma-Op โช โจ โ-magma โฉแตแต โซแตแต using () renaming ( _โ_ to _ยท_ ) roundtrip-โ-ma : โ (a b : โ) โ a ยท b โก a + b roundtrip-โ-ma a b = refl