Firstly we assume that we have natural numbers β: 0, 1, 2, β¦
We consider functions βα΅ β β, and identify ββ° β β with just β, i.e. we have unique k assigned to each function. f : βα΅ β β means that f accepts k arguments.
Now we postulate a few basic functions:
- Constant functions for each k, n β β:
C k n : βα΅ β β. - Successor function:
S : β β β. - Projection functions for each 1 β€ i β€ k β β:
Ο i k : βα΅ β β.
And a few basic operators that construct a new function from some already defined ones:
- Composition operator
f β (gβ, β¦, gβ) : βα΅ β β, wheref : ββΏ β βandgα΅’ : βα΅ β βfor each 1 β€ i β€ n. - Primitive recursion operator
Ο f g : βα΅βΊΒΉ β β, wheref : βα΅ β βandg : βα΅βΊΒ² β β. - Minimization operator
ΞΌ f : βα΅ β βwheref : βα΅βΊΒΉ β β.
This is enough to write typechecker, but now we need to give computational semantics for these functions.
We denote function application as f(xβ, β¦, xβ) for function f : ββΏ β β.
Then we define function application recursively:
(C k n)(xβ, β¦, xβ)β‘n.S(x)β‘x + 1(here we assume that there is a way to calculatex + 1, but itβs not necessary to definex + yfor arbitrary x, y β β).(Ο i k)(xβ, β¦, xβ)β‘xα΅’.(f β (gβ, β¦, gβ))(xβ, β¦, xβ)β‘f(gβ(xβ, β¦, xβ), β¦, gβ(xβ, β¦, xβ)).(Ο f g)(0, xβ, β¦, xβ)β‘f(xβ, β¦, xβ).(Ο f g)(y + 1, xβ, β¦, xβ)β‘g(y, (Ο f g)(y, xβ, β¦, xβ), xβ, β¦, xβ).(ΞΌ f)(xβ, β¦, xβ)is a minimumysuch thatf(y, xβ, β¦, xβ)β‘ 0. Iff(y, xβ, β¦, xβ)is always greater than zero, it does not terminate.