Martin Escardo, December 2012, going back to work done circa 2010.

The theorem here is that the "squashed sum" of any countable family of
searchable sets is itself searchable (see the module Searchable,
imported below, for the definition and fundamental facts about the

(The terminology "squashed sum" comes from the paper "Infinite sets
that satisfy the principle of omniscience in all varieties of
constructive mathematics", where this concept is investigated within
the Cantor type ℕ → ₂, which makes the squashing self-evident.)

Given a countable family of sets.

   X : ℕ → Set,

extend it to a ℕ∞-indexed family of sets as follows

  _[_] : (ℕ → Set) → (ℕ∞ → Set)
  X [ u ] = (k : ℕ) → u ≣ k → X k

where u ranges over ℕ∞, the one-point compactification of the natural
numbers ℕ, defined in the module GenericConvergentSequence.

The squashed sum of X : ℕ → Set is defined to be

   Σ¹ X = Σ \(u : ℕ∞) → X [ u ]

Intuitively, the squashed sum is the disjoint sum with an added limit
point at infinity. 

Assuming excluded middle, Σ¹ X is isomorphic to (Σ \(n : ℕ) → X n) + 1
where 1 is the one-point type.

Assuming Brouwerian continuity axioms, Σ¹ X is the one-point
compatification of the disjoint sum (Σ \(n : ℕ) → X n).

But we don't assume excluded middle or continuiy axioms here. We work
within intensional MLTT with function extensionality as a postulate
(rather than as a meta-theoretical rule).


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

module SquashedSumOld where

open import GenericConvergentSequence 
open import Naturals hiding (_≣_)
open import SetsAndFunctions
open import Searchable
open import ConvergentSequenceSearchable
open import Two
open import CurryHoward
open import Equality
open import Extensionality

_[_] : (  Set)  (ℕ∞  Set)
X [ u ] = (k : )  u  k  X k

Σ¹ : (  Set)  Set
Σ¹ X = Σ \(u : ℕ∞)  X [ u ]

∞¹ : {X :   Set}  Σ¹ X
∞¹ = ( ,  k r  ⊥-elim (∞-is-not-ℕ k r)))


This point at infinity is unique assuming extensionality, because:


H : {X :   Set}   u  u    ∀(y y' : X [ u ])  y  y'
H {X} u r y y' = funext k  funext s  lemma k s))
  lemma :  k s  y k s  y' k s 
  lemma k s = ⊥-elim(∞-is-not-ℕ k (trans (sym r) s)) 


Next we have an isomorphism X [ u ] ≅ X n if u ≣ n:


F : {X :   Set}   n u  u  n  X n  X [ u ]
F {X} n u r x k s = subst {} {X} (under-mono(trans (sym r) s)) x

G : {X :   Set}   n u  u  n  X [ u ]  X n
G n u r y = y n r

FG : {X :   Set}   n u  ∀(r : u  n)   y  F n u r (G n u r y)  y
FG {X} n u r y = funext k  funext s  lemma k s))
  t :  k  u  k  n  k
  t k s = under-mono(trans (sym r) s)

  A :   n k  n  k  Set
  A n k t =  u  ∀(r : u  n)(s : u  k)  ∀(y : X [ u ]) 
           subst {} {X} t (y n r)  y k s

  φ :  n  A n n refl
  φ n = λ u r s y  cong (y n) (ℕ∞-hset r s) 

  lemma :  k s  subst {} {X} (under-mono (trans (sym r) s)) (y n r)  y k s
  lemma k s = J A φ {n} {k} (t k s) u r s y

GF : {X :   Set}   n u  ∀(r : u  n)  ∀(x : X n)  G {X} n u r (F n u r x)  x
GF {X} n u r x = s
  claim₀ : subst  {} {X} (under-mono (trans (sym r) r)) x  subst  {} {X} (under-mono refl) x
  claim₀ = cong  t  subst  {} {X} (under-mono t) x) (trans-sym r)
  claim₁ : subst {} {X} (under-mono refl) x  x
  claim₁ = cong  t  subst {} {X} t x) (under-mono-refl n)
  s : subst {} {X} (under-mono (trans (sym r) r)) x  x
  s = trans claim₀ claim₁


We now can show that the type X [ u ] is searchable for every u : ℕ∞
provided the type X n is searchable for every n : ℕ. This is tricky,
because a priory it is not enough to consider the cases u ≣ n and u ≡ ∞.

The above isomorphism is used to prove the correctness of the witness
y₀ below, which is easily defined (using one direction of the


extension-searchable : {X :   Set}  (∀ n  searchable(X n))   u  searchable(X [ u ])
extension-searchable {X} ε u p = ∃-intro y₀ lemma
  Y : Set
  Y = X [ u ]
  -- ε : ∀ n → searchable(X n)
  -- u : ℕ∞
  -- p  : Y → ₂

  y₀ : Y
  y₀ n r = ∃-witness(ε n (p  (F n u r)))

  lemma₁ :  n  u  n  p y₀     y  p y  
  lemma₁ n r e = claim₃
    claim₀ :  y  p(F n u r (G n u r y))  p y
    claim₀ y = cong p (FG n u r y)
    claim₁ : p(F n u r (G n u r y₀))    ∀(x : X n)  p(F n u r x)  
    claim₁ =  ∃-elim(ε n (p  (F n u r)))
    claim₂ : ∀(x : X n)  p(F n u r x)  
    claim₂ = claim₁ (trans (claim₀ y₀) e)
    claim₃ :  y  p y  
    claim₃ y = trans (sym(claim₀ y)) (claim₂ (G n u r y))

  lemma₂ : u    p y₀     y  p y  
  lemma₂ r e y = trans (cong p (H u r y y₀)) e

  lemma₁' : p y₀     y  p y     n  u  under n 
  lemma₁' e y s n r = zero-is-not-one (trans (sym s) (lemma₁ n r e y))

  lemma₂' : p y₀     y  p y    u  
  lemma₂' e y s r = zero-is-not-one (trans (sym s) (lemma₂ r e y))

  lemma : p y₀     y  p y  
  lemma r y = Lemma[b≢₀→b≡₁] s  lemma₂' r y s (not-ℕ-is-∞(lemma₁' r y s)))


Finally, we can show that the squashed sum of any sequence of
searchable sets is itself searchable, as claimed above:


squashed-sum-searchable : {X :   Set}  (∀ n  searchable(X n))  searchable(Σ¹ X)
squashed-sum-searchable {X} f = sums-preserve-searchability {ℕ∞} ℕ∞-is-searchable (extension-searchable {X} f)