This example, extracted from Robin Milner's Communicating and Mobile Systems: the pi-calculus,
simulates the interaction going on between cell phones, the stations that directly communicate to the
cell phones and the centrals that regulate which station is to be used for the communications. The
general idea is to represent cell phone mobility, considering the shifting connectivity to the stations.
Starting by the definition of the behavior of a cell phone, it consists in either talking and continuing
with the initial communication links or switching to new communication links, which represents a
change of the station used for communication.
defproc Mobile(talk,switch)= select { talk?().Mobile(talk, switch); switch?(talkn, switchn).Mobile(talkn,switchn) };Now it is possible to define the station's behavior simply by saying that it can either communicate to the
defproc BaseStation(talk, switch, give, alert) = select { talk!().BaseStation(talk, switch, give, alert); give?(talkn, switchn).switch!(talkn,switchn). BaseStationIdle(talk,switch, give, alert) } and BaseStationIdle(talk, switch, give, alert) = alert?().BaseStation(talk, switch, give, alert);Finally we have the central whose job is simply to inform a base station that it has to give the connectivity
defproc Central(talk, talkNxt, switch, switchNxt, give, giveNxt, alert, alertNxt) = give!(talkNxt, switchNxt).alertNxt!().Central(talkNxt, talk, switchNxt, switch, giveNxt, give, alertNxt, alert);To finish off the process definitions a very simple system is defined having just one cell phone, the two
defproc System = (new talk1, talk2, switch1, switch2, give1, give2, alert1, alert2 in ( Mobile(talk1, switch1) | BaseStation(talk1,switch1,give1,alert1) | BaseStationIdle(talk2,switch2,give2,alert2) | Central(talk1, talk2, switch1, switch2, give1, give2, alert1, alert2) ));We now define a standard behavioral property that expresses that the system is never deadlocked, i.e.,
defprop deadLockFree = maxfix X. (<>true and []X);And we check to see if the system satisfies this property.
check System |= deadLockFree;We now intend to verify that our system is race free, or in other words, does not have two processes
defprop write(x) = (1 and < x! >true); defprop read(x) = (1 and < x? >true);We now state that the existence of a race can be specified by looking underneath all restrictions and
defprop hasRace = inside (exists x.(write(x) | write(x) | read(x) | true));Finally we state that race freeness is not having a race in any possible configuration.
defprop raceFree = maxfix X.((not hasRace) and []X);We check to see if our system satisfies this property.
check System |= raceFree;