Chuangjie Xu, 2012

\begin{code}

module Space-exponential where

open import Mini-library
open import Cons
open import Space
open import Extensionality

-- Exponentials of C-spaces

infixr 3 _⇒_

_⇒_ : Space  Space  Space
(X , P , P-conds)  (Y , Q , qc₀ , qc₁ , qc₂) =
            CtsXtoY , R , rc₀ , rc₁ , rc₂
 where
  CtsXtoY : Set
  CtsXtoY = Σ \(f : X  Y) 
             continuous {X , P , P-conds} {Y , Q , qc₀ , qc₁ , qc₂} f

  R : Subset(₂ℕ  CtsXtoY)
  R r = ∀(p : ₂ℕ  X)  p  P  ∀(t : ₂ℕ  ₂ℕ)  t  C 
                                 α  (π₀  r)(t α)(p α))  Q

  rc₀ : ∀(r : ₂ℕ  CtsXtoY)  constant r  r  R
  rc₀ r cr p pP t uct = subst {₂ℕ  Y}  q  q  Q} claim₂ claim₀
   where
    claim₀ : (π₀(r ))  p  Q
    claim₀ = π₁(r ) p pP
    claim₁ : ∀(α : ₂ℕ)  π₀(r )(p α)  (π₀  r) (t α) (p α)
    claim₁ α = fun-cong (cong π₀ (cr  (t α))) (p α)
    claim₂ : (π₀(r ))  p  λ α  (π₀  r)(t α)(p α)
    claim₂ = extensionality claim₁
             --------------

  rc₁ : ∀(t : ₂ℕ  ₂ℕ)  uniformly-continuous-₂ℕ t 
             ∀(r : ₂ℕ  CtsXtoY)  r  R  r  t  R
  rc₁ t uc r rR p pP t' uc' = rR p pP (t  t') (Lemma[∘-UC] t uc t' uc')

  rc₂ : ∀(r : ₂ℕ  CtsXtoY) 
         ( \(n : )  ∀(s : ₂Fin n)  (r  (cons s))  R)  r  R
  rc₂ r ex p pP t uc = qc₂  α  (π₀  r)(t α)(p α)) (∃-intro n' prf)
   where
    n : 
    n = ∃-witness ex
    ps : ∀(s : ₂Fin n)  (r  (cons s))  R
    ps = ∃-elim ex
    n' : 
    n' = ∃-witness (coverage-axiom n t uc)
    prf : ∀(s' : ₂Fin n')   α  (π₀  r)(t(cons s' α))(p(cons s' α)))  Q
    prf s' = subst {₂ℕ  Y}  q  q  Q} claim₂ claim₀
     where
      s'' : ₂Fin n
      s'' = ∃-witness (∃-elim (coverage-axiom n t uc) s')
      t'' : ₂ℕ  ₂ℕ
      t'' = ∃-witness (∃-elim (∃-elim (coverage-axiom n t uc) s'))
      uct'' : uniformly-continuous-₂ℕ t''
      uct'' = ∧-elim₀ (∃-elim (∃-elim (∃-elim (coverage-axiom n t uc) s')))
      eq : t  (cons s')  (cons s'')  t''
      eq = ∧-elim₁ (∃-elim (∃-elim (∃-elim (coverage-axiom n t uc) s')))
      ps'inP : (p  (cons s'))  P
      ps'inP = ∧-elim₀ (∧-elim₁ P-conds) (cons s') (Lemma[cons-UC] s') p pP
      claim₀ :  α  (π₀  r)(cons s'' (t'' α))(p(cons s' α)))  Q
      claim₀ = ps s'' (p  (cons s')) ps'inP t'' uct''
      claim₁ : ∀(α : ₂ℕ)  (π₀  r)(cons s'' (t'' α))(p(cons s' α)) 
                           (π₀  r)(t(cons s' α))(p(cons s' α))
      claim₁ α = cong  x  (π₀  r)(x α)(p(cons s' α))) (sym eq)
      claim₂ :   α  (π₀  r)(cons s'' (t'' α))(p(cons s' α)))
                α  (π₀  r)(t (cons s' α))(p(cons s' α)))
      claim₂ = extensionality claim₁
               --------------

\end{code}