21
Theory Comput Syst (2012) 51:85–105 DOI 10.1007/s00224-011-9377-9 Non-determinism in Gödel’s System T Lars Kristiansen · Bedeho Mesghina Wolde Mender Published online: 24 November 2011 © Springer Science+Business Media, LLC 2011 Abstract The calculus T is a successor-free version of Gödel’s T . It is well known that a number of important complexity classes, like e.g. the classes LOGSPACE, P, LINSPACE, ETIME and PSPACE, are captured by natural fragments of T and related calculi. We introduce the calculus T , which is a non-deterministic variant of T , and compare the computational power of T and T . First, we provide a denota- tional semantics for T and prove this semantics to be adequate. Furthermore, we prove that LINSPACE G 0 NLINSPACE and ETIME G 1 ESPACE where G 0 and G 1 are classes of problems decidable by certain fragments of T . (It is proved elsewhere that the corresponding fragments of T equal respectively LINSPACE and ETIME.) Finally, we show a way to interpret T in T . Keywords Complexity Theory · Non-determinism · Gödel’s System T · Denotational semantics 1 Introduction Roughly speaking, T and PCF are, respectively, Gödel’s system T and Plotkin’s programming language PCF where successor-like functions are removed. Variants of T and PCF are studied in a series of papers by the first author (and coauthors) [310]. A variant of PCF is defined as an extension of a variant of T , which again is defined as an extension of a variant of the typed λ-calculus. Sum types and product L. Kristiansen ( ) Department of Mathematics, University of Oslo, Oslo, Norway e-mail: [email protected] B.M.W. Mender Institute of Informatics, University of Oslo, Oslo, Norway e-mail: bmmender@ifi.uio.no

Non-determinism in Gödel’s System T

Embed Size (px)

Citation preview

Page 1: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105DOI 10.1007/s00224-011-9377-9

Non-determinism in Gödel’s System T

Lars Kristiansen ·Bedeho Mesghina Wolde Mender

Published online: 24 November 2011© Springer Science+Business Media, LLC 2011

Abstract The calculus T − is a successor-free version of Gödel’s T . It is well knownthat a number of important complexity classes, like e.g. the classes LOGSPACE, P,LINSPACE, ETIME and PSPACE, are captured by natural fragments of T − and relatedcalculi. We introduce the calculus T �, which is a non-deterministic variant of T −,and compare the computational power of T � and T −. First, we provide a denota-tional semantics for T � and prove this semantics to be adequate. Furthermore, weprove that LINSPACE ⊆ G�

0 ⊆ NLINSPACE and ETIME ⊆ G�1 ⊆ ESPACE where G�

0and G�

1 are classes of problems decidable by certain fragments of T �. (It is provedelsewhere that the corresponding fragments of T − equal respectively LINSPACE andETIME.) Finally, we show a way to interpret T � in T −.

Keywords Complexity Theory · Non-determinism · Gödel’s System T ·Denotational semantics

1 Introduction

Roughly speaking, T − and PCF− are, respectively, Gödel’s system T and Plotkin’sprogramming language PCF where successor-like functions are removed. Variantsof T − and PCF− are studied in a series of papers by the first author (and coauthors)[3–10]. A variant of PCF− is defined as an extension of a variant of T −, which againis defined as an extension of a variant of the typed λ-calculus. Sum types and product

L. Kristiansen (�)Department of Mathematics, University of Oslo, Oslo, Norwaye-mail: [email protected]

B.M.W. MenderInstitute of Informatics, University of Oslo, Oslo, Norwaye-mail: [email protected]

Page 2: Non-determinism in Gödel’s System T

86 Theory Comput Syst (2012) 51:85–105

types may—or may not—be available, and we can choose between a unary and abinary version of T −. The unary version is the typed λ-calculus extended with

– for each i ∈ N a constant ki of the base type ι

– recursor terms of the form Rσ (Nι,F ι,σ→σ ,Gσ ) with the accompanying reductionrules

Rσ (k0,F,G) � G and Rσ (kn+1,F,G) � F(kn,Rσ (kn,F,G))

and the binary version is the typed λ-calculus extended with

– for each α ∈ {0,1}∗ a constant kα of the base type ι

– recursor terms of the form Rσ (Nι,Fι,σ→σ0 ,F

ι,σ→σ1 ,Gσ ) with the accompanying

reduction rules• Rσ (kε,F0,F1,G) � G where ε denotes the empty string• Rσ (kiα,F0,F1,G) � Fi(kα,Rσ (kα,F0,F1,G)) where i ∈ {0,1} and α ∈

{0,1}∗.

The calculus PCF− is some version of the calculus T − extended with a fixed-pointterm Yσ M of type σ for each term M of type σ → σ and reduction rules of the formYσ M �M(Yσ M).

Anyone familiar with T and PCF might find it hard to believe that any interest-ing functions at all can be defined when successor-like functions are not available.However, it turns out that T − and PCF− are surprisingly powerful when it comesto decision problems. Even more surprisingly, neat and natural fragments of T − andPCF− induce hierarchies capturing many of the well-known complexity classes, likee.g. LOGSPACE, LINSPACE, PSPACE, P, ETIME. These classes are defined by impos-ing explicit resource bounds on Turing machines, but note that the classes are notuniformly defined as some are defined by imposing time bounds, whereas other aredefined by imposing space bounds. Hierarchies induced by T − and PCF− do alsocapture small subrecursive classes, e.g. the relational Grzegorczyk classes E 0∗ , E 1∗and E 2∗ . (For more details, see [8].) In contrast to a complexity class, a subrecursiveclass is defined as the least class containing some initial functions and closed un-der certain composition and recursion schemes. Some of the schemes might containexplicit bounds, but no machine models are involved.

The classes in the PCF− and T −-hierarchies are uniformly defined without re-ferring to explicit bounds. Thus, one should not expect these hierarchies to capturesuch a wide variety of classes, that is, both time classes, space classes and subrecur-sive classes. This indicates that further investigation of our successor-free program-ming languages might be rewarding, in particular, it will be interesting to extendthe languages with non-deterministic operators. This might shed light upon some ofthe notoriously hard open problems involving non-deterministic complexity classes.Moreover, this will also yield non-deterministic versions of all classes we can charac-terise by fragments of T − and PCF−, even those classes we cannot characterise byimposing natural resource bounds on Turing machines, e.g., the small Grzegorczykclasses E 0∗ and E 1∗ . How do such non-deterministic subrecursive classes relate to eachother? How do they relate to the deterministic ones? Will such classes spawn a newplethora of open problems?

Page 3: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 87

So far for the motivations behind introducing non-determinism. We conclude thisintroductory section by a summary of the remainder of this paper.

In Sect. 2, we will give a detailed definition of the unary version of T −. Thereafter,we extend this calculus with a naive and straightforward notion of non-determinism:we introduce terms of the form (M|N) and the two accompanying reduction rules(M|N) � M and (M|N) � N . The resulting calculus is dubbed T �. In Sect. 3, weprovide a denotational semantics for T � and prove this semantics to be adequate(Theorem 1).

In Sects. 4 and 5, we analyse the computational power of T � and comparecomputational power of T � and T −. Let G�

n denote the class of problems decid-able by T �-terms of recursor rank n, that is, T �-terms not containing any recur-sor terms Rσ (. . .) where the rank of the type σ is strictly greater than n; let Gn

denote the corresponding class of problems for the calculus T −. In Sect. 4, weprove that G�

0 ⊆ NLINSPACE (Theorem 2) and G�1 ⊆ ESPACE (Theorem 3). It fol-

lows straightforwardly from these two theorems and results published elsewhere thatLINSPACE = G0 ⊆ G�

0 ⊆ NLINSPACE and ETIME = G1 ⊆ G�1 ⊆ ESPACE. In Sect. 5,

