Setoid.Subalgebras.Subuniverses¶
Subuniverses of setoid algebras¶
This is the Setoid.Subalgebras.Subuniverses module of the Agda Universal Algebra Library.
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 _ (π¨ : Algebra Ξ± Οα΅) where private A = π[ π¨ ] -- the forgetful functor Subuniverses : Pred (Pred A β) (π β π₯ β Ξ± β β ) Subuniverses B = β 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 _ {π¨ : 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
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).