Anfang A2b_v2
This commit is contained in:
parent
e41bd51c77
commit
250c28a74e
Binary file not shown.
|
@ -0,0 +1,4 @@
|
||||||
|
<root>
|
||||||
|
<spec>v2_spec.mcrl2</spec>
|
||||||
|
<properties/>
|
||||||
|
</root>
|
Binary file not shown.
|
@ -0,0 +1,55 @@
|
||||||
|
%-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
sort
|
||||||
|
CardinalDirection = struct north | east | south | west;
|
||||||
|
|
||||||
|
map
|
||||||
|
otherDirection : CardinalDirection -> CardinalDirection;
|
||||||
|
|
||||||
|
eqn
|
||||||
|
otherDirection(north) = south;
|
||||||
|
otherDirection(south) = north;
|
||||||
|
otherDirection(east) = west;
|
||||||
|
otherDirection(west) = east;
|
||||||
|
|
||||||
|
%-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
sort
|
||||||
|
Colour = struct red | green | yellow;
|
||||||
|
|
||||||
|
map
|
||||||
|
nextColour: Colour -> Colour;
|
||||||
|
|
||||||
|
eqn
|
||||||
|
nextColour(red) = green;
|
||||||
|
nextColour(green) = yellow;
|
||||||
|
nextColour(yellow) = red;
|
||||||
|
|
||||||
|
|
||||||
|
%------------------------------------------------------------------------
|
||||||
|
|
||||||
|
act
|
||||||
|
show : CardinalDirection # Colour;
|
||||||
|
crossingUnsafe : Colour # Colour # Colour # Colour;
|
||||||
|
safe : Bool;
|
||||||
|
emptyAct;
|
||||||
|
|
||||||
|
%------------------------------------------------------------------------
|
||||||
|
|
||||||
|
proc
|
||||||
|
TrafficLight(direction : CardinalDirection) = TF(direction, red);
|
||||||
|
|
||||||
|
TF(direction : CardinalDirection, colour : Colour) =
|
||||||
|
show(direction, colour) . TF(direction, nextColour(colour))
|
||||||
|
;
|
||||||
|
|
||||||
|
Monitor =
|
||||||
|
emptyAct
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
init
|
||||||
|
TrafficLight(north) || TrafficLight(east) || TrafficLight(south) || TrafficLight(west) || Monitor
|
||||||
|
;
|
Binary file not shown.
Binary file not shown.
|
@ -65,14 +65,15 @@ act
|
||||||
% Definition of the processes
|
% Definition of the processes
|
||||||
%
|
%
|
||||||
proc
|
proc
|
||||||
VendingMachine = VM(0);
|
|
||||||
|
|
||||||
VM(credit : Int) =
|
VM(credit : Int) =
|
||||||
(credit < 200) -> sum c : Coin.accept(c).VM(credit + value(c))
|
(credit < 200) -> sum c : Coin.accept(c).VM(credit + value(c))
|
||||||
+ (credit > 0) -> returnChange(credit).ReturnChange(credit);
|
|
||||||
|
+ (credit > 0) -> returnChange(credit).ReturnChange(credit)
|
||||||
|
|
||||||
+ sum p : Product.(
|
+ sum p : Product.(
|
||||||
(credit >= price(p)) -> offer(p).serve(p).VM(credit - price(p))
|
(credit >= price(p)) -> offer(p).serve(p).VM(credit - price(p))
|
||||||
)
|
);
|
||||||
|
|
||||||
|
|
||||||
ReturnChange(credit : Int) =
|
ReturnChange(credit : Int) =
|
||||||
|
@ -80,8 +81,10 @@ proc
|
||||||
((credit - value(c)) > 0) -> ReturnChange(credit - value(c)) <> VM(credit - value(c))
|
((credit - value(c)) > 0) -> ReturnChange(credit - value(c)) <> VM(credit - value(c))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
init
|
init
|
||||||
VendingMachine
|
VM(0)
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in New Issue