we show how to interpret T � in T −. We show that any T �-term Mι→ι can be trans-formed into a T −-term Nι→ι such that, for any m ∈ N, the term N(km) reduces to k0iff the term M(km) reduces to k0 (Theorem 4).

2 The Calculi T − and T �

In this section we give the full definition of the calculi we will work with in this paper.We will assume that the reader is familiar with the typed λ-calculus and Gödel’s T .For more on Gödel’s T , see Avigad & Feferman [1].

We define the types recursively:

– ι is a type (primitive type)– σ × τ is a type if σ and τ are types (product types)– σ → τ is a type if σ and τ are types (arrow types).

The notation σ1, σ2, . . . , σn → τ is shorthand for σ1 → (σ2 → (. . . (σn → τ) . . .)),and TYP denotes the set of all types.

We define the terms of the typed λ-calculus:

– We have an infinite supply of variables xσ0 , xσ

1 , xσ2 , . . . for each type σ . A variable

of type σ is a term of type σ

– λxM is a term of type σ → τ if x is a variable of type σ and M is a term of typeτ (lambda abstraction)

– (MN) is a term of type τ if M is a term of type σ → τ and N is a term of type σ

(application)– 〈M,N〉 is a term of type σ × τ if M is a term of type σ and N is a term of type τ

(pair)– fstM (sndM) is a term of type σ (τ ) if M is a term of type σ × τ (projections).

We will use the standard conventions in the literature: M[x := N ] denotes theterm M where every free occurrence of the variable x is replaced by the term N ; the

Page 4: Non-determinism in Gödel’s System T

88 Theory Comput Syst (2012) 51:85–105

notation Mσ signifies that the term M is of type σ ; M(M1,M2) denotes the term((MM1)M2), etcetera.

Next we define the reduction rules of the typed λ-calculus. We have

– β-conversions: (λxM)N �M[x := N ] if N is substitutable for x in M ; fst〈M,N〉�M ; and snd〈M,N〉�N .

– α-conversion and all the other standard reduction rules, i.e., (MN) � (MN ′) ifN �N ′; (MN)� (M ′N) if M �M ′; etcetera.

The calculus T −n is the typed λ-calculus extended with

– for each i ∈ {0,1, . . . , n} a constant ki of type ι; these constants are called numerals– recursor terms Rσ (Nι,F ι,σ→σ ,Gσ ) of type σ and the two accompanying reduc-

tion rules given in the introductory section. These reduction rules will be referredto as R-conversions or R-rules.

The calculus T �n is the calculus T −

n extended with

– choice terms (Mσ |Nσ ) of type σ , that is, (M|N) is a term of type σ if M and N

are terms of type σ

– reduction rules of the form

(M|N) �M and (M|N) �N.

These reduction rules will be referred to as γ -conversions or γ -rules.

We define the calculi T − and T � by respectively T − = ⋃n∈N

T −n and T � =⋃

n∈NT �

n .We use M�N to denote that the term M reduces to the term N in one step modulo

α-conversions, and� denotes the transitive-reflexive closure of the relation �. A term

M is in normal form when there does not exist N such that M � N ; and β-normalform when there does not exist N such that M �N by applying a β-conversion. Weuse ≡ to denote syntactical equality between terms. For convenience, we will alwaysassume that n > 0 when we are working with calculi like T �

n and T −n . It is easy to

see that the set of T �n -terms is closed under the reduction rules, that is, if M is a

T �n -term and M

� N , then N is also a T �

n -term. This becomes useful in the nextsection where we develop a denotational semantics: any T �

n -term can be interpretedin a finite domain.

Berger [2] demonstrates that natural extensions of Gödel’s T are strongly normal-ising by using Tait’s method of strong computability for the simply typed λ-calculus,see Tait [18]. The lemma below follows from Berger’s results.

Lemma 1 (Strong Normalisation) There does not exist an infinite sequence M0,M1,

M2, . . . of T �-term such that Mi �Mi+1.

3 A Denotational Semantics for T �

We assume that the reader is familiar with basic domain theory and denotationalsemantics. An introduction to these subjects can be found in Streicher [16].

Page 5: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 89

We will interpret a T �n -term of the base type ι as a subset of the natural numbers

{0,1, . . . , n}. E.g., the term k4 will be interpreted as the set {4}, and (k4|k2) will beinterpreted as the set {4,2}. T �

n -terms of type ι → ι will be interpreted as functionsfrom the power set of {0,1, . . . , n} into the power set of {0,1, . . . , n}, and in general,T �

n -terms of type σ → τ will be interpreted as a function from a finite domain Dσn+1

into a finite domain Dτn+1. The formal definitions of the domains and the interpreta-

tion operator follow.

Definition 1 We use P (A) to denote the power set of the set A and A × B to denotethe Cartesian product of the set A and the set B . Furthermore, we use (a, b) to denotethe ordered pair of a and b, and we use π0 and π1 to denote projections, that is,π0((a, b)) = a and π1((a, b)) = b.

For any b > 0, we define the domain over type σ in base b, written Dσb , and a

binary relation σb over Dσ

b , recursively over the structure of σ .

– Dιb = P ({0, . . . , b − 1}), and d ι

b e ⇔ d ⊆ e for all d, e ∈ Dιb

– Dσ×τb = Dσ

b × Dτb , and (d0, d1) σ×τ

b (e0, e1) ⇔ d0 σb e0 ∧ d1 τ

b e1 for all(d0, d1), (e0, e1) ∈ Dσ×τ

b

– Dσ→τb is the set of all functions from Dσ

b into Dτb , and f σ→τ

b g ⇔ f (d) τb

g(d) for all d ∈ Dσb .

It is easy to see that σb is a partial order of Dσ

b .

Definition 2 We define the binary operator ∨σb over Dσ

b recursively over the structureof σ .

– d ∨ιb e = d ∪ e

– (d0, d1) ∨σ×τb (e0, e1) = (d0 ∨σ

b e0, d1 ∨τb e1)

– f ∨σ→τb g = h where h(x) = f (x) ∨τ

b g(x) for all x ∈ Dσb .

The proof of the next lemma is straightforward.

Lemma 2 For any d, e, f ∈ Dσb

– d ∨σb e = e ∨σ

b d

– (d ∨σb e) ∨σ

b f = d ∨σb (e ∨σ

b f )

– d σb d ∨σ

b e.

Definition 3 We define the notation∨σ,b

i∈S φi , where S is a nonempty finite set{i0, i1, . . . , in} and φi is an expression depending on i ∈ S, by

σ,b∨

i∈S

φi = φi0 ∨σb φi1 ∨σ

b · · · ∨σb φin .

The definition makes sense as ∨σb is commutative and associative.

For any σ and b > 0 we define ψσb : {0, . . . , b − 1} × D

ι,σ→σb × Dσ

b → Dσb and

Ψ σb : Dι

b\{∅} × Dι,σ→σb × Dσ

b → Dσb by

Page 6: Non-determinism in Gödel’s System T

90 Theory Comput Syst (2012) 51:85–105

– ψσb (0, f, g) = g

– ψσb (i + 1, f, g) = f ({i},ψσ

b (i, f, g))

– Ψ σb (S,f, g) = ∨σ,b

n∈S ψσb (n,f, g).

Lemma 3 For any S1, S2 ∈ Dιb\{∅}, any f ∈ D

ι,σ→σb and any g ∈ Dσ

b , we have

Ψ σb (S1 ∪ S2, f, g) = Ψ σ

b (S1, f, g) ∨σb Ψ σ

b (S2, f, g).

Proof We have

Ψ σb (S1 ∪ S2, f, g) =

σ,b∨

n∈S1∪S2

ψσb (n,f, g)

=⎛

⎝σ,b∨

n∈S1

ψσb (n,f, g)

⎠ ∨σb

⎝σ,b∨

n∈S2

