Examples.Setoid.HSPCommutativeMonoid¶
Worked example: Birkhoff's HSP theorem specialized to (β, +, 0)¶
This is the Examples.Setoid.HSPCommutativeMonoid module of the Agda Universal Algebra Library.
Setoid.Varieties.HSP proves Birkhoff's variety theorem for an arbitrary class
π¦ of algebras over an arbitrary signature. This module instantiates
that theorem at the singleton class π¦β = { (β, +, 0) } over the
monoid signature Sig-Monoid, reusing the commutative monoid
β-commutativeMonoid of Examples.Classical.CommutativeMonoid as
the generating algebra.
We record four facts about the variety V π¦β generated by
(β, +, 0):
- the generating algebra belongs to its own variety (
ββV, from expansiveness ofV); - every identity true in
(β, +, 0)β in particular commutativity β is an identity of the whole variety (V-commutative, from identity preservation); - Birkhoff's theorem, specialized: every model of the equational theory of
V π¦βlies inV π¦β(Birkhoff-β); - and its converse (
Birkhoff-converse-β).
1β 2β : Level 1β = lsuc 0β 2β = lsuc 1β
The generating algebra and the singleton class¶
β-commutativeMonoid is a Ξ£-pair of a Sig-Monoid
algebra and a proof that it satisfies the commutative-monoid equations; its first
projection is the underlying (β, +, 0) setoid algebra.
π¨β : Algebra 0β 0β π¨β = projβ β-commutativeMonoid -- the singleton class { π¨β }, as a one-constructor family. With the explicit-class -- V-expaβ² the closure operators no longer need this shape to infer π¦; we keep the -- data family because π¦ββ«comm (below) reads cleanly by matching its inβ constructor. data π¦β : Pred (Algebra 0β 0β) 1β where inβ : π¦β π¨β π¨ββπ¦β : π¨β β π¦β π¨ββπ¦β = inβ
The variety Vβ² π¦β generated by π¨β. Because every
universe in play here is 0β, we use Vβ² β the common-case
specialization of V that collapses its eight level parameters to
those of the generating class β giving a single concrete predicate
π that the corollaries below can refer to without pinning any
level by hand or leaving unsolved level metavariables.
π : Pred (Algebra 0β 0β) 2β π = Vβ² 0β 1β π¦β
Corollary 1: the generator lies in its own variety¶
V is expansive, so (β, +, 0) belongs to the variety
it generates. We obtain the membership from V-expaβ², the
explicit-class form of expansiveness: the class π¦β is passed
positionally, so nothing has to be inferred and the intermediate levels are pinned
by unification with the Vβ² goal π.
ββV : π¨β β π ββV = V-expaβ² 0β 1β π¦β π¨ββπ¦β
Corollary 2: the variety is commutative¶
Commutativity of (β, +, 0) is exactly +-comm: the
term identity x Β· y β y Β· x holds under every environment. Since
π¦β is the singleton { π¨β }, the class models this
identity; identity preservation (V-id1) then lifts it to the whole
variety.
-- the two sides of the commutativity identity, over two variables xΒ·y yΒ·x : Term (Fin 2) xΒ·y = node β-Op Ξ» { 0F β β 0F ; 1F β β 1F } yΒ·x = node β-Op Ξ» { 0F β β 1F ; 1F β β 0F } π¦ββ«comm : π¦β β« (xΒ·y βΜ yΒ·x) π¦ββ«comm .β«-proof π© inβ Ο = +-comm (Ο 0F) (Ο 1F) V-commutative : π β« (xΒ·y βΜ yΒ·x) V-commutative = V-id1 π¦ββ«comm
Birkhoff's theorem, specialized¶
Finally, the theorem itself and its converse, instantiated at π¦β.
Birkhoff-β : {π¨ : Algebra 0β 0β} β π¨ β Mod (Th (V 0β 1β π¦β)) β π¨ β V 0β 1β π¦β Birkhoff-β = Birkhoff {π¦ = π¦β} Birkhoff-converse-β : {π¨ : Algebra 0β 0β} β π¨ β (V 0β 1β π¦β) β π¨ β Mod (Th (V 0β 1β π¦β)) Birkhoff-converse-β = Birkhoff-converse {π¦ = π¦β} Birkhoff-β' : {π¨ : Algebra 0β 0β} β π¨ β Mod (Th π) β π¨ β V 0β 1β π¦β Birkhoff-β' = Birkhoff {π¦ = π¦β} Birkhoff-converse-β' : {π¨ : Algebra 0β 0β} β π¨ β π β π¨ β Mod (Th π) Birkhoff-converse-β' = Birkhoff-converse {π¦ = π¦β}