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.

45 lines
1.3 KiB

2 months ago
  1. // sum of two dice as the asynchronous parallel composition of
  2. // two copies of Knuth's model of a fair die using only fair coins
  3. mdp
  4. //Coin Probabilities
  5. const double p1;
  6. const double p2;
  7. module die1
  8. // local state
  9. s1 : [0..7] init 0;
  10. // value of the dice
  11. d1 : [0..6] init 0;
  12. [] s1=0 -> p1 : (s1'=1) + 1-p1 : (s1'=2);
  13. [] s1=1 -> p1 : (s1'=3) + 1-p1 : (s1'=4);
  14. [] s1=2 -> p1 : (s1'=5) + 1-p1 : (s1'=6);
  15. [] s1=3 -> p1 : (s1'=1) + 1-p1 : (s1'=7) & (d1'=1);
  16. [] s1=4 -> p1 : (s1'=7) & (d1'=2) + 1-p1 : (s1'=7) & (d1'=3);
  17. [] s1=5 -> p1 : (s1'=7) & (d1'=4) + 1-p1 : (s1'=7) & (d1'=5);
  18. [] s1=6 -> p1 : (s1'=2) + 1-p1 : (s1'=7) & (d1'=6);
  19. [] s1=7 & s2=7 -> 1: (s1'=7);
  20. endmodule
  21. module die2 = die1 [ s1=s2, s2=s1, d1=d2, p1=p2 ] endmodule
  22. rewards "coinflips"
  23. [] s1<7 | s2<7 : 1;
  24. endrewards
  25. label "done" = s1=7 & s2=7;
  26. label "two" = s1=7 & s2=7 & d1+d2=2;
  27. label "three" = s1=7 & s2=7 & d1+d2=3;
  28. label "four" = s1=7 & s2=7 & d1+d2=4;
  29. label "five" = s1=7 & s2=7 & d1+d2=5;
  30. label "six" = s1=7 & s2=7 & d1+d2=6;
  31. label "seven" = s1=7 & s2=7 & d1+d2=7;
  32. label "eight" = s1=7 & s2=7 & d1+d2=8;
  33. label "nine" = s1=7 & s2=7 & d1+d2=9;
  34. label "ten" = s1=7 & s2=7 & d1+d2=10;
  35. label "eleven" = s1=7 & s2=7 & d1+d2=11;
  36. label "twelve" = s1=7 & s2=7 & d1+d2=12;
  37. label "doubles" = s1=7 & s2=7 & d1=d2;