|
| 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 | +open import Relation.Binary.Bundles using (Setoid) |
| 14 | +open import Relation.Binary.Structures using (IsEquivalence) |
| 15 | + |
| 16 | +module Function.Structures.Biased {a b ℓ₁ ℓ₂} |
| 17 | + {A : Set a} (_≈₁_ : Rel A ℓ₁) -- Equality over the domain |
| 18 | + {B : Set b} (_≈₂_ : Rel B ℓ₂) -- Equality over the codomain |
| 19 | + where |
| 20 | + |
| 21 | +open import Data.Product.Base as Product using (∃; _×_; _,_) |
| 22 | +open import Function.Base |
| 23 | +open import Function.Definitions |
| 24 | +open import Function.Structures _≈₁_ _≈₂_ |
| 25 | +open import Function.Consequences.Setoid |
| 26 | +open import Level using (_⊔_) |
| 27 | + |
| 28 | +------------------------------------------------------------------------ |
| 29 | +-- Surjection |
| 30 | +------------------------------------------------------------------------ |
| 31 | + |
| 32 | +record IsStrictSurjection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 33 | + field |
| 34 | + isCongruent : IsCongruent f |
| 35 | + strictlySurjective : StrictlySurjective _≈₂_ f |
| 36 | + |
| 37 | + open IsCongruent isCongruent public |
| 38 | + |
| 39 | + isSurjection : IsSurjection f |
| 40 | + isSurjection = record |
| 41 | + { isCongruent = isCongruent |
| 42 | + ; surjective = strictlySurjective⇒surjective |
| 43 | + Eq₁.setoid Eq₂.setoid cong strictlySurjective |
| 44 | + } |
| 45 | + |
| 46 | +open IsStrictSurjection public |
| 47 | + using () renaming (isSurjection to isStrictSurjection) |
| 48 | + |
| 49 | +------------------------------------------------------------------------ |
| 50 | +-- Bijection |
| 51 | +------------------------------------------------------------------------ |
| 52 | + |
| 53 | +record IsStrictBijection (f : A → B) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 54 | + field |
| 55 | + isInjection : IsInjection f |
| 56 | + strictlySurjective : StrictlySurjective _≈₂_ f |
| 57 | + |
| 58 | + isBijection : IsBijection f |
| 59 | + isBijection = record |
| 60 | + { isInjection = isInjection |
| 61 | + ; surjective = strictlySurjective⇒surjective |
| 62 | + Eq₁.setoid Eq₂.setoid cong strictlySurjective |
| 63 | + } where open IsInjection isInjection |
| 64 | + |
| 65 | +open IsStrictBijection public |
| 66 | + using () renaming (isBijection to isStrictBijection) |
| 67 | + |
| 68 | +------------------------------------------------------------------------ |
| 69 | +-- Left inverse |
| 70 | +------------------------------------------------------------------------ |
| 71 | + |
| 72 | +record IsStrictLeftInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 73 | + field |
| 74 | + isCongruent : IsCongruent to |
| 75 | + from-cong : Congruent _≈₂_ _≈₁_ from |
| 76 | + strictlyInverseˡ : StrictlyInverseˡ _≈₂_ to from |
| 77 | + |
| 78 | + isLeftInverse : IsLeftInverse to from |
| 79 | + isLeftInverse = record |
| 80 | + { isCongruent = isCongruent |
| 81 | + ; from-cong = from-cong |
| 82 | + ; inverseˡ = strictlyInverseˡ⇒inverseˡ |
| 83 | + Eq₁.setoid Eq₂.setoid cong strictlyInverseˡ |
| 84 | + } where open IsCongruent isCongruent |
| 85 | + |
| 86 | +open IsStrictLeftInverse public |
| 87 | + using () renaming (isLeftInverse to isStrictLeftInverse) |
| 88 | + |
| 89 | +------------------------------------------------------------------------ |
| 90 | +-- Right inverse |
| 91 | +------------------------------------------------------------------------ |
| 92 | + |
| 93 | +record IsStrictRightInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 94 | + field |
| 95 | + isCongruent : IsCongruent to |
| 96 | + from-cong : Congruent _≈₂_ _≈₁_ from |
| 97 | + strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from |
| 98 | + |
| 99 | + isRightInverse : IsRightInverse to from |
| 100 | + isRightInverse = record |
| 101 | + { isCongruent = isCongruent |
| 102 | + ; from-cong = from-cong |
| 103 | + ; inverseʳ = strictlyInverseʳ⇒inverseʳ |
| 104 | + Eq₁.setoid Eq₂.setoid from-cong strictlyInverseʳ |
| 105 | + } where open IsCongruent isCongruent |
| 106 | + |
| 107 | +open IsStrictRightInverse public |
| 108 | + using () renaming (isRightInverse to isStrictRightInverse) |
| 109 | + |
| 110 | +------------------------------------------------------------------------ |
| 111 | +-- Inverse |
| 112 | +------------------------------------------------------------------------ |
| 113 | + |
| 114 | +record IsStrictInverse (to : A → B) (from : B → A) : Set (a ⊔ b ⊔ ℓ₁ ⊔ ℓ₂) where |
| 115 | + field |
| 116 | + isLeftInverse : IsLeftInverse to from |
| 117 | + strictlyInverseʳ : StrictlyInverseʳ _≈₁_ to from |
| 118 | + |
| 119 | + isInverse : IsInverse to from |
| 120 | + isInverse = record |
| 121 | + { isLeftInverse = isLeftInverse |
| 122 | + ; inverseʳ = strictlyInverseʳ⇒inverseʳ |
| 123 | + Eq₁.setoid Eq₂.setoid from-cong strictlyInverseʳ |
| 124 | + } where open IsLeftInverse isLeftInverse |
| 125 | + |
| 126 | +open IsStrictInverse public |
| 127 | + using () renaming (isInverse to isStrictInverse) |
0 commit comments