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(viterbi)).   15
   16:- if(current_predicate(use_rendering/1)).   17:- use_rendering(c3).   18:- endif.   19
   20:- viterbi.   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) : 0.6.
   35fault_rupture(east_west) : 0.55.
   36
   37:- end_lpad.

?- viterbi(eruption,P,E). P = 0.252, E = [rule(0, eruption, [eruption:0.6, earthquake:0.3, '':0.10000000000000003], [sudden_energy_release, fault_rupture(southwest_northeast)]), rule(1, sudden_energy_release, [sudden_energy_release:0.7, '':0.30000000000000004], []), rule(2, fault_rupture(southwest_northeast), [fault_rupture(southwest_northeast):0.6, '':0.4], [])].

*/