Copyright © Curt Hill Other Automata Pushdown through Turing machines
Copyright © Curt Hill Finite State Machine We have previously seen these What can they not do? They are unable to handle the recursive nature of most programming languages Eg. C –A statement may be a for-statement –A for-statement contains a statement They cannot remember where they came from
Finite State Automata Two things (and only two things) determine the next state: –Current state –Input symbol To strengthen this we add a stack –The symbols on the stack may be different than input This results in the pushdown machine Copyright © Curt Hill
Pushdown automata The transition function now has three parameters Three things choose the next state: –Current state –Input symbol –Symbol on top of stack Any state transition may push or pop a symbol on/off the stack –Or decline to do so Copyright © Curt Hill
Pictures Copyright © Curt Hill Finite Control acba… Finite State Automaton Finite Control acba… Pushdown Automaton xyw… Input (r/o) Stack (r/w)
Transition Relation A finite state automaton has a transition function A pushdown automaton has a transition relation The parameters are: –The current input value –The current state –The top of stack The result is: –The new state –The action on the stack Copyright © Curt Hill
State Transitions The form is: (a, s, t) (s, n) a is the symbol on the input s is the state t is the top of the stack –0 means it is ignored n is the new action –0 means no action Copyright © Curt Hill
A very simple grammar V – {X} T – {a,b,c} S – X P –X ::= b –X ::= a X c This will give expressions of the form: a n bc n –b–b –aaabccc Why is this not a Type 3 grammar? Copyright © Curt Hill
Why is this not regular? The best we can do in a regular language is arbitrary string of a followed by one b and an arbitrary string of c a*bc* There is no way to force the number of as and cs to match The simple grammar above requires equal numbers Copyright © Curt Hill
Grammar State Transitions (a, s1, 0) (s1, push x) (b, s1, 0) (s2, 0) (c, s2, x) (s3, pop) (c, s3, x) (s3, pop) (c, s3, empty) (s4, 0) Copyright © Curt Hill
Graphics Copyright © Curt Hill Finite State Automata are simple –There representation is simple Push Down Automata are somewhat more complex –This makes the picture more complicated We will attempt: : a n bc n
PDA Copyright © Curt Hill s1s1 s2s2 s3s3 a,0 Push x b,0 c,x pop c,x pop s4s4 c,empty Transitions have two pieces to choose and one action –First is input, second is stack –Zero means ignore this input –Second line is action
What’s next? Turing machine A thought experiment devised by Alan Turing in 1936 –Original paper is 1937 Turing wanted to investigate what was and was not computable Copyright © Curt Hill
Description A finite state machine The input is now a tape that is infinite in both directions The finite automaton may read forward or backward as many times as desired Any symbol read may be rewritten –Not read/only like Finite State Machine or Pushdown machine Copyright © Curt Hill
In Practice and Theory In practice, this is a terrible way to make a computer In theory, there is no stronger means of computation –Strong: ability to compute a result This is one of the foundations of the theoretical computer science With the exception of the infinite storage a Turing machine is equivalent to Von Neumann machines Copyright © Curt Hill
Equivalence A CPU is a finite state machine –Very many states If we consider the memory/secondary storage as equivalent to tape the parallels should be clear –We may simulate an array with a list so random access memory is faster but not stronger than the tape Copyright © Curt Hill
Simulators There are a variety of simulators for a Turing machine on the web Here are few (2014) – – e/ e/ – ook/tmjava.htmlhttp:// ook/tmjava.html – er-turing-machine/ er-turing-machine/ Copyright © Curt Hill
Linear Bounded Recall that context sensitive languages may be handled by linear bounded automaton What is that? A Turing machine with limited tape that may make a limited number of passes through that tape Copyright © Curt Hill
Equivalences A Finite State Automaton may recognize a Type 3 or Regular Language A Push Down Automaton may recognize a Type 2 or Context Free Language A Linear Bounded Automaton may recognize a Type 1 or Context Sensitive Language A Turing Machine may recognize a Type 0 or any phrase structured language Copyright © Curt Hill