[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Assignments] [Labs]

Back to Functional Programming, Concluded. On to Laboratory Session: Prolog.

**Held** Monday, March 15

**Summary**

**Contents**

**Handouts**

**Notes**

- 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.

- See outline 21 for more information.

- 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 langauge.

- 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
operations, including
- 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''?

**History**

- 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 CS302 98S.
- 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.

Back to Functional Programming, Concluded. On to Laboratory Session: Prolog.

[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Assignments] [Labs]

**Disclaimer** Often, these pages were created ``on the fly'' with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS302/99S/Outlines/outline.22.html

Source text last modified Mon Mar 15 14:23:29 1999.

This page generated on Mon Mar 15 14:28:03 1999 by SiteWeaver. Validate this page's HTML.

Contact our webmaster at rebelsky@math.grin.edu