A paper I'm reading says the following:
Plaisted [3] showed that it is possible to write formally correct PROLOG programs using first-order predicate-calculus semantics and yet derive nonsense results such as 3 < 2.
It is referring to the fact that Prologs didn't use the occurs check back then (the 1980s).
Unfortunately, the paper it cites is behind a paywall. I'd still like to see an example such as this. Intuitively, it feels like the omission of the occurs check just expands the universe of structures to include circular ones (but this intuition must be wrong, according to the author).
I hope this example isn't
smaller(3, 2) :- X = f(X).
That would be disappointing.
unify_with_occurs_check/2
. This means head unification by default never does occurs check. To switch it on globally: occurs check flag – Purim?- sort([X1,X2,X3],[3,1,2]).
yieldsX1 = 3, X2 = 1, X3 = 2.
. I'm going to write a new sort, I swear! – Purimsort([X1,X2,X3],[3,1,2])
Bug? It's unaffected byset_prolog_flag(occurs_check, true).
in SWI – Yevettesort/2
("arg2 should be at least a possible result of sorting arg1") and the actual operational semantics according to which it is specified and implemented ("sort arg1 according to the standard order and then unify with arg2"). – Purim