1/*
    2This program is inspired by the morphological characteristics of the Stromboli
    3Italian island.
    4The Stromboli island is located at the intersection of two geological faults, 
    5one in the southwest-northeast direction, the other in the east-west direction,
    6and contains one of the three volcanoes that are active in Italy. 
    7This program models the possibility that an eruption or an earthquake occurs at Stromboli.
    8
    9From
   10Elena Bellodi and Fabrizio Riguzzi. Structure learning of probabilistic logic 
   11programs by searching the clause space. Theory and Practice of Logic 
   12Programming, FirstView Articles, 2014
   13*/
   14:- use_module(library(pita)).   15
   16:- if(current_predicate(use_rendering/1)).   17:- use_rendering(c3).   18:- endif.   19
   20:- pita.   21
   22:- begin_lpad.   23
   24eruption : 0.6 ; earthquake : 0.3 :- 
   25  sudden_energy_release,
   26  fault_rupture(_).
   27% If there is a sudden energy release under the island and there is a fault 
   28% rupture, then there can be an eruption of the volcano on the island with 
   29% probability 0.6 or an earthquake in the area with probability 0.3
   30
   31sudden_energy_release : 0.7.
   32% The energy release occurs with probability 0.7 
   33
   34fault_rupture(southwest_northeast).
   35fault_rupture(east_west).
   36% we are sure that ruptures occur in both faults
   37
   38:- end_lpad.

?- prob(eruption,Prob). % what is the probability of an eruption? % expected result 0.588 ?- prob(earthquake,Prob). % what is the probability of an earthquake? % expected result 0.357 ?- prob(eruption,Prob),bar(Prob,C). % what is the probability of an eruption? % expected result 0.588 ?- prob(earthquake,Prob),bar(Prob,C). % what is the probability of an earthquake? % expected result 0.357

*/