| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Definitions for types of functions. |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
-- The contents of this file should usually be accessed from `Function`. |
| 8 |
|
| 9 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 10 |
|
| 11 |
module Function.Definitions where |
| 12 |
|
| 13 |
open import Data.Product.Base using (∃; _×_) |
| 14 |
open import Level using (Level) |
| 15 |
open import Relation.Binary.Core using (Rel) |
| 16 |
|
| 17 |
private |
| 18 |
variable |
| 19 |
a ℓ₁ ℓ₂ : Level |
| 20 |
A B : Set a |
| 21 |
|
| 22 |
------------------------------------------------------------------------ |
| 23 |
-- Basic definitions |
| 24 |
|
| 25 |
module _ |
| 26 |
(_≈₁_ : Rel A ℓ₁) -- Equality over the domain |
| 27 |
(_≈₂_ : Rel B ℓ₂) -- Equality over the codomain |
| 28 |
where |
| 29 |
|
| 30 |
Congruent : (A → B) → Set _ |
| 31 |
Congruent f = ∀ {x y} → x ≈₁ y → f x ≈₂ f y |
| 32 |
|
| 33 |
Injective : (A → B) → Set _ |
| 34 |
Injective f = ∀ {x y} → f x ≈₂ f y → x ≈₁ y |
| 35 |
|
| 36 |
Surjective : (A → B) → Set _ |
| 37 |
Surjective f = ∀ y → ∃ λ x → ∀ {z} → z ≈₁ x → f z ≈₂ y |
| 38 |
|
| 39 |
Bijective : (A → B) → Set _ |
| 40 |
Bijective f = Injective f × Surjective f |
| 41 |
|
| 42 |
Inverseˡ : (A → B) → (B → A) → Set _ |
| 43 |
Inverseˡ f g = ∀ {x y} → y ≈₁ g x → f y ≈₂ x |
| 44 |
|
| 45 |
Inverseʳ : (A → B) → (B → A) → Set _ |
| 46 |
Inverseʳ f g = ∀ {x y} → y ≈₂ f x → g y ≈₁ x |
| 47 |
|
| 48 |
Inverseᵇ : (A → B) → (B → A) → Set _ |
| 49 |
Inverseᵇ f g = Inverseˡ f g × Inverseʳ f g |
| 50 |
|
| 51 |
------------------------------------------------------------------------ |
| 52 |
-- Strict definitions |
| 53 |
|
| 54 |
-- These are often easier to use once but much harder to compose and |
| 55 |
-- reason about. |
| 56 |
|
| 57 |
StrictlySurjective : Rel B ℓ₂ → (A → B) → Set _ |
| 58 |
StrictlySurjective _≈₂_ f = ∀ y → ∃ λ x → f x ≈₂ y |
| 59 |
|
| 60 |
StrictlyInverseˡ : Rel B ℓ₂ → (A → B) → (B → A) → Set _ |
| 61 |
StrictlyInverseˡ _≈₂_ f g = ∀ y → f (g y) ≈₂ y |
| 62 |
|
| 63 |
StrictlyInverseʳ : Rel A ℓ₁ → (A → B) → (B → A) → Set _ |
| 64 |
StrictlyInverseʳ _≈₁_ f g = ∀ x → g (f x) ≈₁ x |