Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:37:04+00:00 2026-06-07T20:37:04+00:00

I’m a prolog beginner. I would really appreciate any help for compiling this example.

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:37:05+00:00Added an answer on June 7, 2026 at 8:37 pm

    The error message is about your usage of the semi-colon, ;. You can’t redefine it.

    You can’t change the false predicate either. So I’m surprised that you say this compiles:

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

    It doesn’t compile for me. 🙂 (SWI-Prolog)

    In the second rule, I think 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. In that case you would need:

    catch(X,Y) :- ...,...,...,...,not(intelligent(Y)).

    (As you found yourself, and edited in your post. 🙂

    Note: The link you provided shows some statements which are logically equivalent but that doesn’t mean you can use them in code, because they are not procedurally equivalent in Prolog. You can use false and ; in your queries (at the prolog prompt), or in rule bodies, but not in rule heads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I would like to run a str_replace or preg_replace which looks for certain words
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.