Setoid.Subalgebras.Subuniverses¶
Subuniverses of setoid algebras¶
This is the Setoid.Subalgebras.Subuniverses module of the Agda Universal Algebra Library.
A subuniverse of π¨ is a subset of its carrier that is closed under the
basic operations: whenever every entry of an argument tuple lies in the subset, so
does the result of applying an operation to that tuple. Subuniverses are the
concrete counterpart of the abstract _β€_ of
Setoid.Subalgebras.Basic, which asks only for an embedding and says nothing
about carriers being subsets.
This module defines Subuniverses, the predicate itself, and the
subuniverse Sg generated by an arbitrary subset, given
inductively by a generator constructor and an operation constructor. The two
facts that make generation usable are sgIsSub, that Sg G really
is a subuniverse, and sgIsSmallest, that it is contained in every
subuniverse containing G. Also here: closure of subuniverses under arbitrary
intersection (βs), which is what makes the lattice of
Setoid.Subalgebras.CompleteLattice complete; and hom-unique,
that two homomorphisms agreeing on a generating set agree everywhere.
The term-level results are the remainder. sub-term-closed says a
subuniverse is closed under the term operations: if every variable is sent into
B, so is the value of any term. TermImage approaches the same
ground from the other side, as the inductively defined set of values of terms with
arguments drawn from B, and TermImageIsSub shows it is a
subuniverse containing B (B-onlyif-TermImageB).
Those two facts pin TermImage B down completely: it is the subuniverse
generated by B. SgB-onlyif-TermImageB gives one inclusion,
since Sg B is the smallest subuniverse containing B, and
TermImageB-onlyif-SgB gives the other by induction on
TermImage, a generator already lying in Sg B and Sg B being
closed under the operations. So the generated subuniverse admits two equivalent
descriptions, top-down as the least subuniverse above B and bottom-up as the set
of values of terms over B, and a proof may use whichever is convenient.
One converse is genuinely absent, and it is not this one:
sub-term-closed is not accompanied by a proof that closure under
the term operations implies membership in Subuniverses.
We first show how to represent in Agda the collection of subuniverses of an
algebra π¨. Since a subuniverse is viewed as a subset of the domain of π¨, we
define it as a predicate on π[ π¨ ]. Thus, the collection of subuniverses is a
predicate on predicates on π[ π¨ ].
module _ {π : Signature π π₯}(π¨ : Algebra {π = π} Ξ± Οα΅) where private A = π[ π¨ ] -- the forgetful functor Subuniverses : Pred (Pred A β) (π β π₯ β Ξ± β β ) Subuniverses B = (f : OperationSymbolsOf π) (a : ArityOf π f β A) β Im a β B β (f ^ π¨) a β B -- Subuniverses as a record type record Subuniverse : Type(ov {π = π} (Ξ± β β)) where constructor mksub field sset : Pred A β isSub : sset β Subuniverses -- Subuniverse Generation data Sg (G : Pred A β) : Pred A (π β π₯ β Ξ± β β) where var : β {v} β v β G β v β Sg G app : β f a β Im a β Sg G β (f ^ π¨) a β Sg G
(The inferred types in the app constructor are f : OperationSymbolsOf π and
a : ArityOf π π β π[ π¨ ].)
Given an arbitrary subset X of the domain π[ π¨ ] of an π-algebra π¨, the
type Sg X does indeed represent a subuniverse of π¨. Proving this using the
inductive type Sg is trivial, as we see here.
sgIsSub : {G : Pred A β} β Sg G β Subuniverses sgIsSub = app
Next we prove by structural induction that Sg X is the smallest subuniverse of π¨ containing X.
sgIsSmallest : {G : Pred A β}(B : Pred A Οα΅) β B β Subuniverses β G β B β Sg G β B sgIsSmallest _ _ GβB (var Gx) = GβB Gx sgIsSmallest B Bβ€A GβB {.((f ^ π¨) a)} (app f a SgGa) = Goal where IH : Im a β B IH i = sgIsSmallest B Bβ€A GβB (SgGa i) Goal : (f ^ π¨) a β B Goal = Bβ€A f a IH
When the element of Sg G is constructed as app f a SgGa, we may assume (the induction hypothesis) that the arguments in the tuple a belong to B. Then the result of applying f to a also belongs to B since B is a subuniverse.
module _ {π¨ : Algebra {π = π} Ξ± Οα΅} where private A = π[ π¨ ] βs : {ΞΉ : Level}(I : Type ΞΉ){Ο : Level}{π : I β Pred A Ο} β (β i β π i β Subuniverses π¨) β β I π β Subuniverses π¨ βs I Ο f a Ξ½ = Ξ» i β Ο i f a (Ξ» x β Ξ½ x i)
In the proof above, we assume the following typing judgments:
Ξ½ : Im a β β I π
a : ArityOf π f β Setoid.Subalgebras.A π¨
f : OperationSymbolsOf π
Ο : (i : I) β π i β Subuniverses π¨
and we must prove (f ^ π¨) a β β I π. (The command C-c C-a works in this case;
Agda fills in the proof term Ξ» i β Ο i f a (Ξ» x β Ξ½ x i) automatically.)
module _ {π : Signature π π₯}{π¨ : Algebra {π = π} Ξ± Οα΅} where private A = π[ π¨ ] open Setoid using ( Carrier ) open Environment π¨ open Func renaming ( to to _β¨$β©_ ) -- subuniverses are closed under the action of term operations sub-term-closed : (B : Pred A β) β (B β Subuniverses π¨) β (t : Term {π = π} X) β (b : Carrier (Env X)) β (β x β b x β B) β β¦ t β§ β¨$β© b β B sub-term-closed _ _ (β x) b Bb = Bb x sub-term-closed B Bβ€A (node f t)b Ξ½ = Bβ€A f (Ξ» z β β¦ t z β§ β¨$β© b) Ξ» x β sub-term-closed B Bβ€A (t x) b Ξ½
In the induction step of the foregoing proof, the typing judgments of the premise are the following:
Ξ½ : (x : X) β b x β B
b : Setoid.Carrier (Env X)
t : ArityOf π f β Term X
f : OperationSymbolsOf π
Ο : B β Subuniverses π¨
B : Pred A Ο
Ο : Level
π¨ : Algebra Ξ± Οα΅
and the given proof term establishes the goal β¦ node f t β§ β¨$β© b β B.
Alternatively, we could express the preceeding fact using an inductive type representing images of terms.
data TermImage (B : Pred A Οα΅) : Pred A (π β π₯ β Ξ± β Οα΅) where var : β {b : A} β b β B β b β TermImage B app : β f ts β ((i : ArityOf π f) β ts i β TermImage B) β (f ^ π¨) ts β TermImage B -- `TermImage B` is a subuniverse of π¨ that contains B. TermImageIsSub : {B : Pred A Οα΅} β TermImage B β Subuniverses π¨ TermImageIsSub = app B-onlyif-TermImageB : {B : Pred A Οα΅} β B β TermImage B B-onlyif-TermImageB Ba = var Ba -- Since `Sg B` is the smallest subuniverse containing B, we obtain the following inclusion. SgB-onlyif-TermImageB : (B : Pred A Οα΅) β Sg π¨ B β TermImage B SgB-onlyif-TermImageB B = sgIsSmallest π¨ (TermImage B) TermImageIsSub B-onlyif-TermImageB -- The reverse inclusion, by induction on TermImage: a generator is already in -- `Sg B`, and `Sg B` is closed under the operations. TermImageB-onlyif-SgB : (B : Pred A Οα΅) β TermImage B β Sg π¨ B TermImageB-onlyif-SgB B (var Ba) = var Ba TermImageB-onlyif-SgB B (app f ts Ξ½) = app f ts (Ξ» i β TermImageB-onlyif-SgB B (Ξ½ i))
A basic but important fact about homomorphisms is that they are uniquely determined by
the values they take on a generating set. This is the content of the next theorem, which
we call hom-unique.
module _ {π© : Algebra {π = π} Ξ² Οα΅} (gh hh : hom π¨ π©) where open Algebra π© using ( Interp ) renaming ( Domain to B ) open Setoid B using ( _β_ ; sym ) open Func using ( cong ) renaming ( to to _β¨$β©_ ) open SetoidReasoning B private g = _β¨$β©_ (projβ gh) h = _β¨$β©_ (projβ hh) open IsHom open Environment π© hom-unique : (G : Pred A β) β ((x : A) β (x β G β g x β h x)) β (a : A) β (a β Sg π¨ G β g a β h a) hom-unique G Ο a (var Ga) = Ο a Ga hom-unique G Ο .((f ^ π¨) a) (app f a SgGa) = Goal where IH : β i β h (a i) β g (a i) IH i = sym (hom-unique G Ο (a i) (SgGa i)) Goal : g ((f ^ π¨) a) β h ((f ^ π¨) a) Goal = begin g ((f ^ π¨) a) ββ¨ compatible (projβ gh) β© (f ^ π©)(g β a ) βΛβ¨ cong Interp (refl , IH) β© (f ^ π©)(h β a) βΛβ¨ compatible (projβ hh) β© h ((f ^ π¨) a ) β
In the induction step, the following typing judgments are assumed:
SgGa : Im a β Sg π¨ G
a : ArityOf π f β Subuniverses π¨
f : OperationSymbolsOf π
Ο : (x : A) β x β G β g x β h x
G : Pred A β
hh : hom π¨ π©
gh : hom π¨ π©
and, under these assumptions, we proved g ((f ^ π¨) a) β h ((f ^ π¨) a).