Module aims

This is a programming module that introduces Prolog as the best-known example of a logic programming language. You are not expected to have previous knowledge of Prolog or logic programming, but you are expected to be able to program in more mainstream languages and be aware of general principles of coding and software engineering. The emphasis is on laboratory exercises. The majority of the teaching hours are supported lab sessions. There are 10 hours of lectures to introduce language features and explain effective approaches. After a short period to familiarise you with the language, the module settles down into a series of assessed practical assignments, each with an artificial intelligence dimension.                               

Learning outcomes

After completing this module you will be able to:
* Solve well-defined, general computational problems using Prolog
* Design Prolog applications that follow principles of good software engineering
* Apply both declarative and procedural programming styles appropriately
* Use Prolog language features and design patterns to write efficient procedures
* Construct meta programs and parsers using Prolog-specific support for such applications

Module syllabus


  • Prolog as subset of the predicate calculus
  • Prolog querying as inference rule
  • Prolog syntax: simple and compound terms
  • Unification, query evaluation mechanism and search space tree

Language features and techniques:

  • Recursion
  • Lists and list processing
  • Negation as Failure
  • Aggregation
  • Tail recursion
  • The cut and conditionals

Further topics:

  • Meta-level programming: controling backtracking with cut and negation; meta-variables and meta-predicates. Dynamic modification of memory contents. Basic implementation of meta-interpreters and expert systems.
  • Definite clause grammars
  • Constraint logic programming

Teaching methods

You will study primarily from a comprehensive set of notes written specifically for this module. This will be provided before teaching begins. Live classes will interleave lecturing and worked problems, following the structure of the notes, with one chapter being presented each week. The notes have short exercises integrated throughout, that you can attempt in advance of the relevant lecture. Solutions to the exercises are provided in the notes to allow you to self-assess, and many of the exercises will also be discussed in class. However, the main learning activity are the lab exercises. A series of programming assignments are published throughout the module, with lab hours each week where you can ask questions and get feedback on your solutions as you are developing them.                               

An online service will be used as a discussion forum for the module. 


* Simple exercises are integrated into the module notes to reinforce fundamental points of learning alongside their explanation. These address all ILOs. Selected exercises are set and then discussed during live classes. All exercises have provided solutions in the notes to allow self-assessment.
* Two sets of formative introductory problems are set in the first two weeks' lab sessions. Model solutions are published following the supported lab hours.   
* Five summative laboratory exercises, one a week starting after the third week of teaching, contribute 20% of the total mark. Exercises 1-4 assess the use of a variety of language features. Exercise 5 specifically assesses meta programming and use of definite clause grammars.
* One timed laboratory-based examination contributes 80% of the total mark, assessing all learning outcomes.          

* Feedback on formative problems and lab exercises is available in the form of: model solutions to all exercises for self-assessment; and discussion within live classes. Mentimeter is used to enable students to submit answers in class which are then discussed and sometimes "live-marked".
* Feedback on the five summative lab assignments set during the module is provided by publishing provisional marks and annotating all submissions with written feedback. Feedback on each assignment is provided in time to feed forward into later assignments.

Reading list

Core Reading

Module leaders

Dr Timothy Kimber