Logic Programming
06-25433
Autumn 2012

 

 

 

Lecture 5: manipulating atomics and clauses

  • reading input from the keyboard using recursion;
  • looking words up in a dictionary;
  • building a simple morphological analyser using sub_atom/5;
  • using Prolog's operator notation to make code more readable;
  • using clause/2 to access clauses in the Prolog program, for instance to display them in some helpful layout.
How to prepare

 
  • Ensure you understand why recursion requires (at least):
    • one base (terminating) clause
    • one recursive clause;
  • find definitions of functor/3, arg/3 and clause/2;
  • try examples of these predicates by typing queries in the Prolog interpreter.
Video

  Recording of the lecture (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 - using recursion in reading in text Example 2 - looking words up in a dictionary Example 3 - using a morphological analyser
Example 4 - making dictionary entries more readable (by humans) Example 5 - pretty printing a Prolog clause

Individual study suggestions and further reading

 

Study how to represent information, search strategies and simple rules and how non-deterministic problems can be described and processed in Prolog.

An introduction to morphology (Described by Jocelyn Payne as "Another nice introduction, which explains why the possessive suffix 's is a problem that breaks the modularity of some analysers.")

Recursion is covered in:

Assessed work associated with this lecture

  Tutorial sheet 3