5Protocol for Sending Data ReadySendingdata indonetimeoutStart
6FA Recognizing Strings Ending in “ing” Get next character in any state except the finish stateWhere we go depends on which characteremptySaw iiNot iSaw inggNot i or gSaw innNot i or nStartDouble circle denotes“finish” or “accepting”stateString recognized may not be the entire input
7Automata to CodeIn C/C++, make a piece of code for each state that does the followingReads the next input.Decides on the next state.Jumps to the beginning of the code for that state.
8Code 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 */. . .
9E-commerce example E-commerce requires protocols to prevent fraud Protocols can be modeled by finite automataExample: protocol to ensure that e-money is transferred from customer to merchant on shipped purchases
10E-commerce 2paycancelcancel2134startredeemtransferbankcustomerPay does not change state of customer. Free to cancel orderBank can go down either cancel path or path that leads to e-money transfer following a redeem request from e-store
11E-commerce 3 Store preferred path a->b->c->f->g redeemstartbcfegpayshiptransferstoreStore preferred path a->b->c->f->gAlternate paths allow ship before transfer complete
12This representation is not complete paycancelaredeemstartbcfegpayshiptransfercancel2134startredeemtransferAll parts must have adefined response to everyinput even if the responseis no change of state.
13Each loop labeled by actions that do not change states RstartbcfegPSTCP,CP,C,R,S,TC2134startRTP,SP,C,R,SP=payC=cancelR=redeemS=shipT=transfer
14Customer is in a “free” state startbcfegPSTCP,CP,C,S,R,TC2134startRTP,SP,C,R,SNo interactions betweenstore and bank canchange customer’s state
15Analysis 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
16Store-Bank product FAPaths exist to state (c,2) that has no exit. Customer cancelled and store shipped before transfer of payment from bank.
18Analysis of protocol using FA startbcfegPSTCP,CP,C,S,R,TC2134startRTP,SP,C,R,SIf customer state is C,then interactions betweenstore and bank canlead to failure
19Store-Bank product automaton 3 startbcfegPSTCP,CProduct automatonreveals problem withthe protocol. State(c,2) is accessiblefrom (a,1) but onlyloops back.C2134startRTP,SP,C,R,SState (c,2) is case wherestore has shipped beforeredeeming payment frombank and customer hascanceled
20Far out exampleOn 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.
21Strange 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.
22Strange 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?
23Relationship 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.
24Strange 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.
25Strange Planet with 2 Individuals 200002020110101011acball states are “must-fail”all possible events lead to states where have all same speciesanalogous to “termination” states automata
26“Meta-states” are populations of different size 200020002abc011101110This analysis of a “meta-state” consist of “exhaustiveenumeration”.List all possible species distributions.For each distribution, list all possible transitions.
27Strange Planet with 3 Individuals “must-fail” state111acb300030003aa210102021201120012cbbc“can’t-fail” states are parts of cycles.
28Strange Planet with 4 Individuals 400022130103211acb040202013310121bac004220301031112cba“might-fail” states appearSome breeding choices lead to terminationOthers lead to a cycle
29Taking Advantage of Symmetry In exhaustive enumeration of meta-states, we see repeated patterns.Nodes and edges have different labels but topology is same.200002020110101011acb
30Taking Advantage of Symmetry 2 Outcome (termination) is the same regardless of which species is extinct and which 2 have a single individual.200002020110101011acb
31Taking Advantage of Symmetry 3 Develop a “prototype” that illustrates states and transitions allowed for populations of various sizeList species-specific populations in decreasing orderReplace specific type of transition (a, b, c) with xprototype200002020110101011acb110200x
32Prototypes for 2, 3, 4x110200x211400111xxx300310x210220xThe “might-fail” state of prototype 4 is a nondeterminism.Different transitions are possible from 211 on the same input.
33Prototype for meta-state 5 Drop the unnecessary edge label “x”Prototype has standard form of a directed graphBasic graph algorithms can find cycles4105003203112211 must-fail state; 1 can’t fail cycle; 1 might fail state
34Strange planet example illustrates 3 types of states you could find in finite automata: must terminate, might terminate and can’t terminateMethods of analysis to find those states: exhaustive enumeration and graph theory