Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decidability and Enumerability

Similar presentations


Presentation on theme: "Decidability and Enumerability"— Presentation transcript:

1 Decidability and Enumerability
Lecture 27 Section 3.2 Wed, Oct 24, 2007

2 Turing Machines as Language Enumerators
To enumerate a language is to list all of its words in some order. The order does not matter. An enumerator is a Turing machine that will do this. If the language is infinite, then the enumerator will loop.

3 Examples Let  = {0, 1}*. Design the following enumerators.
G enumerates all strings in *. E1 enumerates all strings in * that contain an even number of 1s. E2 enumerates all string in * that contain the substring 111.

4 Examples The first enumerator G begins by “writing” , followed by #.
Then it “copies”  to the right of # and replaces it with its successor 0, followed by #. Then it copies 0, replaces it with 1, followed by # This process is repeated indefinitely.

5 Examples The second enumerator E1 uses the first enumerator G as a module. G writes a string on Tape 2. E1 writes 0 on Tape 3. Then E1 scans the string on Tape 2.

6 Examples Every time it reads 1, it changes the 0 on Tape 3 to a 1, or the 1 to a 0. When it reaches the #, if the number on Tape 3 is 0, then copy the string from Tape 2 to Tape 1 Repeat the procedure on the next string.

7 Examples The third enumerator E2 is similar to E1 except that it searches the string on Tape 2 for the substring 111. If it finds it, it copies the string to Tape 1. In either case, it then proceeds on to the next string.

8 Decidable  Canonically Enumerable
Theorem: A language is Turing decidable if and only if there is an enumerator that enumerates its member in canonical order.

9 Decidable  Canonically Enumerable
Proof (): The previous examples contain the main idea. If a language L is Turing decidable, then by definition there is a Turing machine D that decides L. We will build enumerator E of L with G and D as modules.

10 Decidable  Canonically Enumerable
Start up the enumerator G. G writes its strings on Tape 2. Each time G writes a string, E copies it to Tape 3. The decider D processes the string on Tape 3. If D accepts the string, E writes it on Tape 1.

11 Decidable  Canonically Enumerable
Whether D accepts or rejects the string, E continues on with the next string. Every string in L will eventually appear on Tape 1, and it will appear in its proper canonical place.

12 Decidable  Canonically Enumerable
w E no Write yes G

13 Canonically Enumerable  Decidable
Proof (): Suppose that L is enumerable in canonical order. Let E be an enumerator of L that enumerates L in canonical order. Let C be a Turing Machine that compares two strings and returns <, =, or >.

14 Canonically Enumerable  Decidable
We will build a decider D for L using E and C as modules. D reads a string w (on Tape 1). Then D starts up E, which writes strings on Tape 2. Each time E produces a string x, D copies x and w to Tape 3.

15 Canonically Enumerable  Decidable
C processes the strings on Tape 3. If C reports =, then D accepts w. If C reports <, then D gets the next string from E and continues on. If C reports >, then D rejects w.

16 Canonically Enumerable  Decidable
x D > = E w < yes no

17 Recognizable  Enumerable
Theorem: A language is Turing recognizable if and only if there is an enumerator that enumerates it.

18 Recognizable  Enumerable
Proof (): The previous examples again contain the main idea. If a language L is Turing recognizable, then by definition there is a Turing machine R that recognizes L.

19 Recognizable  Enumerable
We will build enumerator E of L using the generator G and the recognizer R as modules. Start up G. As G writes a string onto Tape 2, E copies it to Tape 3 and lets R process it. If R accepts it, then E copies it to Tape 1.

20 Recognizable  Enumerable
In this way, E writes every string in L onto Tape 1. There is a catch: What if R loops on one of the strings? Then E will also loop. Uh-oh.

21 Recognizable  Enumerable
To guard against this, E will Run string 1 for 1 step. Run string 1 for 2 steps and string 2 for 1 step. Run string 1 for 3 steps, string 2 for 2 steps, and string 3 for 1 step. Etc. This way, for any i and j, we will eventually run string i for j steps.

22 Recognizable  Enumerable
If a string is accepted by R, it is accepted after a finite number of steps. Eventually we will try that string for that number of steps, and accept it. But if a string is not accepted by R, then E will not get hung up by looping on it.

23 Recognizable  Enumerable
wi E SUCC M does not halt on j steps M halts on j steps j i G

24 Enumerable  Recognizable
Proof (): Now suppose that a language L is enumerated by some enumerator E. We will build a Turing machine M that recognizes L.

25 Enumerable  Recognizable
Write the input string w onto Tape 1. Have the enumerator E begin writing strings in L onto Tape 2. As each string is written, compare it to w. If they match, then go to the accept state. Otherwise, continue.

26 Enumerable  Recognizable
x w w = x w  x yes M


Download ppt "Decidability and Enumerability"

Similar presentations


Ads by Google