Finite-State Machines (Automata) lecture 11 cl • a simple form of computation • used widely • one way to find patterns • with thanks to Gérard Berry 1
ATM wrong PIN insert card PIN ok withdraw e c n a l a b return card choose a/c withdraw take money amount no ok? r e t u r n c a r d yes £ 2
� Counting trains A B axle sensor (detects passing wheels) from-a-to-b : a ↓ ; b ↓ ; a ↑ ; b ↑ from-b-to-a : b ↓ ; a ↓ ; b ↑ ; a ↑ a b 3
Finite-state machines b axle sensor a ↓ b ↓ a ↑ b ↑ a b a b b ↓ b ↑ a ↑ a ↓ ab ba inputs : a ↑ , a ↓ , b ↑ , b ↓ a ↑ a ↓ b ↓ b ↑ outputs : b a from-a-to-b, b ↑ / from-a-to-b a ↑ / from-b-to-a from-b-to-a 4 a
� Hierarchical FSMs b A B carriage counter a2b b2a inputs : b2a a2b a2b , b2a b2a a2b b2a a2b outputs : A2B , B2A a2b a2b b2a b2a a2b / A2B b2a / B2A a2b = from-a-to-b 5
Application Fields Industry • real-time control, vending machines, cash dispensers, etc. Electronic circuits • data path / control path • memory / cache handling • protocols, USB, etc. Communication protocols • initiation and maintenance of communication links • error detection and handling, packet retransmission Language analysis • natural languages • programming languages 001 • search engines 6
A Decimal Number skip ε d + ⎮ − . S d d d d start end sta sta repetition alternative paths 7
finite state machines R S 8
sequence RS ε R S ε ε 9
alternation R|S ε ε R S ε ε 10
iteration R* ε ε R ε ε 11
finite state spaghetti 12
suss this? [^su] stands for any character except s or u [^su] [^su] [^su] su sus s <> s u s s u s [^s] state FSAs can be represented as: sus • s su [] - transition tables as well as sus • - graphs s s s input If you’re in state s and you’re looking at a u, go to u [] su [] su state su [^su] [] [] [] [] [^su] stands for any character except s or u 13
rara S r a r a r r 14
ra(ra)* S r a r r 15
(flip)|(flop) = fl(i|o)p S f l i p [] f fl fl(i|o) o 16
wha+m S w h a m wh [] w wha+ • [] w wh wha+ a w w [] [] [] h [] wh [] [] a wha+ [] [] wha+ • m [] [] [] 17
Recommend
More recommend