Class 22: Introduction to Logic Programming
Held Monday, March 15
- Are there questions on exam 2?
- Assignment 4 is due.
Because of problems on the MathLAN, I may not have an answer
key ready yet, but I'll work on one this afternoon.
- In the movement from imperative programming to functional programming,
you've seen a corresponding movement from explicit instructions for how
to do things to some factual information with the implicit control.
- E.g., when is an argument to a function evaluated? It depends, in part
on the design of the language and the meaning of "patterns" in the
- The declarative languages take this direction even further. In a
declarative language, a program is a collection of facts or utterances.
Typically, there is then a base statement which is then used with
the program to drive computation.
- Most typically, the facts are given in some logic, the input
to the program is a question, and the logic plus facts are used to
derive answers to the questions.
- You can think of many functional languages as being based on
a simplified logic of equations and functions (e.g., if f(x) = g(y) and
g(y) = z then f(x) = z).
- There are, of course, many other logics.
- Note also that this model of computation applies to some AI techniques,
such as expert systems.
- One of the most common(?) logics is predicate logic, a
logic based on the definition and understanding of predicates,
functions that return true or false.
- What are some typical predicates? It depends on the domain, but here
are some that we'll probably visit.
- X ``is an ancestor of'' Y.
- L ``is a sorted list''.
- S ``is a sorted version of'' L.
- X ``is a person''.
- X ``is mortal''.
- How do we define predicates? Traditionally, using some standard
- if-then, if-and-only-if
- and, or, not
- for each (with corresponding variables)
- there exists (with corresponding variables)
- As with functions, we might also list truthful statements.
- For example,
- For all X, if X is a person then X is mortal. (Phrased in
ancient times as "all men are mortal".)
- Socrates is a mortal.
- How might we write ``is an ancestor of''?
- Created Tuesday, January 19, 1999 as a blank outline.
- Filled in some details on Sunday, March 14, 1999. Many of these
details were taken from
outline 32 and
outline 33 of
- After class on Monday, March 15, 1999, I moved some of those details
to the next outline, since they weren't covered in class today.