1

In Prolog using the cut. Why is the effect of the following query to return the following:

?- !,false.
no

yet this query returns the following:

?- !;false.
yes
false
  • 10,264
  • 13
  • 101
  • 209
General_9
  • 2,249
  • 4
  • 28
  • 46

1 Answers1

2

The first query performs an AND on ! (which always returns yes) and false, which always returns no. yes AND no = no.

In the second query, the ! commits execution to the first branch, that is, !, which always returns yes.

levinia
  • 48
  • 6
  • 1
    `;` does not act the same as logical OR in the presence of `!`. For example `parent(X) :- !,false;father(X).` always returns `no`. – svick Jul 12 '11 at 19:34
  • Of course, that makes perfect sense. I edited the answer accordingly, thanks! – levinia Jul 12 '11 at 20:28