You are on page 1of 89

Reductions

Fall 2006 Costas Busch - RPI 1


Problem X is reduced to problem Y

If we can solve problem Y


then we can solve problem X

Fall 2006 Costas Busch - RPI 2


Definition: A B
Language A w f (w )
is reduced to
language B

There is a computable
function f (reduction) such that:

w  A  f (w )  B

Fall 2006 Costas Busch - RPI 3


Recall:

Computable function f :
There is a deterministic Turing machine M
which for any string w computes f (w)

Fall 2006 Costas Busch - RPI 4


Theorem:
If: a: Language A is reduced to B
b: Language B is decidable
Then: A is decidable

Proof:
Basic idea:
Build the decider for A
using the decider for B

Fall 2006 Costas Busch - RPI 5


Decider for A
Reduction YES
Input accept YES
accept
string compute f (w ) Decider (halt) (halt)
w
f (w ) for B NO
reject NO
reject
(halt)
(halt)

w  A  f (w )  B

END OF PROOF
Fall 2006 Costas Busch - RPI 6
Example:

EQUALDFA  { M1 , M2 : M1 and M2 are DFAs


that accept the same languages }

is reduced to:

EMPTYDFA  { M : M is a DFA that accepts


the empty language  }

Fall 2006 Costas Busch - RPI 7


We only need to construct:

Turing Machine
M1 , M2 for reduction f f  M1 , M2 
 M DFA

M1 , M2  EQUALDFA  M  EMPTYDFA

Fall 2006 Costas Busch - RPI 8


Let L1 be the language of DFA M1
Let L2 be the language of DFA M2

Turing Machine
M1 , M2 for reduction f f  M1 , M2 
 M DFA

construct DFA M
by combining M1 and M2 so that:

L(M )  (L1  L2 )  (L1  L2 )


Fall 2006 Costas Busch - RPI 9
L(M )  (L1  L2 )  (L1  L2 )

L1  L2  L(M )  

M1 , M2  EQUALDFA  M  EMPTYDFA

Fall 2006 Costas Busch - RPI 10


Decider for EQUALDFA
Input Reduction
YES
string compute YES
M Decider
M1 , M2 f  M1 , M2  EMPTYDFA
NO
NO

Fall 2006 Costas Busch - RPI 11


Theorem (version 1):
If: a: Language A is reduced to B
b: Language A is undecidable
Then: B is undecidable
(this is the negation of the previous theorem)

Proof: Suppose B is decidable


Using the decider for B
build the decider for A
Contradiction!
Fall 2006 Costas Busch - RPI 12
If B is decidable then we can build:
Decider for A
Reduction YES
Input accept YES
accept
string compute f (w ) Decider (halt) (halt)
w
f (w ) for B NO
reject NO
reject
(halt)
(halt)

w  A  f (w )  B
CONTRADICTION!
END OF PROOF
Fall 2006 Costas Busch - RPI 13
Observation:

In order to prove
that some language B is undecidable
we only need to reduce a
known undecidable language A
to B

Fall 2006 Costas Busch - RPI 14


State-entry problem
Input: •Turing Machine M
•State q
•String w
Question: Does M enter state q
while processing input string w?
Corresponding language:
STATETM  { M ,w , q : M is a Turing machine that
enters state q on input string w }
Fall 2006 Costas Busch - RPI 15
Theorem: STATETM is undecidable
(state-entry problem is unsolvable)

Proof: Reduce
HALTTM (halting problem)
to
STATETM (state-entry problem)

Fall 2006 Costas Busch - RPI 16


Halting Problem Decider
Decider for HALTTM
state-entry problem
Reduction decider
YES YES
Compute Mˆ, q ,w Decider
M ,w
f  M ,w  STATETM
NO NO

Given the reduction, A contradiction!


if STATETM is decidable, since HALTTM
then HALTTM is decidable is undecidable
Fall 2006 Costas Busch - RPI 17
We only need to build the reduction:

Reduction
Compute
M ,w Mˆ, q ,w
f  M ,w 
 f  M ,w 

So that:

M ,w  HALTTM Mˆ,w , q  STATETM

Fall 2006 Costas Busch - RPI 18


Construct M̂ from M :

special
M halt state
halting q
states qi
x  x ,R

A transition for every unused


tape symbol x of qi

Fall 2006 Costas Busch - RPI 19



special
M halt state
halting q
states qi

M halts M̂ halts on state q

Fall 2006 Costas Busch - RPI 20


Therefore: M halts on input w

M̂ halts on state q on input w

Equivalently:

M ,w  HALTTM Mˆ,w , q  STATETM

END OF PROOF
Fall 2006 Costas Busch - RPI 21
Blank-tape halting problem

Input: Turing Machine M


