The examples on this page are ProbLog versions of those in Claret et al, Bayesian Inference Using Data Flow Analysis, ESEC/FSE 2013 (and the appendix of the accompagnying technical report).
Tossing two fair coins: what are the outcomes?
Tossing two fair coins and observing at least one comes up heads: what are the outcomes?
While loop with probabilistic condition c: what is the final value of b if we start with true and toggle on every execution of the while loop?
The goal is to keep tossing two coins until at least one of them comes up heads, and then report the outcomes of the last toss.
Here’s a first (wrong) attempt:
Clearly, the probability of every return combination should decrease over time, and not oscillate as it does here. The problem is that ProbLog uses Prolog’s negation as failure, which means or_c1_c2(TT) also fails (and its negation succeeds) if we did not toss any coin at TT (because the or was false at TT-1). We can fix that by making explicit that we stop tossing if we see some heads.
Simulating a coin with parameter p comparing up to d digits of the binary expansion of p to a sequence of bits drawn uniformly at random.
Here’s a version that takes the list of bits in the binary expansion as input:
Simulating a uniform distribution over [0,N-1]
An example of a soft constraint in a students and teachers setting, with an arbitrary input database added.
A more complex soft constraint that depends on random variables, not just the input database as in the students example above.
We have two random n-bit sequences a and b and observe that a<b. What are the posterior probabilities of the individual bits?
Keep tossing a coin until it comes up heads.