Debian Codegraph @

src/Function/Bijection.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.Bijection where
11
12 {-# WARNING_ON_IMPORT
13 "Function.Bijection 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 Relation.Binary.Bundles using (Setoid)
19 open import Relation.Binary.PropositionalEquality as ≡
20 open import Function.Equality as F
21 using (_⟶_; _⟨$⟩_) renaming (_∘_ to _⟪∘⟫_)
22 open import Function.Injection as Inj hiding (id; _∘_; injection)
23 open import Function.Surjection as Surj hiding (id; _∘_; surjection)
24 open import Function.LeftInverse as Left hiding (id; _∘_; leftInverse)
25
26 ------------------------------------------------------------------------
27 -- Bijective functions.
28
29 record Bijective {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 injective : Injective to
35 surjective : Surjective to
36
37 open Surjective surjective public
38
39 left-inverse-of : from LeftInverseOf to
40 left-inverse-of x = injective (right-inverse-of (to ⟨$⟩ x))
41 {-# WARNING_ON_USAGE Bijective
42 "Warning: Bijective was deprecated in v2.0.
43 Please use Function.(Structures.)IsBijection instead."
44 #-}
45
46 ------------------------------------------------------------------------
47 -- The set of all bijections between two setoids.
48
49 record Bijection {f₁ f₂ t₁ t₂}
50 (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
51 Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
52 field
53 to : From ⟶ To
54 bijective : Bijective to
55
56 open Bijective bijective public
57
58 injection : Injection From To
59 injection = record
60 { to = to
61 ; injective = injective
62 }
63
64 surjection : Surjection From To
65 surjection = record
66 { to = to
67 ; surjective = surjective
68 }
69
70 open Surjection surjection public
71 using (equivalence; right-inverse; from-to)
72
73 left-inverse : LeftInverse From To
74 left-inverse = record
75 { to = to
76 ; from = from
77 ; left-inverse-of = left-inverse-of
78 }
79
80 open LeftInverse left-inverse public using (to-from)
81 {-# WARNING_ON_USAGE Bijection
82 "Warning: Bijection was deprecated in v2.0.
83 Please use Function.(Bundles.)Bijection instead."
84 #-}
85
86 ------------------------------------------------------------------------
87 -- The set of all bijections between two sets (i.e. bijections with
88 -- propositional equality)
89
90 infix 3 _⤖_
91
92 _⤖_ : ∀ {f t} → Set f → Set t → Set _
93 From ⤖ To = Bijection (≡.setoid From) (≡.setoid To)
94 {-# WARNING_ON_USAGE _⤖_
95 "Warning: _⤖_ was deprecated in v2.0.
96 Please use Function.(Bundles.)mk⤖ instead."
97 #-}
98
99 bijection : ∀ {f t} {From : Set f} {To : Set t} →
100 (to : From → To) (from : To → From) →
101 (∀ {x y} → to x ≡ to y → x ≡ y) →
102 (∀ x → to (from x) ≡ x) →
103 From ⤖ To
104 bijection to from inj invʳ = record
105 { to = F.→-to-⟶ to
106 ; bijective = record
107 { injective = inj
108 ; surjective = record
109 { from = F.→-to-⟶ from
110 ; right-inverse-of = invʳ
111 }
112 }
113 }
114 {-# WARNING_ON_USAGE bijection
115 "Warning: bijection was deprecated in v2.0.
116 Please use either Function.Properties.Bijection.trans or
117 Function.Construct.Composition.bijection instead."
118 #-}
119
120 ------------------------------------------------------------------------
121 -- Identity and composition. (Note that these proofs are superfluous,
122 -- given that Bijection is equivalent to Function.Inverse.Inverse.)
123
124 id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Bijection S S
125 id {S = S} = record
126 { to = F.id
127 ; bijective = record
128 { injective = Injection.injective (Inj.id {S = S})
129 ; surjective = Surjection.surjective (Surj.id {S = S})
130 }
131 }
132 {-# WARNING_ON_USAGE id
133 "Warning: id was deprecated in v2.0.
134 Please use either Function.Properties.Bijection.refl or
135 Function.Construct.Identity.bijection instead."
136 #-}
137
138 infixr 9 _∘_
139
140 _∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂}
141 {F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} →
142 Bijection M T → Bijection F M → Bijection F T
143 f ∘ g = record
144 { to = to f ⟪∘⟫ to g
145 ; bijective = record
146 { injective = Injection.injective (Inj._∘_ (injection f) (injection g))
147 ; surjective = Surjection.surjective (Surj._∘_ (surjection f) (surjection g))
148 }
149 } where open Bijection
150 {-# WARNING_ON_USAGE _∘_
151 "Warning: _∘_ was deprecated in v2.0.
152 Please use either Function.Properties.Bijection.trans or
153 Function.Construct.Composition.bijection instead."
154 #-}