I have the following base in Prolog:
holiday(friday,may1).
weather(friday,fair).
weather(saturday,fair).
weather(sunday,fair).
weekend(saturday).
weekend(sunday).
picnic(Day) :- !,weather(Day,fair), weekend(Day).
picnic(Day) :- holiday(Day,may1).
When I run picnic(When). I get the following trace:
[trace] ?- picnic(When).
Call: (6) picnic(_G716) ? creep
Call: (7) weather(_G716, fair) ? creep
Exit: (7) weather(friday, fair) ? creep
Call: (7) weekend(friday) ? creep
Fail: (7) weekend(friday) ? creep
Redo: (7) weather(_G716, fair) ? creep
Exit: (7) weather(saturday, fair) ? creep
Call: (7) weekend(saturday) ? creep
Exit: (7) weekend(saturday) ? creep
Exit: (6) picnic(saturday) ? creep
When = saturday ;
Redo: (7) weather(_G716, fair) ? creep
Exit: (7) weather(sunday, fair) ? creep
Call: (7) weekend(sunday) ? creep
Exit: (7) weekend(sunday) ? creep
Exit: (6) picnic(sunday) ? creep
When = sunday.
My doubt is: the cut operator, as I know, should stop to search alternatives when the predicates to the left of the ! signal are true. What's the meaning of the signal in the first position? Why does the interpreter keep searching for another values that can turn the other predicates true?