1 Introduction
In [4], Jones introduces consfree programming. Working with a small functional programming language, consfree programs are defined to be readonly: recursive data cannot be created or altered (beyond taking subexpressions), only read from the input. By imposing further restrictions on data order and recursion style, classes of consfree programs turn out to characterise various deterministic classes in the time and space hierarchies of computational complexity. Most relevantly to this work, consfree programs with data order characterise the class of decision problems decidable in
on a Turing Machine.
The classes thus characterised are all deterministic: they concern the time and space to solve decision problems on a deterministic Turing Machine. As the language considered by Jones is deterministic, a natural question is whether adding nondeterministic choice to the language would increase expressivity accordingly. The answer, at least in the base case, is no: following an early result by Cook [2], Bonfante shows [1] that adding a nondeterministic choice operator to consfree programs with data order makes no difference in expressivity: whether with or without nondeterministic choice, such programs characterise .
In this paper, we consider the generalisation of this question: does adding nondeterministic choice give more expressivity when data of order greater than is admitted? Surprisingly, the answer is yes! However, we do not obtain the nondeterministic classes; rather, nondeterministic consfree programs of any data order characterise , the class . As this is less useful for complexity arguments, we amend consfreeness with a further restriction—unary variables—which allows us to obtain the expected generalisation: that (thus restricted) consfree programs of data order characterise , whether or not nondeterministic choice is allowed.
We also generalise Jones’ language with pattern matching and userdefined constructors.
2 Consfree programming
For greater generality—and greater ease of expressing examples—we extend Jones’ language to a limited functional programming language with pattern matching. We will use terminology from the term rewriting world, but very little of the possibilities of this world.
2.1 Higherorder Programs
We consider programs using simple types, including product types. The type order of a type is defined as follows: for a sort (base type), and .
Assume given three disjoint set of identifiers: of constructors, of defined symbols and of variables; each symbol is equipped with a type. Following Jones, we limit interest to constructors with a type where all are types of order and is a sort. Terms are expressions such that can be derived for some type using the clauses:

if and each

if and each

if and
Thus, constructors cannot be partially applied, while variables and defined symbols can be. If , we say is the type of , and let be the set of variables occurring in . A term is ground if . We say is a subterm of , notation , if either or with and for some , or and for some . Note that the head of an application is not a subterm of the application.
A rule is a pair of terms such that (a) , (b) no defined symbols occur in any , (c) no variable occurs more than once in , (d) , and (e) has the same type as . A substitution is a mapping from variables to ground terms of the same type, and is obtained by replacing variables in by .
We fix a set of rules, which are consistent: if and are both in , then ; we call the arity of . The set of data terms consists of all ground constructor terms. The set of values is given by: (a) all data terms are values, (b) if are values, then is a value, (c) if has arity , and are values, then is a value if it is welltyped. Note that values whose type is a sort are data terms. The callbyvalue reduction relation on ground terms is defined by:

if and

if each and either , or and

if there are values and a rule with and substitution such that each and
Note that rule selection is nondeterministic; a choice operator might for instance be implemented by having rules and .
2.2 Consfree Programs
Since the purpose of this research is to find groups of programs which can handle restricted classes of Turingcomputable problems, we must impose certain limitations. In particular, we will limit interest to consfree programs:
A rule is consfree if for all subterms of the form with , we have: or . A program is consfree if all its rules are.
This definition follows those for consfree term rewriting in [3, 5] in generalising Jones’ definition in [4]; the latter fixes the constructors in the program and therefore simply requires that the only nonconstant constructor, , does not occur in any righthand side.
In a consfree program, if are all data terms, then any data term occurring in the derivation of is a subterm of some . This includes the result .
3 Turing Machines and decision problems
In this paper, we particularly consider complexity classes of decision problems. A decision problem is a set . A deterministic Turing Machine decides in time if every evaluation starting with a tape completes in at most steps, ending in the state if and in the state otherwise.
Let and . The class consists of those decision problems which can be decided in steps for some .
A program with constructors and (denoted infix) of type , and a defined symbol accepts a decision problem if for all : iff , where if and if . (Note that it is not required that all evaluations end in , just that there is at least one—and none if ).
4 A lower bound for expressivity
To give a lower bound on expressivity, we consider the following result paraphrased from [4]:
Suppose that, given an input list of length , we have a representation of , symbols , and consfree rules with:

for a value representing

if represents , then for a value representing

