---
layout: default
title : "Legacy.Base.Subalgebras.Properties module (The Agda Universal Algebra Library)"
date : "2021-07-18"
author: "agda-algebras development team"
---
### <a id="properties-of-the-subalgebra-inclusion-relation">Properties of the Subalgebra Inclusion Relation</a>
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
open import Overture using (π ; π₯ ; Signature )
module Legacy.Base.Subalgebras.Properties {π : Signature π π₯} where
open import Data.Product using ( _,_ ) renaming ( projβ to fst ; projβ to snd )
open import Function using ( _β_ ; id ; flip ; Injection )
open import Level using ( Level; _β_ )
open import Relation.Unary using ( Pred ; _β_ )
open import Relation.Binary using ( _RespectsΚ³_ ; _RespectsΛ‘_ )
open import Relation.Binary.PropositionalEquality as β‘
using ( _β‘_ ; module β‘-Reasoning )
open import Overture using ( β£_β£ ; β₯_β₯ ; _β»ΒΉ )
open import Legacy.Base.Functions using ( id-is-injective ; IsInjective ; β-injective )
open import Legacy.Base.Algebras {π = π} using ( Algebra ; Lift-Alg ; ov )
open import Legacy.Base.Homomorphisms {π = π} using ( is-homomorphism ; β-hom )
using ( β-is-hom ; _β
_ ; β
toInjective )
using ( β
fromInjective ; β
-refl ; β
-sym )
using ( β
-trans ; Lift-β
; mkiso )
open import Legacy.Base.Subalgebras.Subalgebras
{π = π} using ( _β€_ ; _β₯_ ; _IsSubalgebraOfClass_ )
private variable Ξ± Ξ² Ξ³ π§ : Level
open _β
_
β€-refl : {π¨ : Algebra Ξ±}{π© : Algebra Ξ²} β π¨ β
π© β π¨ β€ π©
β€-refl Ο = (to Ο) , β
toInjective Ο
β₯-refl : {π¨ : Algebra Ξ±}{π© : Algebra Ξ²} β π¨ β
π© β π¨ β₯ π©
β₯-refl Ο = (from Ο) , β
fromInjective Ο
β€-reflexive : (π¨ : Algebra Ξ±) β π¨ β€ π¨
β€-reflexive π¨ = (id , Ξ» π π β β‘.refl) , Injection.injective id-is-injective
β€-trans : (π¨ : Algebra Ξ±){π© : Algebra Ξ²}(πͺ : Algebra Ξ³)
β π¨ β€ π© β π© β€ πͺ β π¨ β€ πͺ
β€-trans π¨ πͺ Aβ€B Bβ€C = (β-hom π¨ πͺ β£ Aβ€B β£ β£ Bβ€C β£) , β-injective β₯ Aβ€B β₯ β₯ Bβ€C β₯
β₯-trans : (π¨ : Algebra Ξ±){π© : Algebra Ξ²}(πͺ : Algebra Ξ³)
β π¨ β₯ π© β π© β₯ πͺ β π¨ β₯ πͺ
β₯-trans π¨ πͺ Aβ₯B Bβ₯C = β€-trans πͺ π¨ Bβ₯C Aβ₯B
```
#### <a id="relations-between">Relations between β€, β₯, and β
</a>
In case all algebras live in the same universe level, we can use some of the definitions
in the standard library. However, to obtain more general versions, we need to either
extend the standard library's Binary.Structures module to be universe polymorphic, or
just implement what we need here. For now we do the latter (below).
```agda
module _ {Ξ± : Level} where
open import Relation.Binary.Structures {a = (ov Ξ±)}{β = (π β π₯ β Ξ±)} (_β
_ {Ξ±}{Ξ±})
open IsPreorder
β€-preorder : IsPreorder _β€_
isEquivalence β€-preorder = record { refl = β
-refl ; sym = β
-sym ; trans = β
-trans }
reflexive β€-preorder = β€-refl
trans β€-preorder {π¨}{π©}{πͺ} Aβ€B Bβ€C = β€-trans π¨ πͺ Aβ€B Bβ€C
β₯-preorder : IsPreorder _β₯_
isEquivalence β₯-preorder = record { refl = β
-refl ; sym = β
-sym ; trans = β
-trans }
reflexive β₯-preorder = β₯-refl
trans β₯-preorder {π¨}{π©}{πͺ} Aβ₯B Bβ₯C = β₯-trans π¨ πͺ Aβ₯B Bβ₯C
```
Here are some consequences of the fact that `_β€_` and `_β₯_` are preorders relative
to `_β
_`. These are essentially equivalent variations on the following obvious fact:
If two algebras are isomorphic and one of them is a subalgebra, then so is the other.
```agda
β€-resp-β
: _β€_ RespectsΚ³ _β
_
β€-resp-β
= βΌ-respΛ‘-β β₯-preorder
β₯-resp-β
: _β₯_ RespectsΚ³ _β
_
β₯-resp-β
{π¨} = βΌ-respΛ‘-β β€-preorder {π¨}
β
-resp-β₯ : _β₯_ RespectsΛ‘ _β
_
β
-resp-β₯ = β€-resp-β
β
-resp-β€ : _β€_ RespectsΛ‘ _β
_
β
-resp-β€ {π¨} = β₯-resp-β
{π¨}
```
#### <a id="relations-between-polymorphic-versions)">Relations between β€, β₯, and β
(universe-polymorphic versions)</a>
```agda
module _ {π¨ : Algebra Ξ±}{π© : Algebra Ξ²}{πͺ : Algebra Ξ³} where
β€-RESP-β
: π¨ β€ π© β π© β
πͺ β π¨ β€ πͺ
β€-RESP-β
a<b bc = β€-trans π¨ πͺ a<b (β€-refl bc)
β₯-RESP-β
: π¨ β₯ π© β π© β
πͺ β π¨ β₯ πͺ
β₯-RESP-β
a<b ac = β€-trans πͺ π¨ (β€-refl (β
-sym ac)) a<b
module _ {π¨ : Algebra Ξ±}{π© : Algebra Ξ²}{πͺ : Algebra Ξ³} where
β
-RESP-β€ : π¨ β
π© β π© β€ πͺ β π¨ β€ πͺ
β
-RESP-β€ ab b<c = β₯-RESP-β
{π¨ = πͺ} b<c (β
-sym ab)
β
-RESP-β₯ : π¨ β
π© β π© β₯ πͺ β π¨ β₯ πͺ
β
-RESP-β₯ ab b<c = β€-RESP-β
b<c (β
-sym ab)
open β‘-Reasoning
isoβinjective : {π¨ : Algebra Ξ±}{π© : Algebra Ξ²}
β (Ο : π¨ β
π©) β IsInjective β£ to Ο β£
isoβinjective {π¨ = π¨} (mkiso f g fβΌg gβΌf) {x} {y} fxfy =
x β‘β¨ (gβΌf x)β»ΒΉ β©
(β£ g β£ β β£ f β£) x β‘β¨ β‘.cong β£ g β£ fxfy β©
(β£ g β£ β β£ f β£) y β‘β¨ gβΌf y β©
y β
β€-mono : (π© : Algebra Ξ²){π¦ π¦' : Pred (Algebra Ξ±) Ξ³}
β π¦ β π¦' β π© IsSubalgebraOfClass π¦ β π© IsSubalgebraOfClass π¦'
β€-mono π© KK' KB = β£ KB β£ , fst β₯ KB β₯ , KK' (β£ snd β₯ KB β₯ β£) , β₯ (snd β₯ KB β₯) β₯
```
#### <a id="lifts-of-subalgebras">Lifts of subalgebras</a>
```agda
module _ {π¦ : Pred (Algebra Ξ±)(ov Ξ±)}{π© : Algebra Ξ±} where
Lift-is-sub : π© IsSubalgebraOfClass π¦ β (Lift-Alg π© Ξ±) IsSubalgebraOfClass π¦
Lift-is-sub (π¨ , (sa , (KA , Bβ
sa))) = π¨ , sa , KA , β
-trans (β
-sym Lift-β
) Bβ
sa
β€-Lift : {π¨ : Algebra Ξ±}(π© : Algebra Ξ²){β : Level} β π¨ β€ π© β π¨ β€ Lift-Alg π© β
β€-Lift π© a<b = β€-RESP-β
{π© = π©} a<b Lift-β
β₯-Lift : (π¨ : Algebra Ξ±){π© : Algebra Ξ²}{β : Level} β π¨ β₯ π© β π¨ β₯ Lift-Alg π© β
β₯-Lift π¨ a>b = β₯-RESP-β
{π¨ = π¨} a>b Lift-β
Lift-β€-Lift : {π¨ : Algebra Ξ±}(βα΅ : Level){π© : Algebra Ξ²}(βα΅ : Level)
β π¨ β€ π© β Lift-Alg π¨ βα΅ β€ Lift-Alg π© βα΅
Lift-β€-Lift βα΅ {π©} βα΅ a<b = β₯-Lift (Lift-Alg π© βα΅) (β€-Lift π© a<b)
```