Martin Escardo and Tom de Jong, October 2021
Modified from UF.ImageAndSurjection.lagda to add the parameter F.
We use F to control the universe where propositional truncations live.
For more comments and explanations, see the original files.
\begin{code}
{-# OPTIONS --safe --without-K #-}
open import MLTT.Spartan
module UF.ImageAndSurjection-Variation (F : Universe โ Universe) where
open import UF.Base
open import UF.Embeddings
open import UF.Equiv
open import UF.EquivalenceExamples
open import UF.Hedberg
open import UF.PropTrunc-Variation F
open import UF.Retracts
open import UF.Sets
open import UF.Sets-Properties
open import UF.Subsingletons
open import UF.Subsingletons-Properties
module ImageAndSurjection (pt : propositional-truncations-exist) where
open PropositionalTruncation pt
_โimage_ : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ Y โ (X โ Y) โ F (๐ค โ ๐ฅ) ฬ
y โimage f = โ x ๊ domain f , f x ๏ผ y
being-in-the-image-is-prop : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (y : Y) (f : X โ Y)
โ is-prop (y โimage f)
being-in-the-image-is-prop y f = โ-is-prop
image : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ F (๐ค โ ๐ฅ) โ ๐ฅ ฬ
image f = ฮฃ y ๊ codomain f , y โimage f
restriction : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ image f โ Y
restriction f (y , _) = y
restriction-embedding : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-embedding (restriction f)
restriction-embedding f = prโ-is-embedding (ฮป y โ โฅโฅ-is-prop)
corestriction : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ X โ image f
corestriction f x = f x , โฃ x , refl โฃ
wconstant-maps-to-sets-have-propositional-images : (X : ๐ค ฬ ) {Y : ๐ฅ ฬ }
โ is-set Y
โ (f : X โ Y)
โ wconstant f
โ is-prop (image f)
wconstant-maps-to-sets-have-propositional-images X s f c (y , p) (y' , p') =
to-ฮฃ-๏ผ (โฅโฅ-rec s (ฮป u โ โฅโฅ-rec s (ฮป v โ h u v) p') p ,
โฅโฅ-is-prop _ p')
where
h : (ฮฃ x ๊ X , f x ๏ผ y) โ (ฮฃ x' ๊ X , f x' ๏ผ y') โ y ๏ผ y'
h (x , e) (x' , e') = y ๏ผโจ e โปยน โฉ
f x ๏ผโจ c x x' โฉ
f x' ๏ผโจ e' โฉ
y' โ
wconstant-map-to-set-truncation-of-domain-map' : (X : ๐ค ฬ ) {Y : ๐ฅ ฬ }
โ is-set Y
โ (f : X โ Y)
โ wconstant f
โ โฅ X โฅ โ image f
wconstant-map-to-set-truncation-of-domain-map' X s f c =
โฅโฅ-rec
(wconstant-maps-to-sets-have-propositional-images X s f c)
(corestriction f)
wconstant-map-to-set-truncation-of-domain-map : (X : ๐ค ฬ ) {Y : ๐ฅ ฬ }
โ is-set Y
โ (f : X โ Y)
โ wconstant f
โ โฅ X โฅ โ Y
wconstant-map-to-set-truncation-of-domain-map X s f c =
restriction f โ wconstant-map-to-set-truncation-of-domain-map' X s f c
wconstant-map-to-set-factors-through-truncation-of-domain : (X : ๐ค ฬ ) {Y : ๐ฅ ฬ }
(s : is-set Y)
(f : X โ Y)
(c : wconstant f)
โ f โผ (wconstant-map-to-set-truncation-of-domain-map X s f c) โ โฃ_โฃ
wconstant-map-to-set-factors-through-truncation-of-domain X s f c = ฮณ
where
g : โฅ X โฅ โ image f
g = wconstant-map-to-set-truncation-of-domain-map' X s f c
p : is-prop (image f)
p = wconstant-maps-to-sets-have-propositional-images X s f c
ฮณ : (x : X) โ f x ๏ผ restriction f (g โฃ x โฃ)
ฮณ x = f x ๏ผโจ refl โฉ
restriction f (corestriction f x) ๏ผโจ ap (restriction f)
(p (corestriction f x) (g โฃ x โฃ)) โฉ
restriction f (g โฃ x โฃ) โ
is-surjection : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ F (๐ค โ ๐ฅ) โ ๐ฅ ฬ
is-surjection f = โ y โ โ x ๊ domain f , f x ๏ผ y
_โ _ : ๐ค ฬ โ ๐ฅ ฬ โ F (๐ค โ ๐ฅ) โ ๐ค โ ๐ฅ ฬ
X โ Y = ฮฃ f ๊ (X โ Y) , is-surjection f
image-is-set : {X : ๐ค ฬ } {Y : ๐ฅ ฬ }
โ (f : X โ Y)
โ is-set Y
โ is-set (image f)
image-is-set f i = subsets-of-sets-are-sets _
(ฮป y โ y โimage f) i
(being-in-the-image-is-prop _ f)
vv-equiv-iff-embedding-and-surjection : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-vv-equiv f โ is-embedding f ร is-surjection f
vv-equiv-iff-embedding-and-surjection f = g , h
where
g : is-vv-equiv f โ is-embedding f ร is-surjection f
g i = (ฮป y โ prโ (prโ the-singletons-are-the-inhabited-propositions (i y))) ,
(ฮป y โ prโ (prโ the-singletons-are-the-inhabited-propositions (i y)))
h : is-embedding f ร is-surjection f โ is-vv-equiv f
h (e , s) = ฮป y โ prโ the-singletons-are-the-inhabited-propositions (e y , s y)
surjective-embeddings-are-vv-equivs : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-embedding f โ is-surjection f โ is-vv-equiv f
surjective-embeddings-are-vv-equivs f e s = prโ (vv-equiv-iff-embedding-and-surjection f) (e , s)
surjective-embeddings-are-equivs : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-embedding f โ is-surjection f โ is-equiv f
surjective-embeddings-are-equivs f e s = vv-equivs-are-equivs f (surjective-embeddings-are-vv-equivs f e s)
corestriction-is-surjection : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-surjection (corestriction f)
corestriction-is-surjection f (y , s) = โฅโฅ-functor g s
where
g : (ฮฃ x ๊ domain f , f x ๏ผ y) โ ฮฃ x ๊ domain f , corestriction f x ๏ผ (y , s)
g (x , p) = x , to-ฮฃ-๏ผ (p , โฅโฅ-is-prop _ _)
pt-is-surjection : {X : ๐ค ฬ } โ is-surjection (ฮป (x : X) โ โฃ x โฃ)
pt-is-surjection t = โฅโฅ-rec โฅโฅ-is-prop (ฮป x โ โฃ x , โฅโฅ-is-prop (โฃ x โฃ) t โฃ) t
Natฮฃ-is-surjection : {X : ๐ค ฬ } (A : X โ ๐ฅ ฬ ) (B : X โ ๐ฆ ฬ ) (ฮถ : Nat A B)
โ ((x : X) โ is-surjection (ฮถ x))
โ is-surjection (Natฮฃ ฮถ)
Natฮฃ-is-surjection A B ฮถ i (x , b) = ฮณ
where
ฮด : (ฮฃ a ๊ A x , ฮถ x a ๏ผ b)
โ ฮฃ (x' , a) ๊ ฮฃ A , (x' , ฮถ x' a) ๏ผ (x , b)
ฮด (a , p) = (x , a) , (ap (x ,_) p)
ฮณ : โ (x' , a) ๊ ฮฃ A , (x' , ฮถ x' a) ๏ผ (x , b)
ฮณ = โฅโฅ-functor ฮด (i x b)
corestriction-of-embedding-is-equivalence : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-embedding f
โ is-equiv (corestriction f)
corestriction-of-embedding-is-equivalence f e =
surjective-embeddings-are-equivs f' e' s'
where
f' : domain f โ image f
f' = corestriction f
s' : is-surjection f'
s' = corestriction-is-surjection f
e' : is-embedding f'
e' (y , p) = retract-of-prop ฮณ (e y)
where
ฮณ : fiber f' (y , p) โ fiber f y
ฮณ = ฮฃ-retract (ฮป x โ f' x ๏ผ y , p) (ฮป x โ f x ๏ผ y) ฯ
where
ฯ : (x : domain f) โ (f' x ๏ผ (y , p)) โ (f x ๏ผ y)
ฯ x = ฯ , ฯ , ฮท
where
ฯ : f x ๏ผ y โ f' x ๏ผ (y , p)
ฯ q = to-subtype-๏ผ (ฮป y' โ โฅโฅ-is-prop) q
ฯ : f' x ๏ผ (y , p) โ f x ๏ผ y
ฯ q' = ap prโ q'
ฮท : ฯ โ ฯ โผ id
ฮท refl = to-ฮฃ-๏ผ (refl , q) ๏ผโจ ap (ฮป - โ to-ฮฃ-๏ผ (refl , -)) h โฉ
to-ฮฃ-๏ผ (refl , refl) ๏ผโจ refl โฉ
refl โ
where
q : โฃ x , refl โฃ ๏ผ โฃ x , refl โฃ
q = โฅโฅ-is-prop โฃ x , refl โฃ โฃ x , refl โฃ
h : q ๏ผ refl
h = props-are-sets โฅโฅ-is-prop q refl
embedding-if-corestriction-is-equivalence : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-equiv (corestriction f)
โ is-embedding f
embedding-if-corestriction-is-equivalence f i =
embedding-closed-under-โผ f' f (โ-is-embedding eโ eโ) H
where
f' : domain f โ codomain f
f' = prโ โ corestriction f
H : f โผ prโ โ corestriction f
H x = refl
eโ : is-embedding (corestriction f)
eโ = equivs-are-embeddings (corestriction f) i
eโ : is-embedding prโ
eโ = prโ-is-embedding (ฮป y โ โฅโฅ-is-prop)
imageInduction : โ {๐ฆ ๐ค ๐ฅ} {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ ๐ค โ ๐ฅ โ ๐ฆ โบ ฬ
imageInduction {๐ฆ} {๐ค} {๐ฅ} {X} {Y} f =
(P : Y โ ๐ฆ ฬ ) โ ((y : Y) โ is-prop (P y)) โ ((x : X) โ P (f x)) โ (y : Y) โ P y
surjection-induction : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-surjection f โ imageInduction {๐ฆ} f
surjection-induction f is P isp a y = โฅโฅ-rec (isp y)
(ฮป ฯ โ transport P (prโ ฯ) (a (prโ ฯ)))
(is y)
image-surjection-converse : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ imageInduction f โ is-surjection f
image-surjection-converse f is' = is' (ฮป y โ โฅ ฮฃ (ฮป x โ f x ๏ผ y) โฅ)
(ฮป y โ โฅโฅ-is-prop)
(ฮป x โ โฃ x , refl โฃ)
image-induction : โ {๐ฆ} {X : ๐ค ฬ } {Y : ๐ฅ ฬ }
(f : X โ Y) (P : image f โ ๐ฆ ฬ )
โ (โ y' โ is-prop (P y'))
โ (โ x โ P (corestriction f x))
โ โ y' โ P y'
image-induction f = surjection-induction (corestriction f)
(corestriction-is-surjection f)
retraction-surjection : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ has-section f โ is-surjection f
retraction-surjection {๐ค} {๐ฅ} {X} f ฯ y = โฃ prโ ฯ y , prโ ฯ y โฃ
prโ-is-surjection : {X : ๐ค ฬ } (A : X โ ๐ฅ ฬ )
โ ((x : X) โ โฅ A x โฅ)
โ is-surjection (ฮป (ฯ : ฮฃ A) โ prโ ฯ)
prโ-is-surjection A s x = ฮณ
where
ฮด : A x โ ฮฃ ฯ ๊ ฮฃ A , prโ ฯ ๏ผ x
ฮด a = (x , a) , refl
ฮณ : โ ฯ ๊ ฮฃ A , prโ ฯ ๏ผ x
ฮณ = โฅโฅ-functor ฮด (s x)
prโ-is-surjection-converse : {X : ๐ค ฬ } (A : X โ ๐ฅ ฬ )
โ is-surjection (ฮป (ฯ : ฮฃ A) โ prโ ฯ)
โ ((x : X) โ โฅ A x โฅ)
prโ-is-surjection-converse A s x = ฮณ
where
ฮด : (ฮฃ ฯ ๊ ฮฃ A , prโ ฯ ๏ผ x) โ A x
ฮด ((.x , a) , refl) = a
ฮณ : โฅ A x โฅ
ฮณ = โฅโฅ-functor ฮด (s x)
surjection-โ-image : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-surjection f
โ image f โ Y
surjection-โ-image {๐ค} {๐ฅ} {X} {Y} f s =
image f โโจ โ-refl _ โฉ
(ฮฃ y ๊ Y , โ x ๊ X , f x ๏ผ y) โโจ ฮฃ-cong ฮณ โฉ
(ฮฃ y ๊ Y , ๐) โโจ โ-refl _ โฉ
Y ร ๐ โโจ ๐-rneutral {๐ฅ} {๐ฅ} โฉ
Y โ
where
ฮณ : (y : Y) โ (โ x ๊ X , f x ๏ผ y) โ ๐
ฮณ y = singleton-โ-๐ (pointed-props-are-singletons (s y) โฅโฅ-is-prop)
โ-is-surjection : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {Z : ๐ฆ ฬ } {f : X โ Y} {g : Y โ Z}
โ is-surjection f โ is-surjection g โ is-surjection (g โ f)
โ-is-surjection {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {Z} {f} {g} ฯ ฯ z =
โฅโฅ-rec โฅโฅ-is-prop ฮณโ (ฯ z)
where
ฮณโ : (ฮฃ y ๊ Y , g y ๏ผ z) โ โ x ๊ X , (g โ f) x ๏ผ z
ฮณโ (y , q) = โฅโฅ-functor ฮณโ (ฯ y)
where
ฮณโ : (ฮฃ x ๊ X , f x ๏ผ y) โ ฮฃ x ๊ X , (g โ f) x ๏ผ z
ฮณโ (x , p) = (x , (g (f x) ๏ผโจ ap g p โฉ
g y ๏ผโจ q โฉ
z โ))
equivs-are-surjections : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {f : X โ Y}
โ is-equiv f โ is-surjection f
equivs-are-surjections ((ฯ , ฮท) , (ฯ , ฮต)) y = โฃ ฯ y , ฮท y โฃ
\end{code}