:- [pg_with_trace]. fgh :- name(FileName, "ex_fgh.pl"), open(FileName,write,Stream), sigma_pg(pg(f,[f,g,h],[ [(f(0,v,w) -> g(v,w)), (f(s(u),v,w) -> f(u,s(v),w)+(f(u,s(v),w)+f(u,s(v),w)))], [(g(0,w) -> h(w)),(g(s(v),w) -> g(v,w)*g(v,w))], [(h(0) -> a),(h(s(w)) -> b(h(w)))] ]),Stream), close(Stream). % bash-2.03$ sicstus % SICStus 3.8.3 (sparc-solaris-5.7): Mon May 8 14:25:09 MET DST 2000 % Licensed to info.univ-angers.fr % | ?- ['example_fgh.pg']. % {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/example_fgh.pg...} % {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/pg_with_trace.pl...} % {loading /opt/SICStus-3.8.3/lib/sicstus-3.8.3/library/lists.po...} % {module lists imported into user} % {loaded /opt/SICStus-3.8.3/lib/sicstus-3.8.3/library/lists.po in module lists, 0 msec 20472 bytes} % {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/pg_with_trace.pl in module user, 20 msec 36744 bytes} % {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/example_fgh.pg in module user, 20 msec 37944 bytes} % yes % | ?- fgh. % yes % | ?- [ex_fgh]. % {consulting /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/ex_fgh.pl...} % {consulted /home/info/helios/stephan/public_html/Research/GRAMMAIRES/PG/PROGRAMMATION/SICSTUS/ex_fgh.pl in module user, 0 msec 1816 bytes} % yes % | ?- phrase_pg(X,f,[s(0),s(0),s(0)],user_output). % f+(f+f) % g+(g+g) % g*g+(g*g+g*g) % g*g*(g*g)+(g*g*(g*g)+g*g*(g*g)) % h*h*(h*h)+(h*h*(h*h)+h*h*(h*h)) % b(h)*b(h)*(b(h)*b(h))+(b(h)*b(h)*(b(h)*b(h))+b(h)*b(h)*(b(h)*b(h))) % b(a)*b(a)*(b(a)*b(a))+(b(a)*b(a)*(b(a)*b(a))+b(a)*b(a)*(b(a)*b(a))) % X = b(a)*b(a)*(b(a)*b(a))+(b(a)*b(a)*(b(a)*b(a))+b(a)*b(a)*(b(a)*b(a))) ? % yes % | ?-