Social networks (Friends & Smokers)

The ProbLog program below encodes a variant of the famous Friends & Smokers problem. The first two rules state that there are two possible causes for a person X to smoke, namely X having stress, and X having a friend Y who smokes himself and influences X. Note that, according to our this program, the presence of stress and of (possibly multiple) smoking friends all contribute to the probability of the person X smoking, namely in a noisy-or way (recall the noisy-or in the coin tossing example). Furthermore, the program encodes that if X smokes, (s)he has asthma with probability 0.4.

The program below considers a scenario with 4 people, having a total of 5 friendship relations.

0.3::stress(X) :- person(X). 0.2::influences(X,Y) :- person(X), person(Y). smokes(X) :- stress(X). smokes(X) :- friend(X,Y), influences(Y,X), smokes(Y). 0.4::asthma(X) :- smokes(X). person(1). person(2). person(3). person(4). friend(1,2). friend(2,1). friend(2,4). friend(3,2). friend(4,2). evidence(smokes(2),true). evidence(influences(4,2),false). query(smokes(1)). query(smokes(3)). query(smokes(4)). query(asthma(1)). query(asthma(2)). query(asthma(3)). query(asthma(4)).

When pressing ‘Evaluate’, ProbLog2 calculates the probability of the various people smoking and having asthma, given the evidence that person 2 does not smoke and that person 4 does not influence person 2. We obtain P(smoke(1)) = 0.50877, P(smoke(3)) = 0.44, P(smoke(4)) = 0.44, P(asthma(1)) = 0.203508, P(asthma(2)) = 0.4, and P(asthma(3)) = P(asthma(4)) = 0.176.