Setoid.Functions.Injective¶
Injective functions on setoids¶
This is the Setoid.Functions.Injective module of the agda-algebras library.
We say that a function f : A β B from one setoid (A , ββ) to another (B , ββ) is injective (or monic) provided the following implications hold: β aβ aβ if f β¨$β© aβ ββ f β¨$β© aβ, then aβ ββ aβ.
A function f : A βΆ B from one setoid (A , ββ) to another
(B , ββ) is called injective provided β aβ aβ, if f β¨$β© aβ ββ f β¨$β©
aβ, then aβ ββ aβ. The Agda Standard Library defines a type representing
injective functions on bare types and we use this type (called Injective) to
define our own type representing the property of being an injective function on
setoids (called IsInjective).
module _ {π¨ : Setoid a Ξ±}{π© : Setoid b Ξ²} where open Setoid π¨ using () renaming (Carrier to A; _β_ to _ββ_) open Setoid π© using ( trans ; sym ) renaming (Carrier to B; _β_ to _ββ_) open Injection {From = π¨}{To = π©} using ( function ; injective ) renaming (to to _β¨$β©_) open _βΆ_ {a = a}{Ξ±}{b}{Ξ²}{From = π¨}{To = π©} renaming (to to _β¨$β©_ ) IsInjective : (π¨ βΆ π©) β Type (a β Ξ± β Ξ²) IsInjective f = Injective _ββ_ _ββ_ (_β¨$β©_ f) open Image_β_ -- Inverse of an injective function preserves setoid equalities LeftInvPreservesβ : (F : Injection π¨ π©) {bβ bβ : B} (u : Image (function F) β bβ) (v : Image (function F) β bβ) β bβ ββ bβ β Inv (function F) u ββ Inv (function F) v LeftInvPreservesβ F (eq aβ xβ) (eq aβ xβ) bb = Goal where faββfaβ : F β¨$β© aβ ββ F β¨$β© aβ faββfaβ = trans (sym xβ) (trans bb xβ) Goal : aβ ββ aβ Goal = injective F faββfaβ
Proving that the composition of injective functions is again injective
is simply a matter of composing the two assumed witnesses to injectivity.
(Note that here we are viewing the maps as functions on the underlying carriers
of the setoids; an alternative for setoid functions, called β-injective, is proved below.)
module _ {A : Type a}(_ββ_ : Rel A Ξ±) {B : Type b}(_ββ_ : Rel B Ξ²) {C : Type c}(_ββ_ : Rel C Ξ³) where β-injective-bare : {f : A β B} {g : B β C} β Injective _ββ_ _ββ_ f β Injective _ββ_ _ββ_ g β Injective _ββ_ _ββ_ (g β f) β-injective-bare finj ginj = finj β ginj module _ {π¨ : Setoid a Ξ±}{π© : Setoid b Ξ²}{πͺ : Setoid c Ξ³} where β-injective : (f : π¨ βΆ π©)(g : π© βΆ πͺ) β IsInjective f β IsInjective g β IsInjective (g β¨ββ© f) β-injective _ _ finj ginj = finj β ginj β-injection : Injection π¨ π© β Injection π© πͺ β Injection π¨ πͺ β-injection fi gi = record { to = to gi β to fi ; cong = cong gi β cong fi ; injective = β-injective (function fi) (function gi) (injective fi) (injective gi) } where open Injection id-is-injective : {π¨ : Setoid a Ξ±} β IsInjective{π¨ = π¨}{π¨} ππ id-is-injective = id