Smart students

These examples are from the slides of various tutorials on ProbLog, e.g., at IJCAI 2015

A small part of the school Bayesian network adapted from the CLP(BN) system in YAP Prolog:

0.6::difficult. 0.7::smart. 0.85::success :- difficult, smart. 0.10::success :- difficult, \+smart. 0.98::success :- \+difficult, smart. 0.45::success :- \+difficult, \+smart. query(difficult). query(smart). query(success).

The same network parameterized to account for several students and courses

0.6::difficult(C) :- course(C). course(C) :- takes(_,C). 0.7::smart(S) :- student(S). student(S) :- takes(S,_). 0.85::success(S,C) :- takes(S,C),difficult(C), smart(S). 0.10::success(S,C) :- takes(S,C),difficult(C), \+smart(S). 0.98::success(S,C) :- takes(S,C),\+difficult(C), smart(S). 0.45::success(S,C) :- takes(S,C),\+difficult(C), \+smart(S). takes(s1,c1). takes(s1,c2). takes(s2,c1). takes(s2,c2). takes(s3,c2). takes(s3,c4). query(difficult(_)). query(smart(_)). query(success(_,_)). evidence(difficult(c2)). evidence(success(s1,c2)).

Note that in the example above, we first project the takes/2 relation to its student or course argument respectively, and then use the new predicates to define smartness and difficulty. If we omit this step, each student taking a course provides an additional cause for the course to be difficult, and similarly for smartness:

0.6::difficult(C) :- takes(_,C). 0.7::smart(S) :- takes(S,_). 0.85::success(S,C) :- takes(S,C),difficult(C), smart(S). 0.10::success(S,C) :- takes(S,C),difficult(C), \+smart(S). 0.98::success(S,C) :- takes(S,C),\+difficult(C), smart(S). 0.45::success(S,C) :- takes(S,C),\+difficult(C), \+smart(S). takes(s1,c1). takes(s1,c2). takes(s2,c1). takes(s2,c2). takes(s3,c2). takes(s3,c4). query(difficult(_)). query(smart(_)). query(success(_,_)). evidence(difficult(c2)). evidence(success(s1,c2)).