je la base suivante Prolog:Prolog Cut opérateur dans le premier prédicat
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).
Quand je lance picnic(When).
-je obtenir la trace suivante:
[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.
Mon doute est: l'opérateur de coupe, comme je sais, devrait cesser de chercher des alternatives lorsque les prédicats à la gauche de la ! le signal est vrai. Quelle est la signification du signal dans la première position? Pourquoi l'interpréteur continue-t-il à chercher d'autres valeurs qui peuvent rendre les autres prédicats vrais?
Merci, maintenant j'ai compris la signification de la coupe. –