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.

40 lines
1.2 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. module die1
  5. // local state
  6. s1 : [0..7] init 0;
  7. // value of the dice
  8. d1 : [0..6] init 0;
  9. [] s1=0 -> 0.5 : (s1'=1) + 0.5 : (s1'=2);
  10. [] s1=1 -> 0.5 : (s1'=3) + 0.5 : (s1'=4);
  11. [] s1=2 -> 0.5 : (s1'=5) + 0.5 : (s1'=6);
  12. [] s1=3 -> 0.5 : (s1'=1) + 0.5 : (s1'=7) & (d1'=1);
  13. [] s1=4 -> 0.5 : (s1'=7) & (d1'=2) + 0.5 : (s1'=7) & (d1'=3);
  14. [] s1=5 -> 0.5 : (s1'=7) & (d1'=4) + 0.5 : (s1'=7) & (d1'=5);
  15. [] s1=6 -> 0.5 : (s1'=2) + 0.5 : (s1'=7) & (d1'=6);
  16. [] s1=7 & s2=7 -> 1: (s1'=7);
  17. endmodule
  18. module die2 = die1 [ s1=s2, s2=s1, d1=d2 ] endmodule
  19. rewards "coinflips"
  20. [] s1<7 | s2<7 : 1;
  21. endrewards
  22. label "done" = s1=7 & s2=7;
  23. label "two" = s1=7 & s2=7 & d1+d2=2;
  24. label "three" = s1=7 & s2=7 & d1+d2=3;
  25. label "four" = s1=7 & s2=7 & d1+d2=4;
  26. label "five" = s1=7 & s2=7 & d1+d2=5;
  27. label "six" = s1=7 & s2=7 & d1+d2=6;
  28. label "seven" = s1=7 & s2=7 & d1+d2=7;
  29. label "eight" = s1=7 & s2=7 & d1+d2=8;
  30. label "nine" = s1=7 & s2=7 & d1+d2=9;
  31. label "ten" = s1=7 & s2=7 & d1+d2=10;
  32. label "eleven" = s1=7 & s2=7 & d1+d2=11;
  33. label "twelve" = s1=7 & s2=7 & d1+d2=12;