我在 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).
当我运行时,picnic(When).
我得到以下跟踪:
[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.
我的疑问是:据我所知,cut 运算符应该在!左侧的谓词时停止搜索替代方案。信号为真。第一个位置的信号是什么意思?为什么解释器一直在寻找可以使其他谓词为真的其他值?