if represents , then iff and iff
Then any problem which can be decided in time is accepted by a consfree program whose data order is the same as that of , and which is deterministic iff is.
Proof Idea.
By simulating an evaluation of a Turing Machine. This simulation
encodes all transitions of the machine as rules; a transition from
state to state , reading symbol , writing and moving
to the right is encoded by a rule . In addition, there
are rules for —which returns the state the
machine is in at time —, —which
returns the position of the tape reader—and —for the symbol on the tape at position and time . Rules
are for instance:
This returns at time , and otherwise the state
reduced to in the last transition.
∎
For , we can represent as any pair of lists, where . For the counting functions, we define:
For any ,there are consfree, deterministic rules defining counting functions as in Lemma 4 such that, for , the numbers can be represented. All function variables in have a type .
Proof Idea.
The observation that the functional variables take only one input argument will be used in Lemma 4 below. The counting techniques from Example 4 and Lemma 4 originate from Jones’ work. However, in a nondeterministic system, we can do significantly more:
Let , and for , . Then for each , we can represent all as a term of type , and accompanying counting functions and can be defined.
Proof.
The base case () is Example 4. For larger , let have bit vector ; we say represents at level if for all : iff for some which represents at level , and iff for such . This relies on nondeterminism: reduces to a representation of every with . A representation of at level is used as a default, e.g. even if each . The and rules rely on testing bit values, using:
.
These rules are nonterminating, but if represents a
number at level , and at level , then reduces to exactly one value: if , and
if .
∎
Thus, we can count up to arbitrarily high numbers; by Lemma 4, every decision problem in is accepted by a nondeterministic consfree program of data order .
To obtain a more finegrained characterisation which still admits nondeterministic choice, we will therefore consider a restriction of consfree programming which avoids Lemma 4.
A consfree program has unary variable if all variables occurring in any rule in have a type or , with .
Intuitively, in a program with unary variables, functional variables cannot be partially applied; thus, such variables represent a function mapping to data, and not to some complex structure. Note that the input type of a unary variable is allowed to be a product . Lemma 4 relies on nonunary variables, but Lemma 4 does not. We obtain:
Any problem in is accepted by a (nondeterministic) extended consfree program of data order .
5 An upper bound for expressivity
To see that extended consfree programs characterise the hierarchy, it merely remains to be seen that every decision problem that is accepted by a callbyvalue consfree program with unary variables and of data order , can be solved by a deterministic Turing Machine—or, equivalently, an algorithm in pseudo code—running in polynomial time.
Algorithm (Finding the values for given input in a fixed extended consfree program ).
Input: a term with each a data term and .
Output: all data terms such that
.
Let .
For all types occurring as data in , generate and a relation , as follows:

if is a sort; for , let if

; if and

; for let if
For all , note that we can safely assume that . For all such , and all , note down a statement: . If , also note down for all .
For all rules , all with or , all and all substitutions mapping the variables to elements of , note down a statement . Mark all statements such that as confirmed, and all other statements unconfirmed. Repeat the following steps until no new statements are confirmed anymore.

For every unconfirmed statement , determine all rules (with or ) and substitutions mapping to an element of , such that each , and mark the statement as confirmed if is confirmed.

For every unconfirmed statement , mark the statement as confirmed if there exists with and is confirmed.

For every unconfirmed statement , mark it as confirmed if there are such that both and each are confirmed.
Then return all such that is marked confirmed.
Algorithm 5 is in —where is the data order of —and returns the claimed output.
Proof Idea.
The complexity of Algorithm 5 is determined by the size of each . The proof of soundness and completeness of the algorithm is more intricate; this fundamentally relies on replacing the values with by subsets of the set of all tuples with the property that, intuitively, . ∎
6 Conclusion
Thus, we obtain the following variation of Jones’ result:
A decision problem is in if and only if there is a consfree program of data order and with unary variables, which accepts . This statement holds whether or not the program is allowed to use nondeterministic choice.
In addition, we have adapted Jones’ language to be more permissive, admitting additional constructors and pattern matching. This makes it easier to specify suitable programs.
Using nondeterministic programs is a step towards further characterisations; in particular, we intend to characterise using restricted nondeterministic consfree programs of data order .
References
 [1] G. Bonfante. Some programming languages for logspace and ptime. In AMAST ’06, volume 4019 of LNCS, pages 66–80, 2006.
 [2] S.A. Cook. Characterizations of pushdown machines in terms of timebounded computers. ACM, 18(1):4–18, 1971.
 [3] D. de Carvalho and J. Simonsen. An implicit characterization of the polynomialtime decidable sets by consfree rewriting. In RTATLCA ’14, volume 8560 of LNCS, pages 179–193, 2014.
 [4] N. Jones. Life without cons. JFP, 11(1):5–94, 2001.
 [5] C. Kop and J. Simonsen. Complexity hierarchies and higherorder consfree rewriting. In FSCD ’16, volume 52 of LIPIcs, pages 23:1–23:18, 2016.
Comments
There are no comments yet.