% 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]). % Animal spune azi (Today) ca ieri a mintit saysItLiedYesterday(Animal, Today) :- next(Yesterday, Today), lies(Animal, WhichDaysLies), not(member(Today, WhichDaysLies)), member(Yesterday, WhichDaysLies). saysItLiedYesterday(Animal, Today) :- next(Yesterday, Today), lies(Animal, WhichDaysLies), member(Today, WhichDaysLies), not(member(Yesterday, WhichDaysLies)). % solutia; verifica in consola cu sol(WhatDay) sol(Today) :- saysItLiedYesterday(lion, Today), saysItLiedYesterday(unicorn, Today).