/*
* Four vikings are about to cross a damaged bridge in the middle of the
* night. The bridge can only carry two of the vikings at the time and to
* find the way over the bridge the vikings need to bring a torch. The
* vikings need 5, 10, 20 and 25 minutes (one-way) respectively to cross
* the bridge.
* Does a schedule exist which gets all four vikings over the bridge
* within 60 minutes?
*/
Prod chan &lputclock px;readydoneworkConschan &lgetclock cx;doneworkreadyBufchan &lput, chan &lgetHalfEmptyFullconst int fastest = 5;
chan put, get; // Take and release torch
clock time; // Global time
Client = Prod(put);
Service = Cons(get);
Buffer = Buf(put,get);
system Client, Service, Buffer;A[] not deadlock
The system is deadlock free.
E<> Viking1.safe
Viking 1 can cross the bridge.
E<> Viking2.safe
E<> Viking3.safe
A[] not (Viking4.safe and time<slowest)
E<> Viking4.safe imply time>=slowest
E<> Viking1.safe and Viking2.safe and Viking3.safe and Viking4.safe
Scheduling problem reformulated as reachability formula. Use
'Diagnostic Trace:Fastest' option to find fastest solution.