Short & Simple Prolog Tutorial
Results 1 to 2 of 2

Thread: Short & Simple Prolog Tutorial

  1. #1
    Senior Member
    Join Date
    Jan 2002
    Posts
    187

    Talking Short & Simple Prolog Tutorial

    i've been here almost 3 months now without really posting anything too useful, so i thought i'd start with a simple toutorial of my latest interest: prolog.

    What is Prolog
    prolog is not like any language you've probably used before. prolog is short for PROgramming in LOGic. programs consist of datebase of rules and facts, and are run by asking the compiler questions that can be proven by the database.

    Who Uses Prolog?
    you aren't going to find many fans of prolog among systems programers or anyone writing large scale applications. it is mostly used in the artifical intelligence community for natural language interfaces and automated reasoning systems.

    Logic
    to start off a program in prolog you need to compile a database of facts. most are pretty straightforward:

    female(sally).

    defines sally as a female.

    parent(chuck, sally).

    defines chuck as sally's parent. once you have a complete database, you can start defining rules. for example:

    father(X,Y):- male(X), parent(X,Y).

    defines the father of Y as the male parent of Y. therefore if my database contains:

    male(bruce).
    male(chuck).
    male(brian).
    parent(brian, alice).
    parent(bruce, steve).
    father(X,Y):- male(x), parent(X,Y).


    asking the compiler
    ?- father(X,Y).

    will return
    X=brain
    Y=alice
    X=bruce
    Y=steve


    more specifically, asking the compiler
    ?-father(x,alice).

    will return
    Y=brian.

    Word of Warning
    prolog compliers are famous for having just one response to dealing with questions they can't answer or databases with syntax errors: "No." if you don't like having your computer telling you "No." then maybe prolog is not for you

    anyway prolog is fun once you get the hang of it. if anyone has any questions, comments, please feel free to message me, i'm always looking for (constructive) criticsism!

    ps - i'm playing with some small interactive programs, little ones that can carry on very simple conversations....just few responses to simple questions ("how are you today?" "great! thanks for asking") and with time could grow to have simple personalities if anyones interested or would like to contribute i'm more then willing to share the spotlight. thanx again!
    U suk at teh intuhnet1!!1!1one

  2. #2
    Senior Member
    Join Date
    Dec 2001
    Posts
    319
    Wow...that brings back memories...haven't heard anything about Prolog in years

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides