It was on the very first day of Artificial Intelligence class that our professor introduced us to the Prolog programming language. Prolog, which means PROgramming in LOGic is one of the standard languages that are used for AI related work. Being used to traditional languages like C and C++, Prolog's approach felt quite a bit odd to me. Prolog is a declarative non-procedural language which takes quite some time to get used to, more so if you are used to programming in usual procedure oriented languages.
Well, I am facing a lot of obstacles to learn Prolog. I cannot clear them all through one blog post. But I guess I can help out everybody with the basics.
Study Materials
I am not at all a knowledgeable person on prolog, but I liked the book "Prolog programming for AI" by Ivan Bratko. Having read no other book on this subject, I cannot possibly compare it, but the book is quite easy to understand.
Compiler
There are a lot of compilers available for prolog on the market. If you already have not got one, I would recommend GProlog which is the GNU implementation of Prolog, available both under Win32 and Linux environments. It supports the ISO standards of Prolog and is completely free. Being a GNU software, it has all the open source advantages too. Download GProlog from the site and install it. The installation is straight forward and intuitive.
First Prolog Program
I am not sure whether prolog has a Hello World program, but I started with a simple parent relationship program as given in Chapter 1 of Bratko's book. You can download the source file parent.pro that I wrote from Bigyan_Prolog, (password: bigyan). To load the file, start GProlog and go to Files>Consult and select the prolog file (extension .pro). Then in the command line you should see a compiled message after which you can try writing goals in the GProlog window.
In Future
I have just began with prolog. I am getting to learn new things regularly. So in future watch out this space for more stuff on Prolog, especially my own programs that I will upload from time to time in the Bigyan_Prolog web space. I have always wanted to distribute the simple programs of mine to everyone who needs them, but for languages like C and C++, I have lost most of them. So this time I plan to methodically upload them to Internet.
Thanks for the program and post. Though it may seem trivial, you solved a problem I was having (of finding out how to load a Prolog program into the interpreter). I didn't know about how consult worked, and so was getting irritated over not being able to use any of the examples given in Bratko.
ReplyDeleteI agree with you on that, by the way. It's a really nice book.
Again, thanks!