Question: Does M halt when started with
a blank tape?

Corresponding language:
BLANKTM  { M : M is aTuring machine that
halts when started on blank tape}
Fall 2006 Costas Busch - RPI 22
Theorem: BLANKTM is undecidable

(blank-tape halting problem is unsolvable)

Proof: Reduce
HALTTM (halting problem)
to
BLANKTM (blank-tape problem)

Fall 2006 Costas Busch - RPI 23


Halting Problem Decider
Decider for HALTTM
blank-tape problem
Reduction decider
YES YES
Compute M̂ Decider
M ,w
f  M ,w  BLANKTM NO NO

Given the reduction, A contradiction!


If BLANKTM is decidable, since HALTTM
then HALTTM is decidable is undecidable
Fall 2006 Costas Busch - RPI 24
We only need to build the reduction:

Reduction
Compute
M ,w M̂
f  M ,w 
 f  M ,w 

So that:

M ,w  HALTTM Mˆ  BLANKTM

Fall 2006 Costas Busch - RPI 25


Construct M̂ from M ,w :

no
Tape is blank?

yes
Run M
Write w on tape
with input w

If M halts then halt

Fall 2006 Costas Busch - RPI 26


no
Tape is blank?

yes
Run M
Write w on tape
with input w

M halts on input w

M̂ halts when started on blank tape


Fall 2006 Costas Busch - RPI 27
M halts on input w

M̂ halts when started on blank tape

Equivalently:

M ,w  HALTTM Mˆ  BLANKTM

END OF PROOF
Fall 2006 Costas Busch - RPI 28
Theorem (version 2):
If: a: Language A is reduced to B
b: Language A is undecidable
Then: B is undecidable

Proof: Suppose B is decidable


Then B is decidable
Using the decider for B
build the decider for A

Contradiction!
Fall 2006 Costas Busch - RPI 29
Suppose B is decidable

reject
Decider (halt)
s
for B
accept
(halt)

Fall 2006 Costas Busch - RPI 30


Suppose B is decidable
Then B is decidable
(we have proven this in previous class)

Decider for B
NO YES
reject accept
(halt)
Decider (halt)
s
for B YES NO
accept reject
(halt)
(halt)

Fall 2006 Costas Busch - RPI 31


If B is decidable then we can build:
Decider for A
Reduction YES
Input accept YES
accept
string compute f (w ) Decider (halt) (halt)
w
f (w ) for B NO NO
reject reject
(halt)
(halt)

w  A  f (w )  B
CONTRADICTION!
Fall 2006 Costas Busch - RPI 32
Alternatively:

Decider for A
Reduction NO
Input reject YES
accept
string compute f (w ) Decider (halt) (halt)
w
f (w ) for B YES NO
accept reject
(halt)
(halt)

w  A  f (w )  B
CONTRADICTION!
END OF PROOF
Fall 2006 Costas Busch - RPI 33
Observation:

In order to prove
that some language B is undecidable
we only need to reduce some
known undecidable language A
to B (theorem version 1)
or to B (theorem version 2)

Fall 2006 Costas Busch - RPI 34


Undecidable Problems for
Turing Recognizable languages
Let L be a Turing-acceptable language

• L is empty?

• L is regular?

• L has size 2?

All these are undecidable problems


Fall 2006 Costas Busch - RPI 35
Let L be a Turing-acceptable language

• L is empty?

• L is regular?

• L has size 2?

Fall 2006 Costas Busch - RPI 36


Empty language problem
Input: Turing Machine M
Question: Is L(M ) empty? L(M )   ?

Corresponding language:
EMPTYTM  { M : M is aTuring machine that
accepts the empty language  }
Fall 2006 Costas Busch - RPI 37
Theorem: EMPTYTM is undecidable
(empty-language problem is unsolvable)

Proof: Reduce
ATM (membership problem)
to
EMPTYTM (empty language problem)

Fall 2006 Costas Busch - RPI 38


membership problem decider
Decider for ATM
empty problem
Reduction decider
YES YES
Compute M̂ Decider
M ,w
f  M ,w  EMPTYTM NO NO

Given the reduction, A contradiction!


if EMPTYTM is decidable, since ATM
then ATM is decidable is undecidable
Fall 2006 Costas Busch - RPI 39
We only need to build the reduction:

Reduction
Compute
M ,w M̂
f  M ,w 
 f  M ,w 
So that:

M ,w  ATTM Mˆ  EMPTYTM

Fall 2006 Costas Busch - RPI 40


Construct M̂ from M ,w :
Tape of M̂
s
input string

skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 41


Tape of M̂
s

skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 42


Tape of M̂
s w

skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 43


During this phase this area is not touched

s w
working area of M

skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 44


