You are on page 1of 9

Overview

Lecture T2: Turing Machines

Attempt to understand essential nature of computation by studying properties of simple machine models. Goal: simplest machine that is "as powerful" as conventional computers. Surprising Fact 1. ! Such machines are not much more complicated than FSAs. Surprising Fact 2. ! Some problems of interest cannot be solved by ANY computer.

2

s

Nondeterministic Finite State Automata
Nondeterministic FSA (NFSA).
s

Extremely simple and cheap to build. Well suited to certain important tasks. – pattern matching, filtering, dishwashers, remote controls, traffic lights, sequential circuits

Simple machine with N states. Start in state 0. Read a bit. Depending on current state and input bit – move to any of several new states Stop when last bit read. Accept if ANY choice of new states ends in state X, reject otherwise. 0 0 1 0

s

s

1 0 0 0 1 0

3 1 2 1

s

s

s

Not sufficiently "powerful" to solve numerous problems of interest.
s

How can we make FSAs more powerful?
s

s

NFSA = FSA + "nondeterminism." (ability to guess the right answer!)

3

4

reject otherwise. s NFSA Example 2 Build an NFSA to match all strings whose 5th to last character is ’x’. and next bit is 1: can move to state 1 can move to state 2 can move to state 3 If in state 2. Start in state 0. reject otherwise. and next bit is 0: can’t move to any state 5 6 Nondeterministic Finite State Automata Nondeterministic FSA (NFSA).Nondeterministic Finite State Automata Nondeterministic FSA (NFSA). Read a bit... Accept if ANY choice of new states ends in state X. Start in state 0. Read a bit. Depending on current state and input bit – move to any of several new states Stop when last bit read. 0 0 1 0 s 1 0 0 0 1 0 Simple machine with N states. % egrep ’x. Accept if ANY choice of new states ends in state X. reject otherwise. Start in state 0. 0 0 1 0 s 3 s 1 0 0 0 1 0 3 1 2 1 s s 1 2 1 s s s s s If in state 2. 0 0 1 0 s 1 0 0 0 1 0 3 1 2 1 s s s s 0 Which strings are accepted? á 0010001 M 00 M 10000111001100 á 10000111001101 x 1 a-z 2 a-z 3 a-z 4 a-z 5 a-z 7 8 . Accept if ANY choice of new states ends in state X. Depending on current state and input bit – move to any of several new states Stop when last bit read.\$’ /usr/dict/words asphyxiate carboxylic contextual inflexible s Simple machine with N states. s Nondeterministic Finite State Automata Nondeterministic FSA (NFSA). Read a bit.. Depending on current state and input bit – move to any of several new states Stop when last bit read. s Simple machine with N states.

J Interested students: see supplemental lecture slides. N-state NFSA ⇒ 2N state FSA. s Given any NFSA. s s Y is at least as powerful as X. Systematic method for NFSA.NFSA Equivalence Theorem: FSA and NFSA are "equally powerful". s Notation: X ⊆ Y. can construct FSA that accepts same inputs. s For FSA. only one possible path to follow. We’ll spare you the details. Machine class Y can be "programmed" to accept all the languages that X can (and maybe more). s Y is at least as powerful as X. Keep track of ALL possible states that the NFSA could be in for a given input. but is it essential? s A FSA is a special type of NFSA. need to consider many paths.A Systematic Method for NFSA Harder to determine whether an NFSA accepts a string than an FSA. One state in FSA for every set of states in the NFSA. s FSA . s Notation: X ⊆ Y. s s Proof (Part 1): FSA ⊆ NFSA. Power of nondeterminism is very useful. For NFSA. Accept if one of possible ending states is accept state. can construct FSA that accepts same inputs. Given any NFSA.NFSA Equivalence Theorem: FSA and NFSA are "equally powerful". s RE – FSA Equivalence Theorem: FSA and RE are "equally powerful". 9 10 FSA . s s 11 12 . Machine class Y can be "programmed" to accept all the languages that X can (and maybe more). s Proof (Part 2): NFSA ⊆ FSA. s Given a nondeterministic FSA. we give recipe to construct a deterministic FSA that recognizes the same language.

s Simple machine with N states. {. 0011. 000111. s s new accept / reject mechanism s 15 16 . A pushdown stack (amount of memory is arbitrarily large). Input on an arbitrarily large TAPE that can be read from *and* written to. s Did it help? s s More powerful. Accept if stack is EMPTY. Accept if yes. s s s s s Pushdown Automata (PDA). Instead. Use notation x/y/z If input is x and top of stack is y.. Read a bit from tape. 00001111. Depending on current state and input bit – write a bit to tape – move tape right or left – move to new state Stop if enter yes or no state. ε. can recognize: – all bit strings with an equal number of 0’s and 1’s – – s all bit strings of the form all "balanced" strings in alphabet: (. check bit at top of stack. . Depending on current state/input bit/stack bit: – move to new state – push the input onto stack. ) 0N1N s s Still can’t recognize language of all palindromes. – amanaplanacanalpanama – 11*181=1991=181*11 – murderforajarofredrum More powerful machines still needed.Pushdown Automata read head How can we make FSA’s more powerful? s Pushdown Automata PDA for deciding whether input is of form 0N1N . reject otherwise. reject if no or does not terminate.. Read a bit. Start in state 0. ]. add "memory" to the FSA. then do z. [. Simple machine with N states. s Nondeterminism didn't help. N 0’s followed by N 1’s for some N. 01. s PDA = FSA + stack. Start in state 0. or pop topmost element from stack Stop when last bit is read. }. different accept / reject mechanism 13 0/0/push top of stack 1/0/pop 0 1/0/pop s s 1 s 0/ε/push s s 14 Pushdown Automata How can we make FSA more powerful? s Turing Machine read / write head Turing Machine.