Martin Escardo 22-23 May 2013 GΓΆdel's system T and its standard set-theoretical semantics. \begin{code} {-# OPTIONS --safe --without-K #-} module EffectfulForcing.MFPSAndVariations.SystemT where open import MLTT.Spartan hiding (rec ; _^_) renaming (β to β©βͺ) open import MLTT.Fin open import EffectfulForcing.MFPSAndVariations.Combinators open import EffectfulForcing.MFPSAndVariations.Continuity open import UF.Base data type : π€β Μ where ΞΉ : type _β_ : type β type β type infixr 6 _β_ \end{code} We work with vector types which notational grow at the end rather than the head. This is because we use vector types to represent contexts, which traditionally grow at the end: \begin{code} _^_ : π€ Μ β β β π€ Μ X ^ 0 = π X ^ (succ n) = X ^ n Γ X infixr 3 _^_ _[_] : {X : Set} {n : β} β X ^ n β Fin n β X _[_] {X} {succ n} (xs , x) π = x _[_] {X} {succ n} (xs , x) (suc i) = xs [ i ] Cxt : β β π€β Μ Cxt n = type ^ n data T : {n : β} (Ξ : Cxt n) (Ο : type) β Type where Zero : {n : β} {Ξ : Cxt n} β T Ξ ΞΉ Succ : {n : β} {Ξ : Cxt n} β T Ξ (ΞΉ β ΞΉ) Rec : {n : β} {Ξ : Cxt n} {Ο : type} β T Ξ ((ΞΉ β Ο β Ο) β Ο β ΞΉ β Ο) Ξ½ : {n : β} {Ξ : Cxt n} (i : Fin n) β T Ξ (Ξ [ i ]) Ζ : {n : β} {Ξ : Cxt n} {Ο Ο : type} β T (Ξ , Ο) Ο β T Ξ (Ο β Ο) _Β·_ : {n : β} {Ξ : Cxt n} {Ο Ο : type} β T Ξ (Ο β Ο) β T Ξ Ο β T Ξ Ο infixl 6 _Β·_ \end{code} The standard interpretation of system T: \begin{code} γ_γ : type β π€β Μ γ ΞΉ γ = β γ Ο β Ο γ = γ Ο γ β γ Ο γ γ_γ : {n : β} (Ξ : Cxt n) β π€β Μ γ Ξ γ = (i : Fin _) β γ Ξ [ i ] γ β¨β© : γ β©βͺ γ β¨β© () _β_ : {n : β} {Ξ : Cxt n} {Ο : type} β γ Ξ γ β γ Ο γ β γ Ξ , Ο γ (xs β x) π = x (xs β x) (suc i) = xs i infixl 6 _β_ β¦_β§ : {n : β} {Ξ : Cxt n} {Ο : type} β T Ξ Ο β γ Ξ γ β γ Ο γ β¦ Zero β§ _ = 0 β¦ Succ β§ _ = succ β¦ Rec β§ _ = rec β¦ Ξ½ i β§ xs = xs i β¦ Ζ t β§ xs = Ξ» x β β¦ t β§ (xs β x) β¦ t Β· u β§ xs = (β¦ t β§ xs) (β¦ u β§ xs) \end{code} Closed terms can be interpreted in a special way: \begin{code} Tβ : type β Type Tβ = T β©βͺ β¦_β§β : {Ο : type} β Tβ Ο β γ Ο γ β¦ t β§β = β¦ t β§ β¨β© T-definable : {Ο : type} β γ Ο γ β Type T-definable {Ο} x = Ξ£ t κ Tβ Ο , β¦ t β§β οΌ x \end{code} System T extended with a formal oracle Ξ©, called T' (rather than TΞ© as previously): \begin{code} data T' : {n : β} (Ξ : Cxt n) (Ο : type) β Type where Ξ© : {n : β} {Ξ : Cxt n} β T' Ξ (ΞΉ β ΞΉ) Zero : {n : β} {Ξ : Cxt n} β T' Ξ ΞΉ Succ : {n : β} {Ξ : Cxt n} β T' Ξ (ΞΉ β ΞΉ) Rec : {n : β} {Ξ : Cxt n} β {Ο : type} β T' Ξ ((ΞΉ β Ο β Ο) β Ο β ΞΉ β Ο) Ξ½ : {n : β} {Ξ : Cxt n} β (i : Fin n) β T' Ξ (Ξ [ i ]) Ζ : {n : β} {Ξ : Cxt n} β {Ο Ο : type} β T' (Ξ , Ο) Ο β T' Ξ (Ο β Ο) _Β·_ : {n : β} {Ξ : Cxt n} β {Ο Ο : type} β T' Ξ (Ο β Ο) β T' Ξ Ο β T' Ξ Ο β¦_β§' : {n : β} {Ξ : Cxt n} {Ο : type} β T' Ξ Ο β Baire β γ Ξ γ β γ Ο γ β¦ Ξ© β§' Ξ± _ = Ξ± β¦ Zero β§' _ _ = 0 β¦ Succ β§' _ _ = succ β¦ Rec β§' _ _ = rec β¦ Ξ½ i β§' _ xs = xs i β¦ Ζ t β§' Ξ± xs = Ξ» x β β¦ t β§' Ξ± (xs β x) β¦ t Β· u β§' Ξ± xs = (β¦ t β§' Ξ± xs) (β¦ u β§' Ξ± xs) \end{code} To regard system T as a sublanguage of T', we need to work with an explicit embedding: \begin{code} embed : {n : β} {Ξ : Cxt n} {Ο : type} β T Ξ Ο β T' Ξ Ο embed Zero = Zero embed Succ = Succ embed Rec = Rec embed (Ξ½ i) = Ξ½ i embed (Ζ t) = Ζ (embed t) embed (t Β· u) = (embed t) Β· (embed u) preservation : {n : β} {Ξ : Cxt n} {Ο : type} (t : T Ξ Ο) (Ξ± : Baire) β β¦ t β§ οΌ β¦ embed t β§' Ξ± preservation Zero Ξ± = refl preservation Succ Ξ± = refl preservation Rec Ξ± = refl preservation (Ξ½ i) Ξ± = refl preservation (Ζ t) Ξ± = ap (Ξ» f xs x β f (xs β x)) (preservation t Ξ±) preservation (t Β· u) Ξ± = apβ (Ξ» f g x β f x (g x)) (preservation t Ξ±) (preservation u Ξ±) \end{code} Some shorthands to simplify examples of system T terms. \begin{code} numeral : {n : β} {Ξ : Cxt n} β β β T Ξ ΞΉ numeral 0 = Zero numeral (succ n) = Succ Β· (numeral n) Ξ½β : {n : β} {Ξ : Cxt(succ n)} β T Ξ (Ξ [ π ]) Ξ½β = Ξ½ π Ξ½β : {n : β} {Ξ : Cxt(succ (succ n))} β T Ξ (Ξ [ suc π ]) Ξ½β = Ξ½ (suc π) Ξ½β : {n : β} {Ξ : Cxt(succ (succ (succ n)))} β T Ξ (Ξ [ suc (suc π) ]) Ξ½β = Ξ½ (suc (suc π)) Ξ½β : {n : β} {Ξ : Cxt(succ (succ (succ (succ n))))} β T Ξ (Ξ [ suc (suc (suc π)) ]) Ξ½β = Ξ½ (suc (suc (suc π))) Ξ½β : {n : β} {Ξ : Cxt(succ (succ (succ (succ (succ n)))))} β T Ξ (Ξ [ suc (suc (suc (suc π))) ]) Ξ½β = Ξ½ (suc (suc (suc (suc π)))) \end{code}