prof. busch - lsu1 decidable languages. prof. busch - lsu2 recall that: a language is...

65
Prof. Busch - LSU 1 Decidable Languages

Upload: everett-lyons

Post on 19-Dec-2015

222 views

Category:

Documents


0 download

TRANSCRIPT

Prof. Busch - LSU 1

Decidable Languages

Prof. Busch - LSU 2

Recall that:

A language is Turing-Acceptableif there is a Turing machine that accepts

Also known as: Turing-Recognizable or Recursively-enumerable languages

LM

L

Prof. Busch - LSU 3

For any string :

Lw

w

halts in an accept state M

Lw halts in a non-accept stateM

or loops forever

Prof. Busch - LSU 4

Definition:

A language is decidableif there is a Turing machine (decider) which accepts and halts on every input string

Also known as recursive languages

L

LM

Prof. Busch - LSU 5

For any string :

Lw

w

halts in an accept state M

Lw halts in a non-accept stateM

Every decidable language is Turing-Acceptable

Prof. Busch - LSU 6

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

acceptqrejectq

These are the only halting states

That result to possible halting configurations

Prof. Busch - LSU 7

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

acceptq

Old machine New machine

Rxx ,

Rxx ,

Rxx ,

Multiple accept states

For each tape symbol x

One accept state

Lxx ,

Prof. Busch - LSU 8

iq

iq Rxx ,

For all tape symbols not used for read in the other transitions of

x

iq

Old machine

New machine

rejectq

Multiple reject states One reject state

Do the following for each possible halting state:

For each

Prof. Busch - LSU 9

Inputstring

Accept

Reject

Decider for LDecisionOn Halt:

acceptq

rejectq

For a decidable language : L

For each input string, the computationhalts in the accept or reject state

Prof. Busch - LSU 10

Inputstring

Turing Machine forLacceptq

rejectq

For a Turing-Acceptable language : L

It is possible that for some input string the machine enters an infinite loop

Prof. Busch - LSU 11

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

Is number prime? x

Corresponding language:

Problem:

We will show it is decidable

Prof. Busch - LSU 12

On input number :x

Divide with all possible numbersbetween and

If any of them divides Then rejectElse accept

x2 x

Decider for : PRIMES

x

Prof. Busch - LSU 13

(Input string)is prime?

Decider for PRIMES

Input numberxYES

NO

the decider for the languagesolves the corresponding problem

(Accept)

(Reject)

x

acceptq

rejectq

Prof. Busch - LSU 14

Theorem:

If a language is decidable,then its complement is decidable too

LL

Proof:

Build a Turing machine that accepts and halts on every input string

M L

( is decider for )LM

Prof. Busch - LSU 15

M acceptq

M

rejectqacceptq

rejectq

aq

rq

aq

rq

Transform accept state to rejectand vice-versa

Prof. Busch - LSU 16

Accepts and halts on every input string

1. Let be the decider forM

If accepts then rejectIf rejects then accept

MM

M Turing Machine

On each input string do: w

2. Run with input stringM w

L

L

END OF PROOF

Prof. Busch - LSU 17

Undecidable Languages

An undecidable language has no decider:

There is a language which isTuring-Acceptable and undecidable

We will show that:

each Turing machine that acceptsdoes not halt on some input string

L

Prof. Busch - LSU 18

We will prove that there is a language :

• is not Turing-acceptable

(not accepted by any Turing Machine)

• is Turing-acceptable

LL

L

Therefore, is undecidableL

the complement of a decidable language is decidable

Prof. Busch - LSU 19

Decidable

Turing-Acceptable

Non Turing-Acceptable L

L

Prof. Busch - LSU 20

A Language which is not

Turing Acceptable

Prof. Busch - LSU 21

