Decidability & Rice's Theorem: Arjun Suresh For GATE Overflow Helped by Subarna and Sukanya
Decidability & Rice's Theorem: Arjun Suresh For GATE Overflow Helped by Subarna and Sukanya
Decidability & Rice's Theorem: Arjun Suresh For GATE Overflow Helped by Subarna and Sukanya
Theorem
15-January-2019
Arjun Suresh
For GATE Overflow
Helped by Subarna and Sukanya
Decision Problem
A problem where the answer is yes or no.
We can get all the “yes” inputs and make a set - this will be the language of the
problem. Here, L is the set of all even numbers.
Decision Problem
So, can we always decide a problem?
I.e., given an input whether we can always say “yes” or “no” ?
Given an input Turing machine ‘M’ and an input word ‘w’ for it, we cannot always
say “yes” or “no” for whether ‘M’ halts on ‘w’. (Sometimes we can say)
This is equivalent to me giving you an Executable program and its input and
asking whether the program will finish running on the input.
● You can try running the program and say “yes” if it does finish. But what if the
program keeps on running - can you be sure that it will never finish say even
after 100 years?
What causes undecidability?
Our problem is to see if a string belongs to some language.
If we have a DFA or a PDA, we start with a given string and after some finite
moves- we either reach a final ACCEPT state or REJECT state.
It may loop forever and never reaches a FINAL state and this causes
Undecidability
So, what makes Turing machine go to infinite loop?
● Its ability to move left and right of the tape and writing capability
● Since the tape is of infinite length this means Turing machine can produce
infinite configurations
○ If the TM moves only in one direction on the tape, it cannot have infinite configurations.
Because at each step, it can change the tape content - tape alphabet set is finite,
change state - no. of states is finite, and move right. After the string is over, TM
encounters BLANK symbol and then it can change the state but only “No. of states”
times which is finite.
○ But if TM can move left also, then it can keep on changing the contents of the tape -- it
works like changing the input string infinite times (no. of possible inputs are infinite).
Tape contents can go on changing like below for the input string “aaa” and the input
alphabet set {a, b}
Aaa -> baa -> bbaa -> ….
○ Stack in a PDA is of infinite length, but it cannot cause infinite moves -- similar to one
way moving TM
So, now you can imagine that “some inputs” can cause Turing machine to go to
infinite loop and then we won’t get any output.
You can consider a computer as a Turing machine and its memory simulating the
input tape of the Turing machine.
Some Terminology
HALTING Turing machines
● RECURSIVE Set is the set of all Recursive languages - i.e., it is a set of set of
strings.
● TM for Recursive set always halts - either accept or reject. So, the set of
problems described by Recursive languages is called DECIDABLE.
Recursively Enumerable
Language of Turing machine (halting or otherwise) is recursively enumerable and
the set of ALL recursively enumerable languages we call Recursively Enumerable
Set. (denoted by RE from now own)
But for Turing machine this won’t hold as there is also a possibility of looping
forever.
Is x divisible by 2? - this is a property of the set and some elements satisfy it and
some do not.
Is x/2 an element of N?
1. Is “0100” an element of L?
2. Are there more than 100 elements in L?
3. Is there a TM, M such that L is recognized by it?
4. Is there no TM, M such that L is not recognized by it?
Properties 3 and 4 are trivial as 3 is true for any recursively enumerable language
and 4 is FALSE for any recursively enumerable language
The Useful theorem - Rice’s Theorem Part 1
Since we have seen about non-trivial properties on RE, lets see Rice’s theorem
Part 1
Since it is the language of a TM, it is usually given in the form of TM like below:
For other examples, you can see the Lyes and Lno at the end of the presentation.
Undecidable but is it semi-decidable?
● Undecidable - for some inputs we are not able to say “yes”/”no”
● Semi-decidable - for all inputs with answer “yes” we can say “yes”
● Decidable - for all inputs we can answer “yes” or “no”.
● So, some problems can be undecidable but still be semi-decidable
● All decidable problems are semi-decidable too.
● Halting problem is an undecidable problem which is semi-decidable
Why not use Intuition first?
Consider the following problem:
Is this problem decidable? - Yes of course. Just do a DFS and detect presence of
backedge.
Run M on ‘w’. If it halts on ‘w’ after some finite moves it will reach a halt state.
Then we can output “yes”. If it continues running without halting, we won't output
anything. But at least we semi-decided - gave output when the answer is “yes”.
Likewise if we can give a procedure which works for “yes” case, the problem
becomes semi-decidable and its corresponding language becomes recursively
enumerable.
Some examples:
All the below languages are undecidable as per Rice’s theorem part 1. Here, we
check for semi-decidability only
1. L = {<M> | L(M) = {0}} - Our checking if M accepts “0” is not enough. We need to be sure M does not
accept anything else - so no way to semi-decide -right?
2. L = {<M> | L(M) is regular} - Any way to semi-decide this?
3. L = {<M> | L(M) = {}] - We can say “no” is M accepts some string, but can we every say “yes” as we
need to check infinite number of strings?
4. L = {<M> | L(M) contains at least 5 strings} - Give strings one by one to M in some order
(lexicographic would do) and say “yes” if M accepts 5 strings. The thing is we cannot wait for M to
finish running on some input as it may go to infinite loop. So, we will run each input for some steps,
run the next input, go back to previous and run for some more steps and so on (dovetailing). Thus
this is semi-decidable
https://gateoverflow.in/1994/gate2014-2-35
5. L = {<M> | L(M) contains at most 0/no strings} - Same as problem 3
6. L = {<M> | L(M) contains at most 5 strings} - Similar to problem 3
7. L = {<M> | L(M) contains exactly 5 strings} - Similar to problem 3
Rice’s Theorem Part 2
In previous slides we saw some intuitive way to identify if a language is recursively
enumerable (semi-decidable). Rice’s theorem part 2 can help here as a proof:
We can take ANY possible Lyes and Lno to ensure the above property. Exists
and not Forall as in the below Formal condition:
Rice’s Theorem Part 2 - Examples
1. L = {<M> | L(M) is finite} - non-monotonic, not Turing recognizable
2. L = {<M> | L(M) is infinite} - not non-monotonic, so Rice’s 2nd theorem not
applicable - may or may not be recursively enumerable
3. L = {<M> | L(M) is regular} - non-monotonic, not Turing recognizable
4. L = {<M> | L(M) is not regular} - non-monotonic, not recognizable
5. L = {<M> | L(M) = {0} } - non- monotonic, not Turing recognizable
6. L = {<M> | L(M) has at least 100 strings}- not non-monotonic, so Rice’s 2nd
theorem not applicable - may or may not be recursively enumerable
7. L = {<M> | L(M) has at most 100 strings} - non-monotonic, not Turing
recognizable
Rice’s Theorem Part 2 - Examples Contd.
L = {<M> | L(M) is finite}
Lno = Σ*
● Part 1 is 2 way
● Part 2 is 1 way
Properties of TM and not its Language
● Whether a given Turing machine has 10 states? Similar to asking if a given C
code has 10 lines of code - we can just see the TM description and say
yes/no
● Whether a given Turing machine ever makes a LEFT move? - without making
a LEFT move Turing machine cannot go into infinite configurations. So, this is
decidable.
● Whether a given Turing machine enters a particular state? - State entry
problem, undecidable even though it is not a property of RE set.
● Whether a given Turing machine ever outputs a particular symbol? -
undecidable even though not a property of RE set
Some Trivial Properties
Just to be clear adding some trivial properties: (these are trivially decidable)
Lyes = Φ
Lno = Σ*
Lyes = Σ*
Lyes = Σ*
Lyes = Φ
Lno = Σ*
Rice’s Theorem Part 1 - Examples Contd.
L = {<M> | L(M) is recursive}
Lyes = Φ
Lno = {0}
Lno = Φ
Lyes = { ab }
Lno = Σ*
Lyes = {0}
Lno = Σ*
Lyes = Φ
Lno = Σ*