% perm(Xs, Ys) :- Ys is a permutation of the list Xs. perm([], []). perm(Xs, [X | Ys]) :- app(X1s, [X | X2s], Xs), app(X1s, X2s, Zs), perm(Zs, Ys). % augmented by the APPEND program app([], Ys, Ys). app([X | Xs], Ys, [X | Zs]) :- app(Xs, Ys, Zs).