ψσb (n,f, g)

= Ψ σb (S1, f, g) ∨σ

b Ψ σb (S2, f, g). �

Definition 4 We define an assignment A in base b as a total mapping from the set ofvariables into

⋃σ∈TYP Dσ

b such that A(xσ ) ∈ Dσb . Furthermore, Ax

d denotes the as-signment mapping x to d , and otherwise behaving like A, that is, we have Ax

d(x) = d ,and for any variable y different from x, we have Ax

d(y) = A(y).Given an assignment in base n + 1, we will interpret a T �

n -term of type σ as anelement in the domain Dσ

n+1. We define the interpretation of the term M under theassignment A, written [[M]]A, recursively over the structure of M .

– [[ki]]A = {i} for any i ∈ {0, . . . , n}– [[x]]A = A(x)

– [[(MN)]]A = [[M]]A([[N ]]A)

– [[λxσ Mτ ]]A = f where f (d) = [[M]]Axd

for any d ∈ Dσn+1

– [[(Mσ |Nσ )]]A = [[M]]A ∨σb+1 [[N ]]A

– [[〈M,N〉]]A = ([[M]]A, [[N ]]A)

– [[fstMσ×τ ]]A = π0([[M]]A)

– [[sndMσ×τ ]]A = π1([[M]]A)

– [[Rσ (N,F,G)]]A = Ψ σb ([[N ]]A, [[F ]]A, [[G]]A).

We may, by straightforward induction on the structure of terms, demonstratethat this interpretation is well-defined, and moreover, that the interpretation of aclosed term is insensitive to the assignment. Because of the latter, we often omitthe assignment and write [[M]] instead of [[M]]A. Additionally, the standard equality[[M]]Ax[[N]]A

= [[M[x := N ]]]A is easily shown to hold.

Lemma 4 (Consistency) Let Mσ be a T �b -term such that M � N , and let A be

any base b + 1 assignment. We have [[N ]]A σb+1 [[M]]A if M � N by the γ -rule;

otherwise , we have [[N ]]A = [[M]]A. Hence, if M� N , then [[N ]]A σ

b+1 [[M]]A.

Page 7: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 91

Proof We consider each conversion type separately.For reduction rules of the forms (MN) � (MN ′) if N � N ′; λxM � λxM ′ if

M �M ′; etcetera, the lemma follows straightforwardly from induction hypothesis onsubterms.

(β-conversions). It is obvious that [[fst〈R,S〉]]A = [[R]]A and [[snd〈R,S〉]]A =[[S]]A. Furthermore, we have

[[(λx.R)S]]A = [[λx.R]]A[[S]]A = [[R]]Ax[[S]]A= [[R[x := S]]]A.

(γ -conversions). By definition of [[ · ]]A we have

[[(R|S)]]A = [[R]]A ∨σb+1 [[S]]A

and by Lemma 2, we have

[[R]]A σb+1 [[R]]A ∨σ

b+1 [[S]]A.

Hence [[R]]A σb+1 [[(R|S)]]A. By the same token we have [[S]]A σ

b+1 [[(R|S)]]A.

(R-conversions). We have

[[Rσ (k0,F,G)]]A = Ψ σb+1([[k0]]A, [[F ]]A, [[G]]A) [[ · ]]A def.

=σ,b+1∨

n∈[[k0]]A

ψσb+1(n, [[F ]]A, [[G]]A) Ψ σ

b+1 def.

= ψσb+1(0, [[F ]]A, [[G]]A) [[k0]]A = {0} def.

= [[G]]A ψσb+1 def.

and

[[Rσ (kn+1,F,G)]]A

= Ψ σb+1([[kn+1]]A, [[F ]]A, [[G]]A) [[ · ]]A def.

=σ,b+1∨

m∈[[kn+1]]A

ψσb+1(m, [[F ]]A, [[G]]A) Ψ σ

b+1 def.

= ψσb+1(n + 1, [[F ]]A, [[G]]A) [[kn+1]]A = {n + 1}

= [[F ]]A({n},ψσb+1(n, [[F ]]A, [[G]]A)) ψσ

b+1 def.

= [[F ]]A

⎝[[kn]]A,

σ,b+1∨

m∈[[kn]]A

ψσb+1(m, [[F ]]A, [[G]]A)

= [[F ]]A([[kn]]A,Ψ σ

b+1([[kn]]A, [[F ]]A, [[G]]A))

Ψ σb+1 def.

= [[F ]]A([[kn]]A, [[Rσ (kn,F,G)]]A) [[ · ]]A def.

= [[F(kn,Rσ (kn,F,G))]]A.

Page 8: Non-determinism in Gödel’s System T

92 Theory Comput Syst (2012) 51:85–105

The last equality holds by a secondary induction on n. �

Lemma 5 Let Mσ be a closed T �-term in normal form.

– if σ = ι, then M is a numeral– if σ = τ → ρ, then M is a lambda abstraction– if σ = τ × ρ, then M is a pair.

Proof We prove all three claims simultaneously by induction over the structure of M .We will first argue that M cannot be of certain forms. (Keep in mind that any subtermof M must also be in normal form.)

Since M is closed, M cannot be a variable; and since M is in normal form, M

can obviously not be of the form (A|B). Neither can M be in form R(N,F,G) sinceNι by the induction hypothesis then would be a numeral, and this allows us to applyan R-reduction. Furthermore, M cannot be in one of the forms (Aτ→ρBτ ), fstAτ×ρ

or sndAτ×ρ , since these forms would by the induction hypothesis on A allow us toapply a β-conversion.

Observe now that the only remaining possible forms are numerals, lambda ab-stractions and pairs. Thus, if M is of type ι, then M cannot be a lambda abstractionor a pair, so the only possible form is a numeral. If M is of type τ → ρ, then M

cannot be a numeral or a pair, so the only possible form is a lambda abstraction. If M

is of type τ × ρ, then M cannot be a numeral or a lambda abstraction , so the onlypossible form is a pair. �

Lemma 6 For any T �b -term M the following holds:

If

(a) M is closed(b) M is not of the form λxQ

(c) M is not of the form 〈Q,R〉(d) at least one γ -conversion applies to M

(e) no other reduction rules (except α-conversions) apply to M

then there exist terms M1,M2 such that

M �M1 and M �M2 and [[M]] = [[M1]] ∨σb+1 [[M2]].

Proof We demonstrate this by induction on the structure of M .

Case M ≡ kn. In this case the implication stated by the lemma holds trivially as thepremise (d) is not fulfilled. The lemma also holds trivially in the case when M is avariable, in the case when M ≡ λxP , and in the case when M ≡ 〈P,Q〉.Case M ≡ fstP σ×τ . Assume M ≡ fstP satisfies (a), (b), (c), (d) and (e). Then, P isclosed as M is closed; P is not of the form λxP ′ as P is of product type; neither canP be of the form 〈P ′,P ′′〉 as M satisfies (e); furthermore, at least one γ -conversionapplies to P since at least one γ -conversion applies to M ; and finally, no other reduc-tion rules apply to P since no reduction rules except γ -conversion apply to M . Hence,P satisfies (a), (b), (c), (d) and (e), and then, by applying the induction hypothesis to

Page 9: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 93

P , we have terms P1 and P2 such that P �P1, P �P2 and [[P ]] = [[P1]] ∨σ×τb+1 [[P2]].

Hence

[[M]] = [[fstP ]]= π0([[P ]]) [[ · ]] def.

= π0([[P1]] ∨σ×τb+1 [[P2]]) ind.hyp.

= π0([[P1]]) ∨σb+1 π0([[P2]]) ∨σ×τ

b+1 def.

= [[fstP1]] ∨σb+1 [[fstP2]]. [[ · ]] def.

Thus, the lemma holds when M1 ≡ fstP1 and M2 ≡ fstP2.

