agda-lattices¶
Lattice theory in Agda, on top of the Agda Universal Algebra Library,
after Freese, Ježek and Nation's Free Lattices. Every module is checked by
Agda under --without-K --exact-split --safe.
What it is¶
agda-lattices is a library of general lattice theory, written in literate Agda. It covers free lattices (lattice terms, Whitman's solution of the word problem, the free lattice and its universal property, canonical forms, Whitman's condition and semidistributivity, substitutions, free generating sets, embeddings and complexity, Whitman's countable family, and the polynomial-time decision of the order), free generation and breadth in lattices satisfying Whitman's condition, Nation's theorem and its proof for finite lattices, bounded homomorphisms, projective lattices and Kostinsky's theorem, quotients, intervals, modular and distributive lattices, central elements and direct decompositions, finite products, lattices given by their operation tables, and worked examples.
The reference throughout is R. Freese, J. Ježek and J. B. Nation, Free Lattices, Mathematical Surveys and Monographs 42, American Mathematical Society, 1995 (Freese, Ježek, and Nation (1995); FJN below), cited by theorem number. The library is built on the algebras, terms, homomorphisms and congruences of the Agda Universal Algebra Library.
Reading the code
Every page is rendered from the literate source that Agda checks, so the proof you read is the proof that compiles. In the code blocks every token is colored by its role and links to its definition: on this site for the library's own names, on the Agda Universal Algebra Library's site for its names, and among the standard library's pages for the rest. Each module's import scaffolding is folded away; the Show all Agda switch in the header shows it.
-
Free lattices
Lattice terms, Whitman's solution of the word problem and its decision, the free lattice
FL(X)and its universal property, canonical forms. -
Nation's theorem
Nation's argument of FJN Section V.3, on finite lattices given by their operation tables.
-
Kostinsky's theorem
Bounded homomorphisms, projective lattices, and the equivalence for a finitely generated lattice.
-
The sibling library
The Agda Universal Algebra Library: signatures, algebras, homomorphisms, terms, varieties, and Birkhoff's HSP theorem.
The modules¶
Every module is under Lattices; the names below drop that prefix. The
navigation lists the same modules as a tree.
- Free lattices. Free is the barrel of the free-lattice
modules: Free.Term (lattice terms),
Free.Whitman (Whitman's rules and their
decision), Free.Universal (the free lattice
FL(X), soundness and completeness of the rules, FJN Theorems 1.8 and 1.11, and the universal property), Free.Derivability (equational logic), Free.Duality, Free.Canonical with Basic, Algorithm, Uniqueness, Joinands, Recognition, Minimality and JoinIrreducible (canonical forms, FJN Theorems 1.17 to 1.20), Free.Semidistributive (FJN Theorems 1.8 and 1.21 forFL(X)), Free.Substitution (substitutions and the homomorphisms they induce), Free.Generation (free generating sets, FJN Corollaries 1.6 and 1.13, decided), Free.Embedding (FJN Lemma 9.13 and its dual), Free.Complexity (the complexity of an element, never lowered by an embedding), Free.WhitmanPolynomials, Free.FixedPointFree, Free.WhitmanChains and Free.Countable (Whitman's countable family, FJN Theorems 1.23 to 1.29), Free.Whitman.Polynomial (the order decided in polynomial time, FJN Chapter XI, Section 8) and Free.Bounded (homomorphisms into a free lattice are bounded, Kostinsky's Lemma 3.1). - Any lattice. Semidistributive and
Semidistributive.FiniteJoins (the
semidistributive laws and Whitman's condition, FJN Theorem 1.21),
Generation (free generation in a lattice satisfying
Whitman's condition, FJN Corollary 1.12), Breadth
(Jónsson and Kiefer's theorem, FJN Theorem 1.30, Corollary 1.31 and the
4-distributive law), Quotient,
Interval, Dual (the dual lattice),
FilterIdeal (principal filters and ideals, and
their union), OrdinalSum (the glued ordinal sum),
Product (binary and finite products),
Modular with Modular.Dedekind
and Modular.Birkhoff (the modular and
distributive laws, and the
N₅andM₃criteria), Distributive with Distributive.Theory, Distributive.Bundle and Distributive.Small (distributive lattices as a structure, its equational theory, its bridge to the standard library's bundle, and the structure at the lowest universe level), and Central with Central.Decomposition (neutral and central elements, and direct decompositions by central elements). - Bounded lattices and Kostinsky's theorem.
Bounded.Homomorphism (bounded
homomorphisms), Bounded.Covers (join covers and
the sets
D_k(L)), Bounded.Preimage (FJN Theorem 2.6 and Lemma 2.7), Bounded.Sublattice (FJN Corollaries 2.15 and 2.16), Bounded.Finite (the D relation and lower boundedness of a finite lattice, FJN Corollary 2.39), Projective (projective lattices, FJN Theorem 5.1), Kostinsky (Kostinsky's theorem: for a finitely generated lattice, projective, sublattice of a free lattice, and bounded with Whitman's condition are equivalent) and Kostinsky.Finite (its finite case on table lattices). - Nation's theorem. Nation states FJN Theorem 5.55 (a finite lattice is a sublattice of a free lattice if and only if it is semidistributive and satisfies Whitman's condition) as a hypothesis, with its easy direction proved; Nation.Order, Nation.Kappa, Nation.Cycle, Nation.Bounded, Nation.Configurations, Nation.BType, Nation.Lemma542, Nation.Subsequences, Nation.Lemma547, Nation.Lemma548, Nation.Extension, Nation.Lemma551, Nation.Alternating, Nation.NoCycle and Nation.Lemma554 follow Nation's argument of FJN Section V.3 on table lattices, to its conclusion that a finite lattice with both semidistributive laws and Whitman's condition has no C-cycle and is bounded.
- Table lattices. Table builds a finite lattice on
Fin nfrom its operation tables. - Worked examples, under
Examples: FreeLattice3, CountableFree, WhitmanTable (FJN Example 11.32), M3, N5, Mn, Partitions (the partition lattices of three and four elements), TwoByThree, SublatticesOfFree (which five-element lattices are sublattices of a free lattice), Central, L2Distributive (the two-element lattice as a distributive lattice) and L3Heyting (the three-element chain as a Heyting algebra).
What is checked¶
Every module carries the pragma
{-# OPTIONS --without-K --exact-split --safe #-}. Under --safe Agda
refuses postulates, unsafe primitives and non-terminating definitions, so
every theorem is proved from the type theory alone. A worked example may
add --lossy-unification, which --safe accepts;
Examples.Central uses it, and says why.
A statement proved by induction is checked when its proof term has the
stated type. A statement about explicit terms or finite lattices is checked
by computation: Whitman's procedure is a decision s ≤ʷ? t, the properties
of a lattice given by its tables are decided, and Agda evaluates the decision
while it checks the module.
Checking it¶
The toolchain is a Nix flake, so a machine with Nix 2.28 or later, with flakes enabled, needs nothing else:
git clone https://github.com/ualib/agda-lattices.git
cd agda-lattices
nix develop --command make check
make check checks every module's pragma, then type-checks every module
under src/. It exits 0 when every module checks; there is no separate
test step, since type-checking is the test. The Agda is a pre-release of
Agda 2.9.0, which Nix builds from source in about an hour unless it can fetch
it from the public binary cache formalverification on Cachix; the
README says how to use it, and which commits of Agda, the
standard library and the Agda Universal Algebra Library the flake pins.
Citing it¶
The repository's CITATION.cff gives the metadata for citing the library,
and GitHub's "Cite this repository" button formats it. The library is
licensed under the Apache License 2.0; its NOTICE records the attribution
it carries from the Agda Universal Algebra Library, where its first modules
were first written.