Factorial.PlusOneLC
Martin Escardo, 21 March 2018, 1st December 2019. We prove the known (constructive) fact that X + ๐ โ Y + ๐ โ X โ Y. The new proof from 1st December 2019 is extracted from the module UF.Factorial and doesn't use function extensionality. The old proof from 21 March 2018 is included at the end.{-# OPTIONS --safe --without-K #-} module Factorial.PlusOneLC where open import Factorial.Swap open import MLTT.Plus-Properties open import MLTT.Spartan open import UF.DiscreteAndSeparated open import UF.Equiv open import UF.Retracts +๐-cancellable : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X + ๐ {๐ฆ} โ Y + ๐ {๐ฃ}) โ X โ Y +๐-cancellable {๐ค} {๐ฅ} {๐ฆ} {๐ฃ} {X} {Y} (ฯ , i) = qinveq f' (g' , ฮท' , ฮต') where zโ : X + ๐ zโ = inr โ tโ : Y + ๐ tโ = inr โ j : is-isolated zโ j = new-point-is-isolated k : is-isolated (ฯ zโ) k = equivs-preserve-isolatedness ฯ i zโ j l : is-isolated tโ l = new-point-is-isolated s : Y + ๐ โ Y + ๐ s = swap (ฯ zโ) tโ k l f : X + ๐ โ Y + ๐ f = s โ ฯ p : f zโ ๏ผ tโ p = swap-equationโ (ฯ zโ) tโ k l g : Y + ๐ โ X + ๐ g = inverse ฯ i โ s h : s โ s โผ id h = swap-involutive (ฯ zโ) tโ k l ฮท : g โ f โผ id ฮท z = inverse ฯ i (s (s (ฯ z))) ๏ผโจ ap (inverse ฯ i) (h (ฯ z)) โฉ inverse ฯ i (ฯ z) ๏ผโจ inverses-are-retractions ฯ i z โฉ z โ ฮต : f โ g โผ id ฮต t = s (ฯ (inverse ฯ i (s t))) ๏ผโจ ap s (inverses-are-sections ฯ i (s t)) โฉ s (s t) ๏ผโจ h t โฉ t โ f' : X โ Y f' x = prโ (inl-preservation f p (sections-are-lc f (g , ฮท)) x) a : (x : X) โ f (inl x) ๏ผ inl (f' x) a x = prโ (inl-preservation f p (sections-are-lc f (g , ฮท)) x) q = g tโ ๏ผโจ ap g (p โปยน) โฉ g (f zโ) ๏ผโจ ฮท zโ โฉ inr โ โ g' : Y โ X g' y = prโ (inl-preservation g q (sections-are-lc g (f , ฮต)) y) b : (y : Y) โ g (inl y) ๏ผ inl (g' y) b y = prโ (inl-preservation g q (sections-are-lc g (f , ฮต)) y) ฮท' : (x : X) โ g' (f' x) ๏ผ x ฮท' x = inl-lc (inl (g' (f' x)) ๏ผโจ (b (f' x))โปยน โฉ g (inl (f' x)) ๏ผโจ (ap g (a x))โปยน โฉ g (f (inl x)) ๏ผโจ ฮท (inl x) โฉ inl x โ) ฮต' : (y : Y) โ f' (g' y) ๏ผ y ฮต' y = inl-lc (inl (f' (g' y)) ๏ผโจ (a (g' y))โปยน โฉ f (inl (g' y)) ๏ผโจ (ap f (b y))โปยน โฉ f (g (inl y)) ๏ผโจ ฮต (inl y) โฉ inl y โ)The old version from 21 March 2018, which uses function extensionality:_โ_ : (X : ๐ค ฬ ) (a : X) โ ๐ค ฬ X โ a = ฮฃ x ๊ X , x โ a open import UF.FunExt module _ (fe : FunExt) where open import UF.Base open import UF.Subsingletons-FunExt add-and-remove-point : {X : ๐ค ฬ } โ X โ (X + ๐) โ (inr โ) add-and-remove-point {๐ค} {X} = qinveq f (g , ฮต , ฮท) where f : X โ (X + ๐ {๐ค}) โ inr โ f x = (inl x , +disjoint) g : (X + ๐) โ inr โ โ X g (inl x , u) = x g (inr โ , u) = ๐-elim (u refl) ฮท : f โ g โผ id ฮท (inl x , u) = to-ฮฃ-๏ผ' (negations-are-props (fe ๐ค ๐คโ) _ _) ฮท (inr โ , u) = ๐-elim (u refl) ฮต : g โ f โผ id ฮต x = refl remove-points : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y) โ qinv f โ (a : X) โ X โ a โ Y โ (f a) remove-points {๐ค} {๐ฅ} {X} {Y} f (g , ฮต , ฮท) a = qinveq f' (g' , ฮต' , ฮท') where f' : X โ a โ Y โ (f a) f' (x , u) = (f x , ฮป (p : f x ๏ผ f a) โ u ((ฮต x)โปยน โ ap g p โ ฮต a)) g' : Y โ (f a) โ X โ a g' (y , v) = (g y , ฮป (p : g y ๏ผ a) โ v ((ฮท y) โปยน โ ap f p)) ฮต' : g' โ f' โผ id ฮต' (x , _) = to-ฮฃ-๏ผ (ฮต x , negations-are-props (fe ๐ค ๐คโ) _ _) ฮท' : f' โ g' โผ id ฮท' (y , _) = to-ฮฃ-๏ผ (ฮท y , negations-are-props (fe ๐ฅ ๐คโ) _ _) add-one-and-remove-isolated-point : {Y : ๐ฅ ฬ } (z : Y + ๐) โ is-isolated z โ ((Y + ๐) โ z) โ Y add-one-and-remove-isolated-point {๐ฅ} {Y} (inl b) i = qinveq f (g , ฮต , ฮท) where f : (Y + ๐) โ (inl b) โ Y f (inl y , u) = y f (inr โ , u) = b g' : (y : Y) โ is-decidable (inl b ๏ผ inl y) โ (Y + ๐) โ (inl b) g' y (inl p) = (inr โ , +disjoint') g' y (inr u) = (inl y , contrapositive (_โปยน) u) g : Y โ (Y + ๐) โ (inl b) g y = g' y (i (inl y)) ฮต : g โ f โผ id ฮต (inl y , u) = to-ฮฃ-๏ผ (p , negations-are-props (fe ๐ฅ ๐คโ) _ _) where ฯ : (p : inl b ๏ผ inl y) (q : i (inl y) ๏ผ inl p) โ i (inl y) ๏ผ inr (โ -sym u) ฯ p q = ๐-elim (u (p โปยน)) ฯ : (v : inl b โ inl y) (q : i (inl y) ๏ผ inr v) โ i (inl y) ๏ผ inr (โ -sym u) ฯ v q = q โ ap inr (negations-are-props (fe ๐ฅ ๐คโ) _ _) h : i (inl y) ๏ผ inr (โ -sym u) h = equality-cases (i (inl y)) ฯ ฯ p : prโ (g' y (i (inl y))) ๏ผ inl y p = ap (prโ โ (g' y)) h ฮต (inr โ , u) = equality-cases (i (inl b)) ฯ ฯ where ฯ : (p : inl b ๏ผ inl b) โ i (inl b) ๏ผ inl p โ g (f (inr โ , u)) ๏ผ (inr โ , u) ฯ p q = r โ to-ฮฃ-๏ผ (refl , negations-are-props (fe ๐ฅ ๐คโ) _ _) where r : g b ๏ผ (inr โ , +disjoint') r = ap (g' b) q ฯ : (v : inl b โ inl b) โ i (inl b) ๏ผ inr v โ g (f (inr โ , u)) ๏ผ (inr โ , u) ฯ v q = ๐-elim (v refl) ฮท : f โ g โผ id ฮท y = equality-cases (i (inl y)) ฯ ฯ where ฯ : (p : inl b ๏ผ inl y) โ i (inl y) ๏ผ inl p โ f (g' y (i (inl y))) ๏ผ y ฯ p q = ap (ฮป - โ f (g' y -)) q โ inl-lc p ฯ : (u : inl b โ inl y) โ i (inl y) ๏ผ inr u โ f (g' y (i (inl y))) ๏ผ y ฯ _ = ap ((ฮป d โ f (g' y d))) add-one-and-remove-isolated-point {๐ฅ} {Y} (inr โ) _ = โ-sym add-and-remove-point +๐-cancellable' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X + ๐) โ (Y + ๐) โ X โ Y +๐-cancellable' {๐ค} {๐ฅ} {X} {Y} (ฯ , e) = X โโจ add-and-remove-point โฉ (X + ๐) โ inr โ โโจ remove-points ฯ (equivs-are-qinvs ฯ e) (inr โ) โฉ (Y + ๐) โ ฯ (inr โ) โโจ add-one-and-remove-isolated-point (ฯ (inr โ)) (equivs-preserve-isolatedness ฯ e (inr โ) new-point-is-isolated) โฉ Y โAdded 16th April 2021.open import UF.Subsingletons-FunExt remove-and-add-isolated-point : funext ๐ค ๐คโ โ {X : ๐ค ฬ } (xโ : X) โ is-isolated xโ โ X โ (X โ xโ + ๐ {๐ฅ}) remove-and-add-isolated-point fe {X} xโ ฮน = qinveq f (g , ฮต , ฮท) where ฯ : (x : X) โ is-decidable (xโ ๏ผ x) โ X โ xโ + ๐ ฯ x (inl p) = inr โ ฯ x (inr ฮฝ) = inl (x , (ฮป (p : x ๏ผ xโ) โ ฮฝ (p โปยน))) f : X โ X โ xโ + ๐ f x = ฯ x (ฮน x) g : X โ xโ + ๐ โ X g (inl (x , _)) = x g (inr โ) = xโ ฮท' : (y : X โ xโ + ๐) (d : is-decidable (xโ ๏ผ g y)) โ ฯ (g y) d ๏ผ y ฮท' (inl (x , ฮฝ)) (inl q) = ๐-elim (ฮฝ (q โปยน)) ฮท' (inl (x , ฮฝ)) (inr _) = ap (ฮป - โ inl (x , -)) (negations-are-props fe _ _) ฮท' (inr โ) (inl p) = refl ฮท' (inr โ) (inr ฮฝ) = ๐-elim (ฮฝ refl) ฮท : f โ g โผ id ฮท y = ฮท' y (ฮน (g y)) ฮต' : (x : X) (d : is-decidable (xโ ๏ผ x)) โ g (ฯ x d) ๏ผ x ฮต' x (inl p) = p ฮต' x (inr ฮฝ) = refl ฮต : g โ f โผ id ฮต x = ฮต' x (ฮน x)