Logic Programming
06-25433
Autumn 2012

 

 

 

Lecture 2: Writing and running simple Prolog programs

  • revision of unification;
  • introducing facts;
  • Prolog use of unification when searching for clauses;
  • writing rules that use facts;
  • how Prolog works - its "hidden" data structure.
How to prepare

 
  • Work your way through Tutorial Sheet 1.
  • Ensure you understand the difference between
    • comparison operators (such as ==/2, \==/2, =:=/2, =\=/2)
    • the more powerful arithmetic operator (is/2)
    • the very much more powerful unification (=/2)
  • Work through Part 2 of Tutorial Sheet 1 to ensure you understand how Prolog passes information into and out of a rule.
Video

  Recording of the lecture (Autumn 2011) (Vimeo)

Slides

  If you really want the slides from the lecture ... but don't forget printing the slides is not the same as understanding them.

Summary

  Summary and programs with commentary from the lecture

Programs from the lecture

 
Example 1 - jealousy Example 2 - friendship

Individual study suggestions and further reading

 

Study the structured object data type and storing and retrieving facts and how rules can be written that encapsulate general knowledge within programs.

Introductions to Prolog include:

Assessed work associated with this lecture

  Tutorial sheet 2