% author: Przemyslaw Kobylanski <przemko@pwr.wroc.pl>

said(knight, X) :- true(X).
said(knave, X) :- false(X).

true(true).
true(knight(knight)).
true(knave(knave)).
true(said(knight, X)) :- true(X).
true(said(knave, X)) :- false(X).
true(not(X)) :- false(X).
true(and(X, Y)) :- true(X), true(Y).
true(or(X, Y)) :- true(X); true(Y).

false(false).
false(knight(knave)).
false(knave(knight)).
false(said(knight, X)) :- false(X).
false(said(knave, X)) :- true(X).
false(not(X)) :- true(X).
false(and(X, Y)) :- false(X); false(Y).
false(or(X, Y)) :- false(X), false(Y).


puzzle26(B, C) :-
	said(B, said(A, knave(A))),
	said(C, knave(B)).

puzzle27(B, C) :-
	said(B, said(A, or(
			   and(knight(A), and(knave(B), knave(C))),
			   or(
			      and(knave(A), and(knight(B), knave(C))),
			      and(knave(A), and(knave(B), knight(C)))
			     )
			  )
		    )
	    ),
	said(C, knave(B)).

puzzle29(A, B) :-
	said(A, or(knave(A), knight(B))).

puzzle30(A) :-
	said(A, or(knave(A), false)).

puzzle33(A, B) :-
	said(A, and(knave(A), knight(B))).
