+ All Categories
Transcript
Page 1: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

1

Decidability

Bernhard Nebel and Christian Becker-Asano

Page 2: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

2

Overview

An investigation into the solvable/decidable

Decidable languages

The halting problem (undecidable)

Page 3: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

3

Decidable problems?

Acceptance problem : decide whether an automaton accepts a string

Equivalence problem : Decide whether two automata are equivalent, i.e.

accept the same language

Emptiness testing problem : Decide whether the language of an automaton is

empty

Can be applied to DFA, NFA, REX, PDA, CFG, TM,โ€ฆ

Page 4: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

4

Acceptance problem for DFAs

To decide whether a particular DFA accept a given string w, we express this in a language: ADFA. ADFA contains the encodings of all DFAs together with the string w the DFAs accept:

{ , | is a DFA that accepts input string }DFAA B w B w

The problem of testing whether a DFA B accepts w is the same as the problem of whether <B,w> is a member of language ADFA . Proof idea: Decider M will simulate B on input ๐‘ค. If B would accept w, then M accepts; if B rejects, then M rejects.

Page 5: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

5

Convert B = (๐‘„, ฮฃ, ๐›ฟ, ๐‘ž0, ๐น) and input ๐‘ค into string for TMโ€™s tape. E.g.:

Theorem 4.1: ๐ด๐ท๐น๐ด is a decidable language.

Proof: M= โ€žOn input ๐ต,๐‘ค , where ๐ต is a DFA and ๐‘ค is a string:

1. Simulate ๐ต on input ๐‘ค.

2. If the simulation ends in an accept state, accept. If it ends in a nonaccepting state, reject.

Acceptance problem for DFAs

q0 q1 q2 q3 # 0 1 # <table> โ€ฆ

# q0 # q2 q3 # # 0 1 1

0 1 1 1 0 # q0

Page 6: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

6

๐ด๐‘๐น๐ด = ๐ต,๐‘ค ๐ต ๐‘–๐‘  ๐‘Ž๐‘› ๐‘๐น๐ด ๐‘กโ„Ž๐‘Ž๐‘ก ๐‘Ž๐‘๐‘๐‘’๐‘๐‘ก๐‘  ๐‘–๐‘›๐‘๐‘ข๐‘ก ๐‘ ๐‘ก๐‘Ÿ๐‘–๐‘›๐‘” ๐‘ค

Theorem 4.2: ๐ด๐‘๐น๐ด is a decidable language.

Proof: N = โ€œOn input ๐ต,๐‘ค where ๐ต is an NFA, and ๐‘ค is a string:

1. Convert NFA ๐ต to an equivalent DFA ๐ถ, using the procedure for this conversion given in Theorem 1.39.

2. Run TM ๐‘€ from Theorem 4.1 on input ๐ถ,๐‘ค .

3. If ๐‘€ accepts, accept; otherwise, reject.

Running TM ๐‘€ in stage 2 of N means incorporating ๐‘€ into the design of N as a subprocedure.

Acceptance problem for NFAs (T 4.2)

Page 7: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

7

๐ด๐‘…๐ธ๐‘‹ = ๐‘…,๐‘ค ๐‘… ๐‘–๐‘  ๐‘Ž ๐‘Ÿ๐‘’๐‘”๐‘ข๐‘™๐‘Ž๐‘Ÿ ๐‘’๐‘ฅ๐‘๐‘Ÿ๐‘’๐‘ ๐‘ ๐‘–๐‘œ๐‘› ๐‘กโ„Ž๐‘Ž๐‘ก ๐‘”๐‘’๐‘›๐‘’๐‘Ÿ๐‘Ž๐‘ก๐‘’๐‘  ๐‘ ๐‘ก๐‘Ÿ๐‘–๐‘›๐‘” ๐‘ค

Theorem 4.3: ๐ด๐‘…๐ธ๐‘‹ is a decidable language.

Proof sketch:

1. Convert regular expression R into an NFA A according to Theorem 1.54.

2. Use Theorem 4.2 to run TM N on input ๐ด,๐‘ค .

3. If N acceptsโ€ฆ

Acceptance problem for regular

expressions

Page 8: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

8

