:- op(1100,xfx,'--->').

% ?- recognise(s,<list(word)>,[]).
recognise(Phrase,[Word|S1],S) :- 
   (Cat ---> [Word]),
   lc(Cat,Phrase,S1,S).

lc(Phrase1,Phrase2,S,S) :- 
   fs_unify(Phrase1,Phrase2).

lc(SubPhrase,SuperPhrase,S0,S) :-
    Phrase ---> [SubPhrase,Right],
    recognise(Right,S0,S1),
    lc(Phrase,SuperPhrase,S1,S).


recognise(MotherFs) --> [Word],
                        {CatFs ---> Word},
                        lc(CatFs,MotherFs).

lc(Fs1,Fs2) --> [],
                {fs_unify(Fs1,Fs2)}.

lc(SubPhraseFs,SuperPhraseFs) -->
    {PhraseFs ---> [SubPhraseFs,RightFs]},
    recognise(RightFs),
    lc(PhraseFs,SuperPhraseFs).
