Debian Codegraph @

src/Function/LeftInverse.agda

raw
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.LeftInverse where
11
12 {-# WARNING_ON_IMPORT
13 "Function.LeftInverse was deprecated in v2.0.
14 Use the standard function hierarchy in Function/Function.Bundles instead."
15 #-}
16
17 open import Level
18 import Relation.Binary.Reasoning.Setoid as EqReasoning
19 open import Relation.Binary.Bundles using (Setoid)
20 open import Function.Equality as Eq
21 using (_⟶_; _⟨$⟩_) renaming (_∘_ to _⟪∘⟫_)
22 open import Function.Equivalence using (Equivalence)
23 open import Function.Injection using (Injective; Injection)
24 open import Relation.Binary.PropositionalEquality as ≡ using (_≡_)
25
26 ------------------------------------------------------------------------
27 -- Left and right inverses.
28
29 _LeftInverseOf_ :
30 ∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →
31 To ⟶ From → From ⟶ To → Set _
32 _LeftInverseOf_ {From = From} f g = ∀ x → f ⟨$⟩ (g ⟨$⟩ x) ≈ x
33 where open Setoid From
34 {-# WARNING_ON_USAGE _LeftInverseOf_
35 "Warning: _LeftInverseOf_ was deprecated in v2.0.
36 Please use Function.(Structures.)IsRightInverse instead."
37 #-}
38
39 _RightInverseOf_ :
40 ∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →
41 To ⟶ From → From ⟶ To → Set _
42 f RightInverseOf g = g LeftInverseOf f
43 {-# WARNING_ON_USAGE _RightInverseOf_
44 "Warning: _RightInverseOf_ was deprecated in v2.0.
45 Please use Function.(Structures.)IsLeftInverse instead."
46 #-}
47
48 ------------------------------------------------------------------------
49 -- The set of all left inverses between two setoids.
50
51 record LeftInverse {f₁ f₂ t₁ t₂}
52 (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
53 Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
54 field
55 to : From ⟶ To
56 from : To ⟶ From
57 left-inverse-of : from LeftInverseOf to
58
59 private
60 open module F = Setoid From
61 open module T = Setoid To
62 open EqReasoning From
63
64 injective : Injective to
65 injective {x} {y} eq = begin
66 x ≈⟨ F.sym (left-inverse-of x) ⟩
67 from ⟨$⟩ (to ⟨$⟩ x) ≈⟨ Eq.cong from eq ⟩
68 from ⟨$⟩ (to ⟨$⟩ y) ≈⟨ left-inverse-of y ⟩
69 y ∎
70
71 injection : Injection From To
72 injection = record { to = to; injective = injective }
73
74 equivalence : Equivalence From To
75 equivalence = record
76 { to = to
77 ; from = from
78 }
79
80 to-from : ∀ {x y} → to ⟨$⟩ x T.≈ y → from ⟨$⟩ y F.≈ x
81 to-from {x} {y} to-x≈y = begin
82 from ⟨$⟩ y ≈⟨ Eq.cong from (T.sym to-x≈y) ⟩
83 from ⟨$⟩ (to ⟨$⟩ x) ≈⟨ left-inverse-of x ⟩
84 x ∎
85 {-# WARNING_ON_USAGE LeftInverse
86 "Warning: LeftInverse was deprecated in v2.0.
87 Please use Function.(Bundles.)RightInverse instead."
88 #-}
89
90 -- The set of all right inverses between two setoids.
91
92 RightInverse : ∀ {f₁ f₂ t₁ t₂}
93 (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) → Set _
94 RightInverse From To = LeftInverse To From
95 {-# WARNING_ON_USAGE RightInverse
96 "Warning: RightInverse was deprecated in v2.0.
97 Please use Function.(Bundles.)LeftInverse instead."
98 #-}
99
100 ------------------------------------------------------------------------
101 -- The set of all left inverses from one set to another (i.e. left
102 -- inverses with propositional equality).
103 --
104 -- Read A ↞ B as "surjection from B to A".
105
106 infix 3 _↞_
107
108 _↞_ : ∀ {f t} → Set f → Set t → Set _
109 From ↞ To = LeftInverse (≡.setoid From) (≡.setoid To)
110 {-# WARNING_ON_USAGE _↞_
111 "Warning: _↞_ was deprecated in v2.0.
112 Please use Function.(Bundles.)_↪_ instead."
113 #-}
114
115 leftInverse : ∀ {f t} {From : Set f} {To : Set t} →
116 (to : From → To) (from : To → From) →
117 (∀ x → from (to x) ≡ x) →
118 From ↞ To
119 leftInverse to from invˡ = record
120 { to = Eq.→-to-⟶ to
121 ; from = Eq.→-to-⟶ from
122 ; left-inverse-of = invˡ
123 }
124 {-# WARNING_ON_USAGE leftInverse
125 "Warning: leftInverse was deprecated in v2.0.
126 Please use Function.(Bundles.)mk↪ instead."
127 #-}
128
129 ------------------------------------------------------------------------
130 -- Identity and composition.
131
132 id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → LeftInverse S S
133 id {S = S} = record
134 { to = Eq.id
135 ; from = Eq.id
136 ; left-inverse-of = λ _ → Setoid.refl S
137 }
138 {-# WARNING_ON_USAGE id
139 "Warning: id was deprecated in v2.0.
140 Please use either Function.Properties.RightInverse.refl or
141 Function.Construct.Identity.rightInverse instead."
142 #-}
143
144 infixr 9 _∘_
145
146 _∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂}
147 {F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} →
148 LeftInverse M T → LeftInverse F M → LeftInverse F T
149 _∘_ {F = F} f g = record
150 { to = to f ⟪∘⟫ to g
151 ; from = from g ⟪∘⟫ from f
152 ; left-inverse-of = λ x → begin
153 from g ⟨$⟩ (from f ⟨$⟩ (to f ⟨$⟩ (to g ⟨$⟩ x))) ≈⟨ Eq.cong (from g) (left-inverse-of f (to g ⟨$⟩ x)) ⟩
154 from g ⟨$⟩ (to g ⟨$⟩ x) ≈⟨ left-inverse-of g x ⟩
155 x ∎
156 }
157 where
158 open LeftInverse
159 open EqReasoning F
160 {-# WARNING_ON_USAGE _∘_
161 "Warning: _∘_ was deprecated in v2.0.
162 Please use either Function.Properties.RightInverse.trans or
163 Function.Construct.Composition.rightInverse instead."
164 #-}