I know this is probably a stupid question, but I’m just reading the first chapter of Bratko Prolog Programming for artificial intelligence.
One of the first programs has clauses like
parent(ann, pat).
My question: parent, is that something that is built in to Prolog? Or is it something that is dealt with dynamically. Can I just go and invent things like:
dog(ann, pluto).
2
Answers
Yes, you can invent things like that. It is called
clause
s, this type of clauses is calledfact
s. Facts are what your database is made of in Prolog. When you sayyou define relationship
dog
between two objectsann
andpluto
, these objects are calledatom
s and they are constant.You can then query your database
Prolog will tell you if there is no defined relationship in database
Yes. The simple answer is that you can just invent things like.
These are simple FACTS that prolog will hold in its internal database. This is not a relational database. Just a collection of FACTS.
parent is not build into Prolog.
What make it interesting and useful is that you can create various rules to expand and confirm relationships for you.
Then you can ask
which will succeed it it is true, or fail if not.
Or you could ask
and prolog should try and find and print out all grandparents of ann
or if you extend your FACTS base to include
then
can be deduced.
Suggest you keep on reading your book and all will be revealed.