| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Ways to give instances of certain structures where some fields can |
| 5 |
-- be given in terms of others. |
| 6 |
-- The contents of this file should usually be accessed from `Function`. |
| 7 |
------------------------------------------------------------------------ |
| 8 |
|
| 9 |
|
| 10 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 11 |
|
| 12 |
open import Relation.Binary.Core using (Rel) |
| 13 |
|
| 14 |
|
| 15 |
module Function.Structures.Biased {a b ℓ₁ ℓ₂} |
| 16 |
{A : Set a} (_≈₁_ : Rel A ℓ₁) -- Equality over the domain |
| 17 |
{B : Set b} (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain |
| 18 |
where |
| 19 |
|
| 20 |
open import Data.Product.Base as Product using (∃; _×_; _,_) |
| 21 |
open import Function.Base using (_∘_; id) |
| 22 |
open import Function.Definitions using(StrictlySurjective; StrictlyInverseˡ; StrictlyInverseʳ; Congruent) |
| 23 |
open import Function.Consequences.Setoid |
| 24 |
using (strictlySurjective⇒surjective; strictlyInverseˡ⇒inverseˡ |
| 25 |
; strictlyInverseʳ⇒inverseʳ) |
| 26 |
open import Level using (_⊔_) |
| 27 |
open import Relation.Binary.Bundles using (Setoid) |
| 28 |
open import Relation.Binary.Structures using (IsEquivalence) |
| 29 |
|
| 30 |
open import Function.Structures _≈₁_ _≈₂_ |
| 31 |
|
| 32 |
------------------------------------------------------------------------ |
| 33 |
-- Surjection |
| 34 |
------------------------------------------------------------------------ |
| 35 |
|
| 36 |
record IsStrictSurjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 37 |
field |
| 38 |
isCongruent : IsCongruent f |
| 39 |
strictlySurjective : StrictlySurjective _≈₂_ f |
| 40 |
|
| 41 |
open IsCongruent isCongruent public |
| 42 |
|
| 43 |
isSurjection : IsSurjection f |
| 44 |
isSurjection = record |
| 45 |
{ isCongruent = isCongruent |
| 46 |
; surjective = strictlySurjective⇒surjective |
| 47 |
Eq₁.setoid Eq₂.setoid cong strictlySurjective |
| 48 |
} |
| 49 |
|
| 50 |
open IsStrictSurjection public |
| 51 |
using () renaming (isSurjection to isStrictSurjection) |
| 52 |
|
| 53 |
------------------------------------------------------------------------ |
| 54 |
-- Bijection |
| 55 |
------------------------------------------------------------------------ |
| 56 |
|
| 57 |
record IsStrictBijection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 58 |
field |
| 59 |
isInjection : IsInjection f |
| 60 |
strictlySurjective : StrictlySurjective _≈₂_ f |
| 61 |
|
| 62 |
isBijection : IsBijection f |
| 63 |
isBijection = record |
| 64 |
{ isInjection = isInjection |
| 65 |
; surjective = strictlySurjective⇒surjective |
| 66 |
Eq₁.setoid Eq₂.setoid cong strictlySurjective |
| 67 |
} where open IsInjection isInjection |
| 68 |
|
| 69 |
open IsStrictBijection public |
| 70 |
using () renaming (isBijection to isStrictBijection) |
| 71 |
|
| 72 |
------------------------------------------------------------------------ |
| 73 |
-- Left inverse |
| 74 |
------------------------------------------------------------------------ |
| 75 |
|
| 76 |
record IsStrictLeftInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 77 |
field |
| 78 |
isCongruent : IsCongruent to |
| 79 |
from-cong : Congruent _≈₂_ _≈₁_ from |
| 80 |
strictlyInverseˡ : StrictlyInverseˡ _≈₂_ to from |
| 81 |
|
| 82 |
isLeftInverse : IsLeftInverse to from |
| 83 |
isLeftInverse = record |
| 84 |
{ isCongruent = isCongruent |
| 85 |
; from-cong = from-cong |
| 86 |
; inverseˡ = strictlyInverseˡ⇒inverseˡ |
| 87 |
Eq₁.setoid Eq₂.setoid cong strictlyInverseˡ |
| 88 |
} where open IsCongruent isCongruent |
| 89 |
|
| 90 |
open IsStrictLeftInverse public |
| 91 |
using () renaming (isLeftInverse to isStrictLeftInverse) |
| 92 |
|
| 93 |
------------------------------------------------------------------------ |
| 94 |
-- Right inverse |
| 95 |
------------------------------------------------------------------------ |
| 96 |
|
| 97 |
record IsStrictRightInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 98 |
field |
| 99 |
isCongruent : IsCongruent to |
| 100 |
from-cong : Congruent _≈₂_ _≈₁_ from |
| 101 |
strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from |
| 102 |
|
| 103 |
isRightInverse : IsRightInverse to from |
| 104 |
isRightInverse = record |
| 105 |
{ isCongruent = isCongruent |
| 106 |
; from-cong = from-cong |
| 107 |
; inverseʳ = strictlyInverseʳ⇒inverseʳ |
| 108 |
Eq₁.setoid Eq₂.setoid from-cong strictlyInverseʳ |
| 109 |
} where open IsCongruent isCongruent |
| 110 |
|
| 111 |
open IsStrictRightInverse public |
| 112 |
using () renaming (isRightInverse to isStrictRightInverse) |
| 113 |
|
| 114 |
------------------------------------------------------------------------ |
| 115 |
-- Inverse |
| 116 |
------------------------------------------------------------------------ |
| 117 |
|
| 118 |
record IsStrictInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 119 |
field |
| 120 |
isLeftInverse : IsLeftInverse to from |
| 121 |
strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from |
| 122 |
|
| 123 |
isInverse : IsInverse to from |
| 124 |
isInverse = record |
| 125 |
{ isLeftInverse = isLeftInverse |
| 126 |
; inverseʳ = strictlyInverseʳ⇒inverseʳ |
| 127 |
Eq₁.setoid Eq₂.setoid from-cong strictlyInverseʳ |
| 128 |
} where open IsLeftInverse isLeftInverse |
| 129 |
|
| 130 |
open IsStrictInverse public |
| 131 |
using () renaming (isInverse to isStrictInverse) |