Programming in pcas [math-WE2N]

Categorical Realizability

Everything here works over a pca A\mathcal{A}.

Definition term [local-0]

Fix a countably infinite set of variables, inductively define the set of terms over a pca A\mathcal{A}:

  1. a variable is a term,
  2. an element of A\mathcal{A} is a term,
  3. given two terms ss and tt, we may form a new term s ts\ t.

Definition defined terms [local-1]

A closed term is defined if, when we interpret s ts\ t as ss applied to tt in A\mathcal{A}, all these applications are defined.

Extends to open term tt then is if all possible substitutions of all variables in tt by elements of A\mathcal{A}, the obtained closed term is defined.

Definition "λ\lambda-abstraction" in pca [local-2]

For a variable xx and a term tt, we can define a new term ⟨x⟩. t\langle x \rangle.\ t by recursion on terms:

  • ⟨x⟩. x≐I=S K K\langle x \rangle.\ x \doteq I = S\ K\ K,
  • ⟨x⟩. y≐K y\langle x \rangle.\ y \doteq K\ y if yy is a variable different from xx,
  • ⟨x⟩. a≐K a\langle x \rangle.\ a \doteq K\ a for a∈Aa \in \mathcal{A},
  • ⟨x⟩. (t1 t2)≐S(⟨x⟩. t1)(⟨x⟩. t2)\langle x \rangle.\ (t_1\ t_2) \doteq S(\langle x \rangle.\ t_1)(\langle x \rangle.\ t_2).

Notation [local-3]

⟨xy⟩. t\langle xy \rangle.\ t writes for ⟨x⟩. (⟨y⟩. t)\langle x \rangle.\ (\langle y \rangle.\ t)

Example [local-4]

Now, we can work on it, e.g.

true≐⟨xy⟩. xfalse≐⟨xy⟩. yif≐⟨x⟩. x\bold{true} \doteq \langle xy \rangle.\ x \\ \bold{false} \doteq \langle xy \rangle.\ y \\ \bold{if} \doteq \langle x \rangle.\ x

so

if true a b=aandif false a b=b\bold{if}\ \bold{true}\ a\ b = a \quad\text{and}\quad \bold{if}\ \bold{false}\ a\ b = b

Pair and projections are

pair≐⟨xyz⟩. zxyfst≐⟨w⟩. w truesnd≐⟨w⟩. w false\bold{pair} \doteq \langle xyz \rangle.\ zxy \\ \bold{fst} \doteq \langle w \rangle.\ w\ \bold{true} \\ \bold{snd} \doteq \langle w \rangle.\ w\ \bold{false}