Prolog
- Prolog is freely available from SWI-Prolog.
- pl will be installed by default to c:\\program files\pl
- Prolog source files typically have a suffix of .pl
- You can break a list apart using [a|b] where
a denotes the first item in the list and b denotes
the rest of the list.
- To test for inequality, use \=
Prolog Environment Commands
- consult(file-name).
- pwd.
- ls.
- cd(directory).
- edit.
- emacs.
- make.
- trace.
- gtrace.
- apropos(word).
- help(word).
- halt.
Examples
12/01 Exercises
- Construct a Prolog genealogy database
that covers 3 generations of your family.
You may use the following facts in your database:
male(x), female(x), and
parent(x, y) where x is the parent of y.
- Define mother(X,Y).
- Define father(X,Y).
- Define grandmother(X,Y).
- Define grandfather(X,Y).
- Define allgrandparents(X,Y). This predicate should
find and print all grandparents of Y.
- Define sibling(X,Y). Make sure that a person is
not his or her own sibling!
- Define allsiblings(X,Y). This predicate should find
and print all siblings of Y.
- Define aunt(X,Y).
- Define uncle(X,Y).
- Define your own Prolog predicate that determines whether an
element is a member of a list.