---
layout: default
title : "Setoid.Functions.Bijective module"
date : "2021-09-13"
author: "the agda-algebras development team"
---
### Bijective functions on setoids
This is the [Setoid.Functions.Bijective][] module of the [agda-algebras][] library.
A *bijective function* from a setoid `๐จ = (A, โโ)` to a setoid `๐ฉ = (B, โโ)` is a function `f : ๐จ โถ ๐ฉ` that is both injective and surjective. (See the definitions in [Setoid.Functions.Injective][] and [Setoid.Functions.Surjective][].
<!--
```agda
{-# OPTIONS --cubical-compatible --exact-split --safe #-}
open import Relation.Binary using ( Setoid )
module Setoid.Functions.Bijective {ฮฑ ฯแต ฮฒ ฯแต}{๐จ : Setoid ฮฑ ฯแต}{๐ฉ : Setoid ฮฒ ฯแต} where
open import Agda.Primitive using ( _โ_ ) renaming ( Set to Type )
open import Data.Product using ( _,_ ; _ร_ )
open import Function.Bundles using () renaming ( Func to _โถ_ )
open import Setoid.Functions.Inverses using ( Image_โ_ ; Inv )
open import Setoid.Functions.Surjective using ( IsSurjective )
open import Setoid.Functions.Injective using ( IsInjective )
open Image_โ_
open Setoid ๐จ using () renaming (Carrier to A; _โ_ to _โโ_)
open Setoid ๐ฉ using ( sym ; trans ) renaming (Carrier to B; _โ_ to _โโ_)
```
-->
```agda
IsBijective : (๐จ โถ ๐ฉ) โ Type (ฮฑ โ ฮฒ โ ฯแต โ ฯแต)
IsBijective f = IsInjective f ร IsSurjective f
BijInv : (f : ๐จ โถ ๐ฉ) โ IsBijective f โ ๐ฉ โถ ๐จ
BijInv f (fM , fE) = record { to = finv ; cong = c }
where
finv : B โ A
finv b = Inv f fE
handler : โ {bโ bโ}(iโ : Image f โ bโ)(iโ : Image f โ bโ)
โ bโ โโ bโ โ (Inv f iโ) โโ (Inv f iโ)
handler (eq a x) (eq aโ xโ) bโโbโ = fM (trans (sym x) (trans bโโbโ xโ))
c : โ {bโ bโ} โ bโ โโ bโ โ (finv bโ) โโ (finv bโ)
c bโโbโ = handler fE fE bโโbโ
```