Martin Escardo 20-21 December 2012

Development adapted from the module ConvergentSequenceSearchable:

Not only is ℕ∞ searchable, but, moreover, minimal witnesses can be


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

open import UF-FunExt

module ConvergentSequenceInfSearchable (fe :  {U V}  funext U V) where

open import SpartanMLTT
open import InfSearchable
open import GenericConvergentSequence

ℕ∞-is-inf-searchable : inf-searchable _≼_
ℕ∞-is-inf-searchable p = a , (putative-root-lemma , (lower-bound-lemma , uborlb-lemma))
  α :   𝟚
  α 0       = p(under 0)
  α(succ n) = min𝟚 (α n) (p(under(succ n)))

  a : ℕ∞
  a = (α , λ i  Lemma[minab≤a])

  Dagger₀ : (n : )  a  under n  p(under n)  
  Dagger₀ 0 r =  ap  w  incl w 0) r
  Dagger₀ (succ n) r = w  t
    s : α n  
    s = ap  w  incl w n) r  under-diagonal₁ n
    t : α(succ n)  
    t = ap  w  incl w(succ n)) r  under-diagonal₀ n
    w : p(under(succ n))  α(succ n)
    w = (ap b  min𝟚 b (p(under(succ n)))) s)⁻¹

  Dagger₁ : a    (n : )  p(under n)  
  Dagger₁ r 0 = ap  w  incl w 0) r
  Dagger₁ r (succ n) = w  t
    s : α n  
    s = ap  w  incl w n) r
    t : α(succ n)  
    t = ap  w  incl w (succ n)) r
    w : p(under(succ n))  α(succ n)
    w = (ap b  min𝟚 b (p(under(succ n)))) s)⁻¹

  Claim₀ : p a    (n : )  a  under n
  Claim₀ r n s = Lemma[b≡₁→b≢₀] r (Lemma s)
    Lemma : a  under n  p a  
    Lemma t = ap p t  Dagger₀ n t

  Claim₁ : p a    a  
  Claim₁ r = not-ℕ-is-∞ fe (Claim₀ r) 

  Claim₂ : p a    (n : )  p(under n)  
  Claim₂ r = Dagger₁(Claim₁ r)

  Claim₃ : p a    p   
  Claim₃ r = (ap p (Claim₁ r))⁻¹  r

  Lemma : p a    (v : ℕ∞)  p v  
  Lemma r = ℕ∞-density fe (Claim₂ r) (Claim₃ r)

  putative-root-lemma : (Σ \u  p u  )  p a  
  putative-root-lemma (x , r) = lemma claim
    lemma : ¬((x : ℕ∞)  p x  )  p a  
    lemma = Lemma[b≢₁→b≡₀]  (contrapositive Lemma)
    claim : ¬((x : ℕ∞)  p x  )
    claim f = Lemma[b≡₁→b≢₀] (f x) r

  lower-bound-lemma : (u : ℕ∞)→ p u    a  u
  lower-bound-lemma u r 0 s = lemma
     claim₀ : incl u 0    p u  α 0
     claim₀ t = ap p (is-Zero-equal-Zero fe t)
     claim₁ : incl u 0      
     claim₁ t = r ⁻¹  claim₀ t  s
     lemma : incl u 0  
     lemma = Lemma[b≢₀→b≡₁] (contrapositive claim₁ zero-is-not-one)

  lower-bound-lemma u r (succ n) s = lemma
    -- s : min𝟚 (incl a n) (p(under(succ n))) ≡ ₁
    IH : incl a n    incl u n  
    IH = lower-bound-lemma u r n
    claim₀ : incl u n  
    claim₀ = IH(Lemma[min𝟚ab≡₁→a≡₁] s)
    claim₁ : p(under(succ n))  
    claim₁ = Lemma[min𝟚ab≡₁→b≡₁]{(incl a n)} s
    claim₂ : incl u (succ n)    u  under(succ n)
    claim₂ = Succ-criterion fe claim₀
    claim₃ : incl u (succ n)    p u  p(under(succ n))
    claim₃ t = ap p (claim₂ t)
    claim₄ : incl u (succ n)    p u  
    claim₄ t = claim₃ t  claim₁
    claim₅ : incl u (succ n)  
    claim₅ t = Lemma[b≡₁→b≢₀] (claim₄ t) r 
    lemma : incl u (succ n)  
    lemma = Lemma[b≢₀→b≡₁] claim₅

  uborlb-lemma : (l : ℕ∞)  ((x : ℕ∞)  p x    l  x)  l  a
  uborlb-lemma l lower-bounder = two-equality-cases lemma₀ lemma₁
    lemma₀ : p a    l  a
    lemma₀ = lower-bounder a
    lemma₁ : p a    l  a
    lemma₁ r n x = ap  a  incl a n) (Claim₁ r)