Non-deterministic Characterisations

11/09/2017 ∙ by Cynthia Kop, et al. ∙ Københavns Uni 0

In this paper, we extend Jones' result -- that cons-free programming with k^th-order data and a call-by-value strategy characterises EXP^kTIME -- to a more general setting, including pattern-matching and non-deterministic choice. We show that the addition of non-determinism is unexpectedly powerful in the higher-order setting. Nevertheless, we can obtain a non-deterministic parallel to Jones' hierarchy result by appropriate restricting rule formation.

READ FULL TEXT VIEW PDF
POST COMMENT

Comments

There are no comments yet.

Authors

page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

In [4], Jones introduces cons-free programming. Working with a small functional programming language, cons-free programs are defined to be read-only: recursive data cannot be created or altered (beyond taking sub-expressions), only read from the input. By imposing further restrictions on data order and recursion style, classes of cons-free programs turn out to characterise various deterministic classes in the time and space hierarchies of computational complexity. Most relevantly to this work, cons-free 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 non-deterministic 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 non-deterministic choice operator to cons-free programs with data order makes no difference in expressivity: whether with or without non-deterministic choice, such programs characterise .

In this paper, we consider the generalisation of this question: does adding non-deterministic choice give more expressivity when data of order greater than is admitted? Surprisingly, the answer is yes! However, we do not obtain the non-deterministic classes; rather, non-deterministic cons-free programs of any data order characterise , the class . As this is less useful for complexity arguments, we amend cons-freeness with a further restriction—unary variables—which allows us to obtain the expected generalisation: that (thus restricted) cons-free programs of data order characterise , whether or not non-deterministic choice is allowed.

We also generalise Jones’ language with pattern matching and user-defined constructors.

2 Cons-free 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 Higher-order 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 well-typed. Note that values whose type is a sort are data terms. The call-by-value 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 non-deterministic; a choice operator might for instance be implemented by having rules and .

2.2 Cons-free Programs

Since the purpose of this research is to find groups of programs which can handle restricted classes of Turing-computable problems, we must impose certain limitations. In particular, we will limit interest to cons-free programs:

A rule is cons-free if for all subterms of the form with , we have: or . A program is cons-free if all its rules are.

This definition follows those for cons-free 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 non-constant constructor, , does not occur in any right-hand side.

In a cons-free 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 cons-free 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 cons-free 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 cons-free, 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.

For , we can count to using an approach much like Example 4. Given , which represents numbers as a type , we can define by representing a number

with bit vector

(with ) as the function in which maps a “number” to if and to otherwise. ∎

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 non-deterministic 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 non-determinism: 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:

XYZ

.
These rules are non-terminating, 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 non-deterministic cons-free program of data order .

To obtain a more fine-grained characterisation which still admits non-deterministic choice, we will therefore consider a restriction of cons-free programming which avoids Lemma 4.

A cons-free 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 non-unary variables, but Lemma 4 does not. We obtain:

Any problem in is accepted by a (non-deterministic) extended cons-free program of data order .

5 An upper bound for expressivity

To see that extended cons-free programs characterise the hierarchy, it merely remains to be seen that every decision problem that is accepted by a call-by-value cons-free 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 cons-free 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 cons-free program of data order and with unary variables, which accepts . This statement holds whether or not the program is allowed to use non-deterministic 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 non-deterministic programs is a step towards further characterisations; in particular, we intend to characterise using restricted non-deterministic cons-free 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 time-bounded computers. ACM, 18(1):4–18, 1971.
  • [3] D. de Carvalho and J. Simonsen. An implicit characterization of the polynomial-time decidable sets by cons-free rewriting. In RTA-TLCA ’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 higher-order cons-free rewriting. In FSCD ’16, volume 52 of LIPIcs, pages 23:1–23:18, 2016.