The file on HotShare:
http://www.hotshare....9526735812.html
Code:
% Teachers
% Mary, jesus, Phil
% Subjects
% Logic, Programming, Maths
% Days
% Monday, Wednesday, Thursday
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FACTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% another way to do it maybe??
%teachers(mary,jesus,phil).
%subjects(logic,programming,maths).
%days(monday,wednesday,thursday).
teacher(mary).
teacher(jesus).
teacher(phil).
subject(logic).
subject(programming).
subject(maths).
day(monday).
day(wednesday).
day(thursday).
works_1(P,D) :- teacher(P), day(D).
is_taught_on_1(C,D) :- subject©, day(D).
teaches_1(P,C) :- teacher(P), subject©.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% day1 is_before_than day2
% day2 is_after_than day1
% teacher works day
% teacher teaches subject
% subject is_taught_on day
%%% subject1 is_before_than subject2
%%% subject2 is_after_than subject1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% --------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
is_after_than(wednesday,monday).
is_after_than(thursday,monday).
is_after_than(thursday,wednesday).
is_before_than(monday,wednesday) :- is_after_than(wednesday,monday).
is_before_than(monday,thursday) :- is_after_than(thursday,monday).
is_before_than(wednesday,thursday) :- is_after_than(thursday,wednesday).
% IF Phil WORKS Monday THEN
% other teachers cant work on monday
% Phil cant work other days other than Monday
% other teachers can work other days
% Phil works on Monday LOL xD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% RULES??
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%teaches(mary,programming).
%is_after_than(programming,logic).
%no_works(phil,monday).
%no_is_taught_on(logic,monday).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ---------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
works_1(P1,D1) :- works_1(P1,D1),
%works(P1,D1) :-
%es(P1,teacher), es(D1,day), es(D2,day), es(P2,teacher), es(D3,day), es(P3,teacher),
%D2\==D1, P2\==P1, P3\==P1, D3\==D1,
%\+works(P1,D2), \+works(P2,D1), works(P3,D3).
%works(P,D) :- \+no_works(P,D).
%no_works(P,D) :- \+works(P,D).
%teaches(P,C) :- es(P,teacher), es(C,subject), \+teaches(not(P),C)), \+teaches(P,not©)), teaches().
%teaches(P,C) :- \+no_teaches(P,C).
%no_teaches(P,C) :- \+teaches(P,C).
%is_taught_on(C,D) :- es(C,subject), es(D,day), \+is_taught_on(not©,D)), \+is_taught_on(C,not(D))), is_taught_on().
%is_taught_on(C,D) :- \+no_is_taught_on(C,D).
%no_is_taught_on(C,D) :- \+is_taught_on(C,D).
%is_before_than(C1,C2) :- is_taught_on(C1,D1), is_taught_on(C2,D2), (is_after_than(D2,D1)).
%is_after_than(C1,C2) :- is_before_than(C2,C1).
%final(P,C,D) :- works(P,D), teaches(P,C), is_taught_on(C,D).