:- dynamic at_work/0, friends/1, familyOrFriends/1, family/1, in_meeting/0, from_son/1, son_at_school/0.
:-compile('gorgias-src-0.6d/lib/gorgias.pl').
:-compile('gorgias-src-0.6d/ext/lpwnf.pl').
:-consult('backgroundRalf.pl').
rule(r1(Call), allow(Call), []).
rule(r2(Call), deny_without_explanation(Call), []).
rule(r3(Call), deny_with_explanation(Call), []).
rule(p1(Call), prefer(r1(Call), r2(Call)), []).
rule(p2(Call), prefer(r1(Call), r3(Call)), []).
rule(p3(Call), prefer(r2(Call), r1(Call)), []):-at_work.
rule(p4(Call), prefer(r3(Call), r1(Call)), []):-at_work.
rule(p5(Call), prefer(r3(Call), r2(Call)), []):-familyOrFriends(Call).
rule(c1(Call), prefer(p3(Call), p1(Call)), []).
rule(c2(Call), prefer(p1(Call), p3(Call)), []):-family(Call).
rule(c3(Call), prefer(p4(Call), p2(Call)), []).
rule(c4(Call), prefer(p2(Call), p4(Call)), []):-family(Call).
rule(c5(Call), prefer(c2(Call), c1(Call)), []).
rule(c6(Call), prefer(c4(Call), c3(Call)), []).
rule(c7(Call), prefer(c3(Call), c4(Call)), []):-in_meeting.
rule(c8(Call), prefer(c7(Call), c6(Call)), []).
rule(c9(Call), prefer(c6(Call), c7(Call)), []):-from_son(Call), son_at_school.
rule(c10(Call), prefer(c8(Call), c9(Call)), [neg(son_is_ill)]).
rule(c11(Call), prefer(c9(Call), c8(Call)), [son_is_ill]).
complement(allow(Call), deny_with_explanation(Call)).
complement(deny_with_explanation(Call), allow(Call)).
complement(allow(Call), deny_without_explanation(Call)).
complement(deny_without_explanation(Call), allow(Call)).
complement(deny_with_explanation(Call), deny_without_explanation(Call)).
complement(deny_without_explanation(Call), deny_with_explanation(Call)).
abducible(neg(son_is_ill), []).
abducible(son_is_ill, []).