Case M ≡ sndP τ×σ . This case is similar to the preceding case.

Case M ≡ P τ→σ Qτ . Assume M satisfies (a), (b), (c), (d) and (e). Our proof splitsinto two cases:

(i) P is a T −-term (thus, no γ -conversions apply to P )(ii) P is not a T −-term (thus, at least one γ -conversion applies to P ).

First, we deal with (i). In this case P is a T −-term, and since no rules except γ -rules apply to M , the term P has to be in normal form. Hence, by Lemma 5, the termP is of the form λxR. But then, M reduces to R[x := Q] by a β-conversion. Thiscontradicts that no β-conversions apply to M (the term M satisfies (e)). Hence, case(i) is not possible.

We turn to (ii). When P is not a T −-term, at least one γ -reduction will apply to P .Moreover, no other reduction rules apply to P since no other reduction rules applyto M . Moreover, P is not of the form λxR as β-conversion does not apply to M .Neither, can P be of the form 〈R,S〉. And finally, P is closed as M is closed. Hence,P satisfies (a), (b), (c), (d) and (e), and by applying the induction hypothesis to P ,we have terms P1 and P2 such that P � P1, P � P2 and [[P ]] = [[P1]] ∨τ→σ

b+1 [[P2]].Hence

[[M]] = [[PQ]]= [[P ]][[Q]] [[ · ]] def.

= {[[P1]] ∨τ→σb+1 [[P2]]

} [[Q]] ind.hyp.

= [[P1]]([[Q]]) ∨σb+1 [[P2]]([[Q]]) ∨τ→σ

b+1 def.

= [[P1Q]] ∨σb+1 [[P2Q]]. [[ · ]] def.

Thus, the lemma holds when M1 ≡ P1Q and M2 ≡ P2Q.

Case M ≡ (P |Q). Let M1 be P and M2 be Q for the desired result.

Case M ≡ Rσ (Nι,F ι,σ→σ ,Gσ ). Assume that M satisfies (a), (b), (c), (d) and (e).Then, it is obvious that N satisfies (a), (b), (c) and (e).

Page 10: Non-determinism in Gödel’s System T

94 Theory Comput Syst (2012) 51:85–105

The following contra positive argument shows that N also satisfies (d): As-sume that no γ -conversions apply to N . Then, since no reduction rules except γ -conversions apply to M , the term N has to be in normal form. Now, as N is a termof type ι in normal form, we can conclude that N is a numeral, and hence, M will beof the form Rσ (ki,F,G). But then, the R-rule applies to M . This contradicts that noreduction rules except γ -conversions apply to M .

This proves that N satisfies (a), (b), (c), (d) and (e). By applying the inductionhypothesis to N , we have terms N1 and N2 such that N � N1, N � N2 and [[N ]] =[[N1]] ∨ι

b+1 [[N2]]. Hence, we have

[[M]] = [[Rσ (N,F,G)]]= Ψ σ

b+1([[N ]], [[F ]], [[G]]) [[ · ]] def.

= Ψ σb+1([[N1]] ∨ι

b+1 [[N2]], [[F ]], [[G]]) ind.hyp.

= Ψ σb+1([[N1]] ∪ [[N2]], [[F ]], [[G]]) ∨ι

b+1 def.

= Ψ σb+1([[N1]], [[F ]], [[G]]) ∨σ

b+1 Ψ σb+1([[N2]], [[F ]], [[G]]) Lemma 3

= [[Rσ (N1,F,G)]] ∨σb+1 [[Rσ (N2,F,G)]]. [[ · ]] def.

Thus, the lemma holds when M1 ≡ Rσ (N1,F,G) and M2 ≡ Rσ (N2,F,G). �

Theorem 1 (Adequacy) For any closed T �n -term Mι, we have

m ∈ [[M]] ⇔ M� km.

Proof First, observe that

M� km ⇒ [[km]] ι

n+1 [[M]] Lemma 4

⇒ {m} ιn+1 [[M]] [[ · ]]A def.

⇒ {m} ⊆ [[M]] ιn+1 def.

⇒ m ∈ [[M]].The converse implication follows straightforwardly from Lemma 1 (strong nor-

malisation) and the Claim 1 below.

Claim 1 Let Mι be a closed term such that m ∈ [[M]]. If M is not in normal form,then there exists N such that M �N and m ∈ [[N ]].

To see that the Claim 1 holds, assume that M is not in normal form. If a β-rule orthe R-rule applies to M , we have a term N such that M �N and n ∈ [[M]] = [[N ]] byLemma 4. If it is not possible to apply a β-rule or the R-rule to M , then the γ -ruleapplies to M . By Lemma 6 we have N1,N2 such that

M �N1 and M �N2 and [[M]] = [[N1]] ∨ιb+1 [[N2]]

Page 11: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 95

that is, [[M]] = [[N1]] ∪ [[N2]]. Thus, we have m ∈ [[N1]] or m ∈ [[N2]]. This provesthe claim. �

4 The Computational Power of T � vs. T −

The previous section shows that T � admits a nice and transparent set-theoreticalsemantics. We may now ask to what extent the naive notion of non-determinism em-bodied in T �, adds any computational power to T −. A possible way to answer sucha vague question is to investigate the relationship between fragments of T � and com-plexity classes. We will assume some familiarity with Turing machines and complex-ity theory. For more on these subjects, the reader might consult e.g. Odifreddi [13].

Definition 5 We define the rank of the type σ , written rk(σ ), recursively over thestructure of σ .

– rk(ι) = 0– rk(σ × τ) = max{rk(σ ), rk(τ )}– rk(σ → τ) = max{rk(σ ) + 1, rk(τ )}.

If M is a term of type σ and rk(σ ) = n, we will say that M is a term of type rankn. Let M

σ11 , . . . ,M

σnn be a list of the recursor terms occurring in a term M , that is,

each Mi is of the form Rσi(. . .). We define the recursor rank of M , written rrk(M),

by rrk(M) = max {0, rk(σ1), . . . , rk(σn)}. Furthermore, we define the term rank of aterm M , written trk(M), by trk(M) = max {rk(σ ) | Nσ is a subterm of M}.

A problem is a subset of N. A term Mι→ι decides a problem A when M(kx)� k0

iff x ∈ A. We define the hierarchy G = ⋃n∈N

Gn by A ∈ Gn iff A is decided by aT −-term of recursor rank n, and the hierarchy G� = ⋃

n∈NG�

n by A ∈ G�n iff A is

decided by a T �-term of recursor rank n.A Turing machine m decides a problem A when m on input x ∈ N halts in a dis-

tinguished accept state if x ∈ A, and in a distinguished reject state if x �∈ A. The inputx ∈ N should be represented in binary on the Turing machine’s input tape. Let |x|denote the length of the standard binary representation of the natural number x. Wedefine LINSPACE (NLINSPACE) to be the set of problems decidable by a deterministic(non-deterministic) Turing machine working in space k|x| for some fixed k ∈ N; andwe define ETIME (NETIME) to be the set of problems decidable by a deterministic(non-deterministic) Turing machine working in time 2k|x| for some fixed k ∈ N; andfinally, we define ESPACE as the set of problems decidable by a deterministic Turingmachine working in space 2k|x| for some fixed k ∈ N.

It is not known if the inclusions LINSPACE ⊆ NLINSPACE and ETIME ⊆ NETIME

are strict. It is proved in Kristiansen & Barra [4] that G0 = LINSPACE, and in Kris-tiansen & Voda [5] that G1 = ETIME and G2 = ESPACE. See also Kristiansen [8, 10].It is of course trivial that we have Gi ⊆ G�

i for any i ∈ N.We will prove that G�

0 ⊆ NLINSPACE and G�1 ⊆ ESPACE. To do that we need three

technical lemmas. The first tells us that we can eliminate most terms of product typewithout restricting the computational power of important fragments of our calculus.

