% Facts
sister(abigail).
sister(brenda).
sister(mary).
sister(paula).
sister(tara).

day(sunday).
day(monday).
day(wednesday).
day(friday).
day(saturday).

month(february).
month(march).
month(june).
month(july).
month(december).

		

solve:-
	sister(AbigailDay), sister(BrendaDay), sister(MaryDay),sister(PaulaDay), sister(TaraDay), 
	all_different([AbigailDay, BrendaDay, MaryDay, PaulaDay, TaraDay]),
	
	sister(AbigailMonth), sister(BrendaMonth), sister(MaryMonth),sister(PaulaMonth), sister(TaraMonth),
	all_different([AbigailMonth, BrendaMonth, MaryMonth, PaulaMonth, TaraMonth]),
	
	Sisters = [ sis(abigail, AbigailDay, AbigailMonth),
				sis(brenda, BrendaDay, BrendaMonth),
				sis(mary, MaryDay, MaryMonth),
				sis(paula, PaulaDay, PaulaMonth),
				sis(tara, TaraDay,TaraMonth)],

%1. Paula was born in March but not on Saturday. Abigail's birthday was not on Friday or Wednesday.
\+ member(sis(paula, saturday, _), Sisters),
\+ member(sis(abigail, friday, _), Sisters),
\+ member(sis(abigail, wednesday, _), Sisters),

%2. The girl whose birthday is on Monday was born earlier in the year than Brenda and Mary.
member(sis(_,monday,_), Sisters), 

%3.Tara wasn't born in February and her birthday was on the weekend.

\+ member(sis(tara,_,february), Sisters),

%4. Mary was not born in December nor was her birthday on a weekday. The girl whose birthday was in June was born on Sunday.
\+ member(sis(mary,_,december), Sisters),
member(sis(_,sunday,june), Sisters),

%5.Tara was born before Brenda, whose birthday wasn't on Friday. Mary wasn't born in July.
\+ member(sis(brenda, friday, _), Sisters),
\+ member(sis(mary,_,july), Sisters),

tell(abigail, AbigailDay, AbigailMonth),
tell(brenda, BrendaDay, BrendaMonth),
tell(mary, MaryDay, MaryMonth),
tell(paula, PaulaDay, PaulaMonth),
tell(tara, TaraDay, TaraMonth).

tell(Woman, Day, Month) :- write('Sister '), write(Woman), write('birth day is '),
write(Day), write(' and her birth month is  '), write(Month), write('.'), nl.

% If the head of the list is in the tail, fail.
all_different([Head|Tail]) :- member(Head, Tail), !, fail.
% Otherwise, check the tail of the list.
all_different([_|Tail]) :- all_different(Tail).
% If there's only one thing in the list, it's fine.
all_different([_]).
