Sunteți pe pagina 1din 65

# Decidable Languages

## Fall 2006 Costas Busch - RPI 1

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

## Fall 2006 Costas Busch - RPI 2

For any string w :

or loops forever

## Fall 2006 Costas Busch - RPI 3

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

## Fall 2006 Costas Busch - RPI 4

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

## Fall 2006 Costas Busch - RPI 5

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

qaccept
qreject

## That result to possible

halting configurations
Fall 2006 Costas Busch - RPI 6
We can convert any Turing machine to
have single accept and reject states

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

x x ,R

## For each tape symbol x

Multiple
One accept state
accept states
Fall 2006 Costas Busch - RPI 7
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
Fall 2006 Costas Busch - RPI 8
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
Fall 2006 Costas Busch - RPI 9
For a Turing-Acceptable language L :

qaccept
Input
string
qreject

## It is possible that for some input string

the machine enters an infinite loop
Fall 2006 Costas Busch - RPI 10
Problem: Is number x prime?

Corresponding language:

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

## Fall 2006 Costas Busch - RPI 11

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

Then reject
Else accept

## Fall 2006 Costas Busch - RPI 12

the decider for the language
solves the corresponding problem

## Decider for PRIMES

qaccept
YES
x
Input number x (Accept)
is prime?
(Input string)
NO
qreject (Reject)

## Fall 2006 Costas Busch - RPI 13

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 )
Fall 2006 Costas Busch - RPI 14
Transform accept state to reject
and vice-versa

M M
qaccept qreject

qa qa

qreject qaccept

qr qr

## Fall 2006 Costas Busch - RPI 15

Turing Machine M
On each input string w do:

## 2. Run M with input string w

If M accepts then reject
If M rejects then accept

## Fall 2006 Costas Busch - RPI END OF PROOF 16

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

## Fall 2006 Costas Busch - RPI 17

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
Fall 2006 Costas Busch - RPI 18
Non Turing-Acceptable L

Turing-Acceptable L

Decidable

## Fall 2006 Costas Busch - RPI 19

A Language which
is not
Turing Acceptable

## Fall 2006 Costas Busch - RPI 20

Consider alphabet {a}

Strings of {a } :

1 2 3 4
a a a a

## Fall 2006 Costas Busch - RPI 21

Consider Turing Machines
that accept languages over alphabet {a}

## They are countable:

M1 , M 2 , M 3 , M 4 ,

## Fall 2006 Costas Busch - RPI 22

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

L( M1), 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
Fall 2006 Costas Busch - RPI 23
Example language accepted by M i

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

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

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
Fall 2006 Costas Busch - RPI 24
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

## Fall 2006 Costas Busch - RPI 25

Consider the language

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

## Fall 2006 Costas Busch - RPI 26

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

L {a , a ,}
3 4
Fall 2006 Costas Busch - RPI 27
Consider the language L

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

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

## Fall 2006 Costas Busch - RPI 28

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

L {a , a ,}
1 2
Fall 2006 Costas Busch - RPI 29
Theorem:
Language L is not Turing-Acceptable

Proof:

L is Turing-Acceptable

## There must exist some machine Mk

that accepts L : L( M k ) L
Fall 2006 Costas Busch - RPI 30
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 M1 ? L( M k ) L
Fall 2006 Costas Busch - RPI 31
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 )
a L ( M1 )
Fall 2006 Costas Busch - RPI 32
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
Fall 2006 Costas Busch - RPI 33
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 )
2
Fall 2006 Costas Busch - RPI
a L( M 2 ) 34
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
Fall 2006 Costas Busch - RPI 35
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 )
3
Fall 2006 Costas Busch - RPI
a L( M 3 ) 36
Similarly: M k Mi for any i
Because either:
a L( M k )
i
a L( M k )
i
or
a L( M i )
i
a L( M i )
i

## the machine M k cannot exist

L is not Turing-Acceptable
End of Proof
Fall 2006 Costas Busch - RPI 37
Non Turing-Acceptable

L
Turing-Acceptable

Decidable

## Fall 2006 Costas Busch - RPI 38

A Language which is
Turing-Acceptable
and Undecidable

## Fall 2006 Costas Busch - RPI 39

We will prove that the language
L {a : a L( M i )}
i i

Is Turing-
Undecidable
Acceptable

## There is a Each machine

Turing machine that accepts L
that accepts L doesnt halt
on some input string
Fall 2006 Costas Busch - RPI 40
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

L {a , a ,}
3 4
Fall 2006 Costas Busch - RPI 41
Theorem: The language

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

Is Turing-Acceptable

accepts L

## Fall 2006 Costas Busch - RPI 42

Turing Machine that accepts L
For any input string w
Compute i , for which wa i

## Find Turing machine Mi

(using the enumerator for Turing Machines)

i
Simulate M i on input a

## If M i accepts, then accept w

End of Proof
Fall 2006 Costas Busch - RPI 43
Observation:

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

Not Turing-acceptable

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

(Thus, L is undecidable)
Fall 2006 Costas Busch - RPI 44
Non Turing-Acceptable
L

Turing-Acceptable
L

Decidable

L?
Fall 2006 Costas Busch - RPI 45
Theorem: L {a : a L( M i )}
i 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!
Fall 2006 Costas Busch - RPI 46
Not Turing-Acceptable
L

Turing-Acceptable
L

Decidable

## Fall 2006 Costas Busch - RPI 47

Turing acceptable languages
and
Enumerators

## Fall 2006 Costas Busch - RPI 48

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

## Fall 2006 Costas Busch - RPI 49

Theorem:
if a language L is decidable then
there is an enumerator for it

Proof:
Let M be the decider for L

## Fall 2006 Costas Busch - RPI 50

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

a
b
Example:
aa
ab
alphabet is {a, b} (proper order)
ba
bb
aaa
aab
......
Fall 2006 Costas Busch - RPI 51
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
Fall 2006 Costas Busch - RPI 52
Enumerator for L
~ M
M Give me
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

## Fall 2006 Costas Busch - RPI 53

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

## Fall 2006 Costas Busch - RPI END OF PROOF 54

Theorem:
if language L is Turing-Acceptable then
there is an enumerator for it

Proof:

## Fall 2006 Costas Busch - RPI 55

Enumerator for L

~ M
M

Enumerates all
Accepts L
strings of input alphabet
in proper order
Fall 2006 Costas Busch - RPI 56
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
Fall 2006 Costas Busch - RPI 57
BETTER APPROACH

M 1

M 2

## M executes first step on w2

second step on w1
Fall 2006 Costas Busch - RPI 58
~ Generates third string w
M 3

## M executes first step on w3

second step on w2
third step on w1

And so on............

## Fall 2006 Costas Busch - RPI 59

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

## Fall 2006 Costas Busch - RPI 60

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

End of Proof
Fall 2006 Costas Busch - RPI 61
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

## Fall 2006 Costas Busch - RPI 63

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
Fall 2006 Costas Busch - RPI 64
By combining the last two theorems,
we have proven:

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