๐ธ๐ท๐น๐ด = ๐ด ๐ด ๐‘–๐‘  ๐ท๐น๐ด ๐‘“๐‘œ๐‘Ÿ ๐‘คโ„Ž๐‘–๐‘โ„Ž ๐ฟ ๐ด = โˆ…

Theorem 4.4 ๐ธ๐ท๐น๐ด is a decidable language.

Proof: A DFA accepts some string iff reaching an accept state from the start state using valid transitions is possible. To test this condition we can design a TM T that uses a marking algorithm similar to that used in the example about connected graph presented in the end of the lecture about โ€œTuring machines.โ€ T=โ€žOn input ๐ด where A is a DFA:

1. Mark the start state of A.

2. Repeat until no new states get marked:

3. Mark any state that has a transition coming into it from any state that is already marked.

4. If no accept state is marked, accept; otherwise, reject.โ€œ

Emptiness testing problem for DFAs

Page 9: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

9

Equivalence problem for DFAs

This expression is sometimes called the of and . Here is the complement

of The symmetric difference is useful h

L(C ) ( L( A ) L( B ) ) ( L( A ) L( B ))

symmetric difference L( A ) L( B ) L( A )

L( A ).

ere because if and only if

One can construct from and with the constructions for proving the class of regular languages are closed

under the complement, union, and intersection

L(C ) L( A ) L( B ).

C A B

. These constructions are algorithms that can be carried out by

Turing machines. Once has been constructed one can use Theorem 4.4 to test whether is empty.

If it is empty, and must

C L(C )

L( A ) L( B ) be equal.

="On input where and are DFAยดs:

1. Construct DFA as described.

2. Run TM from Theorem 4.4 on input

3. If accepts, If rejects, "

F A,B , A B

C

T C .

T accept. T reject.

{ , | and are DFAs and ( ) ( )}

4.5

is a decidable language

DFA

DFA

EQ A B A B L A L B

EQ

Theorem

Proof

L(B) L(A)

The symmetric difference of L(A) and L(B)

Page 10: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

10

Acceptance problem for CFGs

The TM for follows.

="On input where is a CFG and is a string:

1. Convert to an equivalent grammar in Chomsky normal form.

2. List all derivations with steps, where

CFGS A

S G,w , G w

G

2n 1 n is the length of ,

except if then instead list all derivations with 1 step.

3. If any of these derivations generate ; if not, "

w

n 0,

w, accept reject.

{ , | is a CFG that generates input string }

4.6

is a decidable language

Relies on the following property :

If is in Chomsky Normal Form, then any derivation of has length at mo

CFG

CFG

A G w G w

A

G w

Theorem

Proof

st 2 w 1

There are only finitely many derivations of length less than .n

4.7

Page 11: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

11

Emptiness testing problem for CFGs

="On input , where is a CFG:

1. Mark all terminal symbols in

2. Repeat until no new variables get marked:

3. Mark any variable where has a rule and

1 2 k

R G G

G.

A G A U U ...U

each symbol has already been marked.

4. If the start symbol is not marked, ; otherwise "

1 kU ,...,U

accept reject.

{ | is a CFG for which ( ) }

4.7

is a decidable language

Determine for each variable whether that variable

is capable of generating a string of terminals

CFG

CFG

E G G L G

E

Theorem

Proof

4.8

Page 12: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

12

Equivalence problem for CFGs

๐ธ๐‘„๐ถ๐น๐บ = ๐บ,๐ป ๐บ ๐‘Ž๐‘›๐‘‘ ๐ป ๐‘Ž๐‘Ÿ๐‘’ ๐ถ๐น๐บ๐‘  ๐‘Ž๐‘›๐‘‘ ๐ฟ ๐บ = ๐ฟ ๐ป

In fact: ๐ธ๐‘„๐ถ๐น๐บ is not decidable!

The proof follows later.

A method along the lines of the proof for DFAs is bound to fail, because the class of context free languages is not closed under complementation or intersection!

Page 13: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

13

Every CFL is decidable

4.8

Every context free language is decidable

Let be a CFG for and design a TM that decides . We build

a copy of into . It works as follows.

="On input :

