Reputation: 1528
I'm using SWI-Prolog version 7.6.4 on Arch Linux.
I have this database of facts:
female(mary). female(liz). female(mia). female(tina). female(ann). female(sue).
male(mike). male(jack). male(fred). male(tom). male(joe). male(jim).
parent(mary, mia). parent(mary, fred). parent(mary, tina).
parent(mike, mia). parent(mike, fred). parent(mike, tina).
parent(liz, tom). parent(liz, joe).
parent(jack, tom). parent(jack, joe).
parent(mia, ann).
parent(tina, sue). parent(tina, jim).
parent(tom, sue). parent(tom, jim).
And I defined the mother
predicate as follows:
mother(M, C) :- parent(M, C), female(M).
The predicate works as intended:
?- mother(liz, tom).
true .
?- mother(liz, fred).
false.
Now I like to define an operator to be used like liz mother tom
with a relatively low precedence, which I do like this:
op(1111, xfx, mother).
This gives me an error on that exact line:
ERROR: /home/user/prolog/family.pl:13:
No permission to modify static procedure `op/3'
I have no idea what I am doing wrong.
As requested, here's the full file in one listing:
female(mary). female(liz). female(mia). female(tina). female(ann). female(sue).
male(mike). male(jack). male(fred). male(tom). male(joe). male(jim).
parent(mary, mia). parent(mary, fred). parent(mary, tina).
parent(mike, mia). parent(mike, fred). parent(mike, tina).
parent(liz, tom). parent(liz, joe).
parent(jack, tom). parent(jack, joe).
parent(mia, ann).
parent(tina, sue). parent(tina, jim).
parent(tom, sue). parent(tom, jim).
mother(M, C) :- parent(M, C), female(M).
op(1111, xfx, mother).
Upvotes: 4
Views: 304
Reputation: 1528
As @lurker described it in the comments, op/3
is a directive. It works like this:
:- op(1111, xfx, mother).
Upvotes: 4