parent(mohan,mahesh).
parent(jaya,mahesh).
male(mohan).
female(jaya).
father(X,Y) :- parent(X,Y) , male(X).
mother(X,Y) :- parent(X,Y) , female(X).
Didn't get much, did you ? Neither did I (sorry Sonia Ma'am) till I got this crazy idea of learning prolog. To confuse you even more let me add the term Artificial Intelligence into the pot.
Prolog is the language used to solve advanced problems (problems that are a thousand times advanced) using artificial intelligence and the above is the knowledgebase for the first ever program I did in Prolog. What I meant is Prolog is a logical programming language used to create and emulate logic (there goes the geek me again). Never mind leave it you'll understand better as we go on.
Ok, try this. You type the above snippet of code into a .pl file and you execute it with Prolog and then you type in father(mohan,mahesh). the program returns yes. No no this is not how I proved that mohan is in fact my father but it simply is the first program that I did by using Artificial Intelligence (TA-DA!).
Now you would be thinking why would someone need artificial intelligence to do something as simple as that. This program simply shows the basic working of how a Logic Program looks like. Now catch this this is exactly how when you go to some photo page in my Facebook profile you see an ad like
Rahman 360ยบ Mahesh Mohan likes this
University exams fast approaching, I lose my head often. Sorry.
No comments:
Post a Comment