0% found this document useful (0 votes)
7 views65 pages

23 Decidable Undecidable

The document discusses decidable and undecidable languages in the context of Turing machines. It defines decidable languages as those for which a Turing machine halts on every input, while undecidable languages do not have a decider that halts for all inputs. The document also explores the relationship between Turing-acceptable languages and enumerators, concluding that a language is Turing-acceptable if and only if there is an enumerator for it.

Uploaded by

Kshitij Vasule
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)
7 views65 pages

23 Decidable Undecidable

The document discusses decidable and undecidable languages in the context of Turing machines. It defines decidable languages as those for which a Turing machine halts on every input, while undecidable languages do not have a decider that halts for all inputs. The document also explores the relationship between Turing-acceptable languages and enumerators, concluding that a language is Turing-acceptable if and only if there is an enumerator for it.

Uploaded by

Kshitij Vasule
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/ 65

Decidable Languages

Recall that:
A language L is Turing-Acceptable
if there is a Turing machine M
that accepts L

Also known as: Turing-Recognizable


or
Recursively-enumerable
languages
For any string w :

w L M halts in an accept state

w L M halts in a non-accept state


or loops forever
Definition:
A language L is decidable
if there is a Turing machine (decider) M
which accepts L
and halts on every input string

Also known as recursive languages


For any string w :
w L M halts in an accept state

w L M halts in a non-accept state

Every decidable language is Turing-Acceptable


Sometimes, it is convenient to have Turing
machines with single accept and reject states

qaccept
qreject

These are the only halting states

That result to possible


halting configurations
We can convert any Turing machine to
have single accept and reject states

Old machine New machine

x  x ,R qaccept
x  x ,R x  x ,L

x  x ,R

For each tape symbol x


Multiple
One accept state
accept states
Do the following for each possible
halting state:
New machine
Old machine qreject
qi x  x, R
For each
qi For all tape symbols x
not used for read in the
other transitions of qi

Multiple
reject states One reject state
For a decidable language L :

Decision
Decider for L
On Halt:
qaccept
Accept
Input
string
Reject
qreject

For each input string, the computation


halts in the accept or reject state
For a Turing-Acceptable language L :

Turing Machine for L


qaccept
Input
string
qreject

It is possible that for some input string


the machine enters an infinite loop
Problem: Is number x prime?

Corresponding language:

PRIMES  {1, 2, 3, 5, 7, }

We will show it is decidable


Decider for PRIMES :
On input number x :
Divide x with all possible numbers
between 2 and x

If any of them divides x


Then reject
Else accept
the decider for the language
solves the corresponding problem

Decider for PRIMES


qaccept
YES
Input number x (Accept)
is x prime?
(Input string)
NO
qreject (Reject)
Theorem:
If a language L is decidable,
then its complement L is decidable too

Proof:
Build a Turing machine M  that
accepts L and halts on every input string

( M  is decider for L )
Transform accept state to reject
and vice-versa

M M
qaccept qreject

qa qa

qreject qaccept

qr qr
Turing Machine M 
On each input string w do:

1. Let M be the decider for L

2. Run M with input string w


If M accepts then reject
If M rejects then accept

Accepts L and halts on every input string

END OF PROOF
Undecidable Languages

An undecidable language has no decider:


each Turing machine that accepts L
does not halt on some input string

We will show that:


There is a language which is
Turing-Acceptable and undecidable
We will prove that there is a language L:
• L is not Turing-acceptable
(not accepted by any Turing Machine)

• L is Turing-acceptable

the complement of a
decidable language is decidable

Therefore, L is undecidable
Non Turing-Acceptable L

Turing-Acceptable L

Decidable
A Language which
is not
Turing Acceptable
Consider alphabet {a}

Strings of {a } :

a , aa , aaa , aaaa , 

1 2 3 4
a a a a 
Consider Turing Machines
that accept languages over alphabet {a}

They are countable:

M 1, M 2 , M 3 , M 4 , 

(There is an enumerator that generates them)


Each machine accepts some language over {a}
M 1, M 2 , M 3 , M 4 , 

L ( M 1 ), L ( M 2 ), L ( M 3 ), L ( M 4 ), 

Note that it is possible to have


L(M i )  L(M j ) for i j
Since, a language could be accepted by more than one
Turing machine
Example language accepted by M i

L ( M i )  {aa , aaaa , aaaaaa }


2 4 6
L ( M i )  {a , a , a }

Binary representation
1 2 3 4 5 6 7
a a a a a a a 

L(M i ) 0 1 0 1 0 1 0 
Example of binary representations
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 
Consider the language

i i
L  {a : a  L ( M i )}

L consists of the 1’s in the diagonal


1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 

3 4
L  {a , a ,}
Consider the language L

i i
L  {a : a  L ( M i )}

i i
L  {a : a  L ( M i )}

L consists of the 0’s in the diagonal


1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 

1 2
L  {a , a ,}
Theorem:
Language L is not Turing-Acceptable

Proof:

Assume for contradiction that


