1
------------------------------------------------------------------------
3
------------------------------------------------------------------------
5
{-# OPTIONS --universe-polymorphism #-}
7
module Function.Bijection where
9
open import Data.Product
11
open import Relation.Binary
12
open import Function.Equality as F
13
using (_⟶_; _⟨$⟩_) renaming (_∘_ to _⟪∘⟫_)
14
open import Function.Injection as Inj hiding (id; _∘_)
15
open import Function.Surjection as Surj hiding (id; _∘_)
16
open import Function.LeftInverse as Left hiding (id; _∘_)
18
-- Bijective functions.
20
record Bijective {f₁ f₂ t₁ t₂}
21
{From : Setoid f₁ f₂} {To : Setoid t₁ t₂}
23
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
25
injective : Injective to
26
surjective : Surjective to
28
open Surjective surjective public
30
left-inverse-of : from LeftInverseOf to
31
left-inverse-of x = injective (right-inverse-of (to ⟨$⟩ x))
33
-- The set of all bijections between two setoids.
35
record Bijection {f₁ f₂ t₁ t₂}
36
(From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
37
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
40
bijective : Bijective to
42
open Bijective bijective public
44
injection : Injection From To
47
; injective = injective
50
surjection : Surjection From To
53
; surjective = surjective
56
open Surjection surjection public using (equivalent; right-inverse)
58
left-inverse : LeftInverse From To
62
; left-inverse-of = left-inverse-of
65
-- Identity and composition. (Note that these proofs are superfluous,
66
-- given that Bijection is equivalent to Function.Inverse.Inverse.)
68
id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Bijection S S
72
{ injective = Injection.injective (Inj.id {S = S})
73
; surjective = Surjection.surjective (Surj.id {S = S})
79
_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂}
80
{F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} →
81
Bijection M T → Bijection F M → Bijection F T
85
{ injective = Injection.injective (Inj._∘_ (injection f) (injection g))
86
; surjective = Surjection.surjective (Surj._∘_ (surjection f) (surjection g))
88
} where open Bijection