open import 1Lab.Classical
open import 1Lab.Prelude

open import Data.Dec
open import Data.Fin

open import Meta.Invariant

module Data.Set.Projective where


# Set-projective typesπ

private variable
β β' β'' : Level


A type is set-projective if we can commute propositional truncation past families.

is-set-projective : β {β} (A : Type β) β (ΞΊ : Level) β Type _
is-set-projective A ΞΊ =
β (P : A β Type ΞΊ)
β (β a β is-set (P a))
β (β a β β₯ P a β₯)
β β₯ (β a β P a) β₯


Intuitively, a type is set-projective if it validates a sort of version of the axiom of choice.

If is a set, then is set-projective if and only if every surjection from a set splits.

surjections-splitβset-projective
: β {β β'} {A : Type β}
β is-set A
β (β (E : Type (β β β')) β is-set E
β (f : E β A) β is-surjective f
β β₯ (β a β fibre f a) β₯)
β is-set-projective A (β β β')

sets-projectiveβsurjections-split
: β {β β'} {A : Type β}
β is-set A
β is-set-projective A (β β β')
β β {E : Type β'} β is-set E
β (f : E β A) β is-surjective f
β β₯ (β a β fibre f a) β₯

This is essentially a specialization of the of the proof that the axiom of choice is equivalent to every surjection splitting, so we will not dwell on the details.
surjections-splitβset-projective {A = A} A-set surj-split P P-set β₯Pβ₯ =
β₯-β₯-map
(Equiv.to (Ξ -codβ (Fibre-equiv P)))
(surj-split (Ξ£[ x β A ] (P x)) (Ξ£-is-hlevel 2 A-set P-set) fst Ξ» x β
β₯-β₯-map (Equiv.from (Fibre-equiv P x)) (β₯Pβ₯ x))

sets-projectiveβsurjections-split A-set A-pro E-set f =
A-pro (fibre f) (Ξ» x β fibre-is-hlevel 2 E-set A-set f x)


## Closure of set-projectivityπ

Set-projective types are closed under Ξ£-types. Suppose that is a set-projective type, and that is a family of set-projective types, and let be a family of merely inhabited sets. Note that is a family of merely inhabited sets for every so its product must also be inhabited by projectivity of Moreover, is also projective, so is also merely inhabited, as is an family of merely inhabited sets. We can then uncurry this family to finish the proof.

Ξ£-set-projective
: β {A : Type β} {B : A β Type β'}
β is-set-projective A (β' β β'')
β (β a β is-set-projective (B a) β'')
β is-set-projective (Ξ£[ a β A ] B a) β''
Ξ£-set-projective {A = A} {B = B} A-pro B-pro P P-set β₯Pβ₯ = do
β₯-β₯-map uncurry \$
A-pro (Ξ» a β ((b : B a) β P (a , b))) (Ξ» a β Ξ -is-hlevel 2 Ξ» b β P-set (a , b)) Ξ» a β
B-pro a (Ξ» b β P (a , b)) (Ξ» b β P-set (a , b)) Ξ» b β β₯Pβ₯ (a , b)


Moreover, set-projective types are stable under retracts. Suppose that we have with with set-projective, and let be a family of merely inhabited sets. We can precompose with to obtain an family of sets whose product must be inhabited via projectivity of Moreover, we can precompose again with to see that is merely inhabited. Finally, so is merely inhabited.

retractβset-projective
: β {A : Type β} {B : Type β'}
β (f : A β B) (g : B β A)
β is-left-inverse f g
β is-set-projective A β''
β is-set-projective B β''
retractβset-projective {A = A} {B = B} f g retract A-pro P P-set β₯Pβ₯ =
β₯-β₯-map (Ξ» k b β subst P (retract b) (k (g b)))
(A-pro (P β f) (P-set β f) (β₯Pβ₯ β f))


This gives us a nice proof that set-projectivity is stable under equivalence.

Equivβset-projective
: β {A : Type β} {B : Type β'}
β A β B
β is-set-projective A β''
β is-set-projective B β''
Equivβset-projective f A-pro =
retractβset-projective (Equiv.to f) (Equiv.from f) (Equiv.Ξ΅ f) A-pro


By the theorem of finite choice, finite sets are projective.

Fin-set-projective : β {n} β is-set-projective (Fin n) β
Fin-set-projective {n = n} P P-set β₯Pβ₯ = finite-choice n β₯Pβ₯

finiteβset-projective
: {A : Type β}
β Finite A
β is-set-projective A β'
finiteβset-projective finite =
rec! (Ξ» enum β Equivβset-projective (enum eβ»ΒΉ) Fin-set-projective)
(Finite.enumeration finite)


## Taboosπ

As it turns out, the finite types are the only types that are projective constructively! The general sketch of the taboo is that it is consistent that:

1. Propositions are projective.
2. Every infinite set admits an injection from Nat. In other words, every infinite set is Dedekind-infinite.
3. Countable choice fails (IE: the natural numbers are not set-projective).

The existence of such a model is out of scope for this page, so we will focus our attention on the internal portion of the argument. In particular, we will prove that if propositions are set-projective, then the existence of an Dedekind-infinite set-projective type implies countable choice.

First, note that if propositions are set-projective, then the image of every function into a set-projective type is itself set-projective. This follows directly from the definition of images, along with closure of projectives under Ξ£.

module _
(props-projective : β {β β'} β (A : Type β) β is-prop A β is-set-projective A β')
where

props-projectiveβimage-projective
: β {A : Type β} {B : Type β'}
β (f : A β B)
β is-set-projective B (β β β' β β'')
β is-set-projective (image f) β''
props-projectiveβimage-projective f B-pro =
Ξ£-set-projective B-pro Ξ» b β props-projective _ (hlevel 1)


This in turn implies that set-projective types are stable under embeddings, as the image of an embedding is equivalent to

  props-projective+is-embeddingβset-projective
: β {A : Type β} {B : Type β'} {f : A β B}
β is-embedding f
β is-set-projective B (β β β' β β'')
β is-set-projective A β''
props-projective+is-embeddingβset-projective {f = f} f-emb B-pro =
Equivβset-projective
(is-embeddingβimage-equiv f-emb eβ»ΒΉ)
(props-projectiveβimage-projective f B-pro)


If we specialise this result to embeddings then we obtain countable choice from the existence of a Dedekind-infinite type.

  props-projective+dedekind-infinite-projectiveβcountable-choice
: β {A : Type β} {f : Nat β A}
β is-embedding f
β is-set-projective A (β β β')
β is-set-projective Nat β'
props-projective+dedekind-infinite-projectiveβcountable-choice =
props-projective+is-embeddingβset-projective


Note that the set-projectivity of propositions is itself a taboo: in particular, every proposition is set-projective if and only if every set has split support. The following proof is adapted from .

We will start with the reverse direction. Suppose that every proposition is set projective, and let be a set. The truncation of is a propositon, and the constant family is a set-indexed family, so projectivity of directly gives us split support.

props-projectiveβsplit-support
: β {β}
β ((A : Type β) β is-prop A β is-set-projective A β)
β β (A : Type β) β is-set A β β₯ (β₯ A β₯ β A) β₯
props-projectiveβsplit-support props-projective A A-set =
props-projective β₯ A β₯ (hlevel 1) (Ξ» _ β A) (Ξ» _ β A-set) id


For the forward direction, suppose that every set has split support, let be a proposition, and a family of merely inhabited sets. Note that the type is a set, so it must have split support Moreover, is always merely inhabited, so we can readily show that Finally, is a proposition, so we can obtain a from for any if we combine this with our previous observation, we immediately get

split-supportβprops-projective
: β {β}
β (β (A : Type β) β is-set A β β₯ (β₯ A β₯ β A) β₯)
β (A : Type β) β is-prop A β is-set-projective A β
split-supportβprops-projective split-support A A-prop P P-set β₯Pβ₯ = do
s β split-support (Ξ£[ a β A ] P a) (Ξ£-is-hlevel 2 (is-propβis-set A-prop) P-set)
pure Ξ» a β subst P (A-prop _ _) (snd (s (β₯-β₯-map (Ξ» p β (a , p)) (β₯Pβ₯ a))))


## References

• Kraus, Nicolai, M. EscardΓ³, T. Coquand, and Thorsten Altenkirch. 2016. βNotions of Anonymous Existence in Martin-LΓΆf Type Theory.β Log. Methods Comput. Sci.