Advertisement
rtjoa

"Boolean Programs" Model-Checked in Dice

Jan 19th, 2023
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.71 KB | None | 0 0
  1. # hack to allow us to use non-functional probabilistic ITE
  2. Base.ifelse(::Dist{Bool}, ::Any, ::Nothing) = DistUInt32(77)
  3. Base.ifelse(::Dist{Bool}, ::Nothing, ::Any) = DistUInt32(77)
  4.  
  5. choice() = flip(0.5)
  6.  
  7. function main()
  8.     c1, c2 = choice(), choice()
  9.     y = c1
  10.  
  11.     function getUnit()
  12.         x = false
  13.         if y
  14.             if c2
  15.                 y = false  # deleting this causes a ProbException (as it should)
  16.                 x = true
  17.             end
  18.         else
  19.             x = true
  20.         end
  21.  
  22.         if x
  23.             if y
  24.                 error("assert(F)")
  25.             end
  26.         end
  27.         true
  28.     end
  29.  
  30.     getUnit()
  31.     false  # dummy return value
  32. end
  33.  
  34. md = @dice main()
  35. pr(md)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement