Skip to content

Commit 8749a19

Browse files
authored
Set coequalizers (#1439)
This adds coequalizers of maps between sets using set quotients, in preparation for more general colimits in the category of sets. It also adds equivalence relations generated from arbitrary relations on types.
1 parent 53f3da9 commit 8749a19

File tree

4 files changed

+448
-0
lines changed

4 files changed

+448
-0
lines changed

src/foundation.lagda.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ open import foundation.finite-sequences-set-quotients public
197197
open import foundation.finitely-coherent-equivalences public
198198
open import foundation.finitely-coherently-invertible-maps public
199199
open import foundation.fixed-points-endofunctions public
200+
open import foundation.freely-generated-equivalence-relations public
200201
open import foundation.full-subtypes public
201202
open import foundation.function-extensionality public
202203
open import foundation.function-types public
@@ -372,6 +373,7 @@ open import foundation.sections public
372373
open import foundation.separated-types-subuniverses public
373374
open import foundation.sequences public
374375
open import foundation.sequential-limits public
376+
open import foundation.set-coequalizers public
375377
open import foundation.set-presented-types public
376378
open import foundation.set-quotients public
377379
open import foundation.set-truncations public
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# Freely generated equivalence relations
2+
3+
```agda
4+
module foundation.freely-generated-equivalence-relations where
5+
```
6+
7+
<details><summary>Imports</summary>
8+
9+
```agda
10+
open import elementary-number-theory.addition-natural-numbers
11+
open import elementary-number-theory.natural-numbers
12+
13+
open import foundation.action-on-identifications-functions
14+
open import foundation.binary-relations
15+
open import foundation.dependent-pair-types
16+
open import foundation.effective-maps-equivalence-relations
17+
open import foundation.equivalence-classes
18+
open import foundation.equivalence-relations
19+
open import foundation.propositional-truncations
20+
open import foundation.raising-universe-levels
21+
open import foundation.reflecting-maps-equivalence-relations
22+
open import foundation.set-quotients
23+
open import foundation.uniqueness-set-quotients
24+
open import foundation.universal-property-set-quotients
25+
open import foundation.universe-levels
26+
27+
open import foundation-core.cartesian-product-types
28+
open import foundation-core.coproduct-types
29+
open import foundation-core.equality-dependent-pair-types
30+
open import foundation-core.equivalences
31+
open import foundation-core.function-types
32+
open import foundation-core.homotopies
33+
open import foundation-core.identity-types
34+
open import foundation-core.propositions
35+
open import foundation-core.sets
36+
open import foundation-core.transport-along-identifications
37+
```
38+
39+
</details>
40+
41+
## Idea
42+
43+
Given an arbitrary [binary relation](foundation.binary-relations.md) `R`, we
44+
construct the free
45+
[equivalence relation](foundation-core.equivalence-relations.md) on `R`. First,
46+
we construct a new reflexive, symmetric, and transitive relation using paths of
47+
arbitrary length composed of edges of `R`: an edge from `x` to `y` is a term
48+
`R x y + R y x`, i.e. a relation in either direction. A path of length 0 is an
49+
[identification](foundation-core.identity-types.md) `x = y` and a path of
50+
length `n+1` is a choice of intermediate `x'`, a path from `x` to `x'` of length
51+
`n`, and an edge from `x'` to `y`. To construct the equivalence relation we take
52+
the [propositional truncation](foundation.propositional-truncations.md) of this
53+
path relation.
54+
55+
## Definition
56+
57+
```agda
58+
module _
59+
{l1 l2 : Level} {A : UU l1} (R : Relation l2 A)
60+
where
61+
62+
edge-Relation : (x y : A) → UU l2
63+
edge-Relation x y = (R x y) + (R y x)
64+
65+
inv-edge-Relation : (x y : A) (e : edge-Relation x y) → edge-Relation y x
66+
inv-edge-Relation x y (inl e) = inr e
67+
inv-edge-Relation x y (inr e) = inl e
68+
69+
finite-path-Relation : (x y : A) (n : ℕ) → UU (l1 ⊔ l2)
70+
finite-path-Relation x y zero-ℕ = raise l2 (x = y)
71+
finite-path-Relation x y (succ-ℕ n) =
72+
Σ ( A)
73+
( λ x' → (finite-path-Relation x x' n) × (edge-Relation x' y))
74+
75+
finite-path-edge-Relation :
76+
(x y : A) (e : edge-Relation x y) → finite-path-Relation x y 1
77+
finite-path-edge-Relation x y e = x , (map-raise refl , e)
78+
79+
refl-finite-path-Relation : (x : A) → finite-path-Relation x x zero-ℕ
80+
refl-finite-path-Relation x = map-raise refl
81+
82+
concat-finite-path-Relation : (x y z : A) (n m : ℕ)
83+
(q : finite-path-Relation y z m) (p : finite-path-Relation x y n) →
84+
finite-path-Relation x z (n +ℕ m)
85+
concat-finite-path-Relation x y z n zero-ℕ (map-raise q) p = tr _ q p
86+
concat-finite-path-Relation x y z n (succ-ℕ m) (y' , q , e) p =
87+
( y') ,
88+
( concat-finite-path-Relation x y y' n m q p) , e
89+
90+
inv-finite-path-Relation : (x y : A) (n : ℕ)
91+
(p : finite-path-Relation x y n) →
92+
finite-path-Relation y x n
93+
inv-finite-path-Relation x y zero-ℕ (map-raise p) = map-raise (inv p)
94+
inv-finite-path-Relation x y (succ-ℕ n) (x' , p , e) =
95+
tr (λ m → finite-path-Relation y x m) (left-one-law-add-ℕ n)
96+
( concat-finite-path-Relation y x' x 1 n
97+
( inv-finite-path-Relation x x' n p)
98+
( finite-path-edge-Relation y x' (inv-edge-Relation x' y e)))
99+
100+
path-Relation : Relation (l1 ⊔ l2) A
101+
path-Relation x y = Σ ℕ (λ n → finite-path-Relation x y n)
102+
103+
is-reflexive-path-Relation : is-reflexive path-Relation
104+
is-reflexive-path-Relation x = (0 , refl-finite-path-Relation x)
105+
106+
is-symmetric-path-Relation : is-symmetric path-Relation
107+
is-symmetric-path-Relation x y (n , p) =
108+
n , (inv-finite-path-Relation x y n p)
109+
110+
is-transitive-path-Relation : is-transitive path-Relation
111+
is-transitive-path-Relation x y z (n , q) (m , p) =
112+
m +ℕ n , concat-finite-path-Relation x y z m n q p
113+
114+
path-Relation-Prop : Relation-Prop (l1 ⊔ l2) A
115+
path-Relation-Prop x y = trunc-Prop (path-Relation x y)
116+
117+
is-reflexive-path-Relation-Prop :
118+
is-reflexive-Relation-Prop path-Relation-Prop
119+
is-reflexive-path-Relation-Prop =
120+
unit-trunc-Prop ∘ is-reflexive-path-Relation
121+
122+
is-symmetric-path-Relation-Prop :
123+
is-symmetric-Relation-Prop path-Relation-Prop
124+
is-symmetric-path-Relation-Prop x y =
125+
rec-trunc-Prop
126+
( path-Relation-Prop y x)
127+
( unit-trunc-Prop ∘ (is-symmetric-path-Relation x y))
128+
is-transitive-path-Relation-Prop :
129+
is-transitive-Relation-Prop path-Relation-Prop
130+
is-transitive-path-Relation-Prop x y z =
131+
rec-trunc-Prop
132+
( path-Relation-Prop x y ⇒ path-Relation-Prop x z)
133+
( λ q →
134+
rec-trunc-Prop
135+
( path-Relation-Prop x z)
136+
( λ p → unit-trunc-Prop (is-transitive-path-Relation x y z q p)))
137+
138+
is-equivalence-relation-path-Relation-Prop :
139+
is-equivalence-relation path-Relation-Prop
140+
is-equivalence-relation-path-Relation-Prop =
141+
( is-reflexive-path-Relation-Prop) ,
142+
( ( is-symmetric-path-Relation-Prop ,
143+
is-transitive-path-Relation-Prop))
144+
145+
equivalence-relation-path-Relation-Prop : equivalence-relation (l1 ⊔ l2) A
146+
equivalence-relation-path-Relation-Prop =
147+
path-Relation-Prop , is-equivalence-relation-path-Relation-Prop
148+
```
149+
150+
## Properties
151+
152+
### It suffices to check generators
153+
154+
To show that a function `A → B` reflects this path relation, it suffices to show
155+
this on generators. To show that a function reflects the (propositionally
156+
truncated) equivalence relation, we need also the codomain `B` to be a set.
157+
158+
```agda
159+
module _
160+
{l1 l2 : Level} {A : UU l1} (R : Relation l2 A)
161+
where
162+
163+
reflects-path-Relation :
164+
{l3 : Level} (B : UU l3) (f : A → B)
165+
(r : (x y : A) → R x y → f x = f y)
166+
(x y : A) →
167+
path-Relation R x y → f x = f y
168+
reflects-path-Relation B f r x y (zero-ℕ , map-raise refl) = refl
169+
reflects-path-Relation B f r x y (succ-ℕ n , x' , p , e) =
170+
( reflects-path-Relation B f r x x' (n , p)) ∙
171+
( forward-r x' y e)
172+
where
173+
forward-r : (a b : A) → edge-Relation R a b → f a = f b
174+
forward-r a b (inl e) = r a b e
175+
forward-r a b (inr e) = inv (r b a e)
176+
177+
reflects-path-Relation-Prop :
178+
{l3 : Level} (B : Set l3) (f : A → type-Set B)
179+
(r : (x y : A) → R x y → f x = f y) →
180+
reflects-equivalence-relation (equivalence-relation-path-Relation-Prop R) f
181+
reflects-path-Relation-Prop B f r {x} {y} =
182+
rec-trunc-Prop
183+
( Id-Prop B (f x) (f y))
184+
( reflects-path-Relation (type-Set B) f r x y)
185+
```
186+
187+
### Any equivalence relation reflecting generators reflects this relation
188+
189+
```agda
190+
module _
191+
{l1 l2 : Level} {A : UU l1} (R : Relation l2 A)
192+
(E : equivalence-relation l2 A)
193+
(r : (x y : A) → R x y → sim-equivalence-relation E x y)
194+
where
195+
196+
equivalence-relation-reflects-path-Relation :
197+
(x y : A) → path-Relation R x y → sim-equivalence-relation E x y
198+
equivalence-relation-reflects-path-Relation x .x (zero-ℕ , map-raise refl) =
199+
refl-equivalence-relation E x
200+
equivalence-relation-reflects-path-Relation x y (succ-ℕ n , z , p , inl e) =
201+
transitive-equivalence-relation E x z y
202+
( r z y e)
203+
( equivalence-relation-reflects-path-Relation x z (n , p))
204+
equivalence-relation-reflects-path-Relation x y (succ-ℕ n , z , p , inr e) =
205+
transitive-equivalence-relation E x z y
206+
( symmetric-equivalence-relation E y z (r y z e))
207+
( equivalence-relation-reflects-path-Relation x z (n , p))
208+
209+
equivalence-relation-reflects-path-Relation-Prop :
210+
(x y : A) →
211+
sim-equivalence-relation (equivalence-relation-path-Relation-Prop R) x y →
212+
sim-equivalence-relation E x y
213+
equivalence-relation-reflects-path-Relation-Prop x y =
214+
rec-trunc-Prop
215+
( prop-equivalence-relation E x y)
216+
( equivalence-relation-reflects-path-Relation x y)
217+
```

0 commit comments

Comments
 (0)