ex1.smv 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. MODULE main
  2. VAR
  3. semaphore : boolean;
  4. proc1 : process user(semaphore);
  5. proc2 : process user(semaphore);
  6. ASSIGN
  7. init(semaphore) := FALSE;
  8. -- safety property: for all executions, both states cannot be critical at the same time
  9. SPEC AG !(proc1.state = critical & proc2.state = critical)
  10. -- liveness property: for all executions, if proc2 enters, it must eventually become critical
  11. LTLSPEC G (proc2.state = entering -> F proc2.state = critical)
  12. MODULE user(semaphore)
  13. VAR
  14. state : {idle, entering, critical, exiting};
  15. ASSIGN
  16. init(state) := idle;
  17. next(state) :=
  18. case
  19. state = idle : {idle, entering};
  20. state = entering & !semaphore : critical;
  21. state = critical : {critical, exiting};
  22. state = exiting : idle;
  23. TRUE : state;
  24. esac;
  25. next(semaphore) :=
  26. case
  27. state = entering : TRUE;
  28. state = exiting : FALSE;
  29. TRUE : semaphore;
  30. esac;
  31. FAIRNESS
  32. running