Unit 5-Undecidability
Unit 5-Undecidability
UNDECIDABILITY
Non Recursive Enumerable (RE) Language – Undecidable Problem with RE –
Undecidable Problems about TM – Post‘s Correspondence Problem, The Class P
and NP
RECURSIVE AND RECURSIVELY ENUMERABLE LANGUAGES
Recursively Enumerable Language
wєL
YES
M
wL Loops Forever
Recursive Language
A language is said to be recursive if there exists of Turing machine, M that accepts
every string, w L and rejects those strings that are not in L.
If the input is accepted, M halts with the answer,” YES”
wєL
YES
M
wL NO
Proof:
Let L1 and L2 be two recursively enumerable languages accepted by the Turing
machines M1 and M2.
If a string wL1 then M1 returns “YES”, accepting the input string: Else loops
forever. Similarly if a string w L2 then M2 returns “YES”, else loops forever.
RE
YES
M1
YES
wєΣ* M3
RE
M2 YES
RE
Here the output of M1 and M2 are written on the input tape of M3. The turning
machine, M3 returns “YES”, if at least one of the outputs of M1 and M2 is “YES”. The M3
decides on L1UL2 that halts with the answer, “YES” if w L1 or w L2 . Else M3 loops
forever if both M1 and M2 loop forever.
Proof
Let L and L be two recursively enumerable languages accepted by the Turing
machines M1 and M2. If a string, w L, it is accepted by M1 and M1 halts with answer
“YES”. Else M1 enters into infinite loop.
w L1 YES
M1
wєΣ* YES
M3
M2
w L YES
From the above design of TM, if w L, if w L, then M1 accepts w and halts with
“YES”.
Since M1 and M2 are accepting the complements of each other, one of them is
guaranteed to halt for every input, wєΣ*.
Hence M3 is a Turing machine that halts for all strings.
Thus if the language and its complement are recursively enumerable, then they are
recursive.
Property - 3
The complement of a recursive language is recursive.
Proof
Let L be a recursive language accepted by the turning machine, M 1.
Let L be a recursive language accepted by the Turing machine M2.
The construction of M1 and M2 are given as,
L
w L YES NO
M1 M2
w L NO YES
R R
Let w L, then M1 accepts w and halts with “YES”.
Property – 4
The union of two recursive language is recursive.
Proof:-
Let L1 and L2 be two recursive languages that are accepted by the Turing machines M1
and M2, given by
L(M1) = L1
L(M2) = L2
Let M3 be the Turing machine constructed by the union of M1 and M2. M3 is
constructed as follows.
YES
YE
M1 NO
wєΣ*
M3
YES
M2 NO
NO
The Turing machine M3 first simulates M1 with the input string, w.
If w L1 , then M1 accepts and thus M3 also accepts since L(M3) = L(M1) u L(M2).
If M1 rejects string w
L1 , then M3 simulates M2. M3 halts with “YES” if M2
accepts „w‟, else returns “NO”.
Hence M3, M2, M1 halt with either YES or NO on all possible inputs.
Property – 5
The intersection of two recursive language is recursive.
Proof:-
Let L1 and L2 be two recursive languages accepted by M1 and M2 where
L(M1) = L1
L(M2) = L2
Let M3 be the Turing machine that is constructed by the intersection of M1 and M2, M3
is constructed as follows.
NO
NO
wєΣ*
M1
YES
YES
YES
M2
NO
If w L1 , then M1 halts along with M3 with answer “NO”, since L(M3)=L(M1)
L(M2). If then M1 accepts with the answer “YES” and M3 simulates M2.
If M2 accepts the string, then the answer of M2 and M3 are “YES” and halts. Else, M2
and M3 halts with answer “NO”.
Thus, the intersection of two recursive languages is recursive.
Property – 6
Intersection of two recursively enumerable languages is recursively enumerable.
Proof:-
Let L1 and L2 be two recursively enumerable languages accepted by the Turing
machine M1 and M2.
If a string w L1 then M1 returns “YES” accepting the input. Else will not halt after
rejecting w L1 .
Similarly if a string, w L2 , then M2 returns “YES” else rejects „w‟ and loop forever.
M1
wЄ∑* YES
YES
M3
YES Loop Forever
M2
Rejects & Never Halts
w L2
Here the output of M1 and M2 are written the input tape of M3. The machine, M3
returns “YES” if both the outputs of M1 and M2 is “YES”.
Thus M3 decides on L1 L2 that halts if and only if w L1 and w L2 . Else M3
loops forever along with M1 or M2 or both
Hence the intersection of two recursively enumerable languages is recursively
enumerable.
Theorem
Halting problem of Turing machine is unsolvable / undecidable.
Proof
The theorem is proved by the method of proof by contradiction.
Let us assume that Turing machine is solvable / decidable.
Construction of H1
M Halting HALT
machine H1 LOOP FOREVER
Consider, a string describing M and input string, for M.
Let H1 generates “halt” if H1 determines that the turing machine, M stops after
accepting the input, .
Otherwise H1 loops forever when, M doesn‟t stops on processing .
Construction of H2
M Halting HALT
machine H2 LOOP
Construction of H3
M HALT LOOP
H2 H3
LOOP HALT
H3
H3
Undecidable problem
A problem, P is said to be undecidable if there is a Turing machine, TM that doesn‟t
decides P.
The tape head never moves to the left on the first tape.
No blank symbol (B) on the first tape is erased or modified.
For all L, where there exists a transition rule, i on tape 1 with contents
1 # 2 # 3 # ... # n # # (for n 0)
Theorem
A language L ∑* is recursively enumerable if and only if L can be enumerated by
some TM.
Proof
Let M1 be a Turing machine that enumerates L.
And let M2 accepts L. M2 can be constructed as a k-tape Turing machine [k(M2) >
k(M1)].
HALTS HALTS
∑* M1 M2
(L) ( L)
A PCP consists of two lists of string over some alphabet Σ; the two lists must be of equal length.
Generally A=w1,w2, w3, …….wk and B= x1, x2 ,x3, ……xk for some integer k. For each i , the
pair (wi , xi ) is said to be a corresponding pair.
We say this instances of PCP has a solution, if there is a sequence of one or more integers
i1, i2,……., im that, when interpreted as indexes for strings in the A and B lists, yield the same
string.
wi1 wi2 ……. wim = xi1 xi2 ……. xim . We say the sequence i1, i2,……., im is a solution to this
instance of PCP
EXAMPLE
1. For Σ = {a, b} with A = {a, aba3, ab} and B = {a3, ab, b}, Does the PCP with A and B
have a solution?
Solution:
The sequence obtained from A and B = (2, 1, 1, 3) as,
A2 A1 A1 A3
aba3 a a ab
B2 B1 B1 B3
ab a3 a3 b
2. Let Σ = {0, 1}. Let A and B be the lists of three strings defined as
A B
I wi xi
1 1 111
2 10111 10
3 10 0
Solution:
Consider the sequence (2, 1, 1, 3)
A2A1A1A3 => w2w1w1w3 = 101111110
B2B1B1B3 => X2X1X1X3 = 101111110
For computing another function, other appropriate Turing machine is used. To do so, the
machine has to be re-written accordingly.
Hence Turing proposed “Stored Program Computer” concept in 1936 that executes the
program/instructions using the inputs, stored in the memory.
Concept of UTM
The universal Turing machine, Tu takes over the program and the input set to process
the program.
The program and the inputs are encoded and stored on different tapes of a multi-tapeTuring machine.
The Tu thus takes up T, w where T is the special purpose Turing machine that passesthe
program in the form of binary string, w is the data set that is to be processed by T.
Finite
control
Tape of M 0001010000101….
State of M 0000…0BB…
Input to the Tu
The universal Turing machine, Tu is always provided with the code for Transitions,
e(T) and code for input, e(w) as
TM e(T)e(w)
Construction of Tu
As in the figure for universal Turing machine, there are three tapes controlled by a
finite control component through heads for each tape.
Tape -1 Input tape and also serves as output tape. It contain e(T) e(w).
Operation of UTM
Theorm :(Lu is Recursively enumerable )
(To prove this Theorem it is necessary to construct a turning machine that accepts
Lu)
UTM checks the input to verify whether the code for TM=<T,w> is a legitimate
for some TM.
Proof
From the definition and operations of UTM, we know that Lu is recursively
enumerable.
Lu accepts the string w if it is processed by the TM,T. Else, rejects „w‟ and the
machine doesn‟t halts forever.
To prove that Lu is not recursive, the proof can be done by contradiction. Let Lu is
Turing decidable [recursive], and then by definitionacceptable.
Lu (complement of Lu) is Turing
We can show that Lu is Turing acceptable, that leads to Ld to be Turing acceptable.
But we know that Ld is not Turing acceptable.
Integer value, I in binary is the corresponding code for TM, T i. Provide <Ti, wi> to the
algorithm A and accept, w if and only if Ti accepts wi.
This is the algorithm for Ld. Hence Lu is Recursively Enumerable but not recursive.
Tractable problems are those that can be solved in polynomial time period.
Intractable Problems
The languages that cannot be recognized by any Turing machine with reasonable space
and time constraint is called intractable problems.
These problems cannot be solved in finite polynomial time. Even problems with
moderate input size cannot achieve feasible solution
P AND NP PROBLEMS
These refer to how long it takes a program to run. Problems in class P can be solved with
algorithms that run in polynomial time.
An algorithm that finds the smallest integer in an array. One way to do this is by iterating over all
the integers of the array and keeping track of the smallest number you've seen up to that
point. Every time you look at an element, you compare it to the current minimum, and if it's
smaller, you update the minimum.
How long does this take? Let's say there are n elements in the array. For every element the
algorithm has to perform a constant number of operations. Therefore we can say that the
algorithm runs in O(n) time, or that the runtime is a linear function of how many elements are in
the array. So this algorithm runs in linear time.
You can also have algorithms that run in quadratic time (O(n^2)), exponential time (O(2^n)), or
even logarithmic time (O(log n)). Binary search (on a balanced tree) runs in logarithmic time
because the height of the binary search tree is a logarithmic function of the number of elements in
the tree.
If the running time is some polynomial function of the size of the input, for instance if the
algorithm runs in linear time or quadratic time or cubic time, then we say the algorithm runs in
polynomial time and the problem it solves is in class P.
NP
There are a lot of programs that don't (necessarily) run in polynomial time on a regular computer,
but do run in polynomial time on a nondeterministic Turing machine. These programs solve
problems in NP, which stands for nondeterministic polynomial time. A nondeterministic Turing
machine can do everything a regular computer can and more. This means all problems in P are also
in NP.
An equivalent way to define NP is by pointing to the problems that can be verified in polynomial
time. This means there is not necessarily a polynomial-time way to find a solution, but once you
have a solution it only takes polynomial time to verify that it is correct.
P = NP, which means any problem that can be verified in polynomial time can also be solved in
polynomial time and vice versa. If they could prove this, it would revolutionize computer science
because people would be able to construct faster algorithms for a lot of important problems.
NP-hard
Solve a problem by reducing it to a different problem. Reduce Problem B to Problem A if, given
a solution to Problem A, It can easily construct a solution to Problem B. (In this case, "easily"
means "in polynomial time.")
If a problem is NP-hard, this means , reduce any problem in NP to that problem. It can solve
that problem, I can easily solve any problem in NP. If we could solve an NP-hard problem in
polynomial time, this would prove P = NP.
NP-complete
NP-hard, and
in NP.
A technical point: O(n) actually means the algorithm runs in asymptotically linear time, which
means the time complexity approaches a line as n gets very large. Also, O(n) is technically an
upper bound, so if the algorithm ran in sublinear time you could still say it's O(n), even if that's
not the best description of it.
** Note that if the input has many different parameters, like n and k, it might be polynomial in n
and exponential in k