/** ---------------------------------------------------------
holds if all elements of the list are sorted
(in a descending order) without gaps:
given any element A, the next element is strictly A-1
additionally, the last element has to be 1
---------------------------------------------------------- */
properly_ordered([A, B|R]) :- B is A - 1, properly_ordered([B|R]).
properly_ordered([A]) :- A is 1.
PROLOG SESSION:
?- properly_ordered([1, 2, 3]).
No
?- properly_ordered([3, 2, 1]).
Yes