1/*
    2UWCSE model describing a university domain.
    3This theory is the result of translating a Logical Bayesian Network (LBN) constructed on the UWCSE dataset into CP-logic
    4From
    5http://dtai.cs.kuleuven.be/cplve/ilp09/
    6Reference:
    7Wannes Meert, Jan Struyf, Hendrik Blockeel: CP-Logic Theory Inference with Contextual Variable Elimination and Comparison to BDD Based Inference Methods. ILP 2009:96-109
    8*/
    9:- use_module(library(pita)).   10
   11:- if(current_predicate(use_rendering/1)).   12:- use_rendering(c3).   13:- use_rendering(graphviz).   14:- use_rendering(table,[header(['Multivalued variable index','Rule index','Grounding substitution'])]).   15:- endif.   16
   17:- pita.   18
   19
   20:- begin_lpad.   21
   22course(c1).
   23
   24professor(p1).
   25
   26student(s1).
   27
   28student(s2).
   29
   30student(s3).
   31
   32student(s4).
   33
   34advised_by(A,B):0.10708782742681 :-
   35    student(A),
   36    professor(B),
   37    position(B,faculty).
   38
   39advised_by(A,B):0.0278422273781903 :-
   40    student(A),
   41    professor(B),
   42    \+position(B,faculty).
   43
   44course_level(A,level_300):0.0666666666666667; course_level(A,level_400):0.318518518518519; course_level(A,level_500):0.614814814814815 :-
   45    course(A).
   46
   47phase(A,post_Generals):0.935483870967742; phase(A,post_Quals):0.032258064516129; phase(A,pre_Quals):0.032258064516129 :-
   48    student(A),
   49    years_in_program(A,year_6_or_more).
   50
   51phase(A,post_Generals):0.04; phase(A,post_Quals):0.04; phase(A,pre_Quals):0.92 :-
   52    student(A),
   53    \+years_in_program(A,year_6_or_more),
   54    years_in_program(A,year_1).
   55
   56phase(A,post_Generals):0.566666666666667; phase(A,post_Quals):0.366666666666667; phase(A,pre_Quals):0.0666666666666667 :-
   57    student(A),
   58    \+years_in_program(A,year_6_or_more),
   59    \+years_in_program(A,year_1),
   60    years_in_program(A,year_5).
   61
   62phase(A,post_Generals):0.222222222222222; phase(A,post_Quals):0.666666666666667; phase(A,pre_Quals):0.111111111111111 :-
   63    student(A),
   64    \+years_in_program(A,year_6_or_more),
   65    \+years_in_program(A,year_1),
   66    \+years_in_program(A,year_5),
   67    years_in_program(A,year_4).
   68
   69phase(A,post_Generals):0.0476190476190476; phase(A,post_Quals):0.547619047619048; phase(A,pre_Quals):0.404761904761905 :-
   70    student(A),
   71    \+years_in_program(A,year_6_or_more),
   72    \+years_in_program(A,year_1),
   73    \+years_in_program(A,year_5),
   74    \+years_in_program(A,year_4).
   75
   76position(A,faculty):0.732142857142857; position(A,faculty_adjunct):0.125; position(A,faculty_affiliate):0.0714285714285714; position(A,faculty_emeritus):0.0714285714285714 :-
   77    professor(A).
   78
   79aux1_prof_nb_publications(A) :-
   80    advised_by(B,A),
   81    student_nb_publications(B,three_or_more).
   82
   83prof_nb_publications(A,none):0.0416666666666667; prof_nb_publications(A,one_to_nine):0.416666666666667; prof_nb_publications(A,ten_or_more):0.541666666666667 :-
   84    professor(A),
   85    aux1_prof_nb_publications(A).
   86
   87prof_nb_publications(A,none):0.5; prof_nb_publications(A,one_to_nine):0.294117647058824; prof_nb_publications(A,ten_or_more):0.205882352941176 :-
   88    professor(A),
   89    \+aux1_prof_nb_publications(A).
   90
   91shared_publication(A,B):0.00101010101010101 :-
   92    professor(A),
   93    student(B),
   94    student_nb_publications(B,none).
   95
   96shared_publication(A,B):0.956521739130435 :-
   97    professor(A),
   98    student(B),
   99    \+student_nb_publications(B,none),
  100    advised_by(B,A),
  101    years_in_program(B,year_6_or_more).
  102
  103shared_publication(A,B):0.125 :-
  104    professor(A),
  105    student(B),
  106    \+student_nb_publications(B,none),
  107    advised_by(B,A),
  108    \+years_in_program(B,year_6_or_more),
  109    prof_nb_publications(A,none).
  110
  111shared_publication(A,B):0.631578947368421 :-
  112    professor(A),
  113    student(B),
  114    \+student_nb_publications(B,none),
  115    advised_by(B,A),
  116    \+years_in_program(B,year_6_or_more),
  117    \+prof_nb_publications(A,none).
  118
  119shared_publication(A,B):0.00515463917525773 :-
  120    professor(A),
  121    student(B),
  122    \+student_nb_publications(B,none),
  123    \+advised_by(B,A),
  124    prof_nb_publications(A,none).
  125
  126shared_publication(A,B):0.099236641221374 :-
  127    professor(A),
  128    student(B),
  129    \+student_nb_publications(B,none),
  130    \+advised_by(B,A),
  131    \+prof_nb_publications(A,none),
  132    prof_nb_publications(A,one_to_nine),
  133    student_nb_publications(B,one_or_two).
  134
  135shared_publication(A,B):0.0152671755725191 :-
  136    professor(A),
  137    student(B),
  138    \+student_nb_publications(B,none),
  139    \+advised_by(B,A),
  140    \+prof_nb_publications(A,none),
  141    prof_nb_publications(A,one_to_nine),
  142    \+student_nb_publications(B,one_or_two).
  143
  144shared_publication(A,B):0.146017699115044 :-
  145    professor(A),
  146    student(B),
  147    \+student_nb_publications(B,none),
  148    \+advised_by(B,A),
  149    \+prof_nb_publications(A,none),
  150    \+prof_nb_publications(A,one_to_nine).
  151
  152student_nb_publications(A,none):0.594405594405594; student_nb_publications(A,one_or_two):0.195804195804196; student_nb_publications(A,three_or_more):0.20979020979021 :-
  153    student(A).
  154
  155aux1_taught_by(A,B) :-
  156    teaching_assistant(A,C),
  157    advised_by(C,B).
  158
  159aux2_taught_by(A,B) :-
  160    teaching_assistant(A,C),
  161    advised_by(C,B),
  162    shared_publication(B,C).
  163
  164taught_by(A,B):0.777777777777778 :-
  165    course(A),
  166    professor(B),
  167    aux1_taught_by(A,B),
  168    aux2_taught_by(A,B).
  169
  170taught_by(A,B):0.333333333333333 :-
  171    course(A),
  172    professor(B),
  173    aux1_taught_by(A,B),
  174    \+aux2_taught_by(A,B).
  175
  176taught_by(A,B):0.266666666666667 :-
  177    course(A),
  178    professor(B),
  179    \+aux1_taught_by(A,B),
  180    position(B,faculty),
  181    course_level(A,level_300).
  182
  183taught_by(A,B):0.102941176470588 :-
  184    course(A),
  185    professor(B),
  186    \+aux1_taught_by(A,B),
  187    position(B,faculty),
  188    \+course_level(A,level_300).
  189
  190taught_by(A,B):0.029673590504451 :-
  191    course(A),
  192    professor(B),
  193    \+aux1_taught_by(A,B),
  194    \+position(B,faculty).
  195
  196teaching_assistant(A,B):0.0333333333333333 :-
  197    course(A),
  198    student(B),
  199    course_level(A,level_300),
  200    student_nb_publications(B,three_or_more).
  201
  202teaching_assistant(A,B):0.158227848101266 :-
  203    course(A),
  204    student(B),
  205    course_level(A,level_300),
  206    \+student_nb_publications(B,three_or_more).
  207
  208teaching_assistant(A,B):0.0337519623233909 :-
  209    course(A),
  210    student(B),
  211    \+course_level(A,level_300),
  212    course_level(A,level_400).
  213
  214teaching_assistant(A,B):0.0120999219359875 :-
  215    course(A),
  216    student(B),
  217    \+course_level(A,level_300),
  218    \+course_level(A,level_400).
  219
  220years_in_program(A,year_1):0.244444444444444; years_in_program(A,year_2):0.155555555555556; years_in_program(A,year_3):0.233333333333333; years_in_program(A,year_4):0.144444444444444; years_in_program(A,year_5):0.111111111111111; years_in_program(A,year_6_or_more):0.111111111111111 :-
  221    student(A),
  222    student_nb_publications(A,none).
  223
  224years_in_program(A,year_1):0.032258064516129; years_in_program(A,year_2):0.0645161290322581; years_in_program(A,year_3):0.0645161290322581; years_in_program(A,year_4):0.209677419354839; years_in_program(A,year_5):0.306451612903226; years_in_program(A,year_6_or_more):0.32258064516129 :-
  225    student(A),
  226    \+student_nb_publications(A,none).
  227
  228:- end_lpad.

?- prob(taught_by(c1,p1),Prob). % what is the probability that course c1 is taught by professor p1? % expected result 0.09265809305111444 ?- prob_bar(taught_by(c1,p1),Prob). % what is the probability that course c1 is taught by professor p1? % expected result 0.09265809305111444 ?- bdd_dot_string(taught_by(c1,p1),B,V). % draw the bdd for the query

*/