Simply check if M entered an accept state

s altered w

skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 45


Now check input string
s

skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 46


The only possible accepted string
troy


skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 47


M accepts w L(Mˆ)  {troy }  
does not
M w L(Mˆ)  
accept


skip input write w run M
string s on tape on input w

If s  troy yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 48


Therefore:

M accepts w L(Mˆ)  

Equivalently:

M ,w  ATTM Mˆ  EMPTYTM

END OF PROOF
Fall 2006 Costas Busch - RPI 49
Let L be a Turing-acceptable language

• L is empty?

• L is regular?

• L has size 2?

Fall 2006 Costas Busch - RPI 50


Regular language problem
Input: Turing Machine M
Question: Is L(M ) a regular language?

Corresponding language:
REGULARTM  { M : M is aTuring machine that
accepts a regular language}
Fall 2006 Costas Busch - RPI 51
Theorem: REGULARTM is undecidable

(regular language problem is unsolvable)

Proof: Reduce
ATM (membership problem)
to
REGULARTM (regular language problem)

Fall 2006 Costas Busch - RPI 52


membership problem decider
Decider for ATM
regular problem
Reduction decider
YES YES
Compute M̂ Decider
M ,w
f  M ,w  REGULARTM NO NO

Given the reduction, A contradiction!


If REGULARTM is decidable, since ATM
then ATM is decidable is undecidable
Fall 2006 Costas Busch - RPI 53
We only need to build the reduction:

Reduction
Compute
M ,w M̂
f  M ,w 
 f  M ,w 
So that:

M ,w  ATTM Mˆ  REGULARTM

Fall 2006 Costas Busch - RPI 54


Construct M̂ from M ,w :
Tape of M̂
s
input string

skip input write w run M
string s on tape on input w

If s has the form


n
a b n
yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 55


not regular
M accepts w ˆ n n
L(M )  {a b : n  0 }

does not
M w L(Mˆ)   regular
accept

skip input write w run M
string s on tape on input w

If s has the form


n
a b n
yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 56


Therefore:

M accepts w L(Mˆ) is not regular

Equivalently:

M ,w  ATTM Mˆ  REGULARTM

END OF PROOF
Fall 2006 Costas Busch - RPI 57
Let L be a Turing-acceptable language

• L is empty?

• L is regular?

• L has size 2?

Fall 2006 Costas Busch - RPI 58


Size2 language problem
Input: Turing Machine M
Question: Does L(M ) have size 2? | L(M ) | 2 ?
(accepts exactly two strings?)

Corresponding language:
SIZE 2TM  { M : M is aTuring machine that
accepts exactly two strings}
Fall 2006 Costas Busch - RPI 59
Theorem: SIZE 2TM is undecidable
(regular language problem is unsolvable)

Proof: Reduce
ATM (membership problem)
to
SIZE 2TM (size 2 language problem)

Fall 2006 Costas Busch - RPI 60


membership problem decider
Decider for ATM
size2 problem
Reduction decider
YES YES
Compute M̂ Decider
M ,w
f  M ,w  SIZE 2TM NO NO

Given the reduction, A contradiction!


If SIZE 2TM is decidable, since ATM
then ATM is decidable is undecidable
Fall 2006 Costas Busch - RPI 61
We only need to build the reduction:

Reduction
Compute
M ,w M̂
f  M ,w 
 f  M ,w 
So that:

M ,w  ATTM Mˆ  SIZE 2TM

Fall 2006 Costas Busch - RPI 62


Construct M̂ from M ,w :
Tape of M̂
s
input string

skip input write w run M
string s on tape on input w

If s  {troy , albany } yes


M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 63


2 strings
M accepts w L(Mˆ)  {troy , albany }

does not
M w L(Mˆ)   0 strings
accept

skip input write w run M
string s on tape on input w

If s  {troy , albany } yes


M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 64


Therefore:

M accepts w L(Mˆ) has size 2

Equivalently:

M ,w  ATTM Mˆ  SIZE 2TM

END OF PROOF
Fall 2006 Costas Busch - RPI 65
RICE’s Theorem

Undecidable problems:

• L is empty?

• L is regular?

• L has size 2?

This can be generalized to all non-trivial


properties of Turing-acceptable languages

Fall 2006 Costas Busch - RPI 66


Non-trivial property:
A property P possessed by some
Turing-acceptable languages
but not all

Example: P1 : L is empty?
YES L  
NO L  {troy }

NO L  {troy , albany }

Fall 2006 Costas Busch - RPI 67


More examples of non-trivial properties:
P2 : L is regular?
YES L  
YES L  {a n : n  0 }
n n
NO L  {a b : n  0 }

