Chuangjie Xu 2013 (updated and ported to TypeTopology in 2025)
This module collects the bare syntax of GΓΆdel's System T used throughout the
C-space development.
It is intentionally syntax-only: there are no reduction rules, typing
judgements, or semantic interpretations here. Those belong in the modules that
use the language.
\begin{code}
{-# OPTIONS --safe --without-K #-}
module C-Spaces.Syntax.SystemT where
open import MLTT.Spartan
\end{code}
Types
The simple types of System T are generated from booleans, natural numbers,
binary products, and function spaces.
\begin{code}
infixr 10 _β _
infixr 10 _β¨_
data Ty : π€β Μ where
β‘ : Ty
β : Ty
_β _ : Ty β Ty β Ty
_β¨_ : Ty β Ty β Ty
\end{code}
Contexts and variables
Contexts are represented as snoc-lists. The operation `Ξ β Ο` extends the
context `Ξ` with a fresh variable of type `Ο`.
Variables are represented by de Bruijn indices. Since the context is a
snoc-list, `zero` refers to the most recently added variable and `succ`
steps to the left in the context.
\begin{code}
infixl 10 _β_
data Cxt : π€β Μ where
Ξ΅ : Cxt
_β_ : Cxt β Ty β Cxt
length : Cxt β β
length Ξ΅ = zero
length (Ξ β _) = succ (length Ξ)
data Fin : β β π€β Μ where
zero : {n : β} β Fin (succ n)
succ : {n : β} β Fin n β Fin (succ n)
is-nonzero : β β π€β Μ
is-nonzero 0 = π
is-nonzero (succ n) = π
Fin-gives-is-nonzero : {n : β} β Fin n β is-nonzero n
Fin-gives-is-nonzero zero = β
Fin-gives-is-nonzero (succ i) = β
_[_] : (Ξ : Cxt) β Fin (length Ξ) β Ty
Ξ΅ [ i ] = π-elim (Fin-gives-is-nonzero i)
(xs β x) [ zero ] = x
(xs β x) [ succ i ] = xs [ i ]
\end{code}
Terms
The term formers are the standard constants and constructors of System T:
boolean constants and conditionals, natural numbers with primitive recursion,
binary products, lambda abstraction, and application.
\begin{code}
infixl 10 _Β·_
data Tm : Cxt β Ty β π€β Μ where
VAR : {Ξ : Cxt} β (i : Fin (length Ξ)) β Tm Ξ (Ξ [ i ])
β₯ : {Ξ : Cxt} β Tm Ξ β‘
β€ : {Ξ : Cxt} β Tm Ξ β‘
IF : {Ξ : Cxt}{Ο : Ty} β Tm Ξ (β‘ β¨ Ο β¨ Ο β¨ Ο)
ZERO : {Ξ : Cxt} β Tm Ξ β
SUCC : {Ξ : Cxt} β Tm Ξ (β β¨ β)
REC : {Ξ : Cxt}{Ο : Ty} β Tm Ξ (Ο β¨ (β β¨ Ο β¨ Ο) β¨ β β¨ Ο)
PAIR : {Ξ : Cxt}{Ο Ο : Ty} β Tm Ξ Ο β Tm Ξ Ο β Tm Ξ (Ο β Ο)
PRJβ : {Ξ : Cxt}{Ο Ο : Ty} β Tm Ξ (Ο β Ο) β Tm Ξ Ο
PRJβ : {Ξ : Cxt}{Ο Ο : Ty} β Tm Ξ (Ο β Ο) β Tm Ξ Ο
LAM : {Ξ : Cxt}{Ο Ο : Ty} β Tm (Ξ β Ο) Ο β Tm Ξ (Ο β¨ Ο)
_Β·_ : {Ξ : Cxt}{Ο Ο : Ty} β Tm Ξ (Ο β¨ Ο) β Tm Ξ Ο β Tm Ξ Ο
\end{code}