0% found this document useful (0 votes)
9 views

TOC-V

Uploaded by

pvk9398153411
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

TOC-V

Uploaded by

pvk9398153411
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 53

THEORY OF COMPUTATION

Dr.S.Prince Mary M.E.,Ph.D., Associate Professor,


Department of Computer Science and Engineering,
School of Computing

SATHYABAMA
Institute of Science and Technology
Deemed to be University
Chennai.

December 4, 2024 School of Computing 1


UNIT- V
RECURSIVE LANGUAGE
AND
UNDECIDABILITY
Syllabus
• Recursively enumerable and recursive
languages – Properties of Recursively
enumerable and recursive languages -
Enumerating a language. Introduction to
• Undecidability- Halting Problem-
Undecidability of Post correspondence
problem (PCP)-Modified PCP -Rice Theorem.
Recursive Language
• A formal language is recursive if there exists a
Turing machine (a Turing machine that halts for
every given input)
• When given a finite sequence of symbols as
input, accepts it if it belongs to
the language and rejects it otherwise.
• Recursive Languages are also called Turing
decidable languages.
Recursively Enumerable Languages
• A recursively enumerable language is a
formal language for which there exists a
Turing machine (or other computable
function) .
Relation between RL and REL
Theorem1:

• Statement: Every recursive language is Recursively


enumerable.

T( RL) U(REL)
• If T is TM recognizing L(RL) then we can get a TM that
accepts the language L by modifying T so that when the
output is 0 it does not enter the reject state but enters into
an infinite loop.
Theorem 2:

• Statement: Every REL is not recursive.


Theorem 3:

Statement:
The complement of a RL is recursive (or) If L is recursive, so is L ′.

• Let L be a Recursive Language and M be the TM that halts on all inputs and
accepts L.
• Construct M1 for L′.
• M accepts and halts for Yes, then M′ rejects and halts.
• M rejects and halts for N, then M′ accepts and halts.
Theorem 4:

Statements:
i. Union of two recursive languages is recursive.
ii. Union of two recursively enumerable
languages is REL.
iii. Intersection of two recursively enumerable
languages is REL.
i. Union of two recursive languages is recursive.

• Let L1 and L2 be the Recursive languages


accepted by TMs M1 and M2.
• Construct M:
– It first simulates M1, If Yes than M accepts.
– If M1 rejects, then M simulates M2 and accepts if
and only if M2 accepts.
– M accepts L1UL2.
ii ) Union of two Recursively Enumerable
Languages is REL.
• Let L1 and L2 be the Recursive Enumerable
languages accepted by TMs M1 and M2.
• M simultaneously simulates M1 and M2.
• If either accepts, then M accepts .i.e. M accepts
L1UL2.
iii. Intersection of two recursively enumerable languages is REL.

• Let L1 and L2 be the Recursive Enumerable languages


accepted by TMs M1 and M2.
• M halts if both M1 and M2 halts.
• M will never halt if either M1 or M2 enter into infinite
loop.
• (i.e.)M accepts L1∩L2.
Theorem 5:

• Statement: If a Language L and its


complement L′ are both Recursively
Enumerable, then L U L1 is recursive.
Theorem 5:

• Statement: If a Language L and its


complement L′ are both Recursively
Enumerable, then L UL′ is recursive.
– Let M1 and M2 be the TMs accepting L1 and L2
respectively.
– M simultaneously simulates M1 and M2.
– M1 accepts L and M2 accepts L′
• If input to M is in L then M1 accepts and
hence M accepts and halts. If input to M is not
in L then M2 accepts and halts and hence M
halts. Hence M halts on every input and so it is
recursive.
Theorem Statements
1. Every recursive language is Reclusively enumerable.
2. Every REL is not recursive
3. The complement of a RL is recursive (or) If L is
recursive, so is L’.
4. Union of two recursive languages is recursive.
5. Union of two recursively enumerable languages is
REL.
6. Intersection of two recursively enumerable languages
is REL.
7. If a Language L and its complement L’ are both
Recursively Enumerable, then L and hence L’ are
recursive.
Enumerating a Language:

• To enumerate a set means to list out the


elements one at a time.
• A set is enumerable if there exists an algorithm
for enumerating it.
A Turing Machine Enumerating a language:

• Let T be a K tape Turing Machine (K≥1) and L⊊∑*.


• T enumerates L if it operates so that the following
conditions are satisfied.
– The tape head on the first tape never moves to the left
and no non blank symbol printed on tape 1 is
subsequently modified or erased.
– ∀ XϵL, at some point in the operation of T, when tape1
has contents

