| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- This module is DEPRECATED. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
{-# OPTIONS --warning=noUserWarning #-} |
| 9 |
|
| 10 |
module Function.Surjection where |
| 11 |
|
| 12 |
{-# WARNING_ON_IMPORT |
| 13 |
"Function.Surjection was deprecated in v2.0. |
| 14 |
Use the standard function hierarchy in Function/Function.Bundles instead." |
| 15 |
#-} |
| 16 |
|
| 17 |
open import Level |
| 18 |
open import Function.Equality as F |
| 19 |
using (_⟶_) renaming (_∘_ to _⟪∘⟫_) |
| 20 |
open import Function.Equivalence using (Equivalence) |
| 21 |
open import Function.Injection hiding (id; _∘_; injection) |
| 22 |
open import Function.LeftInverse as Left hiding (id; _∘_) |
| 23 |
open import Relation.Binary.Bundles using (Setoid) |
| 24 |
open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) |
| 25 |
|
| 26 |
------------------------------------------------------------------------ |
| 27 |
-- Surjective functions. |
| 28 |
|
| 29 |
record Surjective {f₁ f₂ t₁ t₂} |
| 30 |
{From : Setoid f₁ f₂} {To : Setoid t₁ t₂} |
| 31 |
(to : From ⟶ To) : |
| 32 |
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where |
| 33 |
field |
| 34 |
from : To ⟶ From |
| 35 |
right-inverse-of : from RightInverseOf to |
| 36 |
{-# WARNING_ON_USAGE Surjective |
| 37 |
"Warning: Surjective was deprecated in v2.0. |
| 38 |
Please use Function.(Definitions.)Surjective instead." |
| 39 |
#-} |
| 40 |
|
| 41 |
------------------------------------------------------------------------ |
| 42 |
-- The set of all surjections from one setoid to another. |
| 43 |
|
| 44 |
record Surjection {f₁ f₂ t₁ t₂} |
| 45 |
(From : Setoid f₁ f₂) (To : Setoid t₁ t₂) : |
| 46 |
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where |
| 47 |
field |
| 48 |
to : From ⟶ To |
| 49 |
surjective : Surjective to |
| 50 |
|
| 51 |
open Surjective surjective public |
| 52 |
|
| 53 |
right-inverse : RightInverse From To |
| 54 |
right-inverse = record |
| 55 |
{ to = from |
| 56 |
; from = to |
| 57 |
; left-inverse-of = right-inverse-of |
| 58 |
} |
| 59 |
|
| 60 |
open LeftInverse right-inverse public |
| 61 |
using () renaming (to-from to from-to) |
| 62 |
|
| 63 |
injective : Injective from |
| 64 |
injective = LeftInverse.injective right-inverse |
| 65 |
|
| 66 |
injection : Injection To From |
| 67 |
injection = LeftInverse.injection right-inverse |
| 68 |
|
| 69 |
equivalence : Equivalence From To |
| 70 |
equivalence = record |
| 71 |
{ to = to |
| 72 |
; from = from |
| 73 |
} |
| 74 |
{-# WARNING_ON_USAGE Surjection |
| 75 |
"Warning: Surjection was deprecated in v2.0. |
| 76 |
Please use Function.(Bundles.)Surjection instead." |
| 77 |
#-} |
| 78 |
|
| 79 |
-- Right inverses can be turned into surjections. |
| 80 |
|
| 81 |
fromRightInverse : |
| 82 |
∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} → |
| 83 |
RightInverse From To → Surjection From To |
| 84 |
fromRightInverse r = record |
| 85 |
{ to = from |
| 86 |
; surjective = record |
| 87 |
{ from = to |
| 88 |
; right-inverse-of = left-inverse-of |
| 89 |
} |
| 90 |
} where open LeftInverse r |
| 91 |
{-# WARNING_ON_USAGE fromRightInverse |
| 92 |
"Warning: fromRightInverse was deprecated in v2.0. |
| 93 |
Please use Function.(Properties.)RightInverse.RightInverse⇒Surjection instead." |
| 94 |
#-} |
| 95 |
|
| 96 |
------------------------------------------------------------------------ |
| 97 |
-- The set of all surjections from one set to another (i.e. sujections |
| 98 |
-- with propositional equality) |
| 99 |
|
| 100 |
infix 3 _↠_ |
| 101 |
|
| 102 |
_↠_ : ∀ {f t} → Set f → Set t → Set _ |
| 103 |
From ↠ To = Surjection (≡.setoid From) (≡.setoid To) |
| 104 |
{-# WARNING_ON_USAGE _↠_ |
| 105 |
"Warning: _↠_ was deprecated in v2.0. |
| 106 |
Please use Function.(Bundles.)_↠_ instead." |
| 107 |
#-} |
| 108 |
|
| 109 |
surjection : ∀ {f t} {From : Set f} {To : Set t} → |
| 110 |
(to : From → To) (from : To → From) → |
| 111 |
(∀ x → to (from x) ≡ x) → |
| 112 |
From ↠ To |
| 113 |
surjection to from surjective = record |
| 114 |
{ to = F.→-to-⟶ to |
| 115 |
; surjective = record |
| 116 |
{ from = F.→-to-⟶ from |
| 117 |
; right-inverse-of = surjective |
| 118 |
} |
| 119 |
} |
| 120 |
{-# WARNING_ON_USAGE surjection |
| 121 |
"Warning: surjection was deprecated in v2.0. |
| 122 |
Please use Function.(Bundles.)mk↠ instead." |
| 123 |
#-} |
| 124 |
|
| 125 |
------------------------------------------------------------------------ |
| 126 |
-- Identity and composition. |
| 127 |
|
| 128 |
id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Surjection S S |
| 129 |
id {S = S} = record |
| 130 |
{ to = F.id |
| 131 |
; surjective = record |
| 132 |
{ from = LeftInverse.to id′ |
| 133 |
; right-inverse-of = LeftInverse.left-inverse-of id′ |
| 134 |
} |
| 135 |
} where id′ = Left.id {S = S} |
| 136 |
{-# WARNING_ON_USAGE id |
| 137 |
"Warning: id was deprecated in v2.0. |
| 138 |
Please use Function.Properties.Surjection.refl or |
| 139 |
Function.Construct.Identity.surjection instead." |
| 140 |
#-} |
| 141 |
|
| 142 |
infixr 9 _∘_ |
| 143 |
|
| 144 |
_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂} |
| 145 |
{F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} → |
| 146 |
Surjection M T → Surjection F M → Surjection F T |
| 147 |
f ∘ g = record |
| 148 |
{ to = to f ⟪∘⟫ to g |
| 149 |
; surjective = record |
| 150 |
{ from = LeftInverse.to g∘f |
| 151 |
; right-inverse-of = LeftInverse.left-inverse-of g∘f |
| 152 |
} |
| 153 |
} |
| 154 |
where |
| 155 |
open Surjection |
| 156 |
g∘f = Left._∘_ (right-inverse g) (right-inverse f) |
| 157 |
{-# WARNING_ON_USAGE _∘_ |
| 158 |
"Warning: _∘_ was deprecated in v2.0. |
| 159 |
Please use Function.Properties.Surjection.trans or |
| 160 |
Function.Construct.Composition.surjection instead." |
| 161 |
#-} |