% 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 mințit dacă saysItLiedYesterday(Animal, Today) :- % Today este ziua următoare după Yesteday next(Yesterday, Today), % animalul minte în zilele WhichDaysLies lies(Animal, WhichDaysLies), ( % animalul într-adevăr nu minte azi \+ member(Today, WhichDaysLies), % și ieri a mințit member(Yesterday, WhichDaysLies) ; % sau % animalul minte azi member(Today, WhichDaysLies), % și de fapt ieri nu mințea \+ member(Yesterday, WhichDaysLies) ). % solutia; verifica in consola cu sol(WhatDay) sol(Today) :- saysItLiedYesterday(lion, Today), saysItLiedYesterday(unicorn, Today).