0% found this document useful (0 votes)
120 views17 pages

Unit 5-Undecidability

Uploaded by

shobanasofficial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views17 pages

Unit 5-Undecidability

Uploaded by

shobanasofficial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

UNIT - 5

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

A language L   * is recursively enumerable if there exist a Turing machine, M that


accepts every string, w Land does not accept strings that are not in L.

If the input string is accepted, M halts with the answer, “YES”.


If the string is not an element of L, then M may not halt and enters into infinite loop.

wєL
YES
M
wL Loops Forever

The language, L is Turing Acceptable.

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
wL NO

w L the Turing machine doesn‟t accept the string.


If w L, then M halts with answer, “NO”. This is also called as Turing Decidable
language.

PROPERTIES OF RECURSIVE AND RE LANGUAGES


1. The union of two recursive language is recursive
2. The language L and its complement L are recursively enumerable, then L is
recursive.
3. The complement of a recursive language is recursive.
4. . The Union of two recursively enumerable languages is recursively enumerable.
5. The intersection of two recursive language is recursive.
6. The intersection of two recursively enumerable language is recursively enumerable

Proofs on the Properties


Property-1
The union of two recursively enumerable languages is recursively enumerable.

Proof:
Let L1 and L2 be two recursively enumerable languages accepted by the Turing
machines M1 and M2.

If a string wL1 then M1 returns “YES”, accepting the input string: Else loops
forever. Similarly if a string w L2 then M2 returns “YES”, else loops forever.

The Turing machine M3 that performs the union of L1 and L2 is given as

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.

Hence the union of two recursively enumerable languages is also recursively


enumerable.
Property – 2
A language is recursive if and only if both it and its complement are recursively
enumerable.

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.

If a string, w L w L , then it is accepted by M2 and M2 halts with answer “YES”.


Otherwise M2 loops forever.
The Turing machine, M3 that simulates M1 and M2 simultaneously is given as

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”.

If w L, then M2 accepts ww L 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”.

M1 rejects w if w Land halts with “NO”


M2 is activated once M1 halts.
M2 works on L and hence if M1 returns “YES”, M2 halts with “NO”.
If M1 returns “NO”, then M2 halts with “YES”

Thus for all w, where w L or w L , M2 halts with either “YES” or “NO”

Hence the complement of a recursive language is also recursive.

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.

Thus the union of two recursive languages is also recursive.

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

M3 LM3   L(M1) L(M2 )

YES
YES
M2
NO

The Turing machine M3 simulates M1 with the input string,w.

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.

The Turing machine, M3 = M1  M2 is given as

w L1 Rejects & Never Halts

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”.

If at least one of M1or M2 is NO it rejects „w‟ and never halts.

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.

THE HALTING PROBLEM


 The halting problem is the problem of finding if the program/machine halts or loop
forever.
 The halting problem is un-decidable over Turing machines.
Description
 Consider the Turing machine, M and a given string , the problem is to determine
whether M halts by either accepting or rejecting , or run forever.
 Example
while (1)
{
prinf(“Halting problem”);
}
 The above code goes to an infinite loop since the argument of while loop is true
forever.
 Thus it doesn‟t halts.
 Hence Turing problem is the example for undecidability.
 This concept of solving the halting problem being proved as undecidable was done
by Turing in 1936.
 The undecidability can be proved by reduction technique.

Representation of the halting set


The halting set is represented as,
1 if M halts on input 
h(M, )  
0 otherwise
where,
M  Turing machine
  Input string

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

H2 is constructed with both the inputs being M.


H2 determines M and halts if M halts otherwise loops forever.

Construction of H3

M HALT LOOP
H2 H3
LOOP HALT

Let H3 be constructed from the outputs of H2.

If the outputs of H2 are HALT, then H3 loops forever.

Else, if the output of H2 is loop forever, then H3 halts.

Thus H3 acts contractor to that of H2.

H3
H3

 Let the output of H3 be given as input to itself.


 If the input is loop forever, then H3 acts contradictory to it, hence halts.
 And if the input is halt, then H3 loops by the construction.
 Since the result is incorrect in both the cases, H3 doesnot exist.
 Thus H2 doesnot exist because of H3.
 Similarly H1 doesnot exist, because of H2.
Thus halting problem is undecidable.
PARTIAL SOLVABILITY
Problem types
There are basically three types of problems namely
 Decidable / solvable / recursive
 Undecidable / unsolvable
 Semi decidable / partial solvable / recursively enumerable

Decidable / solvable problems


A problem, P is said to be decidable if there exists a turing machine, TM that
decides P.
Thus P is said to be recursive.
Consider a Turing machine, M that halts with either „yes‟ or „no‟ after computing the
input.
YES (if  L)
 ∑* M
NO (if  L)

The machine finally terminates after processing


It is given by the function,
1 if p()
F () 
p
0 if p()
The machine that applies Fp() is said to be turing computable.

Undecidable problem
A problem, P is said to be undecidable if there is a Turing machine, TM that doesn‟t
decides P.

Semi decidable / partial solvable / recursively enumerable


A problem, P is said to be semi decidable, if P is recursively enumerate.
A problem is RE if M terminates with „YES‟ if it accepts   L; and doesn‟t halt if 
 L.
Then the problem is said to be partial solvable / Turing acceptable.
YES (if  L)
 ∑* M
LOOP FOREVER (if   L)
Partial solvability of a machine is defined as,
1 if p()
F () 
p
undefined if  p()
Enumerating a language
Consider a k-tape turing machine. Then the machine M enumerates the language L
(such that L  ∑*) if

 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)

