Ndfa interpreter

Description

An interpreter for a nondeterministic finite automaton (NDFA)

Source: The Art of Prolog

Download

Program source code: ndfa_interpreter.pl

Listing

/*
	accept(Xs) :-
		The string represented by the list Xs is accepted by
		the NDFA defined by initial/1, delta/3, and final/1.
*/
	accept(Xs) :- initial(Q), accept(Xs,Q).
 
	accept([X|Xs],Q) :- delta(Q,X,Q1), accept(Xs,Q1).
	accept([],Q) :- final(Q).
 
 
	initial(q0).
	final(q0).
 
	delta(q0,a,q1).
	delta(q1,b,q0).
 
%   Program 17.1: An interpreter for a nondeterministic finite automaton (NDFA)
%	Program 17.2: An NDFA that accepts the language (ab)*

Comments

pl/prolog/pllib/ndfa_interpreter.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0