module 1Lab.Function.Surjection where


A function is a surjection if, for each we have that is, all of its fibres are inhabited. Using the notation for mere existence, we may write this as

which is evidently the familiar notion of surjection.

is-surjective : (A β†’ B) β†’ Type _
is-surjective f = βˆ€ b β†’ βˆ₯ fibre f b βˆ₯

To abbreviate talking about surjections, we will use the notation pronounced β€œ covers ”.

_β† _ : Type β„“ β†’ Type β„“' β†’ Type (β„“ βŠ” β„“')
A β†  B = Ξ£[ f ∈ (A β†’ B) ] is-surjective f

The notion of surjection is intimately connected with that of quotient, and in particular with the elimination principle into propositions. We think of a surjection as expressing that can be β€œglued together” by introducing paths between the elements of Since any family of propositions respects these new paths, we can prove a property of by showing it for the β€œgenerators” coming from

  : (f : A β†  B)
  β†’ βˆ€ {β„“} (P : B β†’ Type β„“)
  β†’ (βˆ€ x β†’ is-prop (P x))
  β†’ (βˆ€ a β†’ P (f .fst a))
  β†’ βˆ€ x β†’ P x
is-surjective→elim-prop (f , surj) P pprop pfa x =
  βˆ₯-βˆ₯-rec (pprop _) (Ξ» (x , p) β†’ subst P p (pfa x)) (surj x)

When the type is a set, we can actually take this analogy all the way to its conclusion: Given any cover we can produce an equivalence between and the quotient of under the congruence induced by See surjections are quotient maps.

Closure propertiesπŸ”—

The class of surjections contains the identity β€” and thus every equivalence β€” and is closed under composition.

  : {f : B β†’ C} {g : A β†’ B}
  β†’ is-surjective f
  β†’ is-surjective g
  β†’ is-surjective (f ∘ g)
∘-is-surjective {f = f} fs gs x = do
  (f*x , p) ← fs x
  (g*fx , q) ← gs f*x
  pure (g*fx , ap f q βˆ™ p)

id-is-surjective : is-surjective {A = A} id
id-is-surjective x = inc (x , refl)

is-equiv→is-surjective : {f : A → B} → is-equiv f → is-surjective f
is-equiv→is-surjective eqv x = inc (eqv .is-eqv x .centre)

Relationship with equivalencesπŸ”—

We have defined equivalences to be the maps with contractible fibres; and surjections to be the maps with inhabited fibres. It follows that a surjection is an equivalence precisely if its fibres are also propositions; in other words, if it is an embedding.

  : {f : A β†’ B}
  β†’ is-embedding f
  β†’ is-surjective f
  β†’ is-equiv f
embedding-surjectiveβ†’is-equiv f-emb f-surj .is-eqv x = βˆ₯-βˆ₯-out! do
  pt ← f-surj x
  pure $ is-propβˆ™β†’is-contr (f-emb x) pt