Reddy
Reddy

Reputation: 497

Unable to use user-defined operator in Prolog

I've been stuck for quite some time on this issue, my Prolog program has the following line within its operator definitions:

:- op(100, xfx, [has,gives,'does not',eats,lays,isa]).

and then this fact:

fact :: X isa animal :-
     member(X, [cheetah,tiger,giraffe,zebra,ostrich,penguin, albatross]).

When I try to use the operator It says it is undefined and I just do not understand why.

?- peter isa tiger.
ERROR: [Thread pdt_console_client_0_Default Process] toplevel: Undefined  
procedure: (isa)/2 (DWIM could not correct goal)

Sorry if its something silly (which it probably is) but I am new to Prolog. Any help is much appreciated.

Upvotes: 1

Views: 297

Answers (1)

repeat
repeat

Reputation: 18726

It is working. See for yourself:

    stefan@stefan-Lenovo-G510 ~ $ swipl
    Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.12)
    % ...

    ?- op(100, xfx, [has,gives,'does not',eats,lays,isa]).
    true.

    ?- Term = (peter isa tiger).
    Term = peter isa tiger.

The error message that you got ...

    procedure: (isa)/2 (DWIM could not correct goal)

... says that too!

Is it clearer now?

Upvotes: 3

Related Questions