Logic Programming
06-25433
Autumn 2012

 

 

 

Lecture 12: Definite Clause Grammar

Context-Free Grammar (CFG) is introduced as a way of writing rules about structured knowledge. Definite Clause Grammar (DCG) is Prolog's in-built notation for writing CFGs.

  • Writing DCGs is introduced showing:
    1. the basic framework;
    2. embedding calls to "ordinary" Prolog;
    3. building structures.
    4. DCGs suffer from problems with left-recursive rules
    5. DCGs are a general programming tool with applications beyond natural language parsing, for instance in lexical scanning and support tool writing for programming languages.
How to prepare

  Revise your knowledge of propositional calculus, perhaps by using Dr Lee's notes:

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 - simple type checking scanner Example 2 - program checking - finding missing goals Example 3 - DCG for "a cat sat on the mat"

Individual study suggestions and further reading

 

Good introductions to DCG are:

Assessed work associated with this lecture

  Tutorial sheet 5