我认为追踪器向您展示了回溯追踪器所遵循的所有不同分支。为此,它似乎否定了它尝试的最后一个分支中的一个成功语句,所以这一次它将采用不同的解决方案。
看看整个执行过程,你肯定会看到失败的谓词是真的,就像Fail: (7) lists:member(0, [0, 1, 2])
在第二次评估中一样。
[trace] ?- group([0, 1, 2], 3).
Call: (6) group([0, 1, 2], 3) ? creep
Call: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
Call: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 0+0 ? creep
^ Exit: (7) 0 is 0+0 ? creep
^ Call: (7) _G724 is 0 mod 3 ? creep
^ Exit: (7) 0 is 0 mod 3 ? creep
Call: (7) lists:member(0, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(0, [0, 1, 2]) ? creep
Fail: (7) lists:member(0, [0, 1, 2]) ? creep
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 0+1 ? creep
^ Exit: (7) 1 is 0+1 ? creep
^ Call: (7) _G724 is 1 mod 3 ? creep
^ Exit: (7) 1 is 1 mod 3 ? creep
Call: (7) lists:member(1, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(1, [0, 1, 2]) ? creep
Fail: (7) lists:member(1, [0, 1, 2]) ? creep
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 0+2 ? creep
^ Exit: (7) 2 is 0+2 ? creep
^ Call: (7) _G724 is 2 mod 3 ? creep
^ Exit: (7) 2 is 2 mod 3 ? creep
Call: (7) lists:member(2, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
Call: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 1+0 ? creep
^ Exit: (7) 1 is 1+0 ? creep
^ Call: (7) _G724 is 1 mod 3 ? creep
^ Exit: (7) 1 is 1 mod 3 ? creep
Call: (7) lists:member(1, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(1, [0, 1, 2]) ? creep
Fail: (7) lists:member(1, [0, 1, 2]) ? creep
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 1+1 ? creep
^ Exit: (7) 2 is 1+1 ? creep
^ Call: (7) _G724 is 2 mod 3 ? creep
^ Exit: (7) 2 is 2 mod 3 ? creep
Call: (7) lists:member(2, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 1+2 ? creep
^ Exit: (7) 3 is 1+2 ? creep
^ Call: (7) _G724 is 3 mod 3 ? creep
^ Exit: (7) 0 is 3 mod 3 ? creep
Call: (7) lists:member(0, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(0, [0, 1, 2]) ? creep
Fail: (7) lists:member(0, [0, 1, 2]) ? creep
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
Call: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 2+0 ? creep
^ Exit: (7) 2 is 2+0 ? creep
^ Call: (7) _G724 is 2 mod 3 ? creep
^ Exit: (7) 2 is 2 mod 3 ? creep
Call: (7) lists:member(2, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 2+1 ? creep
^ Exit: (7) 3 is 2+1 ? creep
^ Call: (7) _G724 is 3 mod 3 ? creep
^ Exit: (7) 0 is 3 mod 3 ? creep
Call: (7) lists:member(0, [0, 1, 2]) ? creep
Exit: (7) lists:member(0, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(0, [0, 1, 2]) ? creep
Fail: (7) lists:member(0, [0, 1, 2]) ? creep
Redo: (7) lists:member(_G718, [0, 1, 2]) ? creep
Exit: (7) lists:member(2, [0, 1, 2]) ? creep
^ Call: (7) _G721 is 2+2 ? creep
^ Exit: (7) 4 is 2+2 ? creep
^ Call: (7) _G724 is 4 mod 3 ? creep
^ Exit: (7) 1 is 4 mod 3 ? creep
Call: (7) lists:member(1, [0, 1, 2]) ? creep
Exit: (7) lists:member(1, [0, 1, 2]) ? creep
Exit: (6) group([0, 1, 2], 3) ? creep
true ;
Redo: (7) lists:member(1, [0, 1, 2]) ? creep
Fail: (7) lists:member(1, [0, 1, 2]) ? creep
Fail: (6) group([0, 1, 2], 3) ? creep
false.