The file on HotShare:

http://www.hotshare.net/file/235697-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(C), day(D).

teaches_1(P,C) :- teacher(P), subject(C).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 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(C))), 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(C),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).

Hi everybody!

I recently started learning the Prolog Language in my college.

I really like it, but there are some things our teacher hasn’t explained to us.

Actually, he told us to find out how this exercise could be done

(I must say my knowledge in Prolog is very poor ;) )

“A student of System Engineering has forgotten his class schedule.

However, he can remember a few things about it:

-The name of his teachers: Mary, Jesus, Phil.

-The name of the courses: Logic, Programming, Maths.

-The class days: Monday, Wednesday,Thursday

And some other things:

-Programming class, taught by Mary, is after the Logic class

-Phil does not like to work on Monday, and Monday is a day that Logic is not taught

-He also knows that each teacher teaches a single course and classes are held on different days

Would you help this stupid student relate each teacher with their subject and the weekday class it is taught?

First answer: (NO, I DONT WANT TO HELP THIS MF)

Second answer: WOULD YOU HELP ME TO HELP THIS GUY??”

Haha, well, I dont want to make this post too long, but here I’ll post the things I tried, but without any result :(