Skip to content

gist.not-an-apartness

Martin Escardo, 3rd Feb 2025.

Does the type โ„•โˆžโ‚‚ have a tight apartness? I don't think so. Here is an
illustrative failed attempt, which satisfies all conditions except
cotransitivity.

We use the standard apartness relation _โ™ฏ_ on the Cantor type โ„• โ†’ ๐Ÿš to
define our attempted apartness relation _#_ on โ„•โˆžโ‚‚.


{-# OPTIONS --safe --without-K #-}

open import UF.FunExt
open import UF.PropTrunc

module gist.not-an-apartness
        (fe : Fun-Ext)
        (pt : propositional-truncations-exist)
       where

open import Apartness.Definition
open import CoNaturals.Type
open import MLTT.Spartan
open import MLTT.Two-Properties
open import Notation.CanonicalMap
open import Notation.Order
open import Taboos.LPO
open import TypeTopology.Cantor
open import TypeTopology.FailureOfTotalSeparatedness fe
open import UF.Base
open import UF.DiscreteAndSeparated hiding (_โ™ฏ_)
open import UF.Subsingletons
open import UF.Subsingletons-FunExt

open PropositionalTruncation pt
open Apartness pt

module failed-attempt where

 _#_  : โ„•โˆžโ‚‚ โ†’ โ„•โˆžโ‚‚ โ†’ ๐“คโ‚€ ฬ‡
 (x@(ฮฑ , _) , f) # (y@(ฮฒ , _) , g) =
  (ฮฑ โ™ฏ ฮฒ) + (ฮฃ p ๊ž‰ x ๏ผ โˆž , ฮฃ q ๊ž‰ y ๏ผ โˆž , f p โ‰  g q)

 s : is-strong-apartness _โ™ฏ_
 s = โ™ฏ-is-strong-apartness fe

 I : is-prop-valued _#_
 I (x , f) (y , g) (inl a) (inl a') =
  ap inl (strong-apartness-is-prop-valued _โ™ฏ_ s (ฮน x) (ฮน y) a a')
 I (x , f) (y , g) (inl a) (inr (p , q , _)) =
  ๐Ÿ˜-elim (strong-apartness-is-irreflexive' _โ™ฏ_ s (ฮน x) (ฮน y) a
           (ap ฮน (p โˆ™ q โปยน)))
 I (x , f) (y , g) (inr (p , q , _)) (inl a) =
  ๐Ÿ˜-elim (strong-apartness-is-irreflexive' _โ™ฏ_ s (ฮน x) (ฮน y) a
           (ap ฮน (p โˆ™ q โปยน)))
 I (x , f) (y , g) (inr b) (inr b') =
  ap inr
     (ฮฃ-is-prop
       (โ„•โˆž-is-set fe)
       (ฮป p โ†’ ฮฃ-is-prop (โ„•โˆž-is-set fe) (ฮป q โ†’ negations-are-props fe)) b b')

 II : is-irreflexive _#_
 II (x , f) (inl a) =
  strong-apartness-is-irreflexive _โ™ฏ_ s (ฮน x) a
 II (x , f) (inr (p , q , d)) = ๐Ÿ˜-elim (d (ap f (โ„•โˆž-is-set fe p q)))

 III : is-symmetric _#_
 III (x , f) (y , g) (inl a) =
  inl (strong-apartness-is-symmetric _โ™ฏ_ s (ฮน x) (ฮน y) a)
 III (x , f) (y , g) (inr (p , q , d)) =
  inr (q , p , (โ‰ -sym d))

 IV : is-tight _#_
 IV (x , f) (y , g) ฮฝ = to-ฮฃ-๏ผ (IVโ‚‚ , IVโ‚„)
  where
   IVโ‚€ : ยฌ ((ฮน x) โ™ฏ (ฮน y))
   IVโ‚€ a = ฮฝ (inl a)

   IVโ‚ : (p : x ๏ผ โˆž) (q : y ๏ผ โˆž) โ†’ f p ๏ผ g q
   IVโ‚ p q = ๐Ÿš-is-ยฌยฌ-separated (f p) (g q) (ฮป d โ†’ ฮฝ (inr (p , q , d)))

   IVโ‚‚ : x ๏ผ y
   IVโ‚‚ = to-subtype-๏ผ
        (being-decreasing-is-prop fe)
        (โ™ฏ-is-tight fe (ฮน x) (ฮน y) IVโ‚€)

   IVโ‚ƒ : (r : x ๏ผ y) โ†’ transport (ฮป - โ†’ - ๏ผ โˆž โ†’ ๐Ÿš) r f ๏ผ g
   IVโ‚ƒ refl = dfunext fe (ฮป u โ†’ IVโ‚ u u)

   IVโ‚„ : transport (ฮป - โ†’ - ๏ผ โˆž โ†’ ๐Ÿš) IVโ‚‚ f ๏ผ g
   IVโ‚„ = IVโ‚ƒ IVโ‚‚

 V : is-cotransitive _#_ โ†’ LPO
 V sc = LPO-criterion fe Vโ‚†
  where
   module _ (x : โ„•โˆž) where

    ฮฑ : ๐Ÿšแดบ
    ฮฑ = ฮน x

    u : โ„•โˆžโ‚‚
    u = (x , ฮป _ โ†’ โ‚€)

    a : โˆžโ‚€ # โˆžโ‚
    a = inr (refl , refl , zero-is-not-one)

    Vโ‚€ : (โˆžโ‚€ # u) โˆจ (โˆžโ‚ # u)
    Vโ‚€ = sc โˆžโ‚€ โˆžโ‚ u a

    Vโ‚ : ((๐Ÿ โ™ฏ ฮฑ) + (ฮฃ p ๊ž‰ โˆž ๏ผ โˆž , ฮฃ q ๊ž‰ x ๏ผ โˆž , โ‚€ โ‰  โ‚€))
       โˆจ ((๐Ÿ โ™ฏ ฮฑ) + (ฮฃ p ๊ž‰ โˆž ๏ผ โˆž , ฮฃ q ๊ž‰ x ๏ผ โˆž , โ‚ โ‰  โ‚€))
    Vโ‚ = Vโ‚€

    Vโ‚‚ : ((๐Ÿ โ™ฏ ฮฑ) + (ฮฃ p ๊ž‰ โˆž ๏ผ โˆž , ฮฃ q ๊ž‰ x ๏ผ โˆž , โ‚€ โ‰  โ‚€))
       + ((๐Ÿ โ™ฏ ฮฑ) + (ฮฃ p ๊ž‰ โˆž ๏ผ โˆž , ฮฃ q ๊ž‰ x ๏ผ โˆž , โ‚ โ‰  โ‚€))
       โ†’ (๐Ÿ โ™ฏ ฮฑ) + (ฮฑ ๏ผ ๐Ÿ)
    Vโ‚‚ (inl (inl a)) = inl a
    Vโ‚‚ (inl (inr (p , q , d))) = ๐Ÿ˜-elim (d refl)
    Vโ‚‚ (inr (inl a)) = inl a
    Vโ‚‚ (inr (inr (p , q , d))) = inr (ap ฮน q)

    Vโ‚ƒ : is-prop ((๐Ÿ โ™ฏ ฮฑ) + (ฮฑ ๏ผ ๐Ÿ))
    Vโ‚ƒ = sum-of-contradictory-props
          (โ™ฏ-is-prop-valued fe ๐Ÿ ฮฑ)
          (Cantor-is-set fe)
          Vโ‚ƒ-โ‚€
     where
      Vโ‚ƒ-โ‚€ : (๐Ÿ โ™ฏ ฮฑ) โ†’ (ฮฑ ๏ผ ๐Ÿ) โ†’ ๐Ÿ˜ {๐“คโ‚€}
      Vโ‚ƒ-โ‚€ (n , d , _) refl = d refl

    Vโ‚„ : (๐Ÿ โ™ฏ ฮฑ) + (ฮฑ ๏ผ ๐Ÿ)
    Vโ‚„ = โˆฅโˆฅ-rec Vโ‚ƒ Vโ‚‚ Vโ‚

    Vโ‚… : type-of Vโ‚„ โ†’ is-decidable (ฮฃ n ๊ž‰ โ„• , ฮฑ n ๏ผ โ‚€)
    Vโ‚… (inl (n , d , _)) = inl (n , different-from-โ‚-equal-โ‚€ (โ‰ -sym d))
    Vโ‚… (inr p) = inr (ฮป (n , q) โ†’ equal-โ‚-different-from-โ‚€ (happly p n) q)

    Vโ‚† : is-decidable (ฮฃ n ๊ž‰ โ„• , x โŠ‘ n)
    Vโ‚† = Vโ‚… Vโ‚„


Experiment (9th Feb 2025). Characterization of wconstant endomaps of
the type P + Q, where P and Q are propositions, and hence of when we
have a map โˆฅ P + Q โˆฅ โ†’ P + Q (by generalized Hedberg). This is to be
moved elsewhere when it is tidied up and completed.

We show that there is a wconstant endomap of P + Q if and only there
are functions

          gโ‚€ : P โ†’ ๐Ÿš
          gโ‚ : (p : P) โ†’ gโ‚€ p ๏ผ โ‚ โ†’ Q
          hโ‚€ : Q โ†’ ๐Ÿš
          hโ‚ : (q : Q) โ†’ hโ‚€ q ๏ผ โ‚€ โ†’ P
          w :  (p : P) (q : Q) โ†’ gโ‚€ p ๏ผ hโ‚€ q

The idea is to get rid of "+", with only the type ๐Ÿš left as its
shadow.


open import UF.Hedberg

module _ (P : ๐“ค ฬ‡ )
         (Q : ๐“ฅ ฬ‡ )
         (P-is-prop : is-prop P)
         (Q-is-prop : is-prop Q)
       where

 module _ (gโ‚€ : P โ†’ ๐Ÿš)
          (gโ‚ : (p : P) โ†’ gโ‚€ p ๏ผ โ‚ โ†’ Q)
          (hโ‚€ : Q โ†’ ๐Ÿš)
          (hโ‚ : (q : Q) โ†’ hโ‚€ q ๏ผ โ‚€ โ†’ P)
          (w :  (p : P) (q : Q) โ†’ gโ‚€ p ๏ผ hโ‚€ q)
       where

  private
   fโ‚€ : (p : P) (m : ๐Ÿš) โ†’ gโ‚€ p ๏ผ m โ†’ P + Q
   fโ‚€ p โ‚€ r = inl p
   fโ‚€ p โ‚ r = inr (gโ‚ p r)

   fโ‚ : (q : Q) (n : ๐Ÿš) โ†’ hโ‚€ q ๏ผ n โ†’ P + Q
   fโ‚ q โ‚€ s = inl (hโ‚ q s)
   fโ‚ q โ‚ s = inr q

  f : P + Q โ†’ P + Q
  f (inl p) = fโ‚€ p (gโ‚€ p) refl
  f (inr q) = fโ‚ q (hโ‚€ q) refl

  private
   wc : (p : P) (q : Q) (m n : ๐Ÿš) (r : gโ‚€ p ๏ผ m) (s : hโ‚€ q ๏ผ n)
      โ†’ fโ‚€ p m r ๏ผ fโ‚ q n s
   wc p q โ‚€ โ‚€ r s = ap inl (P-is-prop p (hโ‚ q s))
   wc p q โ‚€ โ‚ r s = ๐Ÿ˜-elim (zero-is-not-one (r โปยน โˆ™ w p q โˆ™ s))
   wc p q โ‚ โ‚€ r s = ๐Ÿ˜-elim (one-is-not-zero (r โปยน โˆ™ w p q โˆ™ s))
   wc p q โ‚ โ‚ r s = ap inr (Q-is-prop (gโ‚ p r) q)

  f-is-wconstant : wconstant f
  f-is-wconstant (inl p) (inl p') = ap (ฮป - โ†’  fโ‚€ - (gโ‚€ -) refl) (P-is-prop p p')
  f-is-wconstant (inl p) (inr q)  = wc p q (gโ‚€ p) (hโ‚€ q) refl refl
  f-is-wconstant (inr q) (inl p)  = (wc p q (gโ‚€ p) (hโ‚€ q) refl refl)โปยน
  f-is-wconstant (inr q) (inr q') = ap (ฮป - โ†’  fโ‚ - (hโ‚€ -) refl) (Q-is-prop q q')

 module _ (f : P + Q โ†’ P + Q)
          (f-is-wconstant : wconstant f)
        where

  private
   ฯ• : P + Q โ†’ ๐Ÿš
   ฯ• (inl p) = โ‚€
   ฯ• (inr q) = โ‚

   ฯ•โ‚€ : (z t : P + Q) โ†’ f z ๏ผ t โ†’ ฯ• t ๏ผ โ‚ โ†’ Q
   ฯ•โ‚€ (inl p) (inr q)  r s = q
   ฯ•โ‚€ (inr q) (inr q') r s = q'

   ฯ•โ‚ : (z t : P + Q) โ†’ f z ๏ผ t โ†’ ฯ• t ๏ผ โ‚€ โ†’ P
   ฯ•โ‚ (inl p) (inl p') r s = p'
   ฯ•โ‚ (inr q) (inl p)  r s = p

  gโ‚€ : P โ†’ ๐Ÿš
  gโ‚€ p = ฯ• (f (inl p))

  gโ‚ : (p : P) โ†’ gโ‚€ p ๏ผ โ‚ โ†’ Q
  gโ‚ p = ฯ•โ‚€ (inl p) (f (inl p)) refl

  hโ‚€ : Q โ†’ ๐Ÿš
  hโ‚€ q = ฯ• (f (inr q))

  hโ‚ : (q : Q) โ†’ hโ‚€ q ๏ผ โ‚€ โ†’ P
  hโ‚ q = ฯ•โ‚ (inr q) (f (inr q)) refl

  private
   wc :  (p : P) (q : Q) (m n : ๐Ÿš) โ†’ gโ‚€ p ๏ผ m โ†’ hโ‚€ q ๏ผ n โ†’ m ๏ผ n
   wc p q โ‚€ โ‚€ r s = refl
   wc p q โ‚€ โ‚ r s = r โปยน โˆ™ ap ฯ• (f-is-wconstant (inl p) (inr q)) โˆ™ s
   wc p q โ‚ โ‚€ r s = r โปยน โˆ™ ap ฯ• (f-is-wconstant (inl p) (inr q)) โˆ™ s
   wc p q โ‚ โ‚ r s = refl

  w :  (p : P) (q : Q) โ†’ gโ‚€ p ๏ผ hโ‚€ q
  w p q = wc p q (gโ‚€ p) (hโ‚€ q) refl refl


Notice that the second direction doesn't use the fact that P and Q are
propositions. But notice also that gโ‚€ and hโ‚€ are wconstant because f
is. So maybe, using this fact, we can instead add the additional
requirement that these two functions are wconstant. Of course, if we
assume that P and Q are propositions, they are wconstant.

In any case, the above two constructions should give a type
equivalence, rather than merely a logical equivalence, when P and Q
are propositions.