Debian Codegraph @

src/Function/Equivalence.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.Equivalence where
11
12 {-# WARNING_ON_IMPORT
13 "Function.Equivalence was deprecated in v2.0.
14 Use the standard function hierarchy in Function/Function.Bundles instead."
15 #-}
16
17 open import Function.Base using (flip)
18 open import Function.Equality as F
19 using (_⟶_; _⟨$⟩_; →-to-⟶) renaming (_∘_ to _⟪∘⟫_)
20 open import Level
21 open import Relation.Binary.Bundles using (Setoid)
22 open import Relation.Binary.Definitions using (Reflexive; TransFlip; Sym)
23 import Relation.Binary.PropositionalEquality as ≡
24
25 ------------------------------------------------------------------------
26 -- Setoid equivalence
27
28 record Equivalence {f₁ f₂ t₁ t₂}
29 (From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
30 Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
31 field
32 to : From ⟶ To
33 from : To ⟶ From
34 {-# WARNING_ON_USAGE Equivalence
35 "Warning: Equivalence was deprecated in v2.0.
36 Please use Function.(Bundles.)Equivalence instead."
37 #-}
38
39 ------------------------------------------------------------------------
40 -- The set of all equivalences between two sets (i.e. equivalences
41 -- with propositional equality)
42
43 infix 3 _⇔_
44
45 _⇔_ : ∀ {f t} → Set f → Set t → Set _
46 From ⇔ To = Equivalence (≡.setoid From) (≡.setoid To)
47 {-# WARNING_ON_USAGE _⇔_
48 "Warning: _⇔_ was deprecated in v2.0.
49 Please use Function.(Bundles.)_⇔_ instead."
50 #-}
51
52 equivalence : ∀ {f t} {From : Set f} {To : Set t} →
53 (From → To) → (To → From) → From ⇔ To
54 equivalence to from = record
55 { to = →-to-⟶ to
56 ; from = →-to-⟶ from
57 }
58 {-# WARNING_ON_USAGE equivalence
59 "Warning: equivalence was deprecated in v2.0.
60 Please use Function.Properties.Equivalence.mkEquivalence instead."
61 #-}
62
63 ------------------------------------------------------------------------
64 -- Equivalence is an equivalence relation
65
66 -- Identity and composition (reflexivity and transitivity).
67
68 id : ∀ {s₁ s₂} → Reflexive (Equivalence {s₁} {s₂})
69 id {x = S} = record
70 { to = F.id
71 ; from = F.id
72 }
73 {-# WARNING_ON_USAGE id
74 "Warning: id was deprecated in v2.0.
75 Please use Function.Properties.Equivalence.refl or
76 Function.Construct.Identity.equivalence instead."
77 #-}
78
79 infixr 9 _∘_
80
81 _∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂} →
82 TransFlip (Equivalence {f₁} {f₂} {m₁} {m₂})
83 (Equivalence {m₁} {m₂} {t₁} {t₂})
84 (Equivalence {f₁} {f₂} {t₁} {t₂})
85 f ∘ g = record
86 { to = to f ⟪∘⟫ to g
87 ; from = from g ⟪∘⟫ from f
88 } where open Equivalence
89 {-# WARNING_ON_USAGE _∘_
90 "Warning: _∘_ was deprecated in v2.0.
91 Please use Function.Properties.Equivalence.trans or
92 Function.Construct.Composition.equivalence instead."
93 #-}
94
95 -- Symmetry.
96
97 sym : ∀ {f₁ f₂ t₁ t₂} →
98 Sym (Equivalence {f₁} {f₂} {t₁} {t₂})
99 (Equivalence {t₁} {t₂} {f₁} {f₂})
100 sym eq = record
101 { from = to
102 ; to = from
103 } where open Equivalence eq
104 {-# WARNING_ON_USAGE sym
105 "Warning: sym was deprecated in v2.0.
106 Please use Function.Properties.Equivalence.sym or
107 Function.Construct.Symmetry.equivalence instead."
108 #-}
109
110 -- For fixed universe levels we can construct setoids.
111
112 setoid : (s₁ s₂ : Level) → Setoid (suc (s₁ ⊔ s₂)) (s₁ ⊔ s₂)
113 setoid s₁ s₂ = record
114 { Carrier = Setoid s₁ s₂
115 ; _≈_ = Equivalence
116 ; isEquivalence = record
117 { refl = id
118 ; sym = sym
119 ; trans = flip _∘_
120 }
121 }
122 {-# WARNING_ON_USAGE setoid
123 "Warning: setoid was deprecated in v2.0.
124 Please use Function.Properties.Equivalence.setoid instead."
125 #-}
126
127 ⇔-setoid : (ℓ : Level) → Setoid (suc ℓ) ℓ
128 ⇔-setoid ℓ = record
129 { Carrier = Set ℓ
130 ; _≈_ = _⇔_
131 ; isEquivalence = record
132 { refl = id
133 ; sym = sym
134 ; trans = flip _∘_
135 }
136 }
137 {-# WARNING_ON_USAGE ⇔-setoid
138 "Warning: ⇔-setoid was deprecated in v2.0.
139 Please use Function.Properties.Equivalence.⇔-setoid instead."
140 #-}
141
142 ------------------------------------------------------------------------
143 -- Transformations
144
145 map : ∀ {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂}
146 {f₁′ f₂′ t₁′ t₂′}
147 {From′ : Setoid f₁′ f₂′} {To′ : Setoid t₁′ t₂′} →
148 ((From ⟶ To) → (From′ ⟶ To′)) →
149 ((To ⟶ From) → (To′ ⟶ From′)) →
150 Equivalence From To → Equivalence From′ To′
151 map t f eq = record { to = t to; from = f from }
152 where open Equivalence eq
153
154 zip : ∀ {f₁₁ f₂₁ t₁₁ t₂₁}
155 {From₁ : Setoid f₁₁ f₂₁} {To₁ : Setoid t₁₁ t₂₁}
156 {f₁₂ f₂₂ t₁₂ t₂₂}
157 {From₂ : Setoid f₁₂ f₂₂} {To₂ : Setoid t₁₂ t₂₂}
158 {f₁ f₂ t₁ t₂} {From : Setoid f₁ f₂} {To : Setoid t₁ t₂} →
159 ((From₁ ⟶ To₁) → (From₂ ⟶ To₂) → (From ⟶ To)) →
160 ((To₁ ⟶ From₁) → (To₂ ⟶ From₂) → (To ⟶ From)) →
161 Equivalence From₁ To₁ → Equivalence From₂ To₂ →
162 Equivalence From To
163 zip t f eq₁ eq₂ =
164 record { to = t (to eq₁) (to eq₂); from = f (from eq₁) (from eq₂) }
165 where open Equivalence