28 Mayıs 2009 Perşembe

Prolog, A Logic Programming Language

Prolog is a useful language in logic issues.
It's paradigm is declarative. In other words, you declare some realities and it creates the relations using a backtrack mechanism. It creates a search tree from the realities that you declared and searches for all valid paths. You can also tell it to cut the operation when it finds a valid way.
Prolog is a very powerful tool if you are interested in developing artifical intelligence-like models and also if you are trying to prove mathematical and computational issues.
The syntax of prolog is a bit different from the usual programming languages that we are familiar with. It consists of declarations which end with a dot as in natural languages. And the symbol :- means that the left-hand side is true if the expressions on the right-hand side are all true.
A short Prolog example is below:

human(socrates).
mortal(X):-human(X).

The little program above means that socrates is a human, and all human beings are mortal. So after loading the source file with command below:

consult(filename).

or

consult('full path of file').

You can make the query mortal(socrates) and you will get yes. Note that if i wrote Socrates instead of socrates, i would mean everything is human.

If you are interested in it, you can find a detailed information about Prolog here:
Prolog Guide

My personal choice of prolog implementation is GNU-Prolog, which you can find at:
gprolog.org

Hiç yorum yok:

Yorum Gönder