Mohamed
Mohamed

Reputation: 29

Vending Machine in NuSMV

I am new to NuSMV, I am trying to create Vending Machine implementation from Kripke structure, I have three boolean (coin, selection, brewing) as well as three states.However, When I compile the code I receive "Line 25: at token ":": syntax error" If anyone sees any errors in my code I would appreciate the help.

Kripke structure

my attempt to write the code is as follow:

MODULE main 

VAR 

   location : {s1,s2,s3};
   coin : boolean;
   selection: boolean;
   brweing: boolean;

ASSIGN

   init(location) := s1;
   init(coin) := FALSE;
   init(selection) := FALSE;
   init(brweing) := FALSE;
   next(location) := 
case
    location = s1 : s2;
    TRUE: coin;  
esac;

next(location) :=
case

location = (s2 : s3 & (TRUE: selection));

location = (s2 : s1 & (FALSE: selection) & (FALSE: coin));
esac;
next(location) :=
case

location = (s3 : s3 & (TRUE: brewing));

location = (s3 : s1 & (FALSE: selection) & (FALSE: coin) & (FALSE: brewing));
esac;


-- specification
•   AG [s ⇒ b] whenever a selection is made coffee is brewed for sure.
•   E [(¬s) U (b)] the coffee will not be brewed as no selection were made.
•   EF[b] there is a state where coffee is brewed.

Upvotes: 1

Views: 682

Answers (2)

Taejoon Byun
Taejoon Byun

Reputation: 109

What I understand from the model is that coin, selection and brew are not only labels but events that trigger the transition. If so, I would write the model like this:

MODULE main
VAR
    location: {s1, s2, s3};
    coin: boolean;
    selection: boolean;
    brew: boolean;
    abort: boolean;

INIT
    !coin & !selection & !brew;

ASSIGN
    init(location) := s1;
    next(location) := case
        location = s1 & next(coin)      : s2;
        location = s2 & next(selection) : s3;
        location = s2 & next(abort)     : s1;
        location = s3                   : {s1, s3};
        TRUE                            : location;
    esac;
    next(brew) := (next(location) = s3);
    next(coin) := case
        next(state) = s1  : FALSE;
        state = s1        : {TRUE, FALSE};
        TRUE              : coin;
    esac;
    next(selection) := case
        state = s2        : {TRUE, FALSE};
        next(state) = s1  : FALSE;
    esac;

Upvotes: 1

dejvuth
dejvuth

Reputation: 7146

The line (among others)

location = (s2 : s3 & (TRUE: selection));

doesn't make much sense. You need only one next statement to assign the next location from all possible values of location. Also, you don't need to declare coin, selection, and brewing as variables. Use DEFINE to define their values based on location:

MODULE main

VAR
   location : {s1,s2,s3};

ASSIGN
  init(location) := s1;
  next(location) :=
  case
    location = s1 : s2;
    location = s2 : {s1,s3};
    location = s3 : {s1,s3};
  esac;

DEFINE
  coin := location = s2 | location = s3;
  -- similarly for selection and brewing

Upvotes: 2

Related Questions