| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Properties of surjections |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Function.Properties.Surjection where |
| 10 |
|
| 11 |
open import Function.Base using (_∘_; _$_) |
| 12 |
open import Function.Definitions using (Surjective; Injective; Congruent) |
| 13 |
open import Function.Bundles |
| 14 |
using (Func; Surjection; _↠_; _⟶_; _↪_; mk↪; _⇔_; mk⇔) |
| 15 |
import Function.Construct.Identity as Identity using (surjection) |
| 16 |
import Function.Construct.Composition as Compose using (surjection) |
| 17 |
open import Level using (Level) |
| 18 |
open import Data.Product.Base using (proj₁; proj₂) |
| 19 |
import Relation.Binary.PropositionalEquality.Core as ≡ using (_≡_; refl) |
| 20 |
open import Relation.Binary.Definitions using (Reflexive; Trans) |
| 21 |
open import Relation.Binary.Bundles using (Setoid) |
| 22 |
import Relation.Binary.Reasoning.Setoid as ≈-Reasoning |
| 23 |
|
| 24 |
private |
| 25 |
variable |
| 26 |
a b c ℓ ℓ₁ ℓ₂ ℓ₃ : Level |
| 27 |
A B : Set a |
| 28 |
T S : Setoid a ℓ |
| 29 |
|
| 30 |
------------------------------------------------------------------------ |
| 31 |
-- Constructors |
| 32 |
|
| 33 |
mkSurjection : (f : Func S T) (open Func f) → |
| 34 |
Surjective Eq₁._≈_ Eq₂._≈_ to → |
| 35 |
Surjection S T |
| 36 |
mkSurjection f surjective = record |
| 37 |
{ Func f |
| 38 |
; surjective = surjective |
| 39 |
} |
| 40 |
|
| 41 |
------------------------------------------------------------------------ |
| 42 |
-- Conversion functions |
| 43 |
|
| 44 |
↠⇒⟶ : A ↠ B → A ⟶ B |
| 45 |
↠⇒⟶ = Surjection.function |
| 46 |
|
| 47 |
↠⇒↪ : A ↠ B → B ↪ A |
| 48 |
↠⇒↪ s = mk↪ {from = to} λ { ≡.refl → proj₂ (strictlySurjective _)} |
| 49 |
where open Surjection s |
| 50 |
|
| 51 |
↠⇒⇔ : A ↠ B → A ⇔ B |
| 52 |
↠⇒⇔ s = mk⇔ to (proj₁ ∘ surjective) |
| 53 |
where open Surjection s |
| 54 |
|
| 55 |
------------------------------------------------------------------------ |
| 56 |
-- Setoid properties |
| 57 |
|
| 58 |
refl : Reflexive (Surjection {a} {ℓ}) |
| 59 |
refl {x = x} = Identity.surjection x |
| 60 |
|
| 61 |
trans : Trans (Surjection {a} {ℓ₁} {b} {ℓ₂}) |
| 62 |
(Surjection {b} {ℓ₂} {c} {ℓ₃}) |
| 63 |
(Surjection {a} {ℓ₁} {c} {ℓ₃}) |
| 64 |
trans = Compose.surjection |
| 65 |
|
| 66 |
------------------------------------------------------------------------ |
| 67 |
-- Other |
| 68 |
|
| 69 |
injective⇒to⁻-cong : (surj : Surjection S T) → |
| 70 |
(open Surjection surj) → |
| 71 |
Injective Eq₁._≈_ Eq₂._≈_ to → |
| 72 |
Congruent Eq₂._≈_ Eq₁._≈_ to⁻ |
| 73 |
injective⇒to⁻-cong {T = T} surj injective {x} {y} x≈y = injective $ begin |
| 74 |
to (to⁻ x) ≈⟨ to∘to⁻ x ⟩ |
| 75 |
x ≈⟨ x≈y ⟩ |
| 76 |
y ≈⟨ to∘to⁻ y ⟨ |
| 77 |
to (to⁻ y) ∎ |
| 78 |
where |
| 79 |
open ≈-Reasoning T |
| 80 |
open Surjection surj |
| 81 |
|