QuickStart Prolog - PowerPoint PPT Presentation

About This Presentation
Title:

QuickStart Prolog

Description:

Created by Robert Kowalski and Alain Colmerauer sometime around 1972. ... Decidedly geek-non-friendly. This, along with late spec publication (1995! ... – PowerPoint PPT presentation

Number of Views:123
Avg rating:3.0/5.0
Slides: 18
Provided by: cscVil
Category:

less

Transcript and Presenter's Notes

Title: QuickStart Prolog


1
QuickStart Prolog
  • Learning to Program in Prolog
  • Richard Banister
  • November 9, 2005

2
What is Prolog?
  • A Logical Programming Language
  • Why logical?
  • Created by Robert Kowalski and Alain Colmerauer
    sometime around 1972.
  • Original intended for natural language parsing
  • Now used in AI, expert systems

3
The Logical Paradigm
  • Based on logical reasoning
  • Execution as mathematical proof
  • Non-sequential design
  • Fun!

4
Prolog as a Logical Language
  • Predicates are entered into a database
  • Rules are created
  • Queries are run against said predicates and rules
  • Results are determined only from what is known to
    be true
  • Well, how do we do anything?

5
A Logical Example
  • Take this example
  • cat(Timmy).legs(cat, 4).?- legs(Timmy, 4)yes
  • Yeah!
  • We can also do useful stuff

6
Prolog Advantages
  • Its a Logical Programming language
  • Its the only game in town
  • Thats about it.

7
Prolog Disadvantages
  • Limited sphere of usefulness
  • Not a pure logical language
  • It dont have the fancy graphics the youngsters
    are raving about
  • It wont make you popular with the ladies

8
Java or Prolog?
  • Kind of a silly question
  • Depends greatly on project goal
  • Prolog for web app not a good idea
  • Java for robot army maybe not a good idea
    either
  • Yet they are being combined together as we speak

9
Prolog Specification
  • Well, its a funny story
  • Prolog spec available for a price
  • Grammar is not reprintable on web
  • Decidedly geek-non-friendly
  • This, along with late spec publication (1995!),
    may be why Prolog hasnt taken over the world?
  • But we do know some things about the grammar

10
Prolog Grammar
  • A free approximate grammar can be found online
    (https//www.freytag.us/twiki/bin/view/Freytag/ISO
    StandardPrologGrammar)
  • Heres a sample
  • Possibly not complete, but note simplicity

11
Is Prolog Dead?
  • Not quite. Still kicking in AI
  • New extensions are being developed
  • Visual Prolog
  • Prova

12
Language Specifics
  • PredicateA statement given to be true ex.
    cat(Timmy).
  • RuleA method for proving future resultsex.
    cat(X) - legs(4, X), whiskers(X),
    intent_to_destroy(X).
  • QueryA request to prove a resultex.
    whiskers(Uncle Jerry). Intent_to_destroy(Uncle
    Jerry). Legs(1, Uncle Jerry). ?- cat(Uncle
    Jerry). no

13
Step 0 Getting Started
  • Get to know logical programming and Prolog
  • There are many websites that contain useful, if
    cryptic, Prolog information.

14
Step 1 Really Getting Started
  • Download install GNU interpreterhttp//pauilla
    c.inria.fr/diaz/gnu-prolog/
  • You can get the source, too, if you really want
    it
  • Read up the GNU interpreter isnt easy

15
Step 2 Writing
  • Create a plain text file
  • Some editors have context-sensitive highlighting,
    but its probably not necessary
  • File should contain predicates and rules, not
    queries
  • Create a legendary, essential logical application
    (maybe, dog(Rover)?)

16
Step 3 Import Source File
  • Start the interpreter.
  • Use the consult command (or shortcut) to open and
    compile the source codeex. consult(/projects/pro
    log/cat.pl).
  • Note the use of Unix-style file reference. This
    isnt necessarily documented in the help file.
  • Assuming no errors, run queries on your program

17
Learning more about Prolog
  • Visit the QuickStart Languages web
    sitehttp//actlab.csc.villanova.edu/quickstart
  • Read up on logical languageshttp//en.wikipedia.o
    rg/wiki/Logic_programming
  • Devote your life to this tutorialhttp//web.archi
    ve.org/web/20041028043137/http//cs.wwc.edu/cs_de
    pt/KU/PR/Prolog.html
Write a Comment
User Comments (0)
About PowerShow.com