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.)
Determine whether JoeSmo is in math 156.
List all students in the database.
List all students in math156.
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:
Notice how multiple rules are used to avoid needing an "or".
When you run this, several couples are listed more than once. Why?
There is enough here to print out information about siblings as well.
You may want to use the siblings predicate in your exercises below.
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: