View source with formatted comments or as raw
    1alpha(a).
    2alpha(b).
    3alpha(c).
    4
    5alpha_num(a).
    6alpha_num(d).
    7alpha_num(e).
    8alpha_num(0).
    9alpha_num(1).
   10alpha_num(2).
   11
   12alpha_spec(e).
   13alpha_spec(f).
   14alpha_spec(g).
   15alpha_spec('#').
   16alpha_spec('&').
   17
   18member(X,[X|T]).
   19member(X,[_|T]) :- member(X,T).
   20
   21state1(L) :- not alpha(X), not member(X,L), not state2(L).
   22state1(X).
   23%state2(L) :- not alpha_num(X), not member(X,L), not state3(L).
   24state2(L) :- not state3(L).
   25%state3(L) :- not alpha_spec(X), not member(X,L), not state1(L).
   26state3(L) :- not