% Alice came across a lion and a unicorn in a forest of forgetfulness. % Those two are strange beings. % The lion lies every Monday, Tuesday and Wednesday % and the other days he speaks the truth. % The unicorn lies on Thursdays, Fridays and Saturdays, % however the other days of the week he speaks the truth. % Lion: Yesterday I was lying. % Unicorn: So was I. % Which day did they say that? days([mon, tue, wed, thu, fri, sat, sun]). check_next(Y, T, [Y, T|_]). check_next(Y, T, [_|Days]) :- check_next(Y, T, Days). next(Y, T) :- days([T|_]), days(Days), reverse(Days, [Y|_]). next(Y, T) :- days(Days), check_next(Y, T, Days). lies(lion, [mon, tue, wed]). lies(unicorn, [thu, fri, sat]). saysLiedYesterday(Animal, Today) :- lies(Animal, DaysLies), next(Yesterday, Today), \+ member(Today, DaysLies), member(Yesterday, DaysLies). saysLiedYesterday(Animal, Today) :- lies(Animal, DaysLies), next(Yesterday, Today), member(Today, DaysLies), \+ member(Yesterday, DaysLies). sol(Today) :- saysLiedYesterday(lion, Today), saysLiedYesterday(unicorn, Today).