Where X1,…….Xn,X are distinct elements of L.


Theorem:

• A language L⊊∑* is REL, if and only if L can be


enumerated by some Turing Machine.
• Proof:

• If there is TM for enumerating language then there


should be a Turing Machine for accepting same
Theorem:

• A language L⊊∑* is REL, if and only if L can be


enumerated by some Turing Machine.
• Proof:
– Let T be a TM enumerating L.
– T1 accepting L is constructed as follows:
• T1 has one more tape than T ie. Tape1 is the extra tape-
input tape.
• T1 simulates T, except that every time # is written on tape
1, simulation of T pauses while T1 compares the input
string to the string just before #.
• If the 2 strings match, T1 accepts.
• T1 will accept precisely the strings that are generated on
tape2, which are the elements of L.
To store the Enumerated Values:
• If there is TM for enumerating language then
there should be a Turing Machine for accepting
same language.
• Add one extra tape: T1-output tape
• For all input it should compare with enumerating
tape, if exist then write on the output tape.
• Output tape: abbbb
• Converse:
Suppose T1 accepts L
– Construct a 3-tape TM, T enumerating L
– Tape 1- Output tape :
∑={a,b}* W={ꓥ,a,b,ab,aa,ab,ba,bb,aaa,………}
Undecidability
• A decision problem is a problem that requires
a yes or no answer.
• A problem that cannot be decided by
algorithmic means even after giving an
unlimited resource and infinite amount of
times, is termed as Undecidable.
• A decision problem that admits no algorithmic
solution is said to be undecidable.
Undecidability
• For an undecidable language, there is no Turing
Machine which accepts the language and
makes a decision for every input string w (TM
can make decision for some input string
though).
• Undecidable languages are not recursive
languages, but sometimes, they may be
recursively enumerable languages.
The Post ‘ S Correspondence Problem
( PcP)
• An instance of Post’s correspondence problem (PCP)
is a set {(α1, β1), (α2, β2), . . . , (αn, βn)} of pairs,
where n ≥ 1 and the αi’s and βi’s are all nonnull
strings over an alphabet .

• The decision problem is this: Given an instance of


this type, does there exist a positive integer k and a
sequence of integers i1, i2, ...,ik with each ij
satisfying 1 ≤ ij ≤ n, satisfying
αi1αi2 ...αik = βi1βi2 ...βik
Example 1: PCP
Consider the following domino’s

Solution :
B A ABC
BA AB C

BAABC
BAABC
Order: 1,2,4
Example 2: PCP
Consider the following domino’s
A B
1. 1 111
2. 10111 10
3. 10 0

Solution :
1 1 1 …..

111 111 111 ……

111
11111111
Order: 1,
Example 3: PCP
Consider the following domino’s

Solution :
10 10 10 …

101 101 101 ….

10101101101
101011011011
Order: 1,3
• Example 4:

1 2 3 4 5
• Solution:

1 5 2 3 4 4 3 4
Halting Problem

Halt Never halt May Halt or May not


Halting Problem
• Given a program/algorithm will ever halt or not?
• Halting means that the program on certain input will
accept it and halt or reject it and halt and it would
never go into an infinite loop.
• Basically halting means terminating.
• So can we have an algorithm that will tell that the
given program will halt or not.
• In terms of Turing machine, will it terminate
when run on some machine with some
particular given input string.
– The answer is NO. we cannot design a generalized
algorithm which can appropriately say that given a
program will ever halt or not?
• Halting Problem is an undecidable problem because we
cannot have an algorithm which will tell us whether a
given program will halt or not in a generalized way i.e
by having specific program/algorithm.
Theorem

Statement: Halting Problem is undecidable:


Proof by Contradiction :
• Design a machine which if given a program can
find out if that program will always halt or not
halt on a particular input?
Solution:
Solution:
• Let us assume that we can design that kind of machine
called as HM(P, I) where HM is the machine/program,
P is the program and I is the input.

• On taking input the both arguments the machine HM


will tell that the program P either halts or not.

• If we can design such a program this allows us to write