Page 12: Non-determinism in Gödel’s System T

96 Theory Comput Syst (2012) 51:85–105

Indeed, we can eliminate all terms of product type if we have recursor terms of typerank 1 available. If we only have recursor terms of type rank 0 available, we caneliminate all product terms of type rank ≥ 1. The second lemma tells us that we cando without choice terms of type rank ≥ 1. None of the T � fragments investigatedin this paper loose computational power if choice terms are required to be of typerank 0. The third lemma tells us that the T � fragment where all recursor terms arerequired to be of type rank ≤ m does not loose computational power if we in additionrequire all terms to be of type rank ≤ m + 1.

Lemma 7 Let Mι→ι be a T �n -term containing no free variables of product type.

(i) There exists a T �n -term N where any subterm of the form 〈P,Q〉 is of type rank 0,

such that [[N ]]A = [[M]]A (for any base n + 1 assignment A). Moreover, we havetrk(N) = trk(M) and rrk(N) = rrk(M). (ii) There exists a T �

n -term N not contain-ing subterms of the form 〈P,Q〉, such that [[N ]]A = [[M]]A (for any base n + 1assignment A). Moreover, trk(N) ≤ max(trk(M),1) and rrk(N) ≤ max(rrk(M),1).

Proof We prove (ii). The proof of (i) is similar, but a bit simpler.Let P σ and Qτ be T �

n -terms not containing any subterms of product type. Thisentails that σ and τ can be written in the forms σ1, . . . , σm → ι and τ1, . . . , τ� → ι

for some k, � ≥ 0. Let

pair[P,Q ] ≡ λzι �x �y .Rι( z , λuι(P �x) , Q�y )

where all displayed variables are fresh and �x = xσ11 , . . . , x

σmm and �y = y

τ11 , . . . , y

τ�

� .For any term R of type ι, σ1, . . . , σm, τ1, . . . , τ� → ι, let

1st[R ] ≡ λx1, . . . , xm . (R(k1, x1, . . . , xk, k0, . . . , k0))

where xσ11 , . . . , x

σm

k are fresh variables and the list k0, . . . , k0 contains � copies of k0;and let

2nd[R ] ≡ λy1, . . . , y� . (R(k0, k0, . . . , k0, y1, . . . , y�))

where yτ11 , . . . , y

τ�

� are fresh variables and the list k0, . . . , k0 contains m copies of k0.Now, we have

[[1st[pair[P,Q ] ]]]A = [[P ]]A and [[2nd[pair[P,Q ] ]]]A = [[Q]]A.

Furthermore, the term pair[P,Q ] is of type ι, σ1, . . . , σm, τ1, . . . , τ� → ι, and

rk(ι, σ1, . . . , σm, τ1, . . . , τ� → ι)

= max(rk(ι) + 1, rk(σ1) + 1, . . . , rk(σm) + 1, rk(τ1) + 1, . . . , rk(τ�) + 1, rk(ι))

= max(rk(ι → ι), rk(σ ), rk(τ )) = max(rk(σ ), rk(τ ),1)

and thus, it is easy to see that trk(pair[P,Q ]) = max(trk(〈P,Q〉),1). It is also easyto see that the term ranks of 1st[R ] and 2nd[R ] equal the term rank of R.

By using terms like the ones given above, we can simulate product terms of termrank 0 by product-free terms of term rank 1, and we can simulate product terms of

Page 13: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 97

term rank k, where k > 1, by product-free terms of term rank k. Moreover, by suchsimulations, we can transform a T �

n -term Mι→ι with no free variables of producttype into a term N satisfying Clause (ii) of the lemma. Though the details of thistransformation may be a bit tedious and messy, it should be clear that this can bedone. �

Lemma 8 Let M be a T �n -term where any subterm of the form 〈P,Q〉 is of type

rank 0. There exists a T �n -term N where

– any subterm of the form 〈P,Q〉 is of type rank 0– any subterm of the form (P |Q) is of type rank 0

such that [[N ]]A = [[M]]A (for any base n + 1 assignment A). Moreover, N is of thesame term rank, and of the same recursor rank, as M .

Proof First we note that for any subterm Sσ of M , the type σ can be written in theform

σ = τ1, . . . , τk → ι × · · · × ι

for some k ≥ 0. This is obvious when σ = ι. When σ = η × ξ , we know that rk(η) =rk(ξ) = 0, and thus, it follows by induction hypotheses on η and ξ that σ can bewritten in the form ι × · · · × ι. When σ = η → τ , the induction hypothesis says thatτ can be written in the form τ1, . . . , τk → ι × · · · × ι, and hence, σ can be written inthe form η, τ1, . . . , τk → ι × · · · × ι.

Next we define a mapping � recursively over the structure of M : �(x) = x

if x is a variable; �(ki) = ki ; �(λxM) = λx�(M); �((MN)) = (�(M)�(N));�(〈M,N〉) = 〈�(M),�(N)〉; �(fstM) = fst�(M); �(sndM) = snd�(M); and�(Rσ (N,F,G)) = Rσ (�(N),�(F),�(G)); and

�((M|N)) = λ�x.(�(M)�x | �(N)�x)

where σ = τ1, . . . , τk → ι × · · · × ι and �x = xτ11 , . . . , x

τk

k are fresh variables.The lemma holds when N ≡ �(M). �

Lemma 9 Let Mι→ι be a closed T �n -term where

(a) any subterm of the form 〈P,Q〉 is of type rank 0(b) any subterm of the form (P |Q) is of type rank 0.

Then, there exists a T �n -term N also satisfying (a) and (b), such that [[N ]] = [[M]]

and trk(N) ≤ rrk(M) + 1.

Proof Let N be M in β-normal form. Obviously, [[N ]] = [[M]]. We will prove thattrk(N) = rrk(N) + 1. It follows that trk(N) ≤ rrk(M) + 1.

Fix a subterm Sσ of N such that rk(σ ) = trk(N) and rk(τ ) < trk(N) for any strictsubterm Rτ of S. Now, S cannot be a variable as N is closed and rk(σ ) = trk(N). Theterm rank of N is greater or equal to 1, and thus, S cannot be of the form (P |Q), or ofthe form 〈P,Q〉, as N satisfies (a) and (b). It is easy to see that S cannot be a constantor in one of the forms fstP and sndP . Neither can S be in the form (P η→σ Qη) as

Page 14: Non-determinism in Gödel’s System T

98 Theory Comput Syst (2012) 51:85–105

rk(η → σ) > rk(σ ) = trk(N). By the same token, S cannot be a recursor term. Hence,S has to be in the form λyσ1P σ2 where σ = σ1 → σ2.

Furthermore, S ≡ λyσ1P σ2 cannot occur in a context of the form (λ�zy.P )Q asN is in β-normal form. Neither can S ≡ λyσ1P σ2 occur in a context of the formRξ (R,F,λ�zy.P ) as trk(F ) > rk(σ ) = trk(N). We are left with two possibilities. Ei-ther we have σ1 = σ2 and S ≡ λyσ1P σ1 occurs in a context of the form

Rσ1(R,λzιλyσ1P σ1,Gσ1)

or we have S ≡ λy.y ≡ N . In either case, the term rank of N equals the recursor rankof N plus 1. �

Theorem 2 G�0 ⊆ NLINSPACE.

Proof We will work with the imperative programming language LOOP studied e.g.in Meyer & Ritchie [12]. This is a powerful language, and it is well-known that afunction can be computed by a LOOP program iff it is primitive recursive.

