\begin{verbatim} %ordering const length = 15. number(1..length). p(X) :- number(Y), X = Y * Y. between(X,Y) :- p(X), p(Y), p(Z), X < Z, Z < Y. next(X,Y) :- p(X), p(Y), X < Y, not between(X,Y). ord_p(N+1,X) :- p(X), p(Y), number(N), ord_p(N,Y), next(Y,X). not_ord_p(1,X) :- p(X), p(Y), Y < X. ord_p(1,X) :- p(X), not not_ord_p(1,X). hide number(X). hide not_ord_p(X,Y). hide next(X,Y). hide between(X,Y). hide p(X). \end{verbatim}