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 ββ¨by-definitionβ© (Ξ£ y κ Y , β x κ X , f x οΌ y) ββ¨ Ξ£-cong Ξ³ β© (Ξ£ y κ Y , π) ββ¨by-definitionβ© 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}