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.

35 lines
761 B

  1. // Knuth's model of a fair die using only fair coins
  2. dtmc
  3. const double p;
  4. const double q;
  5. module die
  6. // local state
  7. s : [0..7] init 0;
  8. // value of the dice
  9. d : [0..6] init 0;
  10. [] s=0 -> p : (s'=1) + (1-p) : (s'=2);
  11. [] s=1 -> q : (s'=3) + (1-q) : (s'=4);
  12. [] s=2 -> q : (s'=5) + (1-q) : (s'=6);
  13. [] s=3 -> p : (s'=1) + (1-p) : (s'=7) & (d'=1);
  14. [] s=4 -> p : (s'=7) & (d'=2) + (1-p) : (s'=7) & (d'=3);
  15. [] s=5 -> p : (s'=7) & (d'=4) + (1-p) : (s'=7) & (d'=5);
  16. [] s=6 -> p : (s'=2) + (1-p) : (s'=7) & (d'=6);
  17. [] s=7 -> 1: (s'=7);
  18. endmodule
  19. rewards "coin_flips"
  20. [] s<7 : 1;
  21. endrewards
  22. label "one" = s=7&d=1;
  23. label "two" = s=7&d=2;
  24. label "three" = s=7&d=3;
  25. label "four" = s=7&d=4;
  26. label "five" = s=7&d=5;
  27. label "six" = s=7&d=6;
  28. label "done" = s=7;