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.

32 lines
728 B

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