ITEC 380 - Chapter 15 Notes - Prolog
PROLOG = PROgramming in LOGic
- Automated Theorem Proving
- Colmerauer & Roussel - France and Kowalski - Edinburgh (65-75)
- Declarative - specify what, not how
- Recursive search with backtracking - try a solution and if
it does not work, try another
- Pattern matching - look for symbols that match a given pattern
- Non-deterministic - results from a given program can
(theoretically) vary from one run to the next (ie a program produces a SET
of results in an arbitrary order)
Programming in Prolog
- Build database of FACTS about OBJECTS and
RULES about relationships among objects
- Use database to questions about objects and their relationships
Program components
- Numbers, Atoms, and Variables
- Structures
- Rules, Facts, and Queries
Example 1:
Family Facts and Rules,
Sample run
Unification and resolution
- Proces of finding instantiations for which a match of goals is
found in database
- Uses pattern matching and backtracking
- The unification process is called RESOLUTION
- Symbolic computing - We use symbols for real world objects and
we compute by manipulating symbols.
Example 2:
Vegetable Facts and Rules
Example 2 continued:
Solving a sample query
The Syntax of Prolog programs (Atoms, variables, etc)
Some details on
Prolog solves queries.
Example 3:
Factorial
Example 4:
Fibonacci
cut and fail
not
List matching and User Input
Some list functions