Download presentation

Presentation is loading. Please wait.

1
**Representation Application and Examples**

Finite Automata 1 Representation Application and Examples

2
What are FA? Finite automata are finite collections of states with transition rules that take you from one state to another.

3
**Representing FA Simplest representation is a graph. Nodes = states.**

Arcs indicate state transitions. Labels on arcs tell what causes the transition.

4
**FA model of on-off switch**

push on Start

5
**Protocol for Sending Data**

Ready Sending data in done timeout Start

6
**FA Recognizing Strings Ending in “ing”**

Get next character in any state except the finish state Where we go depends on which character empty Saw i i Not i Saw ing g Not i or g Saw in n Not i or n Start Double circle denotes “finish” or “accepting” state String recognized may not be the entire input

7
Automata to Code In C/C++, make a piece of code for each state that does the following Reads the next input. Decides on the next state. Jumps to the beginning of the code for that state.

8
**Code for state “saw i” 2: /* i seen */ c = getNextInput();**

if (c == ’n’) goto 3; else if (c == ’i’) goto 2; else goto 1; 3: /* ”in” seen */ . . .

9
**E-commerce example E-commerce requires protocols to prevent fraud**

Protocols can be modeled by finite automata Example: protocol to ensure that e-money is transferred from customer to merchant on shipped purchases

10
E-commerce 2 pay cancel cancel 2 1 3 4 start redeem transfer bank customer Pay does not change state of customer. Free to cancel order Bank can go down either cancel path or path that leads to e-money transfer following a redeem request from e-store

11
**E-commerce 3 Store preferred path a->b->c->f->g**

redeem start b c f e g pay ship transfer store Store preferred path a->b->c->f->g Alternate paths allow ship before transfer complete

12
**This representation is not complete**

pay cancel a redeem start b c f e g pay ship transfer cancel 2 1 3 4 start redeem transfer All parts must have a defined response to every input even if the response is no change of state.

13
**Each loop labeled by actions that do not change states**

R start b c f e g P S T C P,C P,C,R,S,T C 2 1 3 4 start R T P,S P,C,R,S P=pay C=cancel R=redeem S=ship T=transfer

14
**Customer is in a “free” state**

start b c f e g P S T C P,C P,C,S,R,T C 2 1 3 4 start R T P,S P,C,R,S No interactions between store and bank can change customer’s state

15
**Analysis of Store-Bank interactions reveals paths to failure of e-protocols**

Analysis requires “product” FA with all possible combinations of (store, bank) states and paths that connect them. Will discuss construction of product FAs later in course

16
Store-Bank product FA Paths exist to state (c,2) that has no exit. Customer cancelled and store shipped before transfer of payment from bank.

18
**Analysis of protocol using FA**

start b c f e g P S T C P,C P,C,S,R,T C 2 1 3 4 start R T P,S P,C,R,S If customer state is C, then interactions between store and bank can lead to failure

19
**Store-Bank product automaton 3**

start b c f e g P S T C P,C Product automaton reveals problem with the protocol. State (c,2) is accessible from (a,1) but only loops back. C 2 1 3 4 start R T P,S P,C,R,S State (c,2) is case where store has shipped before redeeming payment from bank and customer has canceled

20
Far out example On a distant planet, there are three species, a, b, and c. Any two different species can mate. If they do: The participants die. Two children of the third species are born.

21
Strange Planet – (2) Observation: the number of individuals never changes. The planet fails if at some point all individuals are of the same species. Then, no more breeding can take place. State = sequence of three integers – the numbers of individuals of species a, b, and c.

22
**Strange Planet – Questions**

In a given state, must the planet eventually fail? In a given state, is it possible for the planet to fail, if the wrong breeding choices are made?

23
**Relationship to Computers**

These questions mirror real ones about protocols. Planet “failure” is like protocol “termination” We want protocols to terminate “Must the planet fail” is like asking whether a protocol, in its current state, is guaranteed to terminate.

24
**Strange Planet – Transitions**

An a-event occurs when individuals of species b and c breed and are replaced by two a’s. Analogously: b-events and c-events. Represent these by symbols a, b, and c, respectively.

25
**Strange Planet with 2 Individuals**

200 002 020 110 101 011 a c b all states are “must-fail” all possible events lead to states where have all same species analogous to “termination” states automata

26
**“Meta-states” are populations of different size**

200 020 002 a b c 011 101 110 This analysis of a “meta-state” consist of “exhaustive enumeration”. List all possible species distributions. For each distribution, list all possible transitions.

27
**Strange Planet with 3 Individuals**

“must-fail” state 111 a c b 300 030 003 a a 210 102 021 201 120 012 c b b c “can’t-fail” states are parts of cycles.

28
**Strange Planet with 4 Individuals**

400 022 130 103 211 a c b 040 202 013 310 121 b a c 004 220 301 031 112 c b a “might-fail” states appear Some breeding choices lead to termination Others lead to a cycle

29
**Taking Advantage of Symmetry**

In exhaustive enumeration of meta-states, we see repeated patterns. Nodes and edges have different labels but topology is same. 200 002 020 110 101 011 a c b

30
**Taking Advantage of Symmetry 2**

Outcome (termination) is the same regardless of which species is extinct and which 2 have a single individual. 200 002 020 110 101 011 a c b

31
**Taking Advantage of Symmetry 3**

Develop a “prototype” that illustrates states and transitions allowed for populations of various size List species-specific populations in decreasing order Replace specific type of transition (a, b, c) with x prototype 200 002 020 110 101 011 a c b 110 200 x

32
Prototypes for 2, 3, 4 x 110 200 x 211 400 111 x x x 300 310 x 210 220 x The “might-fail” state of prototype 4 is a nondeterminism. Different transitions are possible from 211 on the same input.

33
**Prototype for meta-state 5**

Drop the unnecessary edge label “x” Prototype has standard form of a directed graph Basic graph algorithms can find cycles 410 500 320 311 221 1 must-fail state; 1 can’t fail cycle; 1 might fail state

34
**Strange planet example illustrates**

3 types of states you could find in finite automata: must terminate, might terminate and can’t terminate Methods of analysis to find those states: exhaustive enumeration and graph theory

Similar presentations

Presentation is loading. Please wait....

OK

Pushdown Automata (PDAs)

Pushdown Automata (PDAs)

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Editorial writing elementary ppt on cells Ppt on information technology act Ppt on money and credit for class 10th Ppt on current trends in hrm Ppt on advancement in science and technology Ppt on transportation in plants for class 10 Ppt on atm machine download Ppt on impact of french revolution Ppt on law of conservation of mass Ppt on drug addiction in india