I'd like to understand why the interaction with swipl
appears to be inconsistent.
Here's a typical example. Suppose I have consulted a knowledgebase that includes the following definitions:
acc_max([H|T], A, Max) :- H > A, acc_max(T, H, Max).
acc_max([H|T], A, Max) :- H =< A, acc_max(T, A, Max).
acc_max([], A, A).
max([H|T], Max) :- acc_max(T, H, Max).
Below I show what my screen looks like after I type max([0, 1, 2], X).
at the prompt, and hit Enter:
?- max([0, 1, 2], X).
X = 2 ▮
(The ▮
indicates the position of the cursor.)
Note, in particular, that the interpreter's next prompt has not yet appeared.
Here's what the screen looks like after I type ;:
?- max([0, 1, 2], X).
X = 2 ;
false.
?- ▮
Now I finally get the interpreter's prompt.
In contrast, below I show what my screen looks like after I type max([2, 0, 1], X).
at the prompt, and hit Enter:
?- max([2, 0, 1], X).
X = 2.
?- ▮
Notice that this time I got the interpreter's prompt right away - I did not need to type ;. Also, there's no false
.
I've found many other similar inconsistencies (e.g. sometimes the output true.
shows up on the screen, but in other similar situations it doesn't).
As a newcomer to Prolog, I find such inconsistencies disconcerting (not to mention discouraging, since they are a constant reminder that I really have no clue of what's going on).
Is there a simple way to rationalize these inconsistencies?
Alternatively, is there some implementation of Prolog that provides a more consistent and predictable interaction than does SWI-Prolog?