another program we call this program CM(X) where X
is any program(taken as argument) and according to
the definition of the program CM(X) shown in the
figure.
• In the program CM(X) we call the function
HM(X), which we have already defined and to
HM() we pass the arguments (X, X), according to
the definition of HM() it can take two arguments
i.e one is program and another is the input.
• Now in the second program we pass X as a
program and X as input to the function HM().
• We know that the program HM() gives two
output either “Halt” or “Not Halt”.
• But in case second program, when HM(X, X) will
halt loop body tells to go in loop and when it
doesn’t halt that means loop, it is asked to
return.
• It is impossible for outer function to halt if its
code (inner body) is in loop and also it is
impossible for outer non halting function to
halt even after its inner code is halting.
• So the both condition is non halting for CM
machine/program even we had assumed in the
beginning that it would halt.
• So this is the contradiction and we can say that
our assumption was wrong and this problem,
i.e., halting problem is undecidable.
RICE THEOREM
• Any non-trivial property of the LANGUAGE recognizable
by a Turing machine is undecidable
OR
• For every nontrivial property P of the RE languages, LP
is undecidable.
To Prove Rice Theorem, the following to be clarified:
• Property of a Language
• Problem of Reduction
Properties of Languages
• Any set of languages is a property of
languages.
• Example: The infiniteness property is the set of
infinite languages.
• As always, languages must be defined by some
descriptive device.
• The most general device we know is the TM.
• Thus, a property as a problem about Turing
machines.
– Let LP be the set of binary TM codes for TM’s M
such that L(M) has property P. 39
Trivial and Non-Trivial Properties
• Property of languages, P, is simply a set of
languages.
• If any language belongs to P (L ∈ P), it is said
that L satisfies the property P.
• A property is called to be trivial if either it is not
satisfied by any recursively enumerable
languages, or if it is satisfied by all recursively
enumerable languages.

40
A non-Trivial Property
• A non-trivial property is satisfied by some
recursively enumerable languages and are not
satisfied by others.
• Formally speaking, in a non-trivial property,
where L ∈ P, both the following properties hold:
– Property 1 − There exists Turing Machines, M1 and
M2 that recognize the same language, i.e. either
( <M1>, <M2> ∈ L ) or ( <M1>,<M2> ∉ L )
– Property 2 − There exists Turing Machines M1 and
M2, where M1 recognizes the language while M2
does not, i.e. <M1> ∈ L and <M2> ∉ L
Reductions
• A reduction from language L to language L’ is an
algorithm (TM that always halts) that takes a
string w and converts it to a string x, with the
property that:
x is in L’ if and only if w is in L.
• If we reduce L to L’, and L’ is decidable,
– then the algorithm for L’ + the algorithm of the
reduction shows that L is also decidable.

42
Picture of the Reduction

Accept
iff M
accepts w
M, w M’
A real Hypothetical
reduction algorithm for
algorithm property P Otherwise
halt without
accepting

This would be an algorithm


for Lu, which doesn’t exist

43
Proof of Rice’s Theorem
• Assume: every nontrivial property P of the RE
languages, LP is decidable.
• We show how to reduce Lu to LP.
• Since we know Lu is decidable, it follows that LP
is also decidable.

44
The Reduction
• Our reduction algorithm must take M and w
and produce a TM M’.
• L(M’) has property P if and only if M accepts
w.
• M’ has two tapes, used for:
 Simulates another TM- ML on the input to M’.
 Simulates M on w.
 Note: neither M, ML, nor w is input to M’.

45
The Reduction – (2)
• Assume that  does not have property P.
• Proof
– Let L be any language with property P, and let ML
be a TM that accepts L.

46
Design of M’
1. On the second tape, write w and then
simulate M on w.
2. If M accepts w, then simulate ML on the input
x to M’, which appears initially on the first
tape.
3. M’ accepts its input x if and only if ML accepts
x.

47
Action of M’ if M Accepts w

On accept

Simulate M Simulate ML
x on input w on input x
Accept
iff x is
in ML

48
Design of M’ – (2)
• Suppose M accepts w.
• Then M’ simulates ML and therefore accepts x
if and only if x is in L.
• That is, L(M’) = L, L(M’) has property P, and M’
is in LP.

49
Design of M’ – (3)
• Suppose M does not accept w.
• Then M’ never starts the simulation of ML, and never
accepts its input x.
• Thus, L(M’) = , and L(M’) does not have property P.
• That is, M’ is not in LP.

50
Design of M’ – Conclusion
• Thus, the algorithm that converts M and w to
M’ is a reduction of Lu to LP.
• Thus, LP is undecidable.
• Hence Rice Theorem is proved

51
Applications of Rice’s Theorem
• We now have any number of undecidable
questions about TM’s:
– Is L(M) a regular language?
– Is L(M) a CFL?
– Does L(M) include any palindromes?
– Is L(M) empty?
– Does L(M) contain more than 1000 strings?
– Etc., etc.

52
THANK YOU

You might also like