Title: Guarded Expressions
1Guarded Expressions
guard -gt Process example xgt0 -gt g!x
P Often used in choice, e.g. xgt0 -gt g!x
P x0 -gt exit NB. Guards do not need to
be exclusive 32 -gtP stop Example
process compin,out(min,maxNat) noexit
in?xNat xltmax xgtmin -gt out!x comp
in,out(min,max) xltmin -gt out!min comp
in,out(min,max) xgtmax -gt out!max comp
in,out(min,max) endproc
2Sequential Composition
P gtgt Q behave like P, and if P
terminates
successfully, then behave like Q.
process enable example process
Getinputin(tToken) exit in?xToken
x t -gt exit xltgt t -gt Getinputin(t)
endproc process Process_input...(...) exit
... endproc Getinputin(eof) gtgt
Process_input...(...) exit
3Disable
P gt 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 ghexit Q
xy exit P gt Q ghexit
xyexit gxyexit
ghxyexit
4Disable
Expansion Theorem B bi Bi i e N C
ci Ci i e N BgtC C bi (Bigt C)
i e N Example P ghexit Q xy exit P gt
Q Q g(hexit)gt Q (i1,j1) hexit
gt Q Q h (exitgtQ) exit gtQ Q
exit Q exit So, PgtQ Q gQ,
ghQ, ghexit So, PgtQ xy exit
gxyexit, ghxyexit, ghexit
xyexit gxyexit ghxyexit
ghexit
5Special Events
Expansion Theorem d termination exit
d stop i internal event P i
P i is used to represent true
non-determinism. Example process
machine..(..) .. coins iteaexit
icoffeeexit istop endproc or a
timeout . Normalbehaviour idisconnect
6Hiding
Process TwoSlotin,out hide mid in
Buffer1in,mid mid Buffer1mid,out endproc
in i (out TwoSlot) 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)
7Exercises
- 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.