Prolog help

Some help on Prolog

Page 1 of 1

3 Replies - 1832 Views - Last Post: 14 April 2009 - 08:50 AM Rate Topic: -----

#1 sniper079  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-April 09

Prolog help

Post icon  Posted 12 April 2009 - 10:11 AM

Hi,

Can somebody help me with this question please, since I can't figure it out how to work it.


Assume that the following rules and facts have been given and that they have been given in this order:
1.	   Bigger(cat,apple).
2.	   Bigger(house,truck).
3.	   Bigger(cat,cat).
4.	   Bigger(lion,cat).
5.	   Bigger(house,lion).
6.	   Bigger(truck,car).
7.	   Bigger_than(A,B):-bigger(A,B).
8.	   Bigger_than(A,B):-bigger(A,C),bigger_than(C,B).

What is the result of executing the query bigger_than(truck,lion)?

This post has been edited by sniper079: 12 April 2009 - 02:19 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Prolog help

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 724
  • View blog
  • Posts: 4,471
  • Joined: 24-October 08

Re: Prolog help

Posted 12 April 2009 - 07:26 PM

this will give you an error, since all the predicates start with a capital letter, in prolog if a word starts with a capital letter then its interpreted as a variable and the name of a predicate cant be a variable.
Was This Post Helpful? 0
  • +
  • -

#3 sniper079  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-April 09

Re: Prolog help

Posted 13 April 2009 - 09:39 AM

View Postsniper079, on 12 Apr, 2009 - 09:11 AM, said:

Hi,

Can somebody help me with this question please, since I can't figure it out how to work it.


Assume that the following rules and facts have been given and that they have been given in this order:
1.	   Bigger(cat,apple).
2.	   Bigger(house,truck).
3.	   Bigger(cat,cat).
4.	   Bigger(lion,cat).
5.	   Bigger(house,lion).
6.	   Bigger(truck,car).
7.	   Bigger_than(A,B):-bigger(A,B).
8.	   Bigger_than(A,B):-bigger(A,C),bigger_than(C,B).

What is the result of executing the query bigger_than(truck,lion)?


but what happens the the query bigger_than(truck,lion)?
I've tried to work it with a prolog programm and this is the result that I'm having, and I'm not sure what I'm doing wrong.
 ?- bigger_than(truck,lion).
ERROR: toplevel: Undefined procedure: bigger_than/2 (DWIM could not correct goal)

Was This Post Helpful? 0
  • +
  • -

#4 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 724
  • View blog
  • Posts: 4,471
  • Joined: 24-October 08

Re: Prolog help

Posted 14 April 2009 - 08:50 AM

bigger_than is not defined in your knowledge base, you have to define the predicate first

This post has been edited by mostyfriedman: 14 April 2009 - 08:50 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1