% -*- prolog -*-

%%% a(string) means string is accepted, ie in language.
%%% eg a([f, o, o]), assuming "foo" is in language.

%%% NFA

%%% Start state

a(S) :- b(0, S).

%%% b(s1, string) means string is accepted starting at state s1.

%%% Accepting states:

b(Q, []) :- member(Q, [0, 30, 50]).

%%% Transitions:

b(Q, [X|S]) :- trans(Q, R, X), b(R, S).

trans(Q, R, X) :- member([Q, R, X],
	                 [[0, 31, x],
		          [0, 51, x],
			  [30, 31, x],
			  [31, 32, x],
			  [32, 30, x],
			  [50, 51, x],
			  [51, 52, x],
			  [52, 53, x],
			  [53, 54, x],
			  [54, 50, x]]).
