Prolog introduction
There are many programming languages that exist in the market. There are many paradigms in programming. Prolog is a logical and declarative language. Program is PROgramming in LOGic. French clause ‘programmation en logique’. This means programming in logic. Prolog differs from other programming languages. It was developed by a French scientist.
Prolog is particularly used by programs that use non numeric objects. Programmer has to specify how to solve a problem. The general purpose of the language is associated with AI and computational linguistics. Program logic is expressed in terms of relations and execution is triggered by running queries over these relations.
What is a relation? It consists of facts and rules. Basically how things are related;
For example: I love programming. This is describing a relationship between me and programming.
Imran loves basketball à relation
?- Imran loves basketball /*The query question mark at beginning indicates a query*/
Yes /*this is the output we get from the query we ran*/
Ejaz_lost_his_room_keys /*this means Ejaz lost his room keys*/
?-Imran_lost_his_room_keys /*we are asking the computer to check if imran lost his room keys*/
No /*we get a no to be the answer*/
What if we have two people doing the same thing like reading a book?
|
?-reads(people,’book’). /*people The group reads a book*/ people=Imran; /*people include Ayesha and Imran*/ people=Ayesha; |
Prolog is a very case sensitive language. What do we mean by saying case sensitive? An example will be HELLO WORLD, and hello world.
HELLO WORLD is in upper case as it is all capitalized where as hello world is in lower case as it is in small characters.
Prolog can be divided into two parts
· One is the program, the program has an extension of pl (i.e. *.pl) this is the file that contains all the facts and rules.
· The other part is the query which is actually running the program. We ask about the relationships we described in the program.
So where is it used? It is used in databases, Backend of websites, Artificial Intelligence, Expert systems, Programs using non numeric objects, computational linguistics.
Where can I get the compiler from? SWI-prolog is the compiler that I know there might be others in the market. But this one works fine. Link is http://www.swi-prolog.org/
Tags: intro to prolog, logic, programming, prolog







Thanks. these are not proper code snippets. just basic information about facts and how prolog works. proper snippets need more explanation than this. so i will try to make up a post in which i can include proper code for SWI-Prolog. so dont worry. i hope the other part that i was trying to explain was clear . if the information on fact and relations is still unclear please let me know.