Guarded Expressions guard Process example x0 gx P

  • Slides: 7
Download presentation
Guarded Expressions [guard] -> Process example [x>0] -> g!x; P Often used in choice,

Guarded Expressions [guard] -> Process example [x>0] -> g!x; P Often used in choice, e. g. [x>0] -> g!x; P [] [x==0] -> exit NB. Guards do not need to be exclusive [3==2] ->P == stop Example process comp[in, out](min, max: Nat): noexit : = in? x: Nat; [x<max && x>min] -> out!x; comp [in, out](min, max) [] [x<=min] -> out!min; comp [in, out](min, max) [] [x>=max] -> out!max; comp [in, out](min, max) endproc 1

Sequential Composition P >> Q behave like P, and if P terminates successfully, then

Sequential Composition P >> Q behave like P, and if P terminates successfully, then behave like Q. process enable example process Getinput[in](t: Token) : exit : = in? x: Token; [x == t] -> exit [] [x<> t] -> Getinput[in](t) endprocess Process_input[. . . ](. . . ) : exit : =. . . endproc Getinput[in](eof) >> Process_input[. . . ](. . . ) : exit 2

Disable P [> Q P can be interrupted by Q behave like P, unless

Disable P [> Q P can be interrupted by Q behave like P, unless Q interrupts. If Q interrupts, then behave like Q. Once P has terminated, Q cannot interrupt. process disable example P = g; h; exit Q = x; y; exit P [> Q == g; h; exit [] x; y; exit [] g; h; x; y; exit 3

Disable Expansion Theorem B = [] {bi; Bi| i e N} C= [] {ci;

Disable Expansion Theorem B = [] {bi; Bi| i e N} C= [] {ci; Ci| i e N} B[>C == C [] []{bi; (Bi[> C) | i e N} Example P = g; h; exit Q = x; y; exit P [> Q = Q [] []{g; (h; exit)[> Q} (i=1, j=1) h; exit [> Q == Q [] []{h; (exit[>Q)} exit [>Q == Q [] []{exit} == Q [] exit So, P[>Q == Q [] []{g; Q, g; h; exit} So, P[>Q == x; y; exit [] []{g; x; y; exit, g; h; exit} == x; y; exit [] g; h; exit} 4

Special Events Expansion Theorem d termination i internal event exit d stop P i

Special Events Expansion Theorem d termination i internal event exit d stop P i P’ i is used to represent true non-determinism. Example process machine[. . ](. . ). . : = coins; i; tea; exit [] i; coffee; exit [] i; stop endproc or a timeout …. Normalbehaviour [] i; disconnect 5

Hiding Process Two. Slot[in, out] : = hide mid in Buffer 1[in, mid] |[mid]|

Hiding Process Two. Slot[in, out] : = hide mid in Buffer 1[in, mid] |[mid]| Buffer 1[mid, out] endproc == in; i; (out; Two. Slot) [] in; out; i; (…. ) in mid out Multiway Synchronisation If you do not hid synchronisation events, synchronisation can be multi-way -- because parallelism operators are associative. Write P |[a]| Q |[a]| R Because (P |[a]| Q) |[a]| R == P |[a]| (Q |[a]| R) 6

Exercises 1. Write a LOTOS spec. of a simple system comprising a human operator

Exercises 1. Write a LOTOS spec. of a simple system comprising a human operator and an ATM. Basic customer behaviour includes: enter card, enter pin number, request money, take money. Assume events: cslot (card slot) mslot (money slot) keyboard screen 2. Now write a more elaborate spec. including behaviour such as: - the customer may be greedy (will take any money offered!) - the bank only issues money if the customer is not in overdraft - the card is kept if the pin is wrong. 7