Debian Codegraph @

src/Function/HalfAdjointEquivalence.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.HalfAdjointEquivalence where
11
12 {-# WARNING_ON_IMPORT
13 "Function.HalfAdjointEquivalence was deprecated in v2.0.
14 Use Function.Properties.Inverse.HalfAdjointEquivalence instead."
15 #-}
16
17 open import Function.Base
18 open import Function.Equality using (_⟨$⟩_)
19 open import Function.Inverse as Inv using (_↔_; module Inverse)
20 open import Level
21 open import Relation.Binary.PropositionalEquality
22
23 -- Half adjoint equivalences (see the HoTT book).
24
25 infix 4 _≃_
26
27 record _≃_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
28 field
29 to : A → B
30 from : B → A
31 left-inverse-of : ∀ x → from (to x) ≡ x
32 right-inverse-of : ∀ x → to (from x) ≡ x
33 left-right :
34 ∀ x → cong to (left-inverse-of x) ≡ right-inverse-of (to x)
35
36 -- Half adjoint equivalences can be turned into inverses.
37
38 inverse : A ↔ B
39 inverse = Inv.inverse to from left-inverse-of right-inverse-of
40
41 -- The forward direction of a half adjoint equivalence is injective.
42
43 injective : ∀ {x y} → to x ≡ to y → x ≡ y
44 injective {x} {y} to-x≡to-y =
45 x ≡⟨ sym (left-inverse-of _) ⟩
46 from (to x) ≡⟨ cong from to-x≡to-y ⟩
47 from (to y) ≡⟨ left-inverse-of _ ⟩
48 y ∎
49 where
50 open ≡-Reasoning
51
52 -- Inverses can be turned into half adjoint equivalences.
53 --
54 -- (This proof is based on one in the HoTT book.)
55
56 ↔→≃ : ∀ {a b} {A : Set a} {B : Set b} → A ↔ B → A ≃ B
57 ↔→≃ A↔B = record
58 { to = to ⟨$⟩_
59 ; from = from ⟨$⟩_
60 ; left-inverse-of = left-inverse-of
61 ; right-inverse-of = right-inverse-of
62 ; left-right = left-right
63 }
64 where
65 open ≡-Reasoning
66 open module A↔B = Inverse A↔B using (to; from; left-inverse-of)
67
68 right-inverse-of : ∀ x → to ⟨$⟩ (from ⟨$⟩ x) ≡ x
69 right-inverse-of x =
70 to ⟨$⟩ (from ⟨$⟩ x) ≡⟨ sym (A↔B.right-inverse-of _) ⟩
71 to ⟨$⟩ (from ⟨$⟩ (to ⟨$⟩ (from ⟨$⟩ x))) ≡⟨ cong (to ⟨$⟩_) (left-inverse-of _) ⟩
72 to ⟨$⟩ (from ⟨$⟩ x) ≡⟨ A↔B.right-inverse-of _ ⟩
73 x ∎
74
75 left-right :
76 ∀ x →
77 cong (to ⟨$⟩_) (left-inverse-of x) ≡ right-inverse-of (to ⟨$⟩ x)
78 left-right x =
79 cong (to ⟨$⟩_) (left-inverse-of x) ≡⟨⟩
80
81 trans refl (cong (to ⟨$⟩_) (left-inverse-of _)) ≡⟨ cong (λ p → trans p (cong (to ⟨$⟩_) _))
82 (sym (trans-symˡ (A↔B.right-inverse-of _))) ⟩
83 trans (trans (sym (A↔B.right-inverse-of _))
84 (A↔B.right-inverse-of _))
85 (cong (to ⟨$⟩_) (left-inverse-of _)) ≡⟨ trans-assoc (sym (A↔B.right-inverse-of _)) ⟩
86
87 trans (sym (A↔B.right-inverse-of _))
88 (trans (A↔B.right-inverse-of _)
89 (cong (to ⟨$⟩_) (left-inverse-of _))) ≡⟨ cong (trans (sym (A↔B.right-inverse-of _))) lemma ⟩
90
91 trans (sym (A↔B.right-inverse-of _))
92 (trans (cong (to ⟨$⟩_) (left-inverse-of _))
93 (trans (A↔B.right-inverse-of _) refl)) ≡⟨⟩
94
95 right-inverse-of (to ⟨$⟩ x) ∎
96 where
97 lemma =
98 trans (A↔B.right-inverse-of _)
99 (cong (to ⟨$⟩_) (left-inverse-of _)) ≡⟨ cong (trans (A↔B.right-inverse-of _)) (sym (cong-id _)) ⟩
100
101 trans (A↔B.right-inverse-of _)
102 (cong id (cong (to ⟨$⟩_) (left-inverse-of _))) ≡⟨ sym (naturality A↔B.right-inverse-of) ⟩
103
104 trans (cong ((to ⟨$⟩_) ∘ (from ⟨$⟩_))
105 (cong (to ⟨$⟩_) (left-inverse-of _)))
106 (A↔B.right-inverse-of _) ≡⟨ cong (λ p → trans p (A↔B.right-inverse-of _))
107 (sym (cong-∘ _)) ⟩
108 trans (cong ((to ⟨$⟩_) ∘ (from ⟨$⟩_) ∘ (to ⟨$⟩_))
109 (left-inverse-of _))
110 (A↔B.right-inverse-of _) ≡⟨ cong (λ p → trans p (A↔B.right-inverse-of _))
111 (cong-∘ _) ⟩
112 trans (cong (to ⟨$⟩_)
113 (cong ((from ⟨$⟩_) ∘ (to ⟨$⟩_))
114 (left-inverse-of _)))
115 (A↔B.right-inverse-of _) ≡⟨ cong (λ p → trans (cong (to ⟨$⟩_) p) _)
116 (cong-≡id left-inverse-of) ⟩
117 trans (cong (to ⟨$⟩_) (left-inverse-of _))
118 (A↔B.right-inverse-of _) ≡⟨ cong (trans (cong (to ⟨$⟩_) (left-inverse-of _)))
119 (sym (trans-reflʳ _)) ⟩
120 trans (cong (to ⟨$⟩_) (left-inverse-of _))
121 (trans (A↔B.right-inverse-of _) refl) ∎