Contents

1 Database Prolog
 1.1 Introduction
 1.2 Facts and rules
  1.2.1 Facts
  1.2.2 Rules
  1.2.3 Horn Clause Logic
 1.3 Goals and queries
 1.4 Unification
 1.5 Exercises
2 Pure Prolog
 2.1 Recursion and lists
  2.1.1 Lists
  2.1.2 first/2
  2.1.3 second/2
  2.1.4 tail/2
  2.1.5 Remarks on Variables
  2.1.6 Exercises:
  2.1.7 Recursion
  2.1.8 member/21
  2.1.9 append/3
  2.1.10 Exercises
 2.2 Operators
  2.2.1 Precedence
  2.2.2 Associativity
 2.3 Arithmetic in Prolog
  2.3.1 length/2
  2.3.2 Exercises
3 Full Prolog
 3.1 Input and output
 3.2 Metalogical predicates
 3.3 Cut
  3.3.1 Examples
  3.3.2 Exercises: memberchk/2
 3.4 Programming Exercise
4 Program examples
 4.1 Natural language processing
  4.1.1 Grammar and lexicon
  4.1.2 The parser
 4.2 A propositional logic interpreter
 4.3 The program
  4.3.1 Operator definitions - syntax
  4.3.2 Operator definitions - semantics
  4.3.3 The database
  4.3.4 The front end
  4.3.5 Complete program listing

List of Exercises

Database Prolog

Pure Prolog

Full Prolog

Program examples