/* File: gram2.pl Author: Mihaela Malita Title: Grammar for L(G)= a^n b^n ?-start. Grammar for a^n b^n Input a word: aabb. Generated Continue(y/n)?= y. Grammar for a^n b^n Input a word as a list: aab. Not generated Continue(y/n)?= n. */ s --> [a],[b]. s --> [a],s,[b]. start:- write('Grammar for a^n b^n'),nl, write('Input a word: '),read(A),atom_chars(A,L), (phrase(s,L) -> write('Generated') ; write('Not generated')), nl,yesorno,start. yesorno:- write('Continue(y/n)?= '),read(R),R=y.