Consider alphabet }{a

,,,, aaaaaaaaaa

1a 2a 3a 4a

}{aStrings of :

Prof. Busch - LSU 22

Consider Turing Machinesthat accept languages over alphabet }{a

They are countable:

,,,, 4321 MMMM

(There is an enumerator that generates them)

Prof. Busch - LSU 23

,,,, 4321 MMMM

Each machine accepts some language over }{a

),(),(),(),( 4321 MLMLMLML

Note that it is possible to have

)()( ji MLML ji Since, a language could be accepted by more than oneTuring machine

for

Prof. Busch - LSU 24

Example language accepted by

},,{)( aaaaaaaaaaaaML i

},,{)( 642 aaaML i

iM

Binary representation

1a 2a 3a 4a 5a 6a 7a

)( iML

0 1 1 10 0 0

Prof. Busch - LSU 25

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Example of binary representations

Prof. Busch - LSU 26

Consider the language

)}(:{ iii MLaaL

L consists of the 1’s in the diagonal

Prof. Busch - LSU 27

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 43 aaL

Prof. Busch - LSU 28

Consider the language

)}(:{ iii MLaaL

L consists of the 0’s in the diagonal

)}(:{ iii MLaaL

L

Prof. Busch - LSU 29

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 21 aaL

Prof. Busch - LSU 30

Proof:

is Turing-AcceptableL

Assume for contradiction that

There must exist some machinethat accepts :

kML LML k )(

Theorem:

Language is not Turing-AcceptableL

Prof. Busch - LSU 31

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?1MMk LML k )(

Prof. Busch - LSU 32

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 1MMk )(

)(

11

1

MLa

MLa k

Prof. Busch - LSU 33

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?2MMk LML k )(

Prof. Busch - LSU 34

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 2MMk )(

)(

22

2

MLa

MLa k

Prof. Busch - LSU 35

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Question: ?3MMk LML k )(

Prof. Busch - LSU 36

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

Answer: 3MMk )(

)(

33

3

MLa

MLa k

Prof. Busch - LSU 37

Similarly: ik MM

)(

)(

ii

ki

MLa

MLa

)(

)(

ii

ki

MLa

MLa

for any i

Because either:

or

the machine cannot exist kM

is not Turing-AcceptableLEnd of Proof

Prof. Busch - LSU 38

Decidable

Turing-Acceptable

Non Turing-Acceptable

L

Prof. Busch - LSU 39

A Language which is Turing-Acceptableand Undecidable

Prof. Busch - LSU 40

There is a Turing machine that accepts

Each machinethat accepts doesn’t halt on some input string

Is Turing-Acceptable

Undecidable

)}(:{ iii MLaaL

We will prove that the language

LL

Prof. Busch - LSU 41

1a 2a 3a 4a

)( 1ML

0 1 10

)( 2ML

)( 3ML

01 0 1

0 1 11

)( 4ML 0 10 0

},,{ 43 aaL

Prof. Busch - LSU 42

The languageTheorem:

)}(:{ iii MLaaL

Is Turing-Acceptable

Proof:We will give a Turing Machine thataccepts L

Prof. Busch - LSU 43

Turing Machine that accepts LFor any input string w

• Compute , for which iaw

• Find Turing machine iM(using the enumerator for Turing Machines)

• Simulate on inputiMia

• If accepts, then accept iM w

i

End of Proof

Prof. Busch - LSU 44

Observation:

)}(:{ iii MLaaL

)}(:{ iii MLaaL

Turing-Acceptable

Not Turing-acceptable

(Thus, is undecidable)L

Prof. Busch - LSU 45

Decidable

Turing-Acceptable

Non Turing-Acceptable L

L

L ?

Prof. Busch - LSU 46

Theorem: )}(:{ iii MLaaL

is undecidable

Proof: If is decidable

Then is decidable

L

L

Contradiction!!!!

However, is not Turing-Acceptable!L

the complement of a decidable language is decidable

Prof. Busch - LSU 47

Decidable

Turing-Acceptable

Not Turing-Acceptable L

L

Prof. Busch - LSU 48

Turing acceptable languages and

Enumerators

Prof. Busch - LSU 49

We will prove:

• If a language is decidable then there is an enumerator for it

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

(weak result)

(strong result)

Prof. Busch - LSU 50

Theorem:

if a language is decidable then there is an enumerator for it

L

Proof:

Let be the decider for M L

Use to build the enumerator for M L

Prof. Busch - LSU 51

Example: alphabet is },{ ba

abaaabbabbaaaaab......

(proper order)

Let be an enumerator that printsall strings from input alphabet in proper order

M~

Prof. Busch - LSU 52

Enumerator for

Repeat:

M~1. generates a string

M

w

2. checks if Lw

YES: print to output w

NO: ignore w

L

This part terminates,because is decidable L

Prof. Busch - LSU 53

MM~Enumerator for

string

Give me next stringEnumerates all

strings of

input alphabet

Generates allStrings in alphabet

iwIf acceptsthen print tooutput

M iw

iw

Tests each stringif it is accepted by

L

M

output

All strings

of L

Prof. Busch - LSU 54

Example:

M~

abaaabbabbaaaaab

M

,....},,,{ aaabbabbL Enumeration

Output

b

ab

bbaaa

reject

reject

reject

accept

accept

accept

accept

reject

END OF PROOF

1w

2w3w

Prof. Busch - LSU 55

Theorem:

if language is Turing-Acceptable thenthere is an enumerator for it

L

Proof:

Let be the Turing machine that accepts M L

Use to build the enumerator for M L

Prof. Busch - LSU 56

MM~

Enumerator for

Accepts LEnumerates allstrings of input alphabetin proper order

L

Prof. Busch - LSU 57

Enumerator for

Repeat: M~ generates a string

M

w

checks if Lw

YES: print to output w

NO: ignore w

NAIVE APPROACH

Problem:If machine may loop forever

LwM

L

Prof. Busch - LSU 58

M~

M

1w

executes first step on

BETTER APPROACH

1w

M~ Generates second string 2w

M executes first step on 2w

second step on 1w

Generates first string

Prof. Busch - LSU 59

M~ Generates third string 3w

M executes first step on 3w

second step on 2w

third step on 1w

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

Prof. Busch - LSU 60

1w 2w 3w 4w

1

Step in computationof string

1 1 1

2 2 2 2

3 3 3 3

String:

4 4 4 4

Prof. Busch - LSU 61

If for any string machine halts in an accepting statethen print on the output

Miw

iw

End of Proof

Prof. Busch - LSU 62

Theorem:

If for language there is an enumeratorthen is Turing-Acceptable

L

L

Proof:

Using the enumerator forwe will build a Turing machine that accepts

L

L

Prof. Busch - LSU 63

wInput Tape

Enumeratorfor L

Compare

Turing Machine that accepts Lw

iwIf same, Accept and Halt

Give me thenext stringin the enumeration sequence

Prof. Busch - LSU 64

Turing machine that accepts L

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

For any input string w

• Compare generated string with w

If same, accept and exit loop

End of Proof

L

Prof. Busch - LSU 65

By combining the last two theorems,we have proven:

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