1. Run TM (fro

G

G

G

G A M A

G M

M w

S

Theorem

Proof

m T4.6) on input ,

2. If this machine accepts, ; if it rejects, ."

G w

accept reject

4.9

(from T4.7)

Page 14: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

14

The relationship amoung classes of languages

Page 15: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

15

The halting problem

There is a specific problem that is algorithmically unsolvable (undecidable), e.g. the halting problem

Philosophical implications : computers are fundamentally limited

Page 16: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

16

The halting problem

๐ด๐‘‡๐‘€ = ๐‘€,๐‘ค ๐‘€ ๐‘–๐‘  ๐‘Ž ๐‘‡๐‘€ ๐‘Ž๐‘›๐‘‘ ๐‘€ ๐‘Ž๐‘๐‘๐‘’๐‘๐‘ก๐‘  ๐‘ค

Theorem 4.11 ๐ด๐‘‡๐‘€ is undecidable.

Proof given later.

Observe that ๐ด๐‘‡๐‘€ is turing-recognizable. Thus, recognizers are more powerful than deciders, because requiring a TM to halt on all inputs (decider) restricts the kinds of languages that it can recognize. The following TM U recognizes ๐ด๐‘‡๐‘€. U=โ€žOn input ๐‘€,๐‘ค where M is a TM and ๐‘ค is a string:

1. Simulate ๐‘€ on input ๐‘ค.

2. If M ever enters its accept state, accept; if M ever enters its reject state, reject.โ€œ

Note: This machine loops on input ๐‘€,๐‘ค if M loops on w, which is why it does not decide ๐ด๐‘‡๐‘€.

Page 17: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

17

Diagonalization

Georg Cantor 1873

Measure the size of (infinite) sets

Consider the function f: Aโ†’B f is injective (one-to-one), if f(a) โ‰  f(b) whenever a โ‰  b

f is surjective (onto), if for every b B there is an a A: f(a) = b

f is bijective (corresponence) if it is injective and surjective

A and B are said to be the same size, if there exists a bijective function f, i.e. for every element in A there exists an unique element in B.

Example: f: N(natural numbers) โ†’ E(even numbers)

๐‘“(๐‘›) = 2๐‘› is a bijective function

Both sets have the same size

Definition: A set is countable, if it is finite or has the same size as N.

n f(n)= 2n

1 2

2 4

3 6

โ€ฆ โ€ฆ

I 2i

Page 18: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

18

Example 4.15: rational numbers

Let โ„š =๐‘š

๐‘›| ๐‘š, ๐‘› โˆˆ โ„• be the set of positive rational

numbers.

โ„š seems to be much larger than โ„•, but

โ„š is countable

Informatik Theorie II (A) WS2008/09

Page 19: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

19

โ„ is uncountable

โ„ = the set of real numbers (have a decimal representation)

Theorem 4.17 โ„ is uncountable.

Proof idea: We proof (by contradiction) that there is no correspondence between โ„ and โ„•. Assume that there were a correspondence ๐‘“, then ๐‘“ must pair all members of โ„• with all members of โ„. We construct ๐‘ฅ โˆˆ โ„ that is not paired with any element of โ„• by choosing the ๐‘–๐‘กโ„Ž fractional digit of ๐‘ฅ to be different from the

๐‘–๐‘กโ„Ž fractional digit of ๐‘“(๐‘–).

Example

n f(n)

1 3.1414โ€ฆ

2 5.567โ€ฆ

3 0.888888โ€ฆ

โ€ฆ โ€ฆ

x = 0.275โ€ฆ

So, x โ‰  f(n) for all n

Page 20: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

20

the set of all infinite binary strings

is uncountable

idea

By analogy to

Let be the set of all languages over

is uncountable

idea

We define a correspondence between and

Let

B

B

L

L

L B

Lemma

Proof

Lemma

Proof

*

1 2

*

{ , ,...}; which is countable

Each language in has a unique in defined as follows

{ , 0, 1, 00, 01, 10, 11, 000, 001, ... } ;

{ 0, 00, 01

characteristic

, 000, 001, ... } ;

sequence

0 1 0 1 1 0 0 1 1 ... .

: : (

A

A

s s

A L B

A

f L B f

) is a correspondenceAA