The syntax of LOOP is as follows. The language has an infinite supply of variables,and suc(X) is a program if X is a variable; Y:=X is a program if X and Y arevariables; Y:=k is a program if Y is a variable and k ∈ N; P;Q is a program if Pand Q are programs; loop X[P] is a program if P is a program and X is a variablenot occurring in P. The semantics of LOOP is as expected from the syntax. Eachvariable holds a natural number, i.e. a value in N. The instruction suc(X) increasesthe number held by X by 1. The instructions Y:=X and Y:=k are ordinary assignmentoperations. To execute the program P;Q, we first execute the program P, then theprogram Q. To execute the program loop X[P], we execute the subprogram P, x

times in a row, where x is the number held by X when the execution starts. The valueheld by X will not be modified during the execution as X does not occur in P.

We extend LOOP to a non-deterministic language by adding imperatives of theform X:=Y|Z that either assigns the value held by the variable Y or the value heldby the variable Z to the variable X.

Claim 2 For any closed T �b -term Mι→ι of recursor rank 0, there exists a non-

deterministic loop program P such that

– there exists an execution of the program X:= m; P that computes the value y intothe variable Y

if and only if y ∈ [[Mkm]]. Moreover, the greatest number held by a variable duringthe execution of X:= m; P is bounded by max(b,m).

We prove Claim 2. Let Mι→ι be a T �b -term of recursor rank 0. By Lemma 7(i),

Lemma 8 and Lemma 9, we can assume that the term rank of M is 1 (M is a first-order program); that all subterms in M of the form (P |Q) are of type rank 0; andthat all subterms in M of the form 〈P,Q〉 are of type rank 0. The non-deterministicloop program P in Claim 2 can be constructed recursively over the structure of M .The construction is tedious and laborious, but straightforward for anyone familiarwith the loop language. The key to the construction is that any recursor term in M

Page 15: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 99

is of type rank 0, and thus, return a k-tuple of numbers. Hence, we can simulate arecursor term by a program of the form ... loop Z [...] computing valuesinto k variables holding natural numbers.

Let us turn to the proof of the theorem. Let A be a problem in G�0 . We will argue

that there exists a non-deterministic Turing machine m deciding the problem A in lin-ear space. By the definition of G�

0 and Theorem 1, there exists a T �b -term Mι→ι such

that 0 ∈ [[Mkm]] iff m ∈ A. By Claim 2, we have a non-deterministic loop program Psuch that

– there exists an execution of the program X:= m; P that computes the value 0 intothe variable Y

if and only if m ∈ A.Given its input m, the Turing machine m mimics the program X:= m; P. Each

program variable is implemented by a dedicated area on one of m’s tape. There is afixed number of variables in P. All the numbers stored in the variables will be lessor equal to max(m,b) where b is a constant (b depends on M , but is independentof the input m). Thus, m needs (|m| + c0) × c1 tape cells, where c0 and c1 are fixednumbers, to represent the program variables. After mimicking the execution of theloop program, m accepts its input if 0 is stored in the variable Y, otherwise m rejectsthe input. Obviously, m decides the problem A. It should also be obvious that it ispossible to construct this Turing machine such that it runs in linear space.

This proves that G�0 ⊆ NLINSPACE. �

Definition 6 The λ〈〉b-calculus is the standard typed λ-calculus extended with

– the constant ki of type ι, for each i ≤ b

– sequences 〈Mι0, . . . ,M

ιb〉 of type ι → ι, that is, 〈M0, . . . ,Mb〉 is a term of type

ι → ι if M0, . . . ,Mb are terms of type ι

– choice terms of any type, that is, (M|N) is a term of type σ if M and N are termsof type σ .

The denotational semantics for the λ〈〉b-calculus is the semantics for T �b extended

with

[[〈M0, . . . ,Mb〉]]A = f

where the function f : Dιb+1 → Dι

b+1 is given by f (d) = ⋃i∈d [[Mi]]A. (Thus, we

have that e.g. f ({0,1,5}) = [[M0]]A ∪ [[M1]]A ∪ [[M5]]A = [[M0]]A ∨ [[M1]]A ∨[[M5]]A.)

Next we define a mapping �b of the T �b -terms into the λ〈〉b-terms. Let �b(x) = x

if x is a variable; �b(ki) = ki ; �b(λxM) = λx�b(M); �b((MN)) = (�b(M)�b(N));�b(〈M,N〉) = 〈�b(M),�b(N)〉; �b((M|N)) = (�b(M)|�b(N)); and

�b(Rσ (N,F,G))

= λ�x.(〈�b(G)�x,�b(F (k0G))�x,�b(F (k1(Fk0G)))�x, . . . ,

�b(F (kb−1 . . . F (k0G) . . .))�x〉�b(N))

Page 16: Non-determinism in Gödel’s System T

100 Theory Comput Syst (2012) 51:85–105

where σ = τ1, . . . , τk → ι and �x = xτ11 , . . . , x

τk

k are fresh variables. The term�b(Rσ (N,F,G)) is undefined if σ is not of the form τ1, . . . , τk → ι.

Let REP(M) denote (a reasonable) representation of the λ〈〉b-term M in a finitealphabet, and let |REP(M)| denote the number of alphabet symbols in REP(M). (Tur-ing machines work with finite alphabets, whereas our terms are terms over an infinitealphabet.)

Lemma 10 (i) For any T �b -term M such that �b(M) is well-defined, we have

[[M]]A = [[�b(M)]]A. (ii) For any T �b -term M , there exists a polynomial p such

that |REP(�b(M))| ≤ p(b).

Proof This is easily proved by induction over the structure of M . We skip the de-tails. �

Theorem 3 G�1 ⊆ ESPACE.

Proof Let A ∈ G�1 . We will describe a deterministic Turing machine that decides the

problem n ∈ A and runs in space 2c|n| for some constant c.

Let Mι→ι be a T �-term of recursor rank 1 such that Mkn

� 0 iff n ∈ A. Such

a term exists since A is in G�1 . By Theorem 1, we have 0 ∈ [[Mkn]] iff n ∈ A. By

Lemma 7(ii), Lemma 8 and Lemma 9, we can assume that M does not contain producttypes; that any subterm of M in the form (P |Q) is of type rank 0; and that the termrank of M equals 2. We can also assume we have n ≥ i for any constant ki occurringin M . This can be assumed as it is sufficient to show that there exists a Turing machinesolving the problem A in exponential space for all but finitely many inputs.

Since M does not contain any product types, the type σ of any recursor termRσ (. . .) occurring in M , will be in the form σ = τ1, . . . , τk → ι. Hence, the term�n(Mkn) is a well-defined λ〈〉b-term.

After reading its in input n, our Turing machine will generate the representationREP(N) of the term N ≡ �n(Mkn). By Lemma 10, we have |REP(N)| ≤ p(n) forsome polynomial p.

A term of the form

(λyπ11 . . . y

πk

k xσ .P τ )(Qπ11 , . . . ,Q

πk

k ,Qσ )

is called a redex, and we define the rank of a redex in this form to be rk(σ → τ).Since the term M is of term rank 2, any redex in N will be of degree 1 or 2, andif the degree is 2, we will say that the redex is maximal. We need the notion of asemi-reduction. In a semi-reduction we do not replace a variable by a term as we doin an ordinary β-reduction. Instead we store the term somewhere else and replace thevariable by an address (pointer) to the term’s storage location. The Turing machinewe are describing, saves space by using such a strategy. We use p1,p2,p3 . . . todenote pointers, and our Turing machine represents a pointer by a bit sequence. LetP x

pidenote the term we get when each occurrence of the variable x in P is replaced by

the pointer pi . Furthermore, let M1, . . . ,M� denote λ〈〉n-terms (possibly containingpointers), and let C[ ] denote a context. We will say that string in the form

C[(λx.P )Q]/p1 : M1/p2 : M2/ · · ·/p� : M�

Page 17: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 101

semi-reduces to the string

C[P xp�+1

]/p1 : M1/p2 : M2/ · · ·/p� : M�/p�+1 : Q.

