\begin{verbatim} const size = 8. col(1..size). row(1..size). not_in(X,Y) :- row(X), col(Y), not in(X,Y). in(X,Y) :- row(X), col(Y), not not_in(X,Y). has_queen(X) :- row(X), col(Y), in(X,Y). :- row(X), not has_queen(X). :- row(X), col(Y), row(XX), not eq(X,XX), in(X,Y), in(XX,Y). :- row(X), col(Y), col(YY), not eq(Y,YY), in(X,Y), in(X,YY). :- row(X), col(Y), row(XX), col(YY), not eq(X,XX), not eq(Y,YY), in(X,Y), in(XX,YY), eq(abs(X-XX),abs(Y-YY)). hide not_in(X,Y). hide row(X). hide col(Y). hide has_queen(X). \end{verbatim}