Page 21: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

21

Some languages are not Turing-

recognizable

(T4.15)

Some languages are not Turing recognizable

There is a countable number of Turing Machines

(Each Turing Machine can be encoded in a string;

the set of all strings over a finite alphab

Theorem

Proof

et is countable;

not all strings need to encode legal TMs)

The set of all languages is uncountable

Therefore there is no correspondence between the

set of all TMs and the set of all languages.

Page 22: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

22

ATM is undecidable (Proof)

{ , | is a TM that accepts }

(T4.9)

is undecidable

by contradiction; assume is decidable

Suppose is a decider for

if accepts ( , )

if does not accept

TM

TM

TM

TM

A M w M w

A

A

H A

accept M wH M w

reject M w

Theorem

Proof

4.11 (revisited)

Page 23: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

23

ATM is undecidable (ctd.)

2. Output the opposite of what outputs ;

So,

Use to define :

On input , where is a TM

1. Run on input < ,

if does not accept ( )

if accepts

if does( )

M

H

H D

M M

H M

accept M MD M

reject M M

and

accept DD D

not accept

if accepts

This is impossible !

D

reject D D

accepts , when accepts

rejects when accepts

rejects when accepts

H M w M w

D M M M

D D D D

Further Explanations

Page 24: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

24

Entry i,j is accept if Mi accepts <Mj>

<M1> <M2> <M3> <M4> ...

M1 accept accept

M2 accept accept accept accept

M3 ...

M4 accept accept

โ‹ฎ โ‹ฎ

Page 25: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

25

Entry i,j is the value of H on input <Mi,<Mj>>

<M1> <M2> <M3> <M4> ...

M1 accept reject accept reject

M2 accept accept accept accept

M3 reject reject reject reject ...

M4 accept reject accept reject

โ‹ฎ โ‹ฎ

Page 26: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

26

What happens if D occurs?

<M1> <M2> <M3> <M4> ... <D> ...

M1 accept reject accept reject accept

M2 accept accept accept accept accept

M3 reject reject reject reject ... reject ...

M4 accept reject accept reject accept

โ‹ฎ โ‹ฎ โ‹ฑ

D reject reject accept accept ?

โ‹ฎ โ‹ฎ โ‹ฑ

Page 27: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

27

Co-Turing-recognizable and decidability

Theorem 4.22 A language is decidable iff it is Turing-recognizable and co-Turing-recognizable.

Proof: Forward direction: If ๐ด is decidable, we can easily see that both ๐ด and its complement ๐ด are Turing-recognizable. Any decidable language is Turing-recognizable and the complement of a decidable language also is decidable. Backward direction: Assume both ๐ด and ๐ด are Turing-recognizable.

Let ๐‘€1 be the recognizer for ๐ด and ๐‘€2 the recognizer for ๐ด .

The following TM ๐‘€ is a decider for ๐ด:

๐‘€=โ€žOn input ๐‘ค:

1. Run both ๐‘€1 and ๐‘€2 on input ๐‘ค in parallel.

2. If ๐‘€1 accepts, accept; if ๐‘€2 accepts, reject.โ€œ

Page 28: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

28

ATM is not Turing-recognizable

Corollary 4.23 ๐ด๐‘‡๐‘€ is not Turing-recognizable.

Proof:

We know that ๐ด๐‘‡๐‘€ is Turing-recognizable.

Assume that ๐ด๐‘‡๐‘€ were also Turing-recognizable.

๐ด๐‘‡๐‘€ would be decidable.

Theorem 4.11 tells us that ๐ด๐‘‡๐‘€ is undecidable.

Contradiction! ๐ด๐‘‡๐‘€ is not Turing-recognizable.

Page 29: Applied Computer Science IIki/teaching/ws1112/acs2/acs2-07-handout.pdfย ยท Convert B=( ,ฮฃ,๐›ฟ, M0, ) and input S into string for TMโ€™s tape. E.g.: Theorem 4.1: ๐ด is a decidable

ACS2: Decidability

29

Summary

ADFA, ANFA, AREX,

ACFG,

EDFA, ECFG,

EQDFA

ATM

ATM

The relationship amoung languages


Top Related