用prolog和can'编写语法;我不能让它正常工作

用prolog和can'编写语法;我不能让它正常工作,prolog,grammar,dcg,Prolog,Grammar,Dcg,这是一个课堂作业,但我不知道如何解决我的问题。 我写了以下内容: sentence(S0, S):- f(S0,S); t(S0, S1),n(S1, S2),t(S2, S). f(S0, S):- termIf(S0, S1), pLeft(S1, S2), b(S2, S3), pRight(S3, S4), termThen(S4, S5), termBegin(S5, S6),sentence(S6, S7), termEnd(S7, S); termIf(S0, S1), pLeft

这是一个课堂作业,但我不知道如何解决我的问题。 我写了以下内容:

sentence(S0, S):- f(S0,S); t(S0, S1),n(S1, S2),t(S2, S).
f(S0, S):- termIf(S0, S1), pLeft(S1, S2), b(S2, S3), pRight(S3, S4), termThen(S4, S5), termBegin(S5, S6),sentence(S6, S7), termEnd(S7, S); termIf(S0, S1), pLeft(S1, S2), b(S2, S3), pRight(S3, S4), termThen(S4, S5),termBegin(S5, S6),sentence(S6, S7), termElse(S7, S8), sentence(S8, S9), termEnd(S9, S).
b(S0, S):- t(S0, S1), e(S1, S2), t(S2, S). 
termIf(S0, S) :- S0=[if|S].
termThen(S0, S):- S0=[then|S].
termBegin(S0, S):- S0=[begin|S].
termEnd(S0, S):- S0=[end|S].
termElse(S0, S):- S0=[else|S].
pLeft(S0, S):- S0=['('|S].
pRight(S0, S):- S0=[')'|S].
t(S0, S):- S0=[x|S].
t(S0, S):- S0=[y|S].
t(S0, S):- S0=[z|S].
t(S0, S):- S0=[1|S].
t(S0, S):- S0=[0|S].
e(S0, S):- S0=[>|S].
e(S0, S):- S0=[<|S].
n(S0, S):- S0=[+|S].
n(S0, S):- S0=[-|S].
n(S0, S):- S0=[=|S].
句子(S0,S):-f(S0,S);t(S0,S1),n(S1,S2),t(S2,S)。
f(S0,S):-术语if(S0,S1),pLeft(S1,S2),b(S2,S3),pRight(S3,S4),termThen(S4,S5),termBegin(S5,S6),句子(S6,S7),termEnd(S7,S);termIf(S0,S1),pLeft(S1,S2),b(S2,S3),pRight(S3,S4),termThen(S4,S5),termBegin(S5,S6),句子(S6,S7),termElse(S7,S8),句子(S8,S9),termEnd(S9,S)。
b(S0,S):-t(S0,S1),e(S1,S2),t(S2,S)。
termIf(S0,S):-S0=[if | S]。
termThen(S0,S):-S0=[then | S]。
termBegin(S0,S):-S0=[begin | S]。
termEnd(S0,S):-S0=[end | S]。
termlse(S0,S):-S0=[else | S]。
pLeft(S0,S):-S0=['('| S]。
pRight(S0,S):-S0=[')'| S]。
t(S0,S):-S0=[x | S]。
t(S0,S):-S0=[y | S]。
t(S0,S):-S0=[z | S]。
t(S0,S):-S0=[1 | S]。
t(S0,S):-S0=[0 | S]。
e(S0,S):-S0=[>| S]。
e(S0,S):-S0=[,0',)',然后,开始,[x,=,1],结束],x)。
调用:(89)句子([如果,,,,,x,>,0,'),然后,开始|…],_66584)?爬行
调用:(90)f([if',(',x,>,0',)',然后,开始|…],_66584)?爬行
调用:(91)termIf([if',(',x,>,0',)',然后,开始|…],_67166)?爬行
调用:(92)[如果,(',x,>,0',)',那么,开始|…]=[如果| 67158]?爬行
退出:(92)[如果'(',x,>,0',)',那么,开始|…]=[如果'(',x,>,0',)',那么,开始|…]?爬行
退出:(91)termIf([if',(',x,>,0',)',然后开始|…],['(',x,>,0',)',然后开始,[…|…]|…])?爬行
呼叫:(91)pLeft(['(',x,>,0')',然后开始[…|…]|…],_67348)?爬行
调用:(92)['(',x,>,0')',然后开始[…|…]|…]=['('||u 67340]?爬行
退出:(92)['(',x,>,0',)',然后开始[…|…]|…]=['(',x,>,0',)',然后开始[…|…]|…]?爬行
退出:(91)pLeft(['(',x,>,0',)',然后,开始,[…|…],[x,>,0',)',然后,开始,[x |…],结束]?爬行
呼叫:(91)b([x,>,0',)',然后开始,[x,…],结束],_67530)?爬行
调用:(92)t([x,>,0',)',然后,开始,[x,…],结束],_67574)?爬行
呼叫:(93)[x,>,0',)',然后开始,[x |…],结束]=[x | | U 67566]?爬行
退出:(93)[x,>,0',)',然后开始,[x |…],结束]=[x,>,0',)',然后开始,[x |…],结束]?爬行
退出:(92)t([x,>,0',)',然后,开始,[x,…],结束],>,0',)',然后,开始,[x,=|…],结束]?爬行
呼叫:(92)e([>,0',)',然后开始,[x,=|…],结束],_67756)?爬行
呼叫:(93)[>,0',)',然后,开始,[x,=|…],结束]=[>|u 67748]?爬行
退出:(93)[>,0',)',然后,开始,[x,=|…],结束]=[>,0',)',然后,开始,[x,=|…],结束]?爬行
退出:(92)e([>,0',)',然后,开始,[x,=,结束,[0',)',然后,开始,[x,=,1],结束]?爬行
调用:(92)t([0',)',然后,开始,[x,=,1],结束],_67938)?爬行
呼叫:(93)[0',)',然后开始,[x,=,1],结束]=[x | 67930]?爬行
失败:(93)[0',)',然后,开始,[x,=,1],结束]=[x | 67930]?爬行
重做:(92)t([0',)',然后,开始,[x,=,1],结束],_68076)?爬行
呼叫:(93)[0',)',然后,开始,[x,=,1],结束]=[y |U 68068]?爬行
失败:(93)[0',)',然后,开始,[x,=,1],结束]=[y |U 68068]?爬行
重做:(92)t([0',)',然后,开始,[x,=,1],结束],_68214)?爬行
呼叫:(93)[0',)',然后,开始,[x,=,1],结束]=[z |68206]?爬行
失败:(93)[0',)',然后,开始[x,=,1],结束]=[z | 68206]?爬行
重做:(92)t([0',)',然后,开始,[x,=,1],结束],_68352)?爬行
呼叫:(93)[0',)',然后开始,[x,=,1],结束]=[1 | 68344]?爬行
失败:(93)[0',)',然后,开始,[x,=,1],结束]=[1 | 68344]?爬行
重做:(92)t([0',)',然后,开始,[x,=,1],结束],_68490)?爬行
呼叫:(93)[0',)',然后开始,[x,=,1],结束]=[0 | 68482]?爬行
退出:(93)[0',)',然后,开始[x,=,1],结束]=[0',)',然后,开始[x,=,1],结束]?爬行
退出:(92)t([0',)',然后,开始,[x,=,1],结束],'),然后,开始,[x,=,1],结束]?爬行
退出:(91)b([x,>,0',)',然后,开始,[x |…],结束,,')',然后,开始,[x,=,1],结束]?爬行
呼叫:(91)pRight(['),然后,begin,[x,=,1],end],_68716)?爬行
呼叫:(92)[')',然后,开始,[x,=,1],结束]=[')'|68708]?爬行
退出:(92)[')',然后,开始,[x,=,1],结束]=[')',然后,开始,[x,=,1],结束]?爬行
Exit:(91)pRight(['),然后,begin,[x,=,1],end],[then,begin,[x,=,1],end])?爬行
呼叫:(91)termThen([然后,开始,[x,=,1],结束],_68898)?爬行
呼叫:(92)[然后,开始,[x,=,1],结束]=[then | u68890]?爬行
退出:(92)[然后,开始,[x,=,1],结束]=[然后,开始,[x,=,1],结束]?爬行
退出:(91)termThen([然后,开始,[x,=,1],结束],[开始,[x,=,1],结束])?爬行
呼叫:(91)termBegin([begin,[x,=,1],end],_69080)?爬行
呼叫:(92)[开始,[x,=,1],结束]=[begin | U 69072]?爬行
退出:(92)[开始,[x,=,1],结束]=[开始,[x,=,1],结束]?爬行
退出:(91)术语开始([begin,[x,=,1],end],[x,=,1],end])?爬行
呼叫:(91)句子([[x,=,1],结束],_69262)?爬行
呼叫:(92)f([[x,=,1],结束],_69306)?爬行
呼叫:(93)termIf([[x,=,1],结束],_69350)?爬行
呼叫:(94)[[x,=,1],结束]=[if | 59342]?爬行
失败:(94)[[x,=,1],结束]=[if |_69342]?爬行
失败:(93)termIf([[x,=,1],结束],_69488)?爬行
重做:(92)f([[x,=,1],结束],_69532)?爬行
呼叫:(93)termIf([[x,=,1],结束],_69576)?爬行
呼叫:(94)[[x,=,1],结束]=[if | 59568]?爬行
失败:(94)[x,=,1],结束]=[if | 59568]?爬行
失败:(93)termIf([[x,=,1],结束],_69714)?爬行
失败:(92)f([[x,=,1],结束],_69758)?爬行
重做:(91)句子([[x,=,1],结束],_69802)?爬行
呼叫:(92)t([[x,=,1],结束],_69846)?爬行
呼叫:(93)[x,=,1],结束]=[x | 59838]?爬行
失败:(93)[x,=,1],结束]=[x|u 69838]?爬行
重做:(92)t([x,=,1],结束],_69984)?爬行
呼叫:(93)[x,=,1],结束]=[y | 59976]?爬行
失败:(93)[x,=,1],结束]=[y | 59976]?爬行
重做:(92)t([[x,=,1],结束],_70122)?爬行
呼叫:(93)[x,=,1],结束]=[z | U 70114]?
[trace] [5]  ?- sentence([if,'(', x, >, 0,')', then, begin, [x, =, 1], end], X).
   Call: (89) sentence([if, '(', x, >, 0, ')', then, begin|...], _66584) ? creep
   Call: (90) f([if, '(', x, >, 0, ')', then, begin|...], _66584) ? creep
   Call: (91) termIf([if, '(', x, >, 0, ')', then, begin|...], _67166) ? creep
   Call: (92) [if, '(', x, >, 0, ')', then, begin|...]=[if|_67158] ? creep
   Exit: (92) [if, '(', x, >, 0, ')', then, begin|...]=[if, '(', x, >, 0, ')', then, begin|...] ? creep
   Exit: (91) termIf([if, '(', x, >, 0, ')', then, begin|...], ['(', x, >, 0, ')', then, begin, [...|...]|...]) ? creep
   Call: (91) pLeft(['(', x, >, 0, ')', then, begin, [...|...]|...], _67348) ? creep
   Call: (92) ['(', x, >, 0, ')', then, begin, [...|...]|...]=['('|_67340] ? creep
   Exit: (92) ['(', x, >, 0, ')', then, begin, [...|...]|...]=['(', x, >, 0, ')', then, begin, [...|...]|...] ? creep
   Exit: (91) pLeft(['(', x, >, 0, ')', then, begin, [...|...]|...], [x, >, 0, ')', then, begin, [x|...], end]) ? creep
   Call: (91) b([x, >, 0, ')', then, begin, [x|...], end], _67530) ? creep
   Call: (92) t([x, >, 0, ')', then, begin, [x|...], end], _67574) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[x|_67566] ? creep
   Exit: (93) [x, >, 0, ')', then, begin, [x|...], end]=[x, >, 0, ')', then, begin, [x|...], end] ? creep
   Exit: (92) t([x, >, 0, ')', then, begin, [x|...], end], [>, 0, ')', then, begin, [x, =|...], end]) ? creep
   Call: (92) e([>, 0, ')', then, begin, [x, =|...], end], _67756) ? creep
   Call: (93) [>, 0, ')', then, begin, [x, =|...], end]=[>|_67748] ? creep
   Exit: (93) [>, 0, ')', then, begin, [x, =|...], end]=[>, 0, ')', then, begin, [x, =|...], end] ? creep
   Exit: (92) e([>, 0, ')', then, begin, [x, =|...], end], [0, ')', then, begin, [x, =, 1], end]) ? creep
   Call: (92) t([0, ')', then, begin, [x, =, 1], end], _67938) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[x|_67930] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[x|_67930] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _68076) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[y|_68068] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[y|_68068] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _68214) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[z|_68206] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[z|_68206] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _68352) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[1|_68344] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[1|_68344] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _68490) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[0|_68482] ? creep
   Exit: (93) [0, ')', then, begin, [x, =, 1], end]=[0, ')', then, begin, [x, =, 1], end] ? creep
   Exit: (92) t([0, ')', then, begin, [x, =, 1], end], [')', then, begin, [x, =, 1], end]) ? creep
   Exit: (91) b([x, >, 0, ')', then, begin, [x|...], end], [')', then, begin, [x, =, 1], end]) ? creep
   Call: (91) pRight([')', then, begin, [x, =, 1], end], _68716) ? creep
   Call: (92) [')', then, begin, [x, =, 1], end]=[')'|_68708] ? creep
   Exit: (92) [')', then, begin, [x, =, 1], end]=[')', then, begin, [x, =, 1], end] ? creep
   Exit: (91) pRight([')', then, begin, [x, =, 1], end], [then, begin, [x, =, 1], end]) ? creep
   Call: (91) termThen([then, begin, [x, =, 1], end], _68898) ? creep
   Call: (92) [then, begin, [x, =, 1], end]=[then|_68890] ? creep
   Exit: (92) [then, begin, [x, =, 1], end]=[then, begin, [x, =, 1], end] ? creep
   Exit: (91) termThen([then, begin, [x, =, 1], end], [begin, [x, =, 1], end]) ? creep
   Call: (91) termBegin([begin, [x, =, 1], end], _69080) ? creep
   Call: (92) [begin, [x, =, 1], end]=[begin|_69072] ? creep
   Exit: (92) [begin, [x, =, 1], end]=[begin, [x, =, 1], end] ? creep
   Exit: (91) termBegin([begin, [x, =, 1], end], [[x, =, 1], end]) ? creep
   Call: (91) sentence([[x, =, 1], end], _69262) ? creep
   Call: (92) f([[x, =, 1], end], _69306) ? creep
   Call: (93) termIf([[x, =, 1], end], _69350) ? creep
   Call: (94) [[x, =, 1], end]=[if|_69342] ? creep
   Fail: (94) [[x, =, 1], end]=[if|_69342] ? creep
   Fail: (93) termIf([[x, =, 1], end], _69488) ? creep
   Redo: (92) f([[x, =, 1], end], _69532) ? creep
   Call: (93) termIf([[x, =, 1], end], _69576) ? creep
   Call: (94) [[x, =, 1], end]=[if|_69568] ? creep
   Fail: (94) [[x, =, 1], end]=[if|_69568] ? creep
   Fail: (93) termIf([[x, =, 1], end], _69714) ? creep
   Fail: (92) f([[x, =, 1], end], _69758) ? creep
   Redo: (91) sentence([[x, =, 1], end], _69802) ? creep
   Call: (92) t([[x, =, 1], end], _69846) ? creep
   Call: (93) [[x, =, 1], end]=[x|_69838] ? creep
   Fail: (93) [[x, =, 1], end]=[x|_69838] ? creep
   Redo: (92) t([[x, =, 1], end], _69984) ? creep
   Call: (93) [[x, =, 1], end]=[y|_69976] ? creep
   Fail: (93) [[x, =, 1], end]=[y|_69976] ? creep
   Redo: (92) t([[x, =, 1], end], _70122) ? creep
   Call: (93) [[x, =, 1], end]=[z|_70114] ? creep
   Fail: (93) [[x, =, 1], end]=[z|_70114] ? creep
   Redo: (92) t([[x, =, 1], end], _70260) ? creep
 Call: (93) [[x, =, 1], end]=[1|_70252] ? creep
   Fail: (93) [[x, =, 1], end]=[1|_70252] ? creep
   Redo: (92) t([[x, =, 1], end], _70398) ? creep
   Call: (93) [[x, =, 1], end]=[0|_70390] ? creep
   Fail: (93) [[x, =, 1], end]=[0|_70390] ? creep
   Fail: (92) t([[x, =, 1], end], _70536) ? creep
   Fail: (91) sentence([[x, =, 1], end], _70580) ? creep
   Redo: (92) e([>, 0, ')', then, begin, [x, =|...], end], _70624) ? creep
   Call: (93) [>, 0, ')', then, begin, [x, =|...], end]=[<|_70616] ? creep
   Fail: (93) [>, 0, ')', then, begin, [x, =|...], end]=[<|_70616] ? creep
   Fail: (92) e([>, 0, ')', then, begin, [x, =|...], end], _70762) ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _70806) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[y|_70798] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[y|_70798] ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _70944) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[z|_70936] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[z|_70936] ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _71082) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[1|_71074] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[1|_71074] ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _71220) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[0|_71212] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[0|_71212] ? creep
   Fail: (92) t([x, >, 0, ')', then, begin, [x|...], end], _71358) ? creep
   Fail: (91) b([x, >, 0, ')', then, begin, [x|...], end], _71402) ? creep
   Redo: (90) f([if, '(', x, >, 0, ')', then, begin|...], _66584) ? creep
   Call: (91) termIf([if, '(', x, >, 0, ')', then, begin|...], _71490) ? creep
   Call: (92) [if, '(', x, >, 0, ')', then, begin|...]=[if|_71482] ? creep
   Exit: (92) [if, '(', x, >, 0, ')', then, begin|...]=[if, '(', x, >, 0, ')', then, begin|...] ? creep
   Exit: (91) termIf([if, '(', x, >, 0, ')', then, begin|...], ['(', x, >, 0, ')', then, begin, [...|...]|...]) ? creep
   Call: (91) pLeft(['(', x, >, 0, ')', then, begin, [...|...]|...], _71672) ? creep
   Call: (92) ['(', x, >, 0, ')', then, begin, [...|...]|...]=['('|_71664] ? creep
   Exit: (92) ['(', x, >, 0, ')', then, begin, [...|...]|...]=['(', x, >, 0, ')', then, begin, [...|...]|...] ? creep
   Exit: (91) pLeft(['(', x, >, 0, ')', then, begin, [...|...]|...], [x, >, 0, ')', then, begin, [x|...], end]) ? creep
   Call: (91) b([x, >, 0, ')', then, begin, [x|...], end], _71854) ? creep
   Call: (92) t([x, >, 0, ')', then, begin, [x|...], end], _71898) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[x|_71890] ? creep
   Exit: (93) [x, >, 0, ')', then, begin, [x|...], end]=[x, >, 0, ')', then, begin, [x|...], end] ? creep
   Exit: (92) t([x, >, 0, ')', then, begin, [x|...], end], [>, 0, ')', then, begin, [x, =|...], end]) ? creep
   Call: (92) e([>, 0, ')', then, begin, [x, =|...], end], _72080) ? creep
   Call: (93) [>, 0, ')', then, begin, [x, =|...], end]=[>|_72072] ? creep
   Exit: (93) [>, 0, ')', then, begin, [x, =|...], end]=[>, 0, ')', then, begin, [x, =|...], end] ? creep
   Exit: (92) e([>, 0, ')', then, begin, [x, =|...], end], [0, ')', then, begin, [x, =, 1], end]) ? creep
   Call: (92) t([0, ')', then, begin, [x, =, 1], end], _72262) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[x|_72254] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[x|_72254] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _72400) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[y|_72392] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[y|_72392] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _72538) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[z|_72530] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[z|_72530] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _72676) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[1|_72668] ? creep
   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[1|_72668] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _72814) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[0|_72806] ? creep
   Exit: (93) [0, ')', then, begin, [x, =, 1], end]=[0, ')', then, begin, [x, =, 1], end] ? creep
   Exit: (92) t([0, ')', then, begin, [x, =, 1], end], [')', then, begin, [x, =, 1], end]) ? creep
   Exit: (91) b([x, >, 0, ')', then, begin, [x|...], end], [')', then, begin, [x, =, 1], end]) ? creep
   Call: (91) pRight([')', then, begin, [x, =, 1], end], _73040) ? creep
   Call: (92) [')', then, begin, [x, =, 1], end]=[')'|_73032] ? creep
   Exit: (92) [')', then, begin, [x, =, 1], end]=[')', then, begin, [x, =, 1], end] ? creep
   Exit: (91) pRight([')', then, begin, [x, =, 1], end], [then, begin, [x, =, 1], end]) ? creep
   Call: (91) termThen([then, begin, [x, =, 1], end], _73222) ? creep
   Call: (92) [then, begin, [x, =, 1], end]=[then|_73214] ? creep
   Exit: (92) [then, begin, [x, =, 1], end]=[then, begin, [x, =, 1], end] ? creep
   Exit: (91) termThen([then, begin, [x, =, 1], end], [begin, [x, =, 1], end]) ? creep
   Call: (91) termBegin([begin, [x, =, 1], end], _73404) ? creep
   Call: (92) [begin, [x, =, 1], end]=[begin|_73396] ? creep
   Exit: (92) [begin, [x, =, 1], end]=[begin, [x, =, 1], end] ? creep
   Exit: (91) termBegin([begin, [x, =, 1], end], [[x, =, 1], end]) ? creep
   Call: (91) sentence([[x, =, 1], end], _73586) ? creep
   Call: (92) f([[x, =, 1], end], _73630)
