Finite-State Machines (Automata) a simple form of computation used - - PDF document

finite state machines automata
SMART_READER_LITE
LIVE PREVIEW

Finite-State Machines (Automata) a simple form of computation used - - PDF document

Finite-State Machines (Automata) a simple form of computation used widely one way to find patterns Saturday, 3 December 2011 ATM insert card PIN ok withdraw e wrong PIN c n a l a b choose a/c t choose a/c a k e c a


slide-1
SLIDE 1

Finite-State Machines (Automata)

  • a simple form of computation
  • used widely
  • one way to find patterns

Saturday, 3 December 2011

slide-2
SLIDE 2

ATM

£

  • k?

yes choose a/c b a l a n c e withdraw insert card wrong PIN PIN ok amount choose a/c no t a k e c a r d return card

Saturday, 3 December 2011

slide-3
SLIDE 3

Counting trains

A B axle sensor (detects passing wheels) from-a-to-b : a↓ ; b↓ ; a↑ ; b↑

a b

from-b-to-a : b↓ ; a↓ ; b↑ ; a↑

Saturday, 3 December 2011

Consider the problem of keeping track of trains passing a level crossing. For simplicity we consider a single-carriage train. The carriage has four axles. We look at each axle end-on, so we just see one wheel. How can we check that the entire carriage has passed the sensor before we open the crossing. How do we make a sensor that can check the direction in which the train is moving? Our sensor has two overlapping arms. We get signals when they go down and up as a wheel rolls over them. If a wheel rolls over the sensor, going from a to b the we have the sequence a↓ ; b↓ ; a↑ ; b↑ If a wheel rolls in the other direction we have the sequence b↓ ; a↓ ; b↑ ; a↑ We must be careful, because when a train stops and starts it may sometimes roll backwards and forwards – and not just keep moving in its direction of travel. We need a diagram to see what can happen.

slide-4
SLIDE 4

Finite-state machines

axle sensor inputs : a↑, a↓, b↑, b↓

  • utputs :

from-a-to-b, from-b-to-a

a↓ b↓ a↑ b↑ / from-a-to-b b↓ a↓ b↑ a↑ / from-b-to-a

a b

a a a b b b ab ba

Saturday, 3 December 2011

This is a finite state machine (or automaton). The nodes of this graph are states and the arcs tell us how the machine changes from one state to another in response to input events. Here the events correspond to change of state. On the left-hand side of the diagram we keep track of a wheel that came from the left-hand a- direction; on the right-hand side, we keep track of a wheel that came from the right-hand b-direction. We keep track even if a wheel comes part-way over the sensor and then rolls back. Exercise for the students: Try drawing a state machine that takes the a→b and b→a events as inputs and out puts events A→B (when a carriage passes from left to right) and B→A (when a carriage passes from right to left). HINT: you can relabel the same diagram.

slide-5
SLIDE 5

Finite-state machines

axle sensor inputs : a↑, a↓, b↑, b↓

  • utputs :

from-a-to-b, from-b-to-a

a↓ b↓ a↑ b↑ / from-a-to-b b↓ a↓ b↑ a↑ / from-b-to-a b↑ a↑ a↓ b↑ a↑ b↓

a b

a a a b b b ab ba

Saturday, 3 December 2011

This is a finite state machine (or automaton). The nodes of this graph are states and the arcs tell us how the machine changes from one state to another in response to input events. Here the events correspond to change of state. On the left-hand side of the diagram we keep track of a wheel that came from the left-hand a- direction; on the right-hand side, we keep track of a wheel that came from the right-hand b-direction. We keep track even if a wheel comes part-way over the sensor and then rolls back. Exercise for the students: Try drawing a state machine that takes the a→b and b→a events as inputs and out puts events A→B (when a carriage passes from left to right) and B→A (when a carriage passes from right to left). HINT: you can relabel the same diagram.

slide-6
SLIDE 6

Hierarchical FSMs

carriage counter inputs : a2b, b2a

  • utputs :

A2B, B2A

a2b a2b b2a

a2b / A2B

b2a b2a b2a

b2a / B2A

b2a b2a a2b a2b a2b a2b

b

A B

a2b = from-a-to-b

Saturday, 3 December 2011

Here is the solution. We just keep track of how many axles have passed. Here we see an example of hierarchy – the outputs of one machine form the inputs of another. Many machines are constructed in this way – by connecting together simple finite-state machines. Weʼll come back to finite-state machines in a few minutes.

slide-7
SLIDE 7

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
  • search engines

Application Fields

001

Saturday, 3 December 2011

slide-8
SLIDE 8

A Decimal Number

d d

+⎮−

.

d d d ε sta sta S

Saturday, 3 December 2011

slide-9
SLIDE 9

A Decimal Number

d d

+⎮−

.

d d d ε start sta sta S

Saturday, 3 December 2011

slide-10
SLIDE 10

A Decimal Number

d d

+⎮−

.

d d d ε start end sta sta S

Saturday, 3 December 2011

slide-11
SLIDE 11

A Decimal Number

d d

+⎮−

.

d d d ε start end sta sta alternative paths S

Saturday, 3 December 2011

slide-12
SLIDE 12

A Decimal Number

d d

+⎮−

.

d d d ε start end sta sta alternative paths repetition S

Saturday, 3 December 2011

slide-13
SLIDE 13

A Decimal Number

d d

+⎮−

.

d d d ε start end sta sta alternative paths repetition skip S

Saturday, 3 December 2011

slide-14
SLIDE 14

finite state machines

R S

Saturday, 3 December 2011

slide-15
SLIDE 15

sequence RS

R S

ε ε ε

Saturday, 3 December 2011

The red lines are automatic transitions that can always happen, without any input. They are normally labelled ε

slide-16
SLIDE 16

alternation R|S

R S

ε ε ε ε

Saturday, 3 December 2011

The red lines are automatic transitions that can always happen, without any input. They are normally labelled ε

slide-17
SLIDE 17

iteration R*

R

ε ε ε ε

Saturday, 3 December 2011

The red lines are automatic transitions that can always happen, without any input. They are normally labelled ε

slide-18
SLIDE 18

finite state spaghetti

Saturday, 3 December 2011