/* Reasoning in Belief Networks in Picat v3. This is a port of the belief networks program from I. Bratko, "Prolog Programming for Artificial Intelligence", 4th edn., Pearson Education / Addison-Wesley 2012 Page 378ff (Figure 16.4 and 16.5) This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import belief_network_v3. main => go. go ?=> L = [ [burglary,[call]], [burglary,[call,lightning]], [burglary,[call,not lightning]], [burglary,[burglary,lightning]] ], foreach(T in L) println(T), prob(T[1],T[2],P), % page 380 println(p=P), nl end, nl. go => true. % Example % Figure 16.5 A specification of the belief network of Fig. 15.10 as % expected by the program of Fig. 15.11. % Belief network "sensor" parent( burglary, sensor). % Burglary tends to trigger sensor parent( lightning, sensor). % Strong lightning may trigger sensor parent( sensor, alarm). parent( sensor, call). p( burglary, 0.001). p( lightning, 0.02). p( sensor, [ burglary, lightning], 0.9). p( sensor, [ burglary, not lightning], 0.9). p( sensor, [ not burglary, lightning], 0.1). p( sensor, [ not burglary, not lightning], 0.001). p( alarm, [ sensor], 0.95). p( alarm, [ not sensor], 0.001). p( call, [ sensor], 0.9). p( call, [ not sensor], 0.0).