%%% Difference lists --- see p&S p.126-7 conc_dl(Front-Back1, Back1-Back2, Front-Back2). %| ?- [conc_dl]. %% consulting /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/conc_dl... %% consulted /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/conc_dl in module user, 0 msec -88 bytes %yes %| ?- conc_dl([1,2,3|X]-X, [4,5,6|Y]-Y, R). %R = [1,2,3,4,5,6|Y]-Y, %X = [4,5,6|Y] ? %yes %| ?- %%% Reflect that S -> NP VP is equivalent to saying %%% s(W) :- np(U), vp(V), conc_dl(U,V,W). %%% %%% This can be partially executed to get rid of the last literal by %%% writing %%% s(P0-P) :- np(P0-P1), vp(P1-P). %%% %%% The following clause then induces a representation of string position %%% in terms of the syubstring following the position. connects(Word, [Word|Rest],Rest). % | ?- [dcg0]. %% consulting /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/dcg0... %% consulted /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/dcg0 in module user, 0 msec -88 bytes %yes %| ?- [conc_dl]. %% consulting /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/conc_dl... %The procedure connects/3 is being redefined. % Old file: /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/dcg0 % New file: /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/conc_dl %Do you really want to redefine it? (y, n, p, s, a, b, or ?) y %% consulted /amd/nfs/pegasus/disk/ptn053/steedman/lectures/tl/conc_dl in module user, 0 msec -488 bytes %yes %| ?- s([harry,sees,the,frog,that,walks],[]). %yes %| ?- s([harry,sees,the,frog,that],[]). %no %| ?- s([harry,sees,the,frog],[]). %yes %| ?- % %%%% Running in (-,+) mode %| ?- s(L,[]). %L = [harry,sees,harry] ? ; %L = [harry,sees,barry] ? ; %L = [harry,sees,the,frog] ? ; %L = [harry,sees,the,frog,that,sees,harry] ? ; %L = [harry,sees,the,frog,that,sees,barry] ? ; %L = [harry,sees,the,frog,that,sees,the,frog] ? ; %L = [harry,sees,the,frog,that,sees,the,frog,that,sees|...] ? ; %L = [harry,sees,the,frog,that,sees,the,frog,that,sees|...] ? %yes %| ?- %%%% NB we never get e.g the frog sees harry.