Ԁ   Fail: (93) [0, ')', then, begin, [x, =, 1], end]=[1|_72668] ? creep
   Redo: (92) t([0, ')', then, begin, [x, =, 1], end], _72814) ? creep
   Call: (93) [0, ')', then, begin, [x, =, 1], end]=[0|_72806] ? creep
   Exit: (93) [0, ')', then, begin, [x, =, 1], end]=[0, ')', then, begin, [x, =, 1], end] ? creep
   Exit: (92) t([0, ')', then, begin, [x, =, 1], end], [')', then, begin, [x, =, 1], end]) ? creep
   Exit: (91) b([x, >, 0, ')', then, begin, [x|...], end], [')', then, begin, [x, =, 1], end]) ? creep
   Call: (91) pRight([')', then, begin, [x, =, 1], end], _73040) ? creep
   Call: (92) [')', then, begin, [x, =, 1], end]=[')'|_73032] ? creep
   Exit: (92) [')', then, begin, [x, =, 1], end]=[')', then, begin, [x, =, 1], end] ? creep
   Exit: (91) pRight([')', then, begin, [x, =, 1], end], [then, begin, [x, =, 1], end]) ? creep
   Call: (91) termThen([then, begin, [x, =, 1], end], _73222) ? creep
   Call: (92) [then, begin, [x, =, 1], end]=[then|_73214] ? creep
   Exit: (92) [then, begin, [x, =, 1], end]=[then, begin, [x, =, 1], end] ? creep
   Exit: (91) termThen([then, begin, [x, =, 1], end], [begin, [x, =, 1], end]) ? creep
   Call: (91) termBegin([begin, [x, =, 1], end], _73404) ? creep
   Call: (92) [begin, [x, =, 1], end]=[begin|_73396] ? creep
   Exit: (92) [begin, [x, =, 1], end]=[begin, [x, =, 1], end] ? creep
   Exit: (91) termBegin([begin, [x, =, 1], end], [[x, =, 1], end]) ? creep
   Call: (91) sentence([[x, =, 1], end], _73586) ? creep
   Call: (92) f([[x, =, 1], end], _73630) ? creep
   Call: (93) termIf([[x, =, 1], end], _73674) ? creep
   Call: (94) [[x, =, 1], end]=[if|_73666] ? creep
   Fail: (94) [[x, =, 1], end]=[if|_73666] ? creep
   Fail: (93) termIf([[x, =, 1], end], _73812) ? creep
   Redo: (92) f([[x, =, 1], end], _73856) ? creep
   Call: (93) termIf([[x, =, 1], end], _73900) ? creep
   Call: (94) [[x, =, 1], end]=[if|_73892] ? creep
   Fail: (94) [[x, =, 1], end]=[if|_73892] ? creep
   Fail: (93) termIf([[x, =, 1], end], _74038) ? creep
   Fail: (92) f([[x, =, 1], end], _74082) ? creep
   Redo: (91) sentence([[x, =, 1], end], _74126) ? creep
   Call: (92) t([[x, =, 1], end], _74170) ? creep
   Call: (93) [[x, =, 1], end]=[x|_74162] ? creep
   Fail: (93) [[x, =, 1], end]=[x|_74162] ? creep
   Redo: (92) t([[x, =, 1], end], _74308) ? creep
   Call: (93) [[x, =, 1], end]=[y|_74300] ? creep
   Fail: (93) [[x, =, 1], end]=[y|_74300] ? creep
   Redo: (92) t([[x, =, 1], end], _74446) ? creep
   Call: (93) [[x, =, 1], end]=[z|_74438] ? creep
   Fail: (93) [[x, =, 1], end]=[z|_74438] ? creep
   Redo: (92) t([[x, =, 1], end], _74584) ? creep
   Call: (93) [[x, =, 1], end]=[1|_74576] ? creep
   Fail: (93) [[x, =, 1], end]=[1|_74576] ? creep
   Redo: (92) t([[x, =, 1], end], _74722) ? creep
   Call: (93) [[x, =, 1], end]=[0|_74714] ? creep
   Fail: (93) [[x, =, 1], end]=[0|_74714] ? creep
   Fail: (92) t([[x, =, 1], end], _74860) ? creep
   Fail: (91) sentence([[x, =, 1], end], _74904) ? creep
   Redo: (92) e([>, 0, ')', then, begin, [x, =|...], end], _74948) ? creep
   Call: (93) [>, 0, ')', then, begin, [x, =|...], end]=[<|_74940] ? creep
   Fail: (93) [>, 0, ')', then, begin, [x, =|...], end]=[<|_74940] ? creep
   Fail: (92) e([>, 0, ')', then, begin, [x, =|...], end], _75086) ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _75130) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[y|_75122] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[y|_75122] ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _75268) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[z|_75260] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[z|_75260] ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _75406) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[1|_75398] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[1|_75398] ? creep
   Redo: (92) t([x, >, 0, ')', then, begin, [x|...], end], _75544) ? creep
   Call: (93) [x, >, 0, ')', then, begin, [x|...], end]=[0|_75536] ? creep
   Fail: (93) [x, >, 0, ')', then, begin, [x|...], end]=[0|_75536] ? creep
   Fail: (92) t([x, >, 0, ')', then, begin, [x|...], end], _75682) ? creep
   Fail: (91) b([x, >, 0, ')', then, begin, [x|...], end], _75726) ? creep
   Fail: (90) f([if, '(', x, >, 0, ')', then, begin|...], _66584) ? creep
   Redo: (89) sentence([if, '(', x, >, 0, ')', then, begin|...], _66584) ? creep
   Call: (90) t([if, '(', x, >, 0, ')', then, begin|...], _75858) ? creep
   Call: (91) [if, '(', x, >, 0, ')', then, begin|...]=[x|_75850] ? creep
   Fail: (91) [if, '(', x, >, 0, ')', then, begin|...]=[x|_75850] ? creep
   Redo: (90) t([if, '(', x, >, 0, ')', then, begin|...], _75996) ? creep
   Call: (91) [if, '(', x, >, 0, ')', then, begin|...]=[y|_75988] ? creep
   Fail: (91) [if, '(', x, >, 0, ')', then, begin|...]=[y|_75988] ? creep
   Redo: (90) t([if, '(', x, >, 0, ')', then, begin|...], _76134) ? creep
   Call: (91) [if, '(', x, >, 0, ')', then, begin|...]=[z|_76126]  
 Fail: (91) [if, '(', x, >, 0, ')', then, begin|...]=[z|_76126] ? creep
   Redo: (90) t([if, '(', x, >, 0, ')', then, begin|...], _76272) ? creep
   Call: (91) [if, '(', x, >, 0, ')', then, begin|...]=[1|_76264] ? creep
   Fail: (91) [if, '(', x, >, 0, ')', then, begin|...]=[1|_76264] ? creep
   Redo: (90) t([if, '(', x, >, 0, ')', then, begin|...], _76410) ? creep
   Call: (91) [if, '(', x, >, 0, ')', then, begin|...]=[0|_76402] ? creep
   Fail: (91) [if, '(', x, >, 0, ')', then, begin|...]=[0|_76402] ? creep
   Fail: (90) t([if, '(', x, >, 0, ')', then, begin|...], _76548) ? creep
   Fail: (89) sentence([if, '(', x, >, 0, ')', then, begin|...], _66584) ? creep
false
?- sentence([if, '(', x, >, 0, ')', then, begin, x, =, 1, end], X).
X = []
Yes (0.00s cpu, solution 1, maybe more)
No (0.00s cpu)
?- phrase(sentence,[if,'(', x, >, 0,')', then, begin, [x, =, 1], end]).
false.

?- phrase(sentence,[_ ,  _, _, _, _,  _,    _,     _, [_|  _  ]|   _]).
false.

sentence--> f ; t, n, t.

?- length(L,_), phrase(sentence,L).
   L = [x, +, x]
;  L = [x, +, y]
;  L = [x, +, z]
;  L = [x, +, 1]
;  L = [x, +, 0]
;  ...