prod('Z',[d]).
prod('Z',['X','Y','Z']).
prod('Y',nil).
prod('Y',[c]).
prod('X',['Y']).
prod('X',[a]).
nonTerminal(X) :- prod(X,_).
nonTerminals(N) :- setof(X,nonTerminal(X),N).
nullable(X) :- prod(X,nil).
nullable(X) :- prod(X,Y), nullableString(Y).
nullableString([]).
nullableString([X|L]) :- nullable(X), nullableString(L).
