1 / 17

QuickStart Prolog

QuickStart Prolog. Learning to Program in Prolog Richard Banister November 9, 2005. 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

liam
Download Presentation

QuickStart Prolog

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 Applied Computing Technology Laboratory

  3. The Logical Paradigm • Based on logical reasoning • Execution as mathematical proof • Non-sequential design • Fun! Applied Computing Technology Laboratory

  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? Applied Computing Technology Laboratory

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

  6. Prolog Advantages • It’s a Logical Programming language • It’s the only game in town • That’s about it. Applied Computing Technology Laboratory

  7. Prolog Disadvantages • Limited sphere of usefulness • Not a “pure” logical language • It don’t have the fancy graphics the youngsters are raving about • It won’t make you popular with the ladies Applied Computing Technology Laboratory

  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 Applied Computing Technology Laboratory

  9. Prolog Specification • Well, it’s 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 hasn’t taken over the world? • But we do know some things about the grammar Applied Computing Technology Laboratory

  10. Prolog Grammar • A free approximate grammar can be found online: (https://www.freytag.us/twiki/bin/view/Freytag/ISOStandardPrologGrammar) • Here’s a sample: • Possibly not complete, but note simplicity Applied Computing Technology Laboratory

  11. Is Prolog “Dead?” • Not quite. Still kicking in AI • New extensions are being developed: • Visual Prolog • Prova Applied Computing Technology Laboratory

  12. Language Specifics Predicate:A statement given to be true ex. cat(Timmy). Rule:A method for proving future resultsex. cat(X) :- legs(4, X), whiskers(X), intent_to_destroy(X). Query:A request to prove a resultex. whiskers(Uncle Jerry). Intent_to_destroy(Uncle Jerry). Legs(1, Uncle Jerry). ?- cat(Uncle Jerry). no Applied Computing Technology Laboratory

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

  14. Step 1: Really Getting Started • Download & install GNU interpreter:http://pauillac.inria.fr/~diaz/gnu-prolog/ • You can get the source, too, if you really want it • Read up… the GNU interpreter isn’t easy Applied Computing Technology Laboratory

  15. Step 2: Writing • Create a plain text file • Some editors have context-sensitive highlighting, but it’s probably not necessary • File should contain predicates and rules, not queries • Create a legendary, essential logical application (maybe, dog(Rover)?) Applied Computing Technology Laboratory

  16. Step 3: Import Source File • Start the interpreter. • Use the consult command (or shortcut) to open and compile the source codeex. consult(‘/projects/prolog/cat.pl’). • Note the use of Unix-style file reference. This isn’t necessarily “documented” in the help file. • Assuming no errors, run queries on your program Applied Computing Technology Laboratory

  17. Learning more about Prolog • Visit the QuickStart Languages web sitehttp://actlab.csc.villanova.edu/quickstart • Read up on logical languageshttp://en.wikipedia.org/wiki/Logic_programming • Devote your life to this tutorialhttp://web.archive.org/web/20041028043137/http://cs.wwc.edu/~cs_dept/KU/PR/Prolog.html Applied Computing Technology Laboratory

More Related