Why does Cut doesn't prevent Visual Prolog from finding another solutions

173 Views Asked by At

If we use fail in a predicate after the cut (!), it somehow still finds another solutoins using backtrack, but I think it shouldn't. Consider the next example in Visual Prolog

implement main
    open core, stdio

class facts
    m : (integer M).

clauses
    m(1).
    m(2).
    m(3).
    m(4).

class predicates
    p : () failure.
clauses
    p() :-
        m(X),
        !,
        write(X),
        nl,
        fail.

clauses
    run() :-
        p().
    run().

end implement main

goal
    console::runUtf8(main::run).

Its output is

1
2
3
4

However, I expected only 1, since, as written in the official doc,

Cut "!" removes all backtrack points created since the entrance to the current predicate, this means all backtrack points to subsequent clauses, plus backtrack points in predicate calls made in the current clause before the "!".

Moreover, if we run similar code in SWI-Prolog, its output will be 1 for p :- m(X), !, write(X), fail. and 1234 for p :- m(X), write(X), fail., as expected. What am I missing?

0

There are 0 best solutions below