module 1Lab.HIT.Truncation where
Propositional truncationπ
Let be a type. The propositional truncation of is a type which represents the proposition βA is inhabitedβ. In MLTT, propositional truncations can not be constructed without postulates, even in the presence of impredicative prop. However, Cubical Agda provides a tool to define them: higher inductive types.
data β₯_β₯ {β} (A : Type β) : Type β where
: A β β₯ A β₯
inc : is-prop β₯ A β₯ squash
The two constructors that generate β₯_β₯
state
precisely that the truncation is inhabited when A
is (inc
), and that it is a proposition (squash
).
: β {β} {A : Type β} β is-prop β₯ A β₯
is-prop-β₯-β₯ = squash is-prop-β₯-β₯
The eliminator for β₯_β₯
says that you
can eliminate onto
whenever it is a family of propositions, by providing a case for inc
.
: β {β β'} {A : Type β}
β₯-β₯-elim {P : β₯ A β₯ β Type β'}
β ((x : _) β is-prop (P x))
β ((x : A) β P (inc x))
β (x : β₯ A β₯) β P x
(inc x) = incc x
β₯-β₯-elim pprop incc (squash x y i) =
β₯-β₯-elim pprop incc (Ξ» j β pprop (squash x y j)) (β₯-β₯-elim pprop incc x)
is-propβpathp (β₯-β₯-elim pprop incc y)
i
The propositional truncation can be called the free
proposition on a type, because it satisfies the universal
property that a left
adjoint would have. Specifically, let B
be a
proposition. We have:
: β {β} {A : Type β} {B : Type β}
β₯-β₯-univ β is-prop B β (β₯ A β₯ β B) β (A β B)
{A = A} {B = B} bprop = IsoβEquiv (inc' , iso rec (Ξ» _ β refl) beta) where
β₯-β₯-univ : (x : β₯ A β₯ β B) β A β B
inc' = f (inc x)
inc' f x
: (f : A β B) β β₯ A β₯ β B
rec (inc x) = f x
rec f (squash x y i) = bprop (rec f x) (rec f y) i
rec f
: _
beta = funext (β₯-β₯-elim (Ξ» _ β is-propβis-set bprop _ _) (Ξ» _ β refl)) beta f
Furthermore, as required of a free construction, the propositional truncation extends to a functor:
: β {β β'} {A : Type β} {B : Type β'}
β₯-β₯-map β (A β B) β β₯ A β₯ β β₯ B β₯
(inc x) = inc (f x)
β₯-β₯-map f (squash x y i) = squash (β₯-β₯-map f x) (β₯-β₯-map f y) i β₯-β₯-map f
Using the propositional truncation, we can define the
existential quantifier as a truncated Ξ£
.
: β {a b} (A : Type a) (B : A β Type b) β Type _
β = β₯ Ξ£ A B β₯ β A B
Note that if is already a proposition, then truncating it does nothing:
: β {β} {P : Type β} β is-prop P β P β β₯ P β₯
is-propβequivβ₯-β₯ = prop-ext pprop squash inc (β₯-β₯-out pprop) is-propβequivβ₯-β₯ pprop
In fact, an alternative definition of is-prop
is given by βbeing equivalent to
your own truncationβ:
: β {β} {P : Type β}
is-propβequivβ₯-β₯ β is-prop P β (P β β₯ P β₯)
{P = P} =
is-propβequivβ₯-β₯
prop-ext is-prop-is-prop eqv-prop is-propβequivβ₯-β₯ invwhere
: (P β β₯ P β₯) β is-prop P
inv = equivβis-hlevel 1 ((eqv eβ»ΒΉ) .fst) ((eqv eβ»ΒΉ) .snd) squash
inv eqv
: is-prop (P β β₯ P β₯)
eqv-prop = Ξ£-path (Ξ» i p β squash (x .fst p) (y .fst p) i)
eqv-prop x y (is-equiv-is-prop _ _ _)
Throughout the 1Lab, we use the words βmereβ and βmerelyβ to modify a type to mean its propositional truncation. This terminology is adopted from the HoTT book. For example, a type is said merely equivalent to if the type is inhabited.
Maps into setsπ
The elimination principle for says that we can only use the inside in a way that doesnβt matter: the motive of elimination must be a family of propositions, so our use of must not matter in a very strong sense. Often, itβs useful to relax this requirement slightly: Can we map out of using a constant function?
The answer is yes, provided weβre mapping into a set! In that case, the image of is a proposition, so that we can map from In the next section, weβll see a more general method for mapping into types that arenβt sets.
From the discussion in 1Lab.Counterexamples.Sigma, we know the definition of image, or more properly of
: β {β β'} {A : Type β} {B : Type β'} β (A β B) β Type _
image {A = A} {B = B} f = Ξ£[ b β B ] β[ a β A ] (f a β‘ b) image
To see that the image
indeed
implements the concept of image, we define a way to factor any map
through its image. By the definition of image, we have that the map
f-image
is always surjective, and
since β
is a family of props, the first projection out of
image
is an embedding. Thus we
factor a map
as
f-image: β {β β'} {A : Type β} {B : Type β'}
β (f : A β B) β A β image f
= f x , inc (x , refl) f-image f x
We now prove the theorem that will let us map out of a propositional truncation using a constant function into sets: if is a set, and is a constant function, then is a proposition.
is-constantβimage-is-prop: β {β β'} {A : Type β} {B : Type β'}
β is-set B
β (f : A β B) β (β x y β f x β‘ f y) β is-prop (image f)
This is intuitively true (if the function is constant, then there is at most one thing in the image!), but formalising it turns out to be slightly tricky, and the requirement that be a set is perhaps unexpected.
A sketch of the proof is as follows. Suppose that we have some and in the image. We know, morally, that (respectively give us some and (resp β which would establish that as we need, since we have where the middle equation is by constancy of β but and are hidden under propositional truncations, so we crucially need to use the fact that is a set so that is a proposition.
(a , x) (b , y) =
is-constantβimage-is-prop bset f fconst (Ξ» _ β squash)
Ξ£-prop-path (β₯-β₯-elimβ (Ξ» _ _ β bset _ _)
(Ξ» { (f*a , p) (f*b , q) β sym p Β·Β· fconst f*a f*b Β·Β· q }) x y)
Using the image factorisation, we can project from a propositional truncation onto a set using a constant map.
: β {β β'} {A : Type β} {B : Type β'}
β₯-β₯-rec-set β is-set B
β (f : A β B)
β (β x y β f x β‘ f y)
β β₯ A β₯ β B
{A = A} {B} bset f fconst x =
β₯-β₯-rec-set {P = Ξ» _ β image f}
β₯-β₯-elim (Ξ» _ β is-constantβimage-is-prop bset f fconst) (f-image f) x .fst
Maps into groupoidsπ
We can push this idea further: as discussed in (Kraus 2015), in general, functions are equivalent to coherently constant functions This involves an infinite tower of conditions, each relating to the previous one, which isnβt something we can easily formulate in the language of type theory.
However, when is an it is enough to ask for the first levels of the tower. In the case of sets, weβve seen that the naΓ―ve notion of constancy is enough. We now deal with the case of groupoids, which requires an additional step: we ask for a function equipped with a witness of constancy and a coherence
This time, we cannot hope to show that the image of is a proposition: the image of a map is Instead, we use the following higher inductive type, which can be thought of as the βcodiscrete groupoidβ on
data β₯_β₯Β³ {β} (A : Type β) : Type β where
: A β β₯ A β₯Β³
inc : β a b β inc a β‘ inc b
iconst : β a b c β PathP (Ξ» i β inc a β‘ iconst b c i) (iconst a b) (iconst a c)
icoh : is-groupoid β₯ A β₯Β³ squash
The recursion principle for this type says exactly that any coherently constant function into a groupoid factors through
β₯-β₯Β³-rec: β {β β'} {A : Type β} {B : Type β'}
β is-groupoid B
β (f : A β B)
β (fconst : β x y β f x β‘ f y)
β (β x y z β fconst x y β fconst y z β‘ fconst x z)
β β₯ A β₯Β³ β B
{A = A} {B} bgrpd f fconst fcoh = go where
β₯-β₯Β³-rec : β₯ A β₯Β³ β B
go (inc x) = f x
go (iconst a b i) = fconst a b i
go (icoh a b c i j) = ββsquare (sym (fcoh a b c)) i j
go (squash x y a b p q i j k) = bgrpd
go (go x) (go y)
(Ξ» i β go (a i)) (Ξ» i β go (b i))
(Ξ» i j β go (p i j)) (Ξ» i j β go (q i j))
i j k
All that remains to show is that is a proposition1, which mainly requires writing more elimination principles.
: β {β} {A : Type β} β is-prop β₯ A β₯Β³
β₯-β₯Β³-is-prop = is-contr-if-inhabitedβis-prop $
β₯-β₯Β³-is-prop (Ξ» _ β hlevel 1)
β₯-β₯Β³-elim-prop (Ξ» a β contr (inc a) (β₯-β₯Β³-elim-set (Ξ» _ β squash _ _) (iconst a) (icoh a)))
Hence we get the desired recursion principle for the usual propositional truncation.
β₯-β₯-rec-groupoid: β {β β'} {A : Type β} {B : Type β'}
β is-groupoid B
β (f : A β B)
β (fconst : β x y β f x β‘ f y)
β (β x y z β fconst x y β fconst y z β‘ fconst x z)
β β₯ A β₯ β B
=
β₯-β₯-rec-groupoid bgrpd f fconst fcoh β₯-β₯Β³-rec bgrpd f fconst fcoh β β₯-β₯-rec β₯-β₯Β³-is-prop inc
As we hinted at above, this method generalises (externally) to we sketch the details of the next level for the curious reader.
The next coherence involves a tetrahedron all of whose faces are or, since weβre doing cubical type theory, a βcubical tetrahedronβ:
data β₯_β₯β΄ {β} (A : Type β) : Type β where
: A β β₯ A β₯β΄
inc : β a b β inc a β‘ inc b
iconst : β a b c β PathP (Ξ» i β inc a β‘ iconst b c i) (iconst a b) (iconst a c)
icoh : β a b c d β PathP (Ξ» i β PathP (Ξ» j β inc a β‘ icoh b c d i j)
iassoc (iconst a b) (icoh a c d i))
(icoh a b c) (icoh a b d)
: is-hlevel β₯ A β₯β΄ 4
squash
β₯-β₯β΄-rec: β {β} {A : Type β} {β'} {B : Type β'}
β is-hlevel B 4
β (f : A β B)
β (fconst : β a b β f a β‘ f b)
β (fcoh : β a b c β PathP (Ξ» i β f a β‘ fconst b c i) (fconst a b) (fconst a c))
β (β a b c d β PathP (Ξ» i β PathP (Ξ» j β f a β‘ fcoh b c d i j)
(fconst a b) (fcoh a c d i))
(fcoh a b c) (fcoh a b d))
β β₯ A β₯β΄ β B
unquoteDef β₯-β₯β΄-rec = make-rec-n 4 β₯-β₯β΄-rec (quote β₯_β₯β΄)
in fact, itβs even a propositional truncation of in that it satisfies the same universal property as β©οΈ
References
- Kraus, Nicolai. 2015. βThe General Universal Property of the Propositional Truncation.β https://doi.org/10.4230/LIPICS.TYPES.2014.111.