L is Turing-Acceptable

There must exist some machine M k


that accepts L : L(M k )  L
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 

Question: M k  M 1 ? L(M k )  L
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 
1
a  L(M k )
Answer: M k  M1 1
a  L(M1)
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 

Question: M k  M 2 ? L(M k )  L
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 
2
a  L(M k )
Answer: Mk  M2
2
a  L(M 2 )
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 

Question: M k  M 3 ? L(M k )  L
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 
3
a  L(M k )
Answer: Mk  M3
3
a  L(M 3 )
Similarly: Mk  Mi for any i
Because either:
i i
a  L(M k ) a  L(M k )
or
i i
a  L(M i ) a  L(M i )

the machine M k cannot exist

L is not Turing-Acceptable
End of Proof
Non Turing-Acceptable

L
Turing-Acceptable

Decidable
A Language which is
Turing-Acceptable
and Undecidable
We will prove that the language
i i
L  {a : a  L ( M i )}

Is Turing-
Undecidable
Acceptable

There is a Each machine


Turing machine that accepts L
that accepts L doesn’t halt
on some input string
1 2 3 4
a a a a 

L(M1) 0 1 0 1 

L(M 2 ) 1 0 0 1 

L(M 3 ) 0 1 1 1 

L(M 4 ) 0 0 0 1 

3 4
L  {a , a ,}
Theorem: The language
i i
L  {a : a  L ( M i )}
Is Turing-Acceptable

Proof: We will give a Turing Machine that


accepts L
Turing Machine that accepts L
For any input string w

• Compute i , for which w  a i

• Find Turing machine M i


(using the enumerator for Turing Machines)

i
• Simulate M i on input a

• If M i accepts, then accept w


End of Proof
Observation:

Turing-Acceptable
i i
L  {a : a  L ( M i )}

Not Turing-acceptable
i i
L  {a : a  L ( M i )}

(Thus, L is undecidable)
Non Turing-Acceptable
L

Turing-Acceptable
L

Decidable

L?
i i
Theorem: L  {a : a  L ( M i )}
is undecidable

Proof: If L is decidable
the complement of a
decidable language is decidable

Then L is decidable

However, L is not Turing-Acceptable!


Contradiction!!!!
Not Turing-Acceptable
L

Turing-Acceptable
L

Decidable
Turing acceptable languages
and
Enumerators
We will prove:
(weak result)
• If a language is decidable then
there is an enumerator for it

(strong result)
• A language is Turing-acceptable
if and only if
there is an enumerator for it
Theorem:
if a language L is decidable then
there is an enumerator for it

Proof:
Let M be the decider for L

Use M to build the enumerator for L


~
Let M be an enumerator that prints
all strings from input alphabet in proper order

a
b
aa
Example:
ab
alphabet is {a , b}
ba (proper order)
bb
aaa
aab
......
Enumerator for L
Repeat:
~
1. M generates a string w

2. M checks if w  L
YES: print w to output
NO: ignore w

This part terminates,


because L is decidable
Enumerator for L
~
M Give me M
Enumerates all next string
If M accepts wi output
strings of
then print wi to
input alphabet string wi All strings
output
of L

Generates all Tests each string


Strings in alphabet if it is accepted by M
Example: L  {b, ab , bb , aaa ,....}
~ Enumeration
M M Output
w1 a reject
w2 b accept b
w3 aa reject
ab accept ab
ba reject

bb accept bb
aaa accept aaa
aab reject

END OF PROOF
Theorem:

if language L is Turing-Acceptable then


there is an enumerator for it

Proof:

Let M be the Turing machine that accepts L

Use M to build the enumerator for L


Enumerator for L

~ M
M

Enumerates all
Accepts L
strings of input alphabet
in proper order
NAIVE APPROACH
Enumerator for L
Repeat:
~ generates a string w
M
M checks if w  L
YES: print w to output
NO: ignore w

Problem: If w  L
machine M may loop forever
BETTER APPROACH

~ Generates first string w


M 1

M executes first step on w1

~ Generates second string w


M 2

M executes first step on w2

second step on w1
~ Generates third string
M w3

M executes first step on w3

second step on w2

third step on w1

And so on............
String: w1 w2 w3 w4 

1 1 1 1

Step in
2 2 2 2
computation
of string
3 3 3 3

4 4 4 4
If for any string wi
machine M halts in an accepting state
then print wi on the output

End of Proof
Theorem:
If for language L
there is an enumerator
then L is Turing-Acceptable

Proof:

Using the enumerator for L


we will build a Turing machine
that accepts L
Input Tape
w

Turing Machine that accepts L


w
Enumerator wi Compare
for L Give me the
If same,
next string Accept and Halt
in the
enumeration
sequence
Turing machine that accepts L

For any input string w

Loop:
• Using the enumerator of L ,
generate the next string of L

• Compare generated string with w


If same, accept and exit loop

End of Proof
By combining the last two theorems,
we have proven:

A language is Turing-Acceptable
if and only if
there is an enumerator for it

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy