Solution
initial(1).
final(3).
arc(1,2,det).
arc(2,2,adj).
arc(2,3,cn).
arc(1,3,pn).
arc(3,1,prep).
lex(a,det).
lex(the,det).
lex(fast,adj).
lex(brave,adj).
lex(witch,cn).
lex(wizard,cn).
lex(broomstick,cn).
lex(rat,cn).
lex(harry,pn).
lex(hermione,pn).
lex(ron,pn).
lex(with,prep).
As for the fsa recognizer we use the one in recognise2.pl but instead of
traverse2('#',String,String).
traverse2(Label,[Label|Symbols],Symbols).
we use
traverse3('#',String,String).
traverse3(Label,[Symbol|Symbols],Symbols) :-
lex(Symbol,Label).
obtaining recognise3.pl