You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

  1. // herman's self stabilising algorithm [Her90]
  2. // gxn/dxp 13/07/02
  3. // the procotol is synchronous with no nondeterminism (a DTMC)
  4. dtmc
  5. // coin
  6. const double p;
  7. // module for process 1
  8. module process1
  9. // Boolean variable for process 1
  10. x1 : [0..1];
  11. i1 : bool init false;
  12. [initial] (!i1) -> 0.5 : (x1'=0) & (i1'=true) + 0.5 : (x1'=1) & (i1'=true);
  13. [step] (i1 & x1=x0) -> p : (x1'=0) + 1-p : (x1'=1);
  14. [step] (i1 & x1!=x0) -> (x1'=x0);
  15. endmodule
  16. // add further processes through renaming
  17. module process2 = process1 [ x1=x2, x0=x1, i1=i2 ] endmodule
  18. module process3 = process1 [ x1=x3, x0=x2, i1=i3 ] endmodule
  19. module process4 = process1 [ x1=x4, x0=x3, i1=i4 ] endmodule
  20. module process5 = process1 [ x1=x0, x0=x4, i1=i5 ] endmodule
  21. formula initialized = i1 & i2 & i3 & i4 & i5;
  22. // cost - 1 in each state (expected number of steps)
  23. rewards "steps"
  24. initialized : 1;
  25. endrewards
  26. // formula, for use in properties: number of tokens
  27. // (i.e. number of processes that have the same value as the process to their left)
  28. formula num_tokens = (x1=x0?1:0)
  29. +(x2=x1?1:0)
  30. +(x3=x2?1:0)
  31. +(x4=x3?1:0)
  32. +(x0=x4?1:0);
  33. // label - stable configurations (1 token)
  34. label "stable" = num_tokens=1 & initialized;