Math 156
Discrete Mathematics for Computer Science
Fall 1999

Toy Prolog Exercises

Complete these exercises online and prepare the required output for each. (You may want to use some cut and paste to copy things from the web pages to a file for printing.) The outputs are due as part of your assignment in PS 3, due on Thursday, September 16.

Class Rosters


Exercises

Write Prolog Queries that do the following (using the facts above). For each turn in only the query, not the entire program and not the output from running the program. (You may turn in hand-written copies if you like.)
  1. Determine whether JoeSmo is in math 156.
  2. List all students in the database.
  3. List all students in math156.
  4. List all students in more than one class.

Family Tree

The top portion of the program below lists some data about my family. Scroll down for the rules.

Notes:

Exercises

For each of these problems, please turn in the both the program (all facts and rules and the query) and and the output. Note that the program is repeated as part of the output, so you can get all of this information from the file that is returned to you when you run the script. (You may delete the middle portion that shows how the script parses things.)

Fill in the rules and queries above to do the following:

  1. Find all of jennie's grandchildren.
  2. Find all of jennie's great-grandchildren.
  3. Find all of andrew's cousins.

  4. Last modified: Monday, 30-Apr-2001 03:11:49 EDT