Saturday, January 8, 2011

Prolog Introduction-I(AI ,CS409)

 

  Hi guys after very long time I’m posting for this blog because My Computer so speed to do blogging or web developing [you know what i mean:) ].

  Any way I came to know this SW with AI lecture  series.First I thought it will be boring one as it has text editor with hard compiling manner but after doing some exercise it makes some sense. That would be the reason why I’m posting this to encourage people to use it.

Before the Starting this use following link download it.It’s come under lesser GNU public license  freely available with SWI-Prolog site and nearly 8Mb.Also don’t forget to check the version before download it’s compatible to your PC.

http://www.swi-prolog.org/download/stable 

 

When you open swi-prolog you can see window like above but when you click on menu item you might get some doubts because it’s refer some menu item for different purpose ex:-Run menu not involve for executing program.

First we need to create new file (extension will be .pl) by file->new then it will open some editor and after editing  save it(it appears as save buffer; Ctrl+S works).

image

Prolog has its roots in formal logic, and unlike many other programming languages, Prolog is declarative: The program logic is expressed in terms of relations, represented as facts and rules. A computation is initiated by running a query over these relations.

There are some basic rules.

after every line finish with full stop(.)
define thing. 
to declare thing use following format declare_what(thing) 
male(nimal). 
this means "Nimal is a male" is true.we can write this one as 
male(Nimal):-true.





 




After saving this have to compile that by file->consults and then open source file then it gives message then type above formula then check it replies true.





1 ?- % j:/Documents and Settings/common/My Documents/Prolog/Ex1.pl compiled 0.00 sec, 136 byte
1 ?- male(nimal).
true . 
2 ?- male(namal).
false .



















For the time being I stop this if you interested check part II(if not you have to best things happen last)  :)

No comments:

Post a Comment

Don't forget to Reply if you like my post.
If you don't Reply Post will Die........