Martin Escardo, August 2018.
Large set quotients in univalent mathematics in Agda notation.
This took place during the Dagstuhl meeting "Formalization of
Mathematics in Type Theory", because Dan Grayson wanted to see how
universe levels work in Agda and I thought that this would be a nice
example to illustrate that.
We assume, in addition to Spartan Martin-LΓΆf type theory,
* function extensionality
(any two pointwise equal functions are equal),
* propositional extensionality
(any two logically equivalent propositions are equal),
* propositional truncation
(any type can be universally mapped into a prop in the same
universe),
and no resizing axioms.
The K axiom is not used (the without-K option below). We also make
sure pattern matching corresponds to Martin-LΓΆf eliminators, using the
option exact-split. With the option safe we make sure that nothing
is postulated - any non-MLTT axiom has to be an explicit assumption
(argument to a function or a module).
\begin{code}
{-# OPTIONS --safe --without-K #-}
open import MLTT.Spartan
open import Quotient.Type
open import UF.Base hiding (_β_)
open import UF.FunExt
open import UF.Powerset
open import UF.PropTrunc
open import UF.Sets
open import UF.Sets-Properties
open import UF.SubtypeClassifier
open import UF.Subsingletons
open import UF.Subsingletons-FunExt
module Quotient.Large
(pt : propositional-truncations-exist)
(fe : Fun-Ext)
(pe : Prop-Ext)
where
open PropositionalTruncation pt
open import UF.ImageAndSurjection pt
\end{code}
(NB. The Agda library uses the word "Level" for universes, and then
what we write "π€ Μ" here is written "Set π€". This is not good for
univalent mathematics, because the types in π€ Μ need not be sets, and
also because it places emphasis on levels rather than universes
themselves.)
Now, using an anonymous module UF.with parameters (corresponding to a
section in Coq), we assume propositional truncations that stay in the
same universe, function extensionality for all universes, two
universes π€ and π₯, propositional truncation for the universe π₯, a type
X : π€ Μ, and an equivalence relation _β_ with values in π₯ Μ.
\begin{code}
module large-quotient
{π€ π₯ : Universe}
(X : π€ Μ )
(β@(_β_ , βp , βr , βs , βt) : EqRel {π€} {π₯} X)
where
\end{code}
Now, Ξ© π₯ is the type of subsingletons, or (univalent) propositions, or
h-propositions, or mere propositions, in the universe π₯, which lives
in the next universe π₯ βΊ.
From the relation _β_ : X β (X β π₯ Μ ) we define a relation
X β (X β Ξ© π₯), which of course is formally a function. We then take
the quotient X/β to be the image of this function.
Of course, it is for constructing the image that we need propositional
truncations.
\begin{code}
equiv-rel : X β (X β Ξ© π₯)
equiv-rel x y = x β y , βp x y
\end{code}
Then the quotient lives in the least upper bound of π€ and π₯ βΊ, where π₯ βΊ
is the successor of the universe π₯:
\begin{code}
X/β : π€ β (π₯ βΊ) Μ
X/β = image equiv-rel
X/β-is-set : is-set X/β
X/β-is-set = subsets-of-sets-are-sets (X β Ξ© π₯) _
(powersets-are-sets'' fe fe pe)
β₯β₯-is-prop
Ξ· : X β X/β
Ξ· = corestriction equiv-rel
\end{code}
Then Ξ· is the universal solution to the problem of transforming
equivalence _β_ into equality _οΌ_ (identity type).
By construction, Ξ· is a surjection, of course:
\begin{code}
Ξ·-surjection : is-surjection Ξ·
Ξ·-surjection = corestrictions-are-surjections equiv-rel
\end{code}
It is convenient to use the following induction principle for
reasoning about the image. Notice that the property we consider has
values in any universe π¦ we please:
\begin{code}
quotient-induction : β {π¦} (P : X/β β π¦ Μ )
β ((x' : X/β) β is-prop (P x'))
β ((x : X) β P (Ξ· x))
β (x' : X/β) β P x'
quotient-induction = surjection-induction Ξ· Ξ·-surjection
\end{code}
The first part of the universal property of Ξ· says that equivalent
points are mapped to equal points:
\begin{code}
Ξ·-identifies-related-points : {x y : X} β x β y β Ξ· x οΌ Ξ· y
Ξ·-identifies-related-points {x} {y} e =
to-Ξ£-οΌ (dfunext fe
(Ξ» z β to-Ξ£-οΌ (pe (βp x z) (βp y z) (βt y x z (βs x y e)) (βt x y z e) ,
being-prop-is-prop fe _ _)) ,
β₯β₯-is-prop _ _)
\end{code}
We also need the fact that Ξ· reflects equality into equivalence:
\begin{code}
Ξ·-relates-identified-points : {x y : X} β Ξ· x οΌ Ξ· y β x β y
Ξ·-relates-identified-points {x} {y} p = equiv-rel-reflect (ap prβ p)
where
equiv-rel-reflect : equiv-rel x οΌ equiv-rel y β x β y
equiv-rel-reflect q = b (βr y)
where
a : (y β y) οΌ (x β y)
a = ap (Ξ» - β prβ (- y)) (q β»ΒΉ)
b : (y β y) β (x β y)
b = Idtofun a
\end{code}
We are now ready to formulate and prove the universal property of the
quotient. What is noteworthy here, regarding universes, is that the
universal property says that we can eliminate into any set A of any
universe π¦.
Ξ·
X ------> X/β
\ .
\ .
f \ . f'
\ .
v
A
\begin{code}
universal-property : β {π¦} (A : π¦ Μ )
β is-set A
β (f : X β A)
β ({x x' : X} β x β x' β f x οΌ f x')
β β! f' κ ( X/β β A), f' β Ξ· βΌ f
universal-property {π¦} A iss f pr = ic
where
Ο : (x' : X/β) β is-prop (Ξ£ a κ A , β x κ X , (Ξ· x οΌ x') Γ (f x οΌ a))
Ο = quotient-induction _ Ξ³ induction-step
where
induction-step : (y : X) β is-prop (Ξ£ a κ A , β x κ X , (Ξ· x οΌ Ξ· y) Γ (f x οΌ a))
induction-step x (a , d) (b , e) = to-Ξ£-οΌ (p , β₯β₯-is-prop _ _)
where
h : (Ξ£ x' κ X , (Ξ· x' οΌ Ξ· x) Γ (f x' οΌ a))
β (Ξ£ y' κ X , (Ξ· y' οΌ Ξ· x) Γ (f y' οΌ b))
β a οΌ b
h (x' , r , s) (y' , t , u) = s β»ΒΉ β pr (Ξ·-relates-identified-points (r β t β»ΒΉ)) β u
p : a οΌ b
p = β₯β₯-rec iss (Ξ» Ο β β₯β₯-rec iss (h Ο) e) d
Ξ³ : (x' : X/β) β is-prop (is-prop (Ξ£ a κ A , β x κ X , (Ξ· x οΌ x') Γ (f x οΌ a)))
Ξ³ x' = being-prop-is-prop fe
k : (x' : X/β) β Ξ£ a κ A , β x κ X , (Ξ· x οΌ x') Γ (f x οΌ a)
k = quotient-induction _ Ο induction-step
where
induction-step : (y : X) β Ξ£ a κ A , β x κ X , (Ξ· x οΌ Ξ· y) Γ (f x οΌ a)
induction-step x = f x , β£ x , refl , refl β£
f' : X/β β A
f' x' = prβ (k x')
r : f' β Ξ· βΌ f
r = h
where
g : (y : X) β β x κ X , (Ξ· x οΌ Ξ· y) Γ (f x οΌ f' (Ξ· y))
g y = prβ (k (Ξ· y))
j : (y : X) β (Ξ£ x κ X , (Ξ· x οΌ Ξ· y) Γ (f x οΌ f' (Ξ· y))) β f' (Ξ· y) οΌ f y
j y (x , p , q) = q β»ΒΉ β pr (Ξ·-relates-identified-points p)
h : (y : X) β f' (Ξ· y) οΌ f y
h y = β₯β₯-rec iss (j y) (g y)
c : (Ο : Ξ£ f'' κ (X/β β A), f'' β Ξ· βΌ f) β (f' , r) οΌ Ο
c (f'' , s) = to-Ξ£-οΌ (t , v)
where
w : β x β f' (Ξ· x) οΌ f'' (Ξ· x)
w x = r x β (s x)β»ΒΉ
t : f' οΌ f''
t = dfunext fe (quotient-induction _ (Ξ» _ β iss) w)
u : f'' β Ξ· βΌ f
u = transport (Ξ» - β - β Ξ· βΌ f) t r
v : u οΌ s
v = dfunext fe (Ξ» x β iss (u x) (s x))
ic : β! f' κ (X/β β A), f' β Ξ· βΌ f
ic = (f' , r) , c
\end{code}
Added 11 Sep 2023 by Martin Escardo. Package the above into the type
of existence of large effective set quotients.
\begin{code}
large-set-quotients : large-set-quotients-exist
large-set-quotients =
record
{ _/_ = Ξ» {π€ π₯ : Universe} (X : π€ Μ ) β large-quotient.X/β X
; Ξ·/ = Ξ» {π€ π₯ : Universe} {X : π€ Μ } β large-quotient.Ξ· X
; Ξ·/-identifies-related-points = Ξ» {π€ π₯ : Universe} {X : π€ Μ }
β large-quotient.Ξ·-identifies-related-points X
; /-is-set = Ξ» {π€ π₯ : Universe} {X : π€ Μ } β large-quotient.X/β-is-set X
; /-universality = Ξ» {π€ π₯ : Universe} {X : π€ Μ } (β : EqRel {π€} {π₯} X)
{π¦ : Universe} {Y : π¦ Μ }
β large-quotient.universal-property X β Y
}
large-effective-set-quotients : are-effective large-set-quotients
large-effective-set-quotients {π€} {π₯} {X} β {x} {y} =
large-quotient.Ξ·-relates-identified-points X β
\end{code}