Theory of Computation & Computer Graphics โ Turing Machine, NEC licence examination syllabus (Nepal Engineering Council).
Non-Deterministic Turing Machines
A machine that guesses โ and the question of whether guessing saves time is the deepest open problem in computer science.
๐ Where this lives: The P versus NP question, which this topic sets up, carries a one-million-dollar prize from the Clay Mathematics Institute and is widely regarded as the most important open problem in computing. It is not an abstract curiosity: if P equalled NP, most modern cryptography would collapse, because the security of RSA and its relatives rests on the belief that verifying a factorisation is easy while finding one is hard. Search "P versus NP Clay Millennium Prize cryptography".
Definition and the equivalence
A NON-DETERMINISTIC TURING MACHINE (NTM) DIFFERS FROM THE
STANDARD MODEL IN ONE PLACE โ THE TRANSITION FUNCTION RETURNS A
**SET** OF POSSIBLE MOVES:
ฮด : Q ร ฮ โ P( Q ร ฮ ร {L, R} )
At each step the machine may have SEVERAL applicable moves,
or none.
โโ ACCEPTANCE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
AN NTM ACCEPTS w IF **SOME** COMPUTATION PATH ACCEPTS.
It rejects only if EVERY path rejects or fails to halt. The
asymmetry is deliberate and total: ONE SUCCESSFUL PATH
SUFFICES, however many others fail.
TWO EQUIVALENT MENTAL MODELS, both useful:
THE GUESSING MODEL โ the machine always guesses the right
move if a right move exists. It is an oracle for its own
choices.
THE PARALLEL MODEL โ the machine splits into copies at each
choice point, exploring all paths simultaneously in a
COMPUTATION TREE, and accepts if any leaf accepts.
NEITHER IS PHYSICALLY REALISABLE, and that is the point: an
NTM is a MATHEMATICAL DEVICE FOR DEFINING COMPLEXITY CLASSES,
not a machine anyone could build.
โโ THE COMPUTATION TREE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The natural picture:
start
/ | \
/ | \
cโ cโ cโ โ choices at step 1
/ \ / \
cโ cโ cโ cโ โ choices at step 2
โฎ โฎ
REJECT ACCEPT โ
ยท Each NODE is a configuration.
ยท Each BRANCH is a non-deterministic choice.
ยท The machine ACCEPTS if ANY leaf is accepting.
ยท Branches may be infinite โ a path that never halts.
โโ THE EQUIVALENCE THEOREM โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
EVERY NON-DETERMINISTIC TURING MACHINE HAS AN EQUIVALENT
DETERMINISTIC ONE.
NON-DETERMINISM ADDS **NO COMPUTATIONAL POWER**.
THE PROOF: SEARCH THE COMPUTATION TREE.
A three-tape deterministic machine D simulates N:
tape 1 โ the input, never altered
tape 2 โ a working copy of N's tape for the current path
tape 3 โ the ADDRESS of the branch being explored, a
string of digits saying which choice to make at
each step
D repeatedly:
1. copies the input to tape 2
2. simulates N, using tape 3 to decide each choice
3. if that path accepts, ACCEPT
4. otherwise write the next address on tape 3 and repeat
THE CRITICAL DETAIL, AND THE ONE EXAMINERS TEST:
THE SEARCH MUST BE **BREADTH-FIRST**, NOT DEPTH-FIRST.
A depth-first search could descend an INFINITE non-halting
branch and never return to explore a sibling branch that
accepts. Breadth-first โ trying all paths of length 1, then
all of length 2, and so on โ REACHES EVERY FINITE ACCEPTING
PATH IN FINITE TIME.
THIS IS THE SAME DOVETAILING PRINCIPLE AS IN THE ENUMERATOR
TOPIC, applied to a tree rather than a list, and for exactly
the same reason: A SINGLE NON-TERMINATING COMPUTATION MUST
NEVER BE ALLOWED TO BLOCK THE REST.
โโ THE COST โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
If N runs in time T(n) with branching factor at most b, the
tree has up to b^T(n) nodes, and D must explore them all.
SIMULATION TIME: O( b^T(n) ) โ EXPONENTIAL.
NUMERICALLY, with branching factor 2:
depth 10 โ 1,024 configurations
depth 30 โ 1,073,741,824 configurations
and with branching factor 3 at depth 20, about 3.5 ร 10โน.
SO NON-DETERMINISM COSTS EXPONENTIALLY IN TIME WHILE COSTING
NOTHING IN POWER โ and WHETHER THAT EXPONENTIAL COST IS
NECESSARY IS PRECISELY THE P VERSUS NP QUESTION.
โโ SPACE IS DIFFERENT โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
A striking contrast, worth knowing:
SAVITCH'S THEOREM: NSPACE( f(n) ) โ DSPACE( f(n)ยฒ )
Non-determinism costs only a SQUARING in space, not an
exponential. Consequently PSPACE = NPSPACE โ the
deterministic and non-deterministic polynomial SPACE classes
are EQUAL.
SO THE OPEN QUESTION IS SPECIFICALLY ABOUT TIME. For space,
the analogous question was settled in 1970.
Non-determinism and the classes P and NP
โโ THE DEFINITIONS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
P โ problems DECIDABLE by a deterministic TM in
polynomial time
NP โ problems decidable by a NON-DETERMINISTIC TM in
polynomial time
THE EQUIVALENT AND MORE USEFUL CHARACTERISATION OF NP:
NP IS THE CLASS OF PROBLEMS WHOSE **SOLUTIONS CAN BE
VERIFIED** IN POLYNOMIAL TIME.
The two definitions match because the non-deterministic
machine's accepting path IS the certificate: guessing it
non-deterministically and verifying it deterministically are
the same computation viewed from two sides.
"NP" STANDS FOR **NON-DETERMINISTIC POLYNOMIAL**, NOT
"NON-POLYNOMIAL". This is the most persistent
misunderstanding in the subject and is worth stating
explicitly in an exam answer.
โโ THE INTUITION โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
FINDING versus CHECKING.
ยท Finding a Hamiltonian cycle in a graph seems to require
searching exponentially many possibilities.
ยท CHECKING a proposed cycle takes linear time โ walk it and
confirm every vertex appears once.
ยท Finding the factors of a large number is hard.
ยท CHECKING a proposed factorisation is one multiplication.
ยท Finding a satisfying assignment for a Boolean formula is
hard.
ยท CHECKING one is a single evaluation.
P โ NP IS OBVIOUS: anything you can solve you can verify, by
solving it again and comparing.
WHETHER NP โ P IS THE OPEN QUESTION โ is checking really
easier than finding, or have we simply not found the clever
algorithms?
โโ WHY IT MATTERS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
THOUSANDS OF PROBLEMS ARE NP-COMPLETE โ the hardest in NP, in
the sense that a polynomial algorithm for any one of them
would give a polynomial algorithm for all of them:
Boolean satisfiability (SAT), travelling salesman,
graph colouring, knapsack, scheduling, protein folding,
circuit minimisation, and many more
THEY ARISE INDEPENDENTLY ACROSS LOGISTICS, BIOLOGY, CHEMISTRY,
CIRCUIT DESIGN AND OPERATIONS RESEARCH, which is why the
question is not confined to theory.
IF P = NP:
ยท these thousands of problems all become efficiently
solvable
ยท MOST MODERN CRYPTOGRAPHY BREAKS, since it relies on
problems being hard to solve and easy to verify
ยท mathematics changes character, because finding a proof
would be as easy as checking one
IF P โ NP, as almost everyone believes:
ยท these problems are genuinely intractable in the worst
case, and the effort must go into approximation,
heuristics and special cases โ which is exactly what
practice already does
THE PROBLEM HAS BEEN OPEN SINCE COOK'S 1971 PAPER, AND NO
APPROACH HAS COME CLOSE. Several proof techniques have been
formally shown to be INCAPABLE of resolving it โ relativisation,
natural proofs, algebrisation โ which is itself a remarkable
body of work: we have proved that whole families of methods
cannot settle the question.
โโ THE COMPARISON ACROSS THE MODELS โโโโโโโโโโโโโโโโโโโโโโโโ
MODEL DOES NON-DETERMINISM ADD POWER?
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
FINITE AUTOMATON NO โ subset construction (a set of
states is finite)
PUSHDOWN AUTOMATON **YES** โ DPDA โ NPDA (a set of stacks
is infinite)
TURING MACHINE NO โ but at EXPONENTIAL time cost
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
THIS PATTERN IS ONE OF THE MOST INSTRUCTIVE FACTS IN THE WHOLE
SUBJECT. The answer is NO, YES, NO as one climbs the
hierarchy โ non-determinism matters in the middle and not at
the ends, for entirely different reasons at each level.
AT THE FINITE LEVEL, all possibilities can be tracked in the
finite state.
AT THE PUSHDOWN LEVEL, they cannot โ there are infinitely
many stack configurations.
AT THE TURING LEVEL, they can be tracked again, because the
unbounded tape can record the whole search โ but the
recording takes exponential time.
The pattern across the three models is no, yes, no โ and for different reasons each time. A finite automaton can track all possibilities in its finite state; a pushdown automaton cannot, since there are infinitely many stack configurations; a Turing machine can again, because the unbounded tape records the whole search โ but recording it takes exponential time.
๐ Go further: The P versus NP problem has resisted attack for over fifty years, and part of what makes it remarkable is that we have proved certain proof techniques cannot settle it. Relativisation (1975) showed that any argument surviving the addition of an oracle must fail, since there are oracles making P = NP and others making P โ NP. Natural proofs (1994) showed that a broad class of combinatorial arguments would, if successful, break the very cryptography they would need to assume secure. Algebrisation (2008) closed a further family. Each result is a theorem about the limits of our methods rather than about the problem itself โ a strange and instructive situation. Search "relativization natural proofs algebrization barriers P vs NP".
๐ก Exam angle: give ฮด : Q ร ฮ โ P(Q ร ฮ ร {L,R}) and the acceptance rule โ some path accepts. Draw a computation tree. For the equivalence theorem, describe the three-tape simulation and stress that the search must be breadth-first, explaining why depth-first fails on an infinite branch. State the exponential b^T(n) cost and that power is unchanged. Define P and NP, give the verification characterisation, and warn that NP means non-deterministic polynomial. Reproduce the no/yes/no comparison across the three machine models with reasons, and mention Savitch's theorem giving PSPACE = NPSPACE.
Syllabus points
NDTM and equivalence to DTM
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.