Table of Contents

Nondeterminism

Intuition

In the figure below, we show an ASCII map:

 
       ---- C3 --- dst --- C4 --- cliff
      /     |              |
     /      |              |
  src  >>-- C1 ----------- C2 --- cliff

Suppose a robot starts from position src, and would like to reach dst. On the map we have four crossroads denoted by Ci with i from 1 to 4.

Now, suppose the robot starts in the direction indicated by » but had a temporary sensor damage, and does not know if he missed the left turn. In fact, the robot has imperfect information regarding his current state: he might be at point C1 as well as at point C2 in the map.

To model imperfect information, we consider that the current position of the robot is {C1,C2}:

What happens after the robot takes the left-turn?

As before, after the left-turn, the robot cannot distinguish C3 from C4, thus his current position is {C3,C4}. We can represent the view which the robot has of the map after the sensor damage, as a finite-state machine:

Action\State q0 (initial state) C1 C2 C3 C4
straight C1, C2 C2 cliff - -
left - C3 C4 src dst
right - - - dst cliff

The matrix-like specification of the state-machine is very similar to that of the Turing Machine:

Note however that, when the actions straight has been read (i.e. executed), the state-machine can nondeterministically move to both C1 and C2.

Formally, the transition function $ \delta$ can no longer be a function, as it requires assigning two different next-states when straight is read in state $ q_0$ .

Questions:

Remark (state-machines):

A state-machine, as informally described above is a non-deterministic automaton. These computing devices will be studied in more details in the Formal Languages and Automata Lecture.

Motivation

In the previous section, we have informally introduced the concept of nondeterminism as imperfect-information, to make it more illustrative and easy-to-understand.

Next, we need to explore nondeterminism from a computational perspective, and to see how this concept is useful for classifying problems according to their hardness.

Boolean Satisfiability (SAT)

In this section, we introduce the Boolean Satisfiability Problem, and use it as a motivating example to drive our discussion.

$ SAT$ is the problem of determining if there exists an interpretation that satisfies a given Boolean formula.

$ SAT$ takes as input a boolean formula $ \psi$ in Conjunctive Normal Form (CNF):

$ \psi = C_1 \wedge C_2 \wedge \ldots \wedge C_n$

where, for each $ i:1 \leq i \leq n$ we have

$ C_i = L_{i1} \vee L_{i2} \vee \ldots \vee L_{im_i}$

and, for each $ j:1 \leq j \leq m_i$ we have

$ L_{ij} = x$ or $ L_{ij}=\neg x$

where $ x$ is a variable, and outputs $ 1$ iff there exists a interpretation $ I$ , such that under interpretation $ I$ the formula $ \psi$ is true.

An interpretation is a function that maps each variable(propositional symbol) to one of the truth values true and false.

SAT can be solved in exponential time

How can we solve SAT?

Given a formula $ \psi$ , we take the following steps:

Therefore $ SAT$ can be solved in exponential time, hence $ SAT \in EXPTIME$ . The major source of complexity consists in generating all possible interpretations on which a verification is subsequently done.

Let's assume that $ SAT$ would be solvable in polynomial time. Could we find problems (possibly related to $ SAT$ ) which are still solvable in exponential time under our assumption? The answer is yes: Let $ \gamma$ be the formula:

$ \gamma = \forall x_1 \forall x_2 \ldots \forall x_k \psi$

where $ \psi$ is a formula in CNF containing variables $ x_1,\ldots,x_k$ , and $ k \in \mathbb{N}$ is arbitrarly fixed. Checking if $ \gamma$ is satisfiable is the problem $ \forall SAT$ . An algorithm for $ \forall SAT$ must build all combinations of 0/1 values for each $ x_i$ with $ i:1 \leq i \leq k$ and for each one, must solve an instance of the $ SAT$ problem. In total, we have $ 2^k$ combinations, and since $ k$ is part of the input, the algorithm runs in exponential time, provided that we have an algorithm for $ SAT$ which runs in polynomial time.

The Nondeterministic Turing Machine

Definition (Non-deterministic TM):

A non-deterministic Turing Machine ($ NTM$ short) is a tuple $ M=(K,F,\Sigma,\delta,s_0)$ over alphabet $ \Sigma$ with $ K$ , $ \Sigma$ and $ s_0$ defined as for (conventional) Turing Machines, $ F=\{s_{yes},s_{no}\}$ and $ \delta \subseteq K \times \Sigma \times K \times \Sigma \times \{L,H,R\}$ is a transition relation.

