---
layout: default
title : "Setoid.Subalgebras.Basic module (The Agda Universal Algebra Library)"
date : "2021-07-17"
author: "agda-algebras development team"
---
#### Subalgebras of setoid algebras
This is the [Setoid.Subalgebras.Basic][] module of the [Agda Universal Algebra Library][].
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
open import Overture using (π ; π₯ ; Signature)
module Setoid.Subalgebras.Basic {π : Signature π π₯} where
open import Agda.Primitive using () renaming ( Set to Type )
open import Data.Product using ( _,_ ; Ξ£-syntax ) renaming ( _Γ_ to _β§_ )
open import Level using ( Level ; _β_ )
open import Relation.Binary using ( REL )
open import Relation.Unary using ( Pred ; _β_ )
open import Overture using ( projβ ; projβ )
open import Setoid.Functions using ( IsInjective )
open import Setoid.Algebras {π = π} using ( Algebra ; ov )
open import Setoid.Homomorphisms {π = π}
using ( hom ; mon ; monβintohom ; kerquo ; FirstHomTheorem )
private variable Ξ± Οα΅ Ξ² Οα΅ β : Level
```
-->
```agda
_β₯_
_IsSupalgebraOf_ : Algebra Ξ± Οα΅ β Algebra Ξ² Οα΅ β Type _
π¨ IsSupalgebraOf π© = Ξ£[ h β hom π© π¨ ] IsInjective (projβ h)
_β€_
_IsSubalgebraOf_ : Algebra Ξ± Οα΅ β Algebra Ξ² Οα΅ β Type (π β π₯ β Ξ± β Οα΅ β Ξ² β Οα΅)
π¨ IsSubalgebraOf π© = Ξ£[ h β hom π¨ π© ] IsInjective (projβ h)
π¨ β₯ π© = π¨ IsSupalgebraOf π©
π¨ β€ π© = π¨ IsSubalgebraOf π©
monββ€ : {π¨ : Algebra Ξ± Οα΅}{π© : Algebra Ξ² Οα΅} β mon π¨ π© β π¨ β€ π©
monββ€ {π¨ = π¨}{π©} x = monβintohom π¨ π© x
record SubalgebraOf : Type (ov (Ξ± β Ξ² β Οα΅ β Οα΅)) where
field
algebra : Algebra Ξ± Οα΅
subalgebra : Algebra Ξ² Οα΅
issubalgebra : subalgebra β€ algebra
Subalgebra : Algebra Ξ± Οα΅ β {Ξ² Οα΅ : Level} β Type _
Subalgebra π¨ {Ξ²}{Οα΅} = Ξ£[ π© β (Algebra Ξ² Οα΅) ] π© β€ π¨
IsSubalgebraREL : {Ξ± Οα΅ Ξ² Οα΅ : Level} β REL (Algebra Ξ± Οα΅)(Algebra Ξ² Οα΅) β β Type _
IsSubalgebraREL {Ξ±}{Οα΅}{Ξ²}{Οα΅} R = β {π¨ : Algebra Ξ± Οα΅}{π© : Algebra Ξ² Οα΅} β π¨ β€ π©
record SubalgebraREL (R : REL (Algebra Ξ² Οα΅)(Algebra Ξ± Οα΅) β) : Type (ov (Ξ± β Ξ² β Οα΅ β β)) where
field
isSubalgebraREL : IsSubalgebraREL R
```
From now on we will use `π© β€ π¨` to express the assertion that `π©` is a subalgebra of `π¨`.
#### Subalgebras of classes of setoid algebras
Suppose `π¦ : Pred (Algebra Ξ± π) Ξ³` denotes a class of `π`-algebras and `π© : Algebra Ξ² Οα΅`
denotes an arbitrary `π`-algebra. Consider the assertion that `π©` is a subalgebra of
an algebra in the class `π¦`. With the next definition we can express this
assertion as `π© IsSubalgebraOfClass π¦`.
```agda
_β€c_
_IsSubalgebraOfClass_ : Algebra Ξ² Οα΅ β Pred (Algebra Ξ± Οα΅) β β Type _
π© IsSubalgebraOfClass π¦ = Ξ£[ π¨ β Algebra _ _ ] ((π¨ β π¦) β§ (π© β€ π¨))
π© β€c π¦ = π© IsSubalgebraOfClass π¦
record SubalgebraOfClass : Type (ov (Ξ± β Ξ² β Οα΅ β Οα΅ β β)) where
field
class : Pred (Algebra Ξ± Οα΅) β
subalgebra : Algebra Ξ² Οα΅
issubalgebraofclass : subalgebra β€c class
record SubalgebraOfClass' : Type (ov (Ξ± β Ξ² β Οα΅ β Οα΅ β β)) where
field
class : Pred (Algebra Ξ± Οα΅) β
classalgebra : Algebra Ξ± Οα΅
isclassalgebra : classalgebra β class
subalgebra : Algebra Ξ² Οα΅
issubalgebra : subalgebra β€ classalgebra
SubalgebrasOfClass : Pred (Algebra Ξ± Οα΅) β β {Ξ² Οα΅ : Level} β Type _
SubalgebrasOfClass π¦ {Ξ²}{Οα΅} = Ξ£[ π© β Algebra Ξ² Οα΅ ] π© β€c π¦
```
#### Consequences of First Homomorphism Theorem
As an example use-case of the `IsSubalgebraOf` type defined above, we prove the
following easy but useful corollary of the First Homomorphism Theorem (proved
in the [Setoid.Homomorphisms.Noether][] module): If `π¨` and `π©` are `π`-algebras
and `h : hom π¨ π©` a homomorphism from `π¨` to `π©`, then the quotient `π¨ β± ker h`
is (isomorphic to) a subalgebra of `π©`.
```agda
FirstHomCorollary : {π¨ : Algebra Ξ± Οα΅} {π© : Algebra Ξ² Οα΅} (hh : hom π¨ π©)
β (kerquo hh) IsSubalgebraOf π©
FirstHomCorollary hh = projβ (FirstHomTheorem hh) , projβ (projβ (FirstHomTheorem hh))
```