Skip to content

Commit

Permalink
added model
Browse files Browse the repository at this point in the history
  • Loading branch information
ianno committed Nov 5, 2014
1 parent d62bee6 commit b266dc7
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
eecs149_spin
============
SPIN model inspired by the Cruise control state machine used in UC Berkeley
EECS 149/249 (Fall 2014) midterm 1.
The model sets a simple state machine, a non-deterministic environment and
a set of 4 LTL properties are verified.

The LTL properties are:
1. (x == ENABLE) -> <> (state == OFF)
2. []((x == DISABLE) -> <>(state == OFF))
3. [](count == 0) -> <>(state == OFF)
4. []( (state == HOLD) -> ((x != DISABLE) && (x != RESUME) )) -> <>(state == STANDBY)

Author: Antonio Iannopollo
Email: [email protected]

Fall 2014 EECS 149/249 spin tutorial model
88 changes: 88 additions & 0 deletions cruise.pml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* SPIN model inspired by the Cruise control state machine used in UC Berkeley
* EECS 149/249 (Fall 2014) midterm 1.
* The model sets a simple state machine, a non-deterministic environment and
* a set of 4 LTL properties are verified.
*
* Author: Antonio Iannopollo
*/

//definition of input values
mtype = {ENABLE, SET, CANCEL, BRAKE, RESUME, DISABLE};
//state definition
mtype = {OFF, STANDBY, CRUISE, HOLD};

//state machine variables
mtype state = OFF;
byte count = 0;
mtype x = SET;

//communication channel
chan input = [0] of {mtype};

/*
* Non-deterministic environment
*/
active proctype Environment() {
do
::if
:: input ! ENABLE;
:: input ! SET;
:: input ! CANCEL;
:: input ! BRAKE;
:: input ! RESUME;
:: input ! DISABLE;
fi;
//or equivalently
//select(x : DISABLE .. ENABLE);
od;
}

/*
* Cruise control state machine
*/
active proctype Cruise() {
do
:: atomic { input ? x ->
if
:: (state == OFF) && (x == ENABLE) ->
count = 0; state = STANDBY;
:: (state == STANDBY) && (x == DISABLE) ->
state = OFF;
:: (state == STANDBY) && (x == SET) ->
state = CRUISE;
:: (state == CRUISE) && (x == DISABLE) ->
state = OFF;
:: (state == CRUISE) && (x == CANCEL) ->
state = STANDBY;
:: (state == CRUISE) && (x == BRAKE) ->
state = HOLD;
:: (state == HOLD) && (x == RESUME) ->
state = CRUISE;
:: (state == HOLD) && (x == DISABLE) ->
state = OFF;
:: (state == HOLD) && ((count == 2) || (x == CANCEL)) ->
count = 0; state = STANDBY
:: (state == HOLD) && ! ((x == RESUME) || \
(x == DISABLE) || ((count == 2) || (x == CANCEL)) ) ->
count = count + 1;
:: else -> skip;
fi;
}
od;

}


/*
* LTL properties
*/

ltl p1 { (x == ENABLE) -> <> (state == OFF) }

ltl p2 { []((x == DISABLE) -> <>(state == OFF)) }

ltl p3 { [](count == 0) -> <>(state == OFF)}

ltl p4 { []( (state == HOLD) -> ((x != DISABLE) && (x != RESUME) )) -> <>(state == STANDBY) }

0 comments on commit b266dc7

Please sign in to comment.