A $ NTM$ terminates iff it reaches a final state. A $ NTM$ $ M$ decides a function $ f:\mathbb{N} \rightarrow \{0,1\}$ iff

  • $ f(n^w)=0 \Longrightarrow M(w)$ reaches state $ s_{no}$ on all possible sequences of transitions and
  • $ f(n^w)=1 \Longrightarrow M(w)$ reaches state $ s_{yes}$ on at least one sequence of transitions.

We say the running time of a $ NTM$ $ M$ is $ T$ iff, for all $ w \in \Sigma$ :

  • the shortest successful sequence of transitions has at most $ T(\mid w\mid)$ steps - if it exists or,
  • the longest unsuccessful sequence of transitions has at most $ T(\mid w\mid)$ steps.

We start with a few technical observations. First note that the $ NTM$ is specifically tailored for decision problems. It has only two final states, which correspond to yes/no answers. Also, the machine does not produce an output, and the usage of the tape is merely for internal computations. In essence, these “design choices” for the $ NTM$ are purely for convenience, and alternatives are possible.

Whereas the conventional Turing Machine assigned, for each combination of state and symbol, a unique next-state, overriding symbol and head movement, a nondeterministic machine assigns a collection of such elements.

The intuition is that the $ NTM$ can simultaneously process a set of conventional configurations, in one single step. While the execution of a Turing Machine can be represented as a sequence, that of the $ NTM$ can be represented as a tree. A path in the tree corresponds to one sequence of transions which the $ NTM$ performs.

Now, notice the conditions under which a $ NTM$ decides a function: if at least one sequence of transitions leads to $ s_{yes}$ , we can interpret the answer of the $ NTM$ as yes. Conversely, if all sequences of transitions lead to $ s_{no}$ , then the machine returns no.

Finally, when accounting for the running time of a $ NTM$ , we do not count all performed transitions (as it would seem reasonable), but only the length of the longest transition sequence performed by the machine. The intuition is that all members of the current configuration are processed in parallel, during a single step.

SAT is Solvable in polynomial time on a NTM

We build the $ NTM$ $ M_{SAT}$ which solves the $ SAT$ problem discussed previously. First, we assume the existence of $ M_{chk}(I,\psi)$ which takes an interpretation and a formula, both encoded as a unique string, and checks if $ I \models \psi$ . $ M_{chk}$ is a conventional $ TM$ , thus upon termination it leaves $ 0$ or $ 1$ on the tape.

If we add up all running times of the three steps, we obtain $ O(n*k)$ .

Conventional and Nondeterministic TMs - a qualitative comparison

NTMs definitely seem faster thus better at solving problems than their conventional counterparts. However:

However, are NTMs more expressive - e.g. able to solve problems which are not recursive? The following proposition answers this question:

Proposition:

Every function which is decidable by an $ NTM$ in polynomial running time, is also by a $ TM$ which runs in exponential time.

Can you think of a way to prove the proposition?

The role of NTMs

We have already seen:

However, the usefulness of NTMs may still be unclear. To convincingly motivate NTMs, let us recall the notion of acceptance of a Turing Machine:

The NTM serves exactly the same kind of purpose, regarding complexity:

Thus, nondeterminism is used to identify a very specific pattern of complexity, just like acceptance is used to identify a specific pattern of undecidability.

It is important to note that:

Convention for describing $ NTM$ in pseudocode

In the previous chapters, we often resorted to traditional pseudocode in order to describe algorithms - that is, Turing Machines. It is occasionaly useful to be able to do the same thing for $ NTM$ s. With this in mind, we introduce some notational conventions. The instruction:

$ v = choice(A)$

where $ v$ is a variable and $ A$ is a set of values, behaves as follows:

We also note that, it is not possible to achieve some form of “communication” between conventional configurations. Thus, it is intuitive to think that the processing (execution of a transition) of a conventional configuration is done independently of all other conventional configurations.

We add two aditional instructions: success and fail. They correspond to a transitions into states $ s_{yes}$ and $ s_{no}$ , respectively.

We illustrate $ NTM$ pseudocode, by re-writing the $ SAT$ algorithm described above. We adopt the same representational conventions from the first Chapter, and also re-use the procedure CHECK.

Example (Pseudocode):

$ SolveSAT(\phi)$

Let $ n$ be the number of variables in $ \varphi$ .

Let $ I$ be a vector with $ n$ components which are initialised with $ 0$ .

$ \mathbf{for} \mbox{ } i=\overline{0,n-1} \mbox{ :}$

$ \quad I \lbrack i \rbrack = choice(\{0,1\})$

$ \mathbf{if} \mbox{ } CHECK(\varphi,I)=0$

$ \quad fail$

$ \mathbf{else} \mbox{ } succes$