After generating the string REP(N) on its tape, our Turing machine starts to carryout semi-reductions. Let w0 be REP(N). The machine picks a maximal redex in theterm represented by w0 and eliminates this redex by a series of semi-reductions.It will pick the leftmost maximal redex (λy1 . . . ykx.P )(Q1, . . . ,Qk,Q) such thatthere are no maximal redexes inside Q1, . . . ,Qk,Q, and by k + 1 semi-reductionsthe Turing machine generates a string w1 representing a term in the form N/p1 :Q1/ · · ·/pk : Qk/pk+1 : Q. The term represented by w1 has exactly one maximalredex less than the term represented by w0. Thereafter, following the same procedure,our Turing machine generates a string w2 from the string w1. Thereafter, it generatesa string w3 from w2, and so on. Sooner or later, this process will terminate since therewill be no maximal redexes left. The result of the process is a string w in the formN/p1 : M1/p2 : M2/ · · ·/pj : Mj representing a λ〈〉n-term of term rank 1. Note thatno semi-reductions will take place inside the terms M1, . . . ,Mj since these terms donot contain maximal redexes. It should be obvious that we can construct the Turingmachine such that

|w| ≤ p(|REP(N)|) for some polynomial p, and thus, |w| ≤ q(n) for somepolynomial q, and thus, |w| ≤ 2c0|n| for some c0 ∈ N.

(*)

Let Q be the term represented by w. We have [[Q]] = [[Mkn]] and |w| ≤ 2c0|n|.Next, our Turing machine computes the set [[Q]]. The machine navigates in Q by us-ing a stack storing pointers occurring in w. There will not be required too much spaceto represent such a stack as the number of pointers is certainly bounded by 2c0|n|.Neither, will there be required too much space to deal with variable assignments. Letv1, v2, . . . , v� be an enumeration of the variables occurring in Q. (Rename variablesto avoid name conflicts.) Every variable occurring in Q is of type ι, and thus, nothingbut subsets of {0, . . . , n} will be assigned to the variables in the list v1, v2, . . . , v�. Torepresent a single subset of {0, . . . , n}, our Turing machine needs n tape cells. Thereexists a constant c1 such that n ≤ 2c1|n|. Moreover, � is obviously bounded by thelength of w, and thus by 2c0|n|. Hence, there exists a constant c2 such that the numberof tape cells needed to represent the variable assignments, is bounded by 2c2|n|.

Now, note that any subterm P ι of Q will in one of the forms

(1) x or ki

(2) (P ι1|P ι

2)

(3) (λxι1, . . . , x

ιk.P

ι0)(N

ι1, . . . ,N

ιk)

(4) 〈P ι0, . . . ,P

ιn−1〉Nι.

If P ι is of the form (1), then given some assignment A, our Turing machine can triv-ially compute [[P ]]A. If P ι is of the form (2), our Turing machine computes [[P ]]A bycomputing [[P ι

1]]A ∪ [[P ι2]]A. If P ι is of the form (3), our Turing machine computes

[[P ]]A by first computing [[Nι1]]A, . . . , [[Nι

k]]A, then it assigns these sets to respec-tively x1, . . . , xk , and finally, it computes [[P ι

0]]A′ where A′ = Ax1,...,xk[[N1]]A,...,[[Nk]]A. If

P ι is of the form (4), our Turing machine computes [[P ]]A by first computing the set

Page 18: Non-determinism in Gödel’s System T

102 Theory Comput Syst (2012) 51:85–105

[[N ]]A, and thereafter, for each i ∈ [[N ]]A, it computes [[P ιi ]]A, finally, it computes

[[P ]]A by computing⋃

i∈[[N ]]A[[P ι

i ]]A.Thus, our Turing machine will compute [[Q]] by systematically computing values

of terms of type ι. Values of sub-computations will be temporarily stored on one ofthe tapes and retrieved when needed. When values are not needed anymore, the spacemight be reused.

Finally, our Turing machine checks if 0 is in the set [[Q]]. If this turns out to bethe case, it accepts its input; if not, it rejects its input. It should be evident from theconsiderations above that there exists a constant c such that our Turing machine runsin space 2c|n|. �

Open Problems Can any of the inclusions in

– LINSPACE = G0 ⊆ G�0 ⊆ NLINSPACE

– ETIME = G1 ⊆ G�1 ⊆ ESPACE

be turned into equalities? And what is the relationship between G�1 and NETIME?

The reader may ask why we cannot prove the inclusions NLINSPACE ⊆ G�0 and

NETIME ⊆ G�1 ? We know that the inclusions LINSPACE ⊆ G0 and ETIME ⊆ G1 hold,

and moreover, we know that they hold because we can simulate a deterministic Tur-ing machines running in linear space (exponential time) by a T −-term of recursorrank 0 (1). So why can we not simulate a non-deterministic Turing machines runningin linear space (exponential time) by a T �-term of recursor rank 0 (1)? Well, theproblem is our notion of non-determinism. It is naive, and it is nice in the sense that itadmits a transparent denotational semantics. However, it seems too weak to add anycomputational power to fragments of T −. Consider a T −-term M with the informalstructure

M ≡ λx.if x is even then x else k0.

This term might reduce as follows in a non-deterministic context:

M(k2|k7)� if k2|k7 is even then k2|k7 else k0

if k2 is even then k7 else k0� k7

In all, it seems impossible to construct a T �-term Mι→ι such that

[[M]](A) ⊆ {n | n ∈ A and n is even} ∪ {0}.By the same token it seems impossible to simulate a non-deterministic Turing ma-chine running in linear space (exponential time) by a T �-term of recursor rank 0 (1).If we try to carry out such a simulation by terms with the informal structure

λx.if x is a certain configuration

then (modify x one way) | (modify x another way)

else . . .

Page 19: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 103

we will fail as the configuration that will be modified might not be the configurationsatisfying the test.

An obvious way to get a stronger notion of non-determinism will be to restrictapplications of the reduction rule

(λxM)N �M[x := N ] if N is substitutable for x in M

to cases when N is a T −-term, that is, before (λxM)N can be reduced to M[x := N ]every subterm of the form (P |Q) has to be removed from N . Given this restric-tion, the proof of the inclusions LINSPACE ⊆ G0 and ETIME ⊆ G1 can easily be con-verted into proofs of the inclusions NLINSPACE ⊆ G�

0 and NETIME ⊆ G�1 . However,

T � with restricted β-conversion seems to defy an informative and transparent deno-tational semantics. We have tried hard to find such a semantics, but we have failed.

A more radical way to achieve a more powerful non-determinism would be towork with a call-by-value calculus. For some relevant research along this line, seeSieber [15]. For more on non-determinism in functional programming languages, seee.g. Søndergaard & Sestoft [17].

5 Interpreting T � in T −

In the previous section we compared the computational power T − and T � by resort-ing to Turing machines and resource bounds. Another sensible way to compare thecomputational power T − and T �, will be to show how a T �-term Mι→ι decidinga problem A, can be efficiently transformed to a T −-term Nι→ι also deciding A,and then, see how the recursor rank of N relates to the recursor rank of M . How theresults of such a comparison should be interpreted does of course depend on whatthe transformation looks like, e.g., is the transformation direct or are other models ofcomputations involved. Carried out the right way, such a comparison will tell some-thing about the algorithms expressible in T � versus those expressible T −, in contrastto telling something about the problems definable T � versus those definable T −.

In this section we will survey some results from the second author’s thesis [11].First we will show how to interpret the domain Dσ

b as a set of natural numbers N σb .

Definition 7 For any type σ and any b > 0, we define the cardinality of σ , written‖σ‖b, recursively over the structure of σ . Let ‖ι‖b = 2b; ‖σ × τ‖b = ‖σ‖b × ‖τ‖b;and ‖σ → τ‖b = ‖τ‖‖σ‖b

b . For any type σ and any b > 0, we define N σb by N σ