Where 1, 2 , 3, ..... , n ,  are distinct elements on L.

If L is finite, then nothing is printed after the # of the left symbol


That is,

 If L is a finite language then the TM, M either


o Halts normally after all the elements appear on the first tape (elements are
processed)
or
o Continue to process and make moves and state changes without
scanning/printing other string on the first tape.
If the language, L is finite, the Turing machine runs forever.

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)].

M2 simulates M1 and M1 pauses whenever M2 scans the „#‟ symbol.


M2 compares its input symbols to that of the symbols before „#‟ while, M1 is in pause.

If the comparison finds a match of the string, M2 accepts L.

Here M2 is a semi acceptor TM for L


 Scans the input string, 
 Runs the transition rules of M1
 If M1 outputs , then  is accepted and M1 hats

If   L, M1 will output  and M2 will eventually accept „‟ and halts.

If   L, then M1 will never provide an output  and so M2 will never halt.

HALTS HALTS
 ∑* M1 M2
(L) ( L)

LOOP FOREVER LOOP FOREVER


 ∑* M1 M2
( L) ( L)
Never halts
Infinite loop

Thus M2 is partially solvable / Turing acceptable for L.

POST CORRESPONDENCE PROBLEM (PCP)


Post correspondence problem, known as PCP is an unsolvable combinatorial problem.
This Undecidable problem was formulated by Emil Post in 1946.

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

Thus A2A1A1A3 = B2B1B1B3 = aba3a3b = aba6b


The PCP given has a solution (2,1,1,3) with the two lists of elements.

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

Thus the PCP has (2, 1, 1, 3) sequences as solution

The Diagonalization Language Ld


We define Ld, the diagonalization language, as follows:
Let w1, w2, w3, . . . be an enumeration of all binary strings.
Let M1, M2, M3, . . . be an enumeration of all Turing machines.

Let Ld = { Wi | Mi does not accept Wi }.

The language Ld, the diagonalization language, is the set of strings Wi


such that Wi is not in L(Mi). That is, Ld consists of all strings w such
that the TM (M ) does not accept when given w as input.
Theorem: Ld is not a recursively enumerable language.
Proof:
Suppose Ld = L(Mi) for some TM Mi.
This gives rise to a contradiction. Consider what Mi will do on an
input string wi.
If Mi accepts wi, then by definition wi cannot be in Ld.
If Mi does not accepts wi, then by definition wi is in Ld.
we must conclude there is no Turing machine that can define Ld.
Hence Ld is not a recursively enumerable language.

UNIVERSAL TURING MACHINE


Motive of UTM
A single Turing machine has a capability of performing a function such as addition,
multiplication etc.

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.

The instructions and inputs are stored on one or more tapes.

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

Input <T, w>

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)

For example, if the input data, w=”baa”, then


e(w) = 10001001001
This e(w) will be appended to e(T) of Tu.

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).

Tape-2  Tape of the TM/Working tape during the simulation of TM

Tape -3  State of the TM, current state of the T in encoded form.

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.

o If the input is not accepted, UTM halts with rejecting, w


 Initialize the second tape to have e(w), that is to have the input, w in encoded form.
Place the code of the initial state on the third tape and move the head of the finite
state control on the first cell of second tape.
 To simulate a move of the Turing machine, UTM searches for the transition -
oi 1oj 1ok 1ol 1om on the first tape, with oi (initial state/current state) on tape -3 and
o j (input symbol to be processed) on tape- 2.
 The state transition is done by changing the tape -3 content as ok as in the
transition.
 Replace o j by ol on tape-2 to indicate the input change.
 Depending on om [m=1 stop, m=2 Left, m=3 Right], move the head on
tape-2 to the position of the next 1 to the left/right/stop accordingly
 If TM has no transition, matching the simulated state and tape symbol, then no
transition will be found. This happens when the TM stops also.
 If the TM, T enters halt (accepting state), then UTM accepts the input, w
Thus for every coded pair <T, w>, UTM simulates T on w, if and only if T accepts the
input string, w.
Thus U TM simulates M and accepts W.Thus Lu is recursively enumerable

Definition of Universal Language [Lu]


The universal language, Lu is the set of all binary strings , where  represents the
ordered pair <T, w> where
T Turing machine
w any input string accepted by T
It can also be represented as  = e(T) e(w) .
Theorem

Lu is the recursively enumerable but not recursive .

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.

Hence Lu is not Turing decidable by proof by contradiction.

Proof on Lu is during acceptable  Ld is Turing acceptable

Hypothetical Accept Accept


w Copy w111w algorithm
T for Lu Reject Reject
T for Ld

Suppose “A” is the algorithm that recognizes Lu .

Then Ld is recognizes as follows. Given a string w(0,1)* determined easily, the


value of I such that w = wi.

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.

So the algorithm accepts w if and only if w = wi which is in L(Ti).

This is the algorithm for Ld. Hence Lu is Recursively Enumerable but not recursive.

TRACTABLE AND INTERACTABLE PROBLEMS


Tractable Problems/Languages
The languages that can be recognized by a Turing machine in finite time and with
reasonable space constraint is said to be tractable.
Example: If the language L1 Time (f), then L is tractable and is less complex in
nature

Example: If L2  Time (f), L2 is complex and cannot be tractable in limited time.

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

A problem is NP-complete if the problem is both

 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

You might also like