P3 : L has size 2?
NO L  
NO L  {troy }
YES L  {troy , albany }
Fall 2006 Costas Busch - RPI 68
Trivial property:
A property P possessed by ALL
Turing-acceptable languages

Examples: P4 : L has size at least 0?


True for all languages
P5 : L is accepted by some
Turing machine?
True for all
Turing-acceptable languages
Fall 2006 Costas Busch - RPI 69
We can describe a property P as the set
of languages that possess the property

If language L has property P then L  P

Example: P : L is empty?
YES L  
P  { } NO L  {troy }

NO L  {troy , albany }

Fall 2006 Costas Busch - RPI 70


Example: Suppose alphabet is   {a }

P : L has size 1?
NO 
YES {  } {a } {aa } {aaa } 
NO { , a } { , aa } {a , aa } 
NO { , a , aa } {aa , aaa , aaaa } 

P  {{ }, {a }, {aa }, {aaa }, {aaaa },}


Fall 2006 Costas Busch - RPI 71
Non-trivial property problem
Input: Turing Machine M
Question: Does L(M ) have the non-trivial
property P ? L(M )  P ?

Corresponding language:

PROPERTYTM  { M : M is aTuring machine


such that L(M ) has the non - trivial
property P , that is, L(M )  P }
Fall 2006 Costas Busch - RPI 72
Rice’s Theorem: PROPERTYTM is undecidable
(the non-trivial property problem is unsolvable)

Proof: Reduce
ATM (membership problem)
to
PROPERTYTM or PROPERTYTM

Fall 2006 Costas Busch - RPI 73


We examine two cases:

Case 1:   P
Examples: P : L(M ) is empty?

P : L(M ) is regular?

Case 2:  P

Example: P : L(M ) has size 2?

Fall 2006 Costas Busch - RPI 74


Case 1:   P

Since P is non-trivial, there is


a Turing-acceptable language X
such that: X  P

Let MX be the Turing machine that


accepts X
Fall 2006 Costas Busch - RPI 75
Reduce
ATM (membership problem)
to
PROPERTYTM

Fall 2006 Costas Busch - RPI 76


membership problem decider
Decider for ATM
Non-trivial property
Reduction problem decider
YES YES
Compute M̂ Decider
M ,w
f  M ,w  PROPERTYTM NO NO

Given the reduction, A contradiction!


if PROPERTYTM is decidable, since ATM
then ATM is decidable is undecidable
Fall 2006 Costas Busch - RPI 77
We only need to build the reduction:

Reduction
Compute
M ,w M̂
f  M ,w 
 f  M ,w 
So that:

M ,w  ATTM Mˆ  PROPERTYTM

Fall 2006 Costas Busch - RPI 78


Construct M̂ from M ,w :
Tape of M̂
s
input string

skip input write w run M
string s on tape on input w

If s X yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 79


For this phase we can run machine MX
that accepts X , with input string s


skip input write w run M
string s on tape on input w

If s X yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 80


M accepts w L(Mˆ)  X P
M
does not
accept
w L(Mˆ)   P

skip input write w run M
string s on tape on input w

If s X yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 81


Therefore:

M accepts w L(Mˆ)  P

Equivalently:

M ,w  ATTM Mˆ  PROPERTYTM

Fall 2006 Costas Busch - RPI 82


Case 2:   P

Since P is non-trivial, there is


a Turing-acceptable language X
such that: X  P

Let MX be the Turing machine that


accepts X
Fall 2006 Costas Busch - RPI 83
Reduce
ATM (membership problem)
to
PROPERTYTM

Fall 2006 Costas Busch - RPI 84


membership problem decider
Decider for ATM
Non-trivial property
Reduction problem decider
YES YES
Compute M̂ Decider
M ,w
f  M ,w  PROPERTYTM NO
NO

Given the reduction, A contradiction!


if PROPERTYTM is decidable, since ATM
then ATM is decidable is undecidable
Fall 2006 Costas Busch - RPI 85
We only need to build the reduction:

Reduction
Compute
M ,w M̂
f  M ,w 
 f  M ,w 
So that:

M ,w  ATTM Mˆ  PROPERTYTM

Fall 2006 Costas Busch - RPI 86


Construct M̂ from M ,w :
Tape of M̂
s
input string

skip input write w run M
string s on tape on input w

If s X yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 87


M accepts w L(Mˆ)  X P
M
does not
accept
w L(Mˆ)   P

skip input write w run M
string s on tape on input w

If s X yes
M accepts w ?
then accept s

Fall 2006 Costas Busch - RPI 88


Therefore:

M accepts w L(Mˆ)  P

Equivalently:

M ,w  ATTM Mˆ  PROPERTYTM

END OF PROOF
Fall 2006 Costas Busch - RPI 89

You might also like