b ={0, . . . ,‖σ‖b − 1}.Lemma 11 For any b > 0 and any type σ , there exists a bijection πσ

b : Dσb → N σ

band a relation �σ

b over N σb such that 〈N σ

b ,�σb 〉 is an ordering isomorphic to

〈Dσb ,σ

b 〉. Furthermore, for any T �b -terms Mσ , Nσ and base b + 1 assignment A,

we have

[[N ]]A = [[M]]A ⇔ πσb+1([[N ]]A) = πσ

b+1([[M]]A)

and for any closed T �b -term Mι, we have

2n �ιb+1 πι

b+1([[M]]) ⇔ M� kn.

Page 20: Non-determinism in Gödel’s System T

104 Theory Comput Syst (2012) 51:85–105

Mender [11] contains a detailed proof of the lemma where the bijection πσb is

effectively constructed recursively over the structure of σ .

Lemma 12 For any closed T �-term Mι→ι, there exists a closed T −-term Nι,ι,ι→ι

and a fixed number b0 such that for any b ≥ b0 and any m,n ≤ b, we have

N(kb, km, kn)� k0 ⇔ 2n �ι

b+1 πιb+1([[M(km)]]).

Moreover, rk(N) ≤ 2(rk(M) + 2).

The long and involved proof of Lemma 12 builds on the techniques used in e.g.[5] and [10] for encoding arithmetical operations into T −. The details of the proofcan be found in Mender [11].

Theorem 4 For any closed T �-term Mι→ι of recursor rank k, there exists a closedT −-term Nι→ι of recursor rank 2(k + 2) such that

N(km)� k0 ⇔ M(km)

� k0.

Proof By Lemma 11 and Lemma 12, we have a term T −-term N ′ such that

N ′(kb, km, k0)� k0 ⇔ 20 �ι

b+1 πιb+1([[M(km)]]) ⇔ M(km)

� k0

whenever m,n ≤ b and b is greater or equal to the constant b0 given by Lemma 12.The maximum function on natural numbers max(x, y) can be implemented by aT −-term of recursor rank 0. Thus, let N ≡ λx.N ′(max(kb0 , x), x, k0), and we have

N(km)� k0 iff M(km)

� k0. Moreover, N is of the required recursor rank. �

Let 2x0 = x and 2x

i+1 = 22xi , and for i ∈ N, let TIME 2lin

i (SPACE 2lini ) be the set

of problems decidable by a deterministic Turing machine working in time (space)2c|x|i for some fixed c ∈ N. Let NTIME 2lin

i and NSPACE 2lini be the non-deterministic

complexity classes corresponding to respectively TIME 2lini and SPACE 2lin

i . It is triv-ial that TIME 2lin

i ⊆ SPACE 2lini and SPACE 2lin

i ⊆ TIME 2lini+1, and thus, we have an

alternating space-time hierarchy

SPACE 2lin0 ⊆ TIME 2lin

1 ⊆ SPACE 2lin1 ⊆ TIME 2lin

2 ⊆ SPACE 2lin2 ⊆ TIME 2lin

3 ⊆ · · · .

(The three bottom classes are also known as respectively LINSPACE, ETIME

and ESPACE.)Kristiansen & Voda [5] prove that the hierarchy G0 ⊆ G1 ⊆ G2 ⊆ . . . matches this

alternating space-time hierarchy level by level. Furthermore, it seems very likely that

SPACE 2lini = G2i ⊆ G�

2i ⊆ NSPACE 2lini

and

TIME 2lini+1 = G2i+1 ⊆ G�

2i+1 ⊆ NTIME 2lini+1

Page 21: Non-determinism in Gödel’s System T

Theory Comput Syst (2012) 51:85–105 105

hold for i ∈ N. By Savitch’s Theorem [14], we have SPACE 2lini = NSPACE 2lin

i wheni > 0, and we have TIME 2lin

i = NTIME 2lini when i > 1. Hence, G�

i ⊆ Gi for i > 1.However, as a corollary of Theorem 4, we get a much weaker result, namely thatG�

i ⊆ G2(i+2). This is interesting as we do not see how to prove a stronger version ofTheorem 4 without resorting to Turing machines and complexity theory. (The currentproof of Theorem 4 is based on computing the semantic interpretation of T �-termsin T −.)

References

1. Avigad, J., Feferman, S.: Gödel’s functional interpretation. In: Buss, S. (ed.) Handbook of Proof The-ory. Elsevier, Amsterdam (1998)

2. Berger, U.: Continuous Semantics for Strong Normalization. Lecture Notes in Computer Science,vol. 3526, pp. 23–34. Springer, Berlin (2003)

3. Kristiansen, L., Voda, P.: The surprising power of restricted programs and Gödel’s functionals. In:Baaz, M., Makowsky, J. (eds.) CSL 2003: Computer Science Logic. Lecture Notes in Computer Sci-ence, vol. 2803, pp. 345–358. Springer, Berlin (2003)

4. Kristiansen, L., Barra, G.: The small Grzegorczyk classes and the typed λ-calculus. In: Cooper, S.B.,et al. (eds.) CiE 2005: New Computational Paradigms. Lecture Notes in Computer Science, vol. 3526,pp. 252–262. Springer, Berlin (2005)

5. Kristiansen, L., Voda, P.: Programming languages capturing complexity classes. Nord. J. Comput. 12,1–27 (2005)

6. Kristiansen, L., Voda, P.: The trade-off theorem and fragments of Gödel’s T . In: Cai, J.-Y., et al.(eds.) TAMC 2006: Theory and Applications of Models of Computation. Lecture Notes in ComputerScience, vol. 3959, pp. 654–674. Springer, Berlin (2006)

7. Kristiansen, L.: Complexity-theoretic hierarchies. In: Beckmann, A., et al. (eds.) CiE 2006: LogicalApproaches to Computational Barriers. Lecture Notes in Computer Science, vol. 3988, pp. 279–288.Springer, Berlin (2006)

8. Kristiansen, L.: Complexity-theoretic hierarchies induced by fragments of Gödel’s T . Theory Com-put. Syst. 43, 516–554 (2008)

9. Kristiansen, L.: Recursion in higher types and resource bounded turing machines. In: CiE’08: Logicand Theory of Algorithms. Lecture Notes in Computer Science, vol. 5028, pp. 336–348. Springer,Berlin (2008)

10. Kristiansen, L.: Higher types, finite domains and resource bounded Turing machines. J. Logic Com-put. Adv. Access published online on February 17, 2010. doi:10.1093/logcom/exq009

11. Mender, B.: Master Thesis. University of Oslo. http://www.duo.uio.no/sok/work.html?WORKID=91952+

12. Meyer, A.R., Ritchie, D.M.: The complexity of loop programs. In: Proc. ACM Nat. Meeting, pp.465–469 (1967)

13. Odifreddi, P.: Classical recursion theory II. In: Studies in Logic and the Foundations of Mathematics,vol. 143. North-Holland, Amsterdam (1999)

14. Savitch, W.J.: Relationships between nondeterministic and deterministic tape complexities. J. Com-put. Syst. Sci. 4, 177–192 (1970)

15. Sieber, K.: Call-by-value and nondeterminism. In: Typed Lambda Calculi and Applications. LectureNotes in Computer Science, vol. 664, pp. 376–390. Springer, Berlin (1993)

16. Streicher, T.: Domain-Theoretic Foundations of Functional Programming. World Scientific, Singapore(2006)

17. Søndergaard, H., Sestoft, P.: Non-determinism in Functional Languages. Comput. J. 35, 514–523(1992)

18. Tait, W.W.: Normal form theorem for barrecursive functions of finite type. In: Fenstad, J.E. (ed.)Proceedings of the Second Scandinavian Logic Symposium, pp. 353–367. North-Holland, Amsterdam(1971)