1:- use_module(library(pita)).    2
    3:- if(current_predicate(use_rendering/1)).    4:- use_rendering(graphviz).    5:- endif.    6
    7:- pita.    8
    9:- begin_lpad.   10
   11intelligent:0.5.
   12
   13good_marks:0.5.
   14
   15difficult_course:0.5.
   16
   17good_teacher:0.5.
   18
   19% factor1(intelligent,good_marks)=3/10 if not intelligent or good_marks, 
   20% 1/10 otherwise
   21factor1: 3/10:- \+intelligent, \+good_marks.
   22factor1: 3/10:- \+intelligent, good_marks.
   23factor1: 1/10:- intelligent, \+good_marks.
   24factor1: 3/10:- intelligent, good_marks.
   25
   26% factor2(difficult_course,good_marks)=3/10 if 
   27% not difficult_course or not good_marks, 
   28% 1/10 otherwise
   29factor2: 3/10:- \+difficult_course, \+good_marks.
   30factor2: 3/10:- \+difficult_course, good_marks.
   31factor2: 3/10:- difficult_course, \+good_marks.
   32factor2: 1/10:- difficult_course, good_marks.
   33
   34% factor3(good_teacher,good_marks)=3/10 if not good_teacher or good_marks, 
   35% 1/10 otherwise
   36factor3: 3/10:- \+good_teacher, \+good_marks.
   37factor3: 3/10:- \+good_teacher, good_marks.
   38factor3: 1/10:- good_teacher, \+good_marks.
   39factor3: 3/10:- good_teacher, good_marks.
   40
   41% factor4(good_teacher,difficult_course)=3/10 
   42% if not good_teacher or not good_marks, 
   43% 1/10 otherwise
   44factor4: 3/10:- \+difficult_course, \+good_teacher.
   45factor4: 3/10:- \+difficult_course, good_teacher.
   46factor4: 3/10:- difficult_course, \+good_teacher.
   47factor4: 1/10:- difficult_course, good_teacher.
   48
   49evidence:- factor1,factor2,factor3,factor4.
   50
   51intelligent_ev:-intelligent,evidence.
   52
   53good_teacher_int_ev:-intelligent_ev,good_teacher.
   54:- end_lpad.   55network_structure(graph([
   56  intelligent-good_marks,good_marks-difficult_course,
   57  difficult_course-good_teacher,
   58  good_teacher-good_marks])).

?- prob(good_marks,evidence,P). ?- prob(good_marks,intelligent_ev,P). ?- prob(good_marks,good_teacher_int_ev,P). ?- network_structure(G).

*/