Agda UALib ↑


Subuniverses

This section presents the Subalgebras.Subuniverses module of the Agda Universal Algebra Library.

We start by defining a type that represents the important concept of subuniverse. Suppose 𝑨 is an algebra. A subset B βŠ† ∣ 𝑨 ∣ is said to be closed under the operations of 𝑨 if for each 𝑓 ∈ ∣ 𝑆 ∣ and all tuples 𝒃 : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ 𝐡 the element (𝑓 Μ‚ 𝑨) 𝒃 belongs to B. If a subset B βŠ† 𝐴 is closed under the operations of 𝑨, then we call B a subuniverse of 𝑨.


{-# OPTIONS --without-K --exact-split --safe #-}

open import Algebras.Signatures using (Signature; π“ž; π“₯)

module Subalgebras.Subuniverses {𝑆 : Signature π“ž π“₯} where

open import Terms.Operations{𝑆 = 𝑆} public
open import Relation.Unary using (β‹‚) public

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 _ {𝓀 𝓦 : Universe} where

 Subuniverses : (𝑨 : Algebra 𝓀 𝑆) β†’ Pred (Pred ∣ 𝑨 ∣ 𝓦)(π“ž βŠ” π“₯ βŠ” 𝓀 βŠ” 𝓦)
 Subuniverses 𝑨 B = (𝑓 : ∣ 𝑆 ∣)(π‘Ž : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ ∣ 𝑨 ∣) β†’ Im π‘Ž βŠ† B β†’ (𝑓 Μ‚ 𝑨) π‘Ž ∈ B

Here’s one way to construct an algebra out of a subuniverse.


 SubunivAlg : (𝑨 : Algebra 𝓀 𝑆)(B : Pred ∣ 𝑨 ∣ 𝓦) β†’ B ∈ Subuniverses 𝑨 β†’ Algebra (𝓀 βŠ” 𝓦) 𝑆
 SubunivAlg 𝑨 B B∈SubA = Ξ£ B , Ξ» 𝑓 𝑏 β†’ (𝑓 Μ‚ 𝑨)(fst ∘ 𝑏) , B∈SubA 𝑓 (fst ∘ 𝑏)(snd ∘ 𝑏)

Subuniverses as records

Next we define a type to represent a single subuniverse of an algebra. If 𝑨 is the algebra in question, then a subuniverse of 𝑨 is a subset of (i.e., predicate over) the domain ∣ 𝑨 ∣ that belongs to Subuniverses 𝑨.


 record Subuniverse {𝑨 : Algebra 𝓀 𝑆} : ov (𝓀 βŠ” 𝓦) Μ‡ where
  constructor mksub
  field
    sset  : Pred ∣ 𝑨 ∣ 𝓦
    isSub : sset ∈ Subuniverses 𝑨

Subuniverse Generation

If 𝑨 is an algebra and X βŠ† ∣ 𝑨 ∣ a subset of the domain of 𝑨, then the subuniverse of 𝑨 generated by X is typically denoted by Sg𝑨(X) and defined to be the smallest subuniverse of 𝑨 containing X. Equivalently,

Sg𝑨(X) = β‹‚ { U : U is a subuniverse of 𝑨 and B βŠ† U }.

We define an inductive type, denoted by Sg, that represents the subuniverse generated by a given subset of the domain of a given algebra, as follows.


 data Sg (𝑨 : Algebra 𝓀 𝑆)(X : Pred ∣ 𝑨 ∣ 𝓦) : Pred ∣ 𝑨 ∣ (π“ž βŠ” π“₯ βŠ” 𝓦 βŠ” 𝓀) where
  var : βˆ€ {v} β†’ v ∈ X β†’ v ∈ Sg 𝑨 X
  app : (𝑓 : ∣ 𝑆 ∣)(π‘Ž : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ ∣ 𝑨 ∣) β†’ Im π‘Ž βŠ† Sg 𝑨 X β†’ (𝑓 Μ‚ 𝑨) π‘Ž ∈ Sg 𝑨 X

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.


module _ {𝓀 𝓦 : Universe} where

 sgIsSub : {𝑨 : Algebra 𝓀 𝑆}{X : Pred ∣ 𝑨 ∣ 𝓦} β†’ Sg 𝑨 X ∈ Subuniverses 𝑨
 sgIsSub = app

Next we prove by structural induction that Sg X is the smallest subuniverse of 𝑨 containing X.


 sgIsSmallest : {𝓑 : Universe}(𝑨 : Algebra 𝓀 𝑆){X : Pred ∣ 𝑨 ∣ 𝓦}(Y : Pred ∣ 𝑨 ∣ 𝓑)
  β†’             Y ∈ Subuniverses 𝑨  β†’  X βŠ† Y  β†’  Sg 𝑨 X βŠ† Y

 sgIsSmallest _ _ _ XinY (var Xv) = XinY Xv

 sgIsSmallest 𝑨 Y YsubA XinY (app 𝑓 π‘Ž SgXa) = fa∈Y
  where
  IH : Im π‘Ž βŠ† Y
  IH i = sgIsSmallest 𝑨 Y YsubA XinY (SgXa i)

  fa∈Y : (𝑓 Μ‚ 𝑨) π‘Ž ∈ Y
  fa∈Y = YsubA 𝑓 π‘Ž IH

When the element of Sg X is constructed as app 𝑓 π‘Ž SgXa, we may assume (the induction hypothesis) that the arguments in the tuple π‘Ž belong to Y. Then the result of applying 𝑓 to π‘Ž also belongs to Y since Y is a subuniverse.

Subuniverse Lemmas

Here we formalize a few basic properties of subuniverses. First, the intersection of subuniverses is again a subuniverse.


module _ {π“˜ 𝓀 𝓦 : Universe} where

 sub-intersection : {𝑨 : Algebra 𝓀 𝑆}{I : π“˜ Μ‡}{π’œ : I β†’ Pred ∣ 𝑨 ∣ 𝓦}
  β†’                 Ξ  i κž‰ I , π’œ i ∈ Subuniverses 𝑨
                    ----------------------------------
  β†’                 β‹‚ I π’œ ∈ Subuniverses 𝑨

 sub-intersection Ξ± 𝑓 π‘Ž Ξ² = Ξ» i β†’ Ξ± i 𝑓 π‘Ž (Ξ» x β†’ Ξ² x i)

In the proof above, we assume the following typing judgments:

 Ξ± : βˆ€ i β†’ π’œ i ∈ Subuniverses 𝑨
 𝑓 : ∣ 𝑆 ∣
 π‘Ž : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ ∣ 𝑨 ∣
 Ξ² : Im π‘Ž βŠ† β‹‚ I π’œ

and we must prove (𝑓 Μ‚ 𝑨) π‘Ž ∈ β‹‚ I π’œ. In this case, Agda will fill in the proof term Ξ» i β†’ Ξ± i 𝑓 π‘Ž (Ξ» x β†’ Ξ² x i) automatically with the command C-c C-a.

Next, subuniverses are closed under the action of term operations.


module _ {𝓀 𝓦 : Universe} where

 sub-term-closed : {𝓧 : Universe}{X : 𝓧 Μ‡}(𝑨 : Algebra 𝓀 𝑆){B : Pred ∣ 𝑨 ∣ 𝓦}
  β†’                (B ∈ Subuniverses 𝑨) β†’ (t : Term X)(b : X β†’ ∣ 𝑨 ∣)
  β†’                Ξ  x κž‰ X , (b x ∈ B)  β†’  (t Μ‡ 𝑨) b ∈ B

 sub-term-closed 𝑨 AB (β„Š x) b Bb = Bb x
 sub-term-closed 𝑨 {B} Ξ± (node 𝑓 𝑑) b Ξ² = Ξ± 𝑓 (Ξ» z β†’ (𝑑 z Μ‡ 𝑨) b) (Ξ» x β†’ sub-term-closed 𝑨 {B} Ξ± (𝑑 x) b Ξ²)

In the induction step of the foregoing proof, the typing judgments of the premise are the following:

𝑨   : Algebra 𝓀 𝑆
B   : Pred ∣ 𝑨 ∣ 𝓦
Ξ±   : B ∈ Subuniverses 𝑨
𝑓   : ∣ 𝑆 ∣
𝑑   : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ Term X
b   : X β†’ ∣ 𝑨 ∣
Ξ²   : βˆ€ x β†’ b x ∈ B

and the given proof term establishes the goal (node 𝑓 𝑑 Μ‡ 𝑨) b ∈ B.

Alternatively, we could express the preceeding fact using an inductive type representing images of terms.


 data TermImage (𝑨 : Algebra 𝓀 𝑆)(Y : Pred ∣ 𝑨 ∣ 𝓦) : Pred ∣ 𝑨 ∣ (π“ž βŠ” π“₯ βŠ” 𝓀 βŠ” 𝓦)
  where
  var : βˆ€ {y : ∣ 𝑨 ∣} β†’ y ∈ Y β†’ y ∈ TermImage 𝑨 Y
  app : βˆ€ 𝑓 𝑑 β†’  Ξ  x κž‰ βˆ₯ 𝑆 βˆ₯ 𝑓 , 𝑑 x ∈ TermImage 𝑨 Y  β†’ (𝑓 Μ‚ 𝑨) 𝑑 ∈ TermImage 𝑨 Y

By what we proved above, it should come as no surprise that TermImage 𝑨 Y is a subuniverse of 𝑨 that contains Y.


 TermImageIsSub : {𝑨 : Algebra 𝓀 𝑆}{Y : Pred ∣ 𝑨 ∣ 𝓦} β†’ TermImage 𝑨 Y ∈ Subuniverses 𝑨
 TermImageIsSub = app

 Y-onlyif-TermImageY : {𝑨 : Algebra 𝓀 𝑆}{Y : Pred ∣ 𝑨 ∣ 𝓦} β†’ Y βŠ† TermImage 𝑨 Y
 Y-onlyif-TermImageY {a} Ya = var Ya

Since Sg 𝑨 Y is the smallest subuniverse containing Y, we obtain the following inclusion.


 SgY-onlyif-TermImageY : (𝑨 : Algebra 𝓀 𝑆)(Y : Pred ∣ 𝑨 ∣ 𝓦) β†’ Sg 𝑨 Y βŠ† TermImage 𝑨 Y
 SgY-onlyif-TermImageY 𝑨 Y = sgIsSmallest 𝑨 (TermImage 𝑨 Y) TermImageIsSub Y-onlyif-TermImageY

Homomorphic images are subuniverses

Now that we have developed the machinery of subuniverse generation, we can prove two basic facts that play an important role in many theorems about algebraic structures. First, the image of a homomorphism is a subuniverse of its codomain.


 hom-image-is-sub : dfunext π“₯ 𝓦 β†’ {𝑨 : Algebra 𝓀 𝑆}{𝑩 : Algebra 𝓦 𝑆}
                    (Ο• : hom 𝑨 𝑩) β†’ (HomImage 𝑩 Ο•) ∈ Subuniverses 𝑩

 hom-image-is-sub fe {𝑨}{𝑩} Ο• 𝑓 b Imfb = eq ((𝑓 Μ‚ 𝑩) b) ((𝑓 Μ‚ 𝑨) ar) Ξ³
  where
  ar : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ ∣ 𝑨 ∣
  ar = Ξ» x β†’ Inv ∣ Ο• ∣ (Imfb x)

  ΞΆ : ∣ Ο• ∣ ∘ ar ≑ b
  ΞΆ = fe (Ξ» x β†’ InvIsInv ∣ Ο• ∣ (Imfb x))

  Ξ³ : (𝑓 Μ‚ 𝑩) b ≑ ∣ Ο• ∣ ((𝑓 Μ‚ 𝑨) ar)
  Ξ³ = (𝑓 Μ‚ 𝑩) b            β‰‘βŸ¨ ap (𝑓 Μ‚ 𝑩)(ΞΆ ⁻¹) ⟩
      (𝑓 Μ‚ 𝑩) (∣ Ο• ∣ ∘ ar) β‰‘βŸ¨(βˆ₯ Ο• βˆ₯ 𝑓 ar)⁻¹ ⟩
      ∣ Ο• ∣ ((𝑓 Μ‚ 𝑨) ar)   ∎

Next we prove the important fact that homomorphisms are uniquely determined by their values on a generating set.


 hom-unique : funext π“₯ 𝓦 β†’ {𝑨 : Algebra 𝓀 𝑆}{𝑩 : Algebra 𝓦 𝑆}
              (X : Pred ∣ 𝑨 ∣ 𝓀)  (g h : hom 𝑨 𝑩)
  β†’           Ξ  x κž‰ ∣ 𝑨 ∣ , (x ∈ X β†’ ∣ g ∣ x ≑ ∣ h ∣ x)
              -------------------------------------------------
  β†’           Ξ  a κž‰ ∣ 𝑨 ∣ , (a ∈ Sg 𝑨 X β†’ ∣ g ∣ a ≑ ∣ h ∣ a)

 hom-unique _ _ _ _ Ξ± a (var x) = Ξ± a x

 hom-unique fe {𝑨}{𝑩} X g h Ξ± fa (app 𝑓 𝒂 Ξ²) = ∣ g ∣ ((𝑓 Μ‚ 𝑨) 𝒂)   β‰‘βŸ¨ βˆ₯ g βˆ₯ 𝑓 𝒂 ⟩
                                               (𝑓 Μ‚ 𝑩)(∣ g ∣ ∘ 𝒂 ) β‰‘βŸ¨ ap (𝑓 Μ‚ 𝑩)(fe IH) ⟩
                                               (𝑓 Μ‚ 𝑩)(∣ h ∣ ∘ 𝒂)  β‰‘βŸ¨ ( βˆ₯ h βˆ₯ 𝑓 𝒂 )⁻¹ ⟩
                                               ∣ h ∣ ((𝑓 Μ‚ 𝑨) 𝒂 )  ∎
  where IH = Ξ» x β†’ hom-unique fe {𝑨}{𝑩} X g h Ξ± (𝒂 x) (Ξ² x)

In the induction step, we have the following typing judgments in the premise:

fe  : funext π“₯ 𝓦
𝑨   : Algebra 𝓀 𝑆
𝑩   : Algebra 𝓦 𝑆
X   : Pred ∣ 𝑨 ∣ 𝓀
g h  : hom 𝑨 𝑩
Ξ±   : Ξ  x κž‰ ∣ 𝑨 ∣ , (x ∈ X β†’ ∣ g ∣ x ≑ ∣ h ∣ x)
fa  : ∣ 𝑨 ∣
fa  = (𝑓 Μ‚ 𝑨) 𝒂
𝑓   : ∣ 𝑆 ∣
𝒂   : βˆ₯ 𝑆 βˆ₯ 𝑓 β†’ ∣ 𝑨 ∣
Ξ²   : Im 𝒂 βŠ† Sg 𝑨 X

and, under these assumptions, we prove ∣ g ∣ ((𝑓 Μ‚ 𝑨) 𝒂) ≑ ∣ h ∣ ((𝑓 Μ‚ 𝑨) 𝒂).


↑ Subalgebras Subalgebras.Subalgebras β†’