applied computer science ii chapter 4: decidability prof. dr. luc de raedt institut für informatik...

22
Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Upload: fernanda-barnaby

Post on 31-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Applied Computer Science IIChapter 4: Decidability

Prof. Dr. Luc De Raedt

Institut für InformatikAlbert-Ludwigs Universität Freiburg

Germany

Page 2: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Overview

• An investigation into the solvable/decidable

• Decidable languages• The halting problem (undecidable)

Page 3: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

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 II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

The acceptance problem for DFAs

{ , | is a DFA that accepts input string }

is a decidable language

DFA

DFA

A B w B w

A

Theorem

Proof

Page 5: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

The acceptance problem for NFAs

{ , | is an NFA that accepts input string }

is a decidable language

NFA

NFA

A B w B w

A

Theorem

Proof

Page 6: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

The acceptance problem for Regular

Expressions{ , | is a regular expression that generates input string }

is a decidable language

REX

REX

A R w R w

A

Theorem

Proof

Page 7: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

The emptiness testing problem for DFAs

{ | is DFA for which ( ) }

is a decidable language

DFA

DFA

E A A L A

E

Theorem

Proof

Page 8: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

The equivalence problem for DFAs

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

is a decidable language

DFA

DFA

EQ A B A B L A L B

EQ

Theorem

Proof

Page 9: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Decidable problems for CF languages

{ , | is a CFG that generates input string }

is a decidable language

Relies on the following property :

If is in Chomsky Normal Form,

then any derivation of has length at most 2 w

CFG

CFG

A G w G w

A

G

w

Theorem

Proof

1

There are only finitely many derivations of length less than n

Page 10: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

{ | is CFG for which ( ) }

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

Page 11: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

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

is not decidable

Follows later

The problem with adapting the proof for DFAs

is that the class of context free languages

is not closed under comp

CFG

CFG

EQ G H G H L G L H

EQ

Theorem

Proof

lementation or intersection !

Page 12: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Every context free language is decidable

Theorem

Proof

Page 13: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

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 14: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

{ , | is a TM that accepts }

is Turing recognizable

Consider : ( )

On input < , , where is a TM and a string

1. Simulate on

2. If ever enters its accept state

TM

TM

A M w M w

A

U Universal Turing Machine

M w M w

M w

M

Theorem

Proof

, ,

if ever enters its reject state,

loops when does

the problem:

is undecidable

shows that recognizers are

halt

more powerful than deciders

requires quite invo

in

lved proof

g

TM

accept

M reject

U M

ATheorem

Page 15: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Diagonalization

• Georg Cantor 1873• Measure the size of (infinite) sets

Consider function :

is if ( ) ( ) whenever

is if for every there is an : ( )

is a if it is onto and one-to-one

Example : : ( ) ( .)

one-to-one

onto

correspondence

f A B

f f a f b a b

f b B a A f a b

f

f natural numbers E even nat

( ) 2 is a correspondence

Both sets have the same size !

A set is if it has the sacount me siab zele as

f n n

Page 16: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

{ | , } the positive rational numbers

is countable

idea

mm n

n

Theorem

Proof

Page 17: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

the set of real numbers (have a decimal representation)

is uncountable

idea

We prove (by contradiction) that there is no correspondence between and

Assume that there were a corresponden

Theorem

Proof

ce

We now construct an that is not paired with any element of

Choose fractional digit of different from frac. digit of ( )

Example

( )

1 3.1414..

2 5.567..

3 0.8888888...

... ...

0.279...

So

f

x

i th x i th f i

n f n

x

, ( ) for all x f n n

Page 18: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

*

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

Le

B

B

L

L

L B

Lemma

Proof

Lemma

Proof

*1 2

*

t { , ,...}; which is countable

Each language in has a unique in defined as follows

{ 0 1 00 01 10 ...}

{ 0 00 10 ...}

0 1 0 1 0 1 ...

: : ( ) is a corres

characteristic sequenc

ponde

n e

e

cA

A

A

s s

A L B

A

f L B f A

Page 19: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

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 alphabet is co

Theorem

Proof

untable;

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 20: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

<

accepts < , when accepts

rejects < > when accepts <

rejects when accepts D

H M w M w

D M M M

D D D

Further Explanations{ , | is a TM that accepts }

is undecidable

by contradiction; assume is decidable

Suppose is a decider for

if accepts ( , )

if does not accept

Use to

TM

TM

TM

TM

A M w M w

A

A

H A

accept M wH M w

reject M w

H

Theorem

Proof

2. Output the opposite of what outputs ;

So,

define :

On input ,where is a TM

1. Run on input < ,

if does not accept ( )

if accepts

if does not acc( )

M

H

D

M M

H M

accept M MD M

reject M M

and

accept DD D

ept

if accepts

This is impossible !

D

reject D D

Page 21: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

A language is if it is the complement

of a language that is Turing recognizable

A language is decidable if and only if it is both Turing-recogni

co-Turi

zable

a

ng recogni

nd co-Turing recog

za

niz

ble

Theorem

1 2

able

1. If is decidable then and Turing recognizable

Trivial

2. If and Turing recognizable then is decidable

Let and be TMs for and

Define :

On input

A A A

A A A

M M A A

M

w

Proof

1 2

1

2

1. Run both and on in parallel

2. If accepts, then accepts;

If accepts, then reject;

decides

all strings are either in or

either 1 or 2 mu

M M w

M

M

M A

A A

M M st accept any given string

always terminates with correct answer

M

is not Turing-recognizable

is Turing-recognizable

If were also Turing-recognizable

Then would be decidable.

TM

TM

TM

TM

A

A

A

A

Theorem

Proof

Page 22: Applied Computer Science II Chapter 4: Decidability Prof. Dr. Luc De Raedt Institut für Informatik Albert-Ludwigs Universität Freiburg Germany

Summary

TMA

TMA

, , , ,

,

DFA NFA REX

CFG

DFA CFG

DFA

A A A

A

E E

EQ