Classical.Equations¶
Equations of Classical Structures¶
This is the Classical.Equations module of the Agda Universal Algebra Library.
It is the syntactic dual of the standard library's Algebra.Definitions module.
The standard library's
Algebra.Definitions
provides a uniform inventory of equation predicates at the evaluated level.
For example, given a carrier A, an equivalence _β_, and an operation,
Associative _β_ _β_ is the type β x y z β (x β y) β z β x β (y β z). This is
what stdlib's IsSemigroup.assoc returns and what users prove for concrete algebras.
This module is the syntactic dual; given a signature π and operation
symbols within it (with arity proofs), Associative β-Op refl returns a function
from three variables to a pair of Sig-π-terms β the LHS (β x β β y) β β z and
the RHS β x β (β y β β z). This is what Th-X : Eq-X β Term (Fin n) Γ Term (Fin n)
is built from, and is what feeds the equational-logic core (Modα΅) for every
concrete theory under Classical/Theories/.
Both views are needed; neither subsumes the other. Algebra.Definitions is what you
prove a specific algebra satisfies; Classical.Equations is what you state
as part of a variety's defining theory, before any algebra is in the picture.
The distinction is the same as the distinction between an equation
(x Β· y) Β· z = x Β· (y Β· z) as a formula (a string of symbols) versus the same
equation as a proposition about a particular algebraic structure (a thing that can
be proved).
The universal-algebra meta-theory operates on the formula view; the user proving
things about a specific algebra operates on the proposition view. The relationship
between the two is mediated by interpretation: Modα΅ Th-X π¨ says "for every equation
(s, t) in Th-X, the formula s β t interpreted in π¨ holds for all environments."
The motivation for distinguishing the two views formally β beyond cleanliness β comes from results like Bryant's The laws of finite pointed groups (Bull. LMS 14 (1982), 119β123), which is a stark illustration of the fact that the equational theory of a structure can depend substantively on the signature it lives over, not just on the carrier and operations. A formal account of equations as syntactic objects, distinct from their evaluations in particular algebras, is what makes that distinction expressible.
See ADR-002 v2 Β§3 for more details about the design rationale.
Note for per-structure-theory authors. The arity-conformance evidence refl
typechecks only when the signature's arity function reduces definitionally to
Fin n on the operation symbol in question. Define arity functions by direct
pattern matching on operation-symbol constructors (ar-X β-Op = Fin 2); avoid
indirect definitions (table lookups, conditionals) that would leave the arity opaque
to the type checker.
The equation-builder API is parameterized over a fixed signature π. Each builder
takes operation symbols from π together with evidence that the symbols' arities
match the equation's shape; given that, the builder returns a function from
however-many-variables-the-equation-needs to a pair of terms over the signature.
Associative, Commutative, and Idempotent Laws¶
-- f (f x y) z β f x (f y z) Associative : (f : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β X β X β X β Term X Γ Term X Associative _ f-bin x y z = appβ f-bin (appβ f-bin (β x) (β y)) (β z) , appβ f-bin (β x) (appβ f-bin (β y) (β z)) -- f x y β f y x Commutative : (f : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β X β X β Term X Γ Term X Commutative _ f-bin x y = appβ f-bin (β x) (β y) , appβ f-bin (β y) (β x) -- f x x β x Idempotent : (f : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β X β Term X Γ Term X Idempotent _ f-bin x = appβ f-bin (β x) (β x) , β x
Identity laws¶
These take a binary operation f together with a nullary "identity element" symbol
e. The arity-conformance evidence for e is ArityOf e β‘ Fin 0, consistent with
the Op (Fin 0) A representation of nullary operations in
Classical.Operations.
-- f e x β x LeftIdentity : (f e : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β ArityOf π e β‘ Fin 0 β X β Term X Γ Term X LeftIdentity _ _ f-bin e-nul x = appβ f-bin (appβ e-nul) (β x) , β x -- f x e β x RightIdentity : (f e : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β ArityOf π e β‘ Fin 0 β X β Term X Γ Term X RightIdentity _ _ f-bin e-nul x = appβ f-bin (β x) (appβ e-nul) , β x
Inverse laws¶
These take a binary f, a nullary identity e, and a unary inverse i. The arity
evidence for i is ArityOf i β‘ Fin 1.
-- f (i x) x β e LeftInverse : (f i e : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β ArityOf π i β‘ Fin 1 β ArityOf π e β‘ Fin 0 β X β Term X Γ Term X LeftInverse _ _ _ f-bin i-un e-nul x = appβ f-bin (appβ i-un (β x)) (β x) , appβ e-nul -- f x (i x) β e RightInverse : (f i e : OperationSymbolsOf π) β ArityOf π f β‘ Fin 2 β ArityOf π i β‘ Fin 1 β ArityOf π e β‘ Fin 0 β X β Term X Γ Term X RightInverse _ _ _ f-bin i-un e-nul x = appβ f-bin (β x) (appβ i-un (β x)) , appβ e-nul
Distributive laws¶
-- x Β· (y + z) β (x Β· y) + (x Β· z) DistributesOverΛ‘ : (Β· + : OperationSymbolsOf π) β ArityOf π Β· β‘ Fin 2 β ArityOf π + β‘ Fin 2 β X β X β X β Term X Γ Term X DistributesOverΛ‘ _ _ Β·-bin +-bin x y z = appβ Β·-bin (β x) (appβ +-bin (β y) (β z)) , appβ +-bin (appβ Β·-bin (β x) (β y)) (appβ Β·-bin (β x) (β z)) -- (y + z) Β· x β (y Β· x) + (z Β· x) DistributesOverΚ³ : (Β· + : OperationSymbolsOf π) β ArityOf π Β· β‘ Fin 2 β ArityOf π + β‘ Fin 2 β X β X β X β Term X Γ Term X DistributesOverΚ³ _ _ Β·-bin +-bin x y z = appβ Β·-bin (appβ +-bin (β y) (β z)) (β x) , appβ +-bin (appβ Β·-bin (β y) (β x)) (appβ Β·-bin (β z) (β x))
Absorption laws¶
These take two binary operations f and g; each builder expresses one
direction of the absorption between them. In a lattice, f and g are
typically β§ and β¨, and both directions appear in the theory.
-- x β¨ (x β§ y) β x AbsorbsLeft : (β¨ β§ : OperationSymbolsOf π) β ArityOf π β¨ β‘ Fin 2 β ArityOf π β§ β‘ Fin 2 β X β X β Term X Γ Term X AbsorbsLeft _ _ β¨-bin β§-bin x y = appβ β¨-bin (β x) (appβ β§-bin (β x) (β y)) , β x -- (x β¨ y) β§ x β x AbsorbsRight : (β¨ β§ : OperationSymbolsOf π) β ArityOf π β¨ β‘ Fin 2 β ArityOf π β§ β‘ Fin 2 β X β X β Term X Γ Term X AbsorbsRight _ _ β¨-bin β§-bin x y = appβ β§-bin (appβ β¨-bin (β x) (β y)) (β x) , β x
In Th-Lattice, both AbsorbsLeft β§-Op β¨-Op refl refl and AbsorbsRight
... appear as separate entries in Eq-Lattice.
This inventory covers every equation in Th-Magma (none), Th-Semigroup
(associativity), Th-Monoid (associativity, left/right identity), Th-Group (the
monoid equations + left/right inverse), Th-CommutativeMonoid (monoid +
commutativity), Th-Semilattice (associativity + commutativity + idempotency),
Th-Lattice (two associative + two commutative + two idempotent + two absorption),
Th-Semiring and Th-Ring (the additive and multiplicative components + the two
distributivity laws + ring-specific identities). Builders for less-uniform equations
(the medial law, semigroup-with-identity-element-of-arity-two, etc.) are added
per-need.