/* File: gram1.pl Author: Mihaela Malita Title: Grammar for L(G)= a^n b^n ?- start. Grammar for a^n b^n Input a word as a list:[a,a,b,b]. Generated! Continue(y/n)?= y. Grammar for a^n b^n Input a word as a list:[a,a,b]. Not generated! Continue(y/n)?= n. */ % This is the Grammar s --> [a],[b]. s --> [a],s,[b]. start:- write('Grammar for a^n b^n'),nl, write('Input a word as a list:'),read(W), (phrase(s,W) -> write('Generated!') ; write('Not generated!')), nl,yesorno,start. yesorno:- write('Continue(y/n)?= '),read(R),R=y.