Ayberk Tosun 10 October 2022 Based directly on MartΓn EscardΓ³'s development from the `CantorSearch` module. -------------------------------------------------------------------------------- In the `CantorSearch` module, the type `β β π` is proved to be searchable for uniformly continuous predicates. In this module, we generalise this to types `β β X`, where `X` is an arbitrary compact type. \begin{code} {-# OPTIONS --safe --without-K #-} open import MLTT.Spartan open import TypeTopology.CompactTypes open import UF.FunExt module TypeTopology.UniformSearch (X : π€ Μ )(fe : funext π€β π€) (ΞΊ : is-compactβ X) where \end{code} \section{Basic operations on streams} \begin{code} head : (β β X) β X head u = u 0 tail : (β β X) β (β β X) tail u = u β succ infixr 9 _β·_ _β·_ : X β (β β X) β (β β X) (x β· Ξ±) zero = x (x β· Ξ±) (succ i) = Ξ± i cons-head-tail : (Ξ± : β β X) β head Ξ± β· tail Ξ± οΌ Ξ± cons-head-tail Ξ± = dfunext fe h where h : head Ξ± β· tail Ξ± βΌ Ξ± h zero = refl h (succ i) = refl \end{code} \section{Local constancy} \begin{code} _οΌβ¦_β§_ : (β β X) β β β (β β X) β π€ Μ π οΌβ¦ zero β§ π = π π οΌβ¦ succ n β§ π = (head π οΌ head π) Γ (tail π οΌβ¦ n β§ tail π ) \end{code} A map `p : ((β β X) β π)` is called *locally constant* if it has a modulus of localy constancy. \begin{code} _is-a-mod-of-lc-of_ : β β ((β β X) β π) β π€ Μ n is-a-mod-of-lc-of p = (π π : β β X) β π οΌβ¦ n β§ π β p π οΌ p π is-locally-constant : ((β β X) β π) β π€ Μ is-locally-constant p = Ξ£ n κ β , n is-a-mod-of-lc-of p \end{code} \begin{code} cons-decreases-mod-of-lc : (p : (β β X) β π) β (n : β) β (succ n) is-a-mod-of-lc-of p β (x : X) β n is-a-mod-of-lc-of (p β x β·_) cons-decreases-mod-of-lc p n Ο x π π eq = Ο (x β· π) (x β· π) (refl , eq) \end{code} \section{Searchability} Since `X` is assumed to be `compactβ` it must be pointed. Call this point `xβ`: \begin{code} xβ : X xβ = compactβ-types-are-pointed ΞΊ \end{code} There must be a selection functional `Ο΅β` for `X`: \begin{code} X-is-compactβ' : is-compactβ' X X-is-compactβ' = compactβ-types-are-compactβ' ΞΊ Ο΅β : (X β π) β X Ο΅β = prβ X-is-compactβ' specification-of-Ο΅β : (p : X β π) β p (Ο΅β p) οΌ β β (x : X) β p x οΌ β specification-of-Ο΅β = prβ X-is-compactβ' \end{code} We now define the universal quantifier for type `X` using its selection functional \begin{code} ββ : (X β π) β π ββ p = p (Ο΅β p) specification-of-ββ-β : (p : X β π) β ββ p οΌ β β (x : X) β p x οΌ β specification-of-ββ-β = specification-of-Ο΅β specification-of-ββ-β : (p : X β π) β ((x : X) β p x οΌ β) β ββ p οΌ β specification-of-ββ-β p Ο = Ο (Ο΅β p) \end{code} We define the selection and universal quantification functionals for `β β X`, but only for locally constant predicates. \begin{code} Ο΅β : β β ((β β X) β π) β (β β X) ββ : β β ((β β X) β π) β π Ο΅β zero p = Ξ» _ β xβ Ο΅β (succ n) p = yβ β· Ο΅β n (Ξ» Ξ± β p (yβ β· Ξ±)) where yβ = Ο΅β Ξ» x β ββ n Ξ» Ξ± β p (x β· Ξ±) ββ n p = p (Ο΅β n p) \end{code} Specification of `ββ` \begin{code} specification-of-ββ-β : (p : (β β X) β π) β (n : β) β n is-a-mod-of-lc-of p β ((π : β β X) β p π οΌ β) β ββ n p οΌ β specification-of-ββ-β p n ΞΆ Ο = Ο (Ο΅β n p) \end{code} \begin{code} specification-of-ββ-β : (p : (β β X) β π) β (n : β) β n is-a-mod-of-lc-of p β ββ n p οΌ β β (π : β β X) β p π οΌ β specification-of-ββ-β p zero ΞΆ Ο π = p π οΌβ¨ ΞΆ π (Ξ» _ β xβ) β β© p (Ξ» _ β xβ) οΌβ¨ Ο β© β β specification-of-ββ-β p (succ n) ΞΆ Ο π = p π οΌβ¨ β β© p (head π β· tail π) οΌβ¨ β‘ β© β β where xβ : X xβ = Ο΅β Ξ» y β ββ n (p β y β·_) β : ββ n (p β xβ β·_) οΌ β β (x : X) β ββ n (p β x β·_) οΌ β β = specification-of-ββ-β Ξ» y β ββ n (p β y β·_) IH : (x : X) β ββ n (p β x β·_) οΌ β β (π : β β X) β p (x β· π) οΌ β IH x = specification-of-ββ-β (p β x β·_) n (cons-decreases-mod-of-lc p n ΞΆ x) β : p π οΌ p (head π β· tail π) β = ap p (cons-head-tail π β»ΒΉ) β‘ : p (head π β· tail π) οΌ β β‘ = IH (head π) (β Ο (head π)) (tail π) \end{code}