module 1Lab.Function.Embedding where

Embeddings🔗

One of the most important observations leading to the development of categorical set theory is that injective maps into a set SS correspond to maps from SS into a universe of propositions, normally denoted Ω\Omega. Classically, this object is Ω={0,1}\Omega = \{ 0 , 1 \}, but there are other settings in which this idea makes sense (elementary topoi) where the subobject classifier is not a coproduct 111 \coprod 1.

To develop this correspondence, we note that, if a map is injective and its codomain is a set, then all the fibres f(x)f^*(x) of ff are propositions.

injective : (A  B)  Type _
injective f =  {x y}  f x ≡ f y  x ≡ y

injective→is-embedding
  : is-set B  (f : A  B)  injective f
    x  is-prop (fibre f x)
injective→is-embedding bset f inj x (f*x , p) (f*x' , q) =
  Σ-prop-path  x  bset _ _) (inj (p ∙ sym q))

In fact, this condition is not only necessary, it is also sufficient. Thus, we conclude that, for maps between sets, these notions are equivalent, and we could take either as the definition of “subset inclusion”.

has-prop-fibres→injective
  : (f : A  B)  (∀ x  is-prop (fibre f x))
   injective f
has-prop-fibres→injective _ prop p = ap fst (prop _ (_ , p) (_ , refl))

between-sets-injective≃has-prop-fibres
  : is-set A  is-set B  (f : A  B)
   injective f ≃ (∀ x  is-prop (fibre f x))
between-sets-injective≃has-prop-fibres aset bset f =
  prop-ext  p q i x  aset _ _ (p x) (q x) i)
           (Π-is-hlevel 1 λ _  is-prop-is-prop)
           (injective→is-embedding bset f)
           (has-prop-fibres→injective f)

Since we want “is a subtype inclusion” to be a property — that is, we really want to not care about how a function is a subtype inclusion, only that it is, we define embeddings as those functions which have propositional fibres:

is-embedding : (A  B)  Type _
is-embedding f =  x  is-prop (fibre f x)

__ : Type ℓ  Type ℓ₁  Type _
A ↪ B = Σ[ f ∈ (A  B) ] is-embedding f

Univalence — specifically, the existence of classifying objects for maps with PP-fibres — tells us that the embeddings into BB correspond to the families of propositional types over BB.

subtype-classifier
  :  {} {B : Type ℓ}
   (Σ[ A ∈ Type ℓ ] (A ↪ B))(B  Σ[ T ∈ Type ℓ ] (is-prop T))
subtype-classifier {} = Map-classifier {=} is-prop
module subtype-classifier {} {B : Type ℓ} = Equiv (subtype-classifier {B = B})

A canonical source of embedding, then, are the first projections from total spaces of propositional families. This is because, as Fibre-equiv tells us, the fibre of π1\pi_1 over xx is equivalent to “the space of possible second coordinates”, i.e., B(x)B(x). Since B(x)B(x) was assumed to be a prop., then so are the fibres of fst.

Subset-proj-embedding
  :  {B : A  Type ℓ}  (∀ x  is-prop (B x))
   is-embedding {A = Σ A B} fst
Subset-proj-embedding {B = B} Bprop x = is-hlevel≃ 1 (Fibre-equiv B x) (Bprop _)

As ff morphisms🔗

A fully faithful functor is a functor whose action on morphisms is an isomorphism everywhere. By the “types are higher groupoids” analogy, functors are functions, so we’re left to consider: what is a fully faithful function? The answer turns out to be precisely “an embedding”, as long as we interpret “fully faithful” to mean “action on morphisms is an equivalence” everywhere.

module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} {f : A  B} where
  embedding-lemma : (∀ x  is-contr (fibre f (f x)))  is-embedding f
  embedding-lemma cffx y (x , p) q =
    is-contr→is-prop (subst is-contr (ap (fibre f) p) (cffx x)) (x , p) q

  cancellable→embedding : (∀ {x y}  (f x ≡ f y)(x ≡ y))  is-embedding f
  cancellable→embedding eqv =
    embedding-lemma λ x  is-hlevel≃ 0 (Σ-ap-snd  _  eqv)) $
      contr (x , refl) λ (y , p) i  p (~ i) , λ j  p (~ i ∨ j)

  embedding→cancellable : is-embedding f   {x y}  is-equiv {B = f x ≡ f y} (ap f)
  embedding→cancellable emb = total→equiv {f = λ y p  ap f {y = y} p}
    (is-contr→is-equiv
      (contr (_ , refl) λ (y , p) i  p i , λ j  p (i ∧ j))
      (contr (_ , refl) (is-hlevel≃ 1 (Σ-ap-snd λ _  sym-equiv) (emb _) _)))

  equiv→cancellable : is-equiv f   {x y}  is-equiv {B = f x ≡ f y} (ap f)
  equiv→cancellable eqv = embedding→cancellable (is-equiv→is-embedding eqv)