Search code examples
prologdcg

Undefined procedure: (=)/4


I want to compare two terms in SWI-Prolog:

np(np(DetBaum,NBaum),Morph1)->det(DetBaum,Morph1),n(NBaum,Morph2),Morph1=Morph2. 

I get the following error message:

ERROR: Undefined procedure: (=)/4  
ERROR:   However, there are definitions for:  
ERROR:         (=)/2

I thought Morph1 and Morph2 are two terms, not four. Am I wrong?


Solution

  • In grammar rules, calls to predicate such as =/2 must be wrapped using the {}/1 control construct:

    np(np(DetBaum, NBaum), Morph1) -->
        det(DetBaum, Morph1),
        n(NBaum, Morph2),
        {Morph1 = Morph2}. 
    

    This prevents the compilation of the grammar rule to interpret =/2 as a non-terminal.