Swi-Prolog: No permission to modify static procedure

Viewed 12096

I'm a prolog beginner. I would really appreciate any help for compiling this example. I guess rules are in the form "consequent :- antecedent"

%rules
prey(Y2), watch(X2,Y2) :- predator(X2).
false :- predator(X1),prey(Y1),intelligent(Y1),watch(X1,Y1),catch(X1,Y1).
catch(X3,Y3);hungry(X3) :- predator(X3),prey(Y3),watch(X3,Y3).

%facts
predator(shaki).
prey(pelusa).
intelligent(shaki).
intelligent(pelusa).
watch(shaki,pelusa).

I compiled the code using SWI-Prolog version 5.10.4 (i386, Ubuntu Natty Narwhal):

swipl -s "pathofthecode.pl"

Swi-Prolog threw this error for the second rule:

'$record_clause'/2: No permission to modify static_procedure `(;)/2'

Thanks azhrei, you said: " I think what you're trying to say is X1 will not be able to catch Y1, even though X1 is a predator watching the prey Y1, because Y1 is intelligent.", yes it is!!

I found that prolog has some strong constrains [1]:

  1. Prolog doesn't allow "or" (disjunctive) facts or conclusions.
  2. Prolog doesn't allow "not" (negative) facts or conclusions.
  3. Prolog doesn't allow most facts or conclusions having existential quantification.
  4. Prolog doesn't directly allow second-order logic.

So I changed the code like so:

%rules
predator(X) :- prey(Y), watch(X,Y).
catch(X,Y) :- predator(X),prey(Y),not(intelligent(Y)),watch(X,Y).
hungry(X) :- predator(X),prey(Y),watch(X,Y),not(catch(X,Y)).

%facts
prey(pelusa).
intelligent(shaki).
intelligent(pelusa).
watch(shaki,pelusa).

I also tried using:

 false :- predator(X),prey(Y),intelligent(Y),watch(X,Y),catch(X,Y).

And it compiles, but when prolog needs to find whether catch(X,Y) is true or not, it can't because the predicate isn't in a rule consequent.

--

[1]. Neil C. Rowe, URL:http://faculty.nps.edu/ncrowe/book/chap14.html

Note: this example was taken from professor Yadira Solano course at UCR, Costa Rica

1 Answers
Related