/************************************************ File: empty0.pl Author: Mihaela Malita Title: The emptiness problem. L(G) = 0 ? Find if your grammar generates at least one word. Example. ?- start. Check if our grammar generates any word generated-[a, b] Yes ***************************************************/ start:- write('Check if our grammar generates any word\n'), empty_grammar. /* L(G)= a^nb^n. Grammar is s --> [a],[b]. s --> [a],s,[b]. */ /* Same in grammar but in Chomsky normal form. */ s --> xa,xb. xa --> [a]. xb --> [b]. s --> xa,y. y --> s,xb. % check if there is any word generated by the grammar % prints first word then stops empty_grammar:- phrase(s,W), write(generated-W).