CMSC 373 Artificial Intelligence
Assignment 1: Simple Expert Systems in PROLOG
Due: In class on Wednesday, October 11, 2023
Download: SWI PROLOG from here. Do this only if you plan to do this exercise on your own computer. SWI Prolog is installed on all Lab computers (both in Windows & Linux).
Part 1: Play with the PROLOG code from class (Simpson's Family Tree). You can find it here: simpsons.pl. Try out all the examples from class. Nothing to hand in for this part.
Part 2: Part 3: Download the file movies.pl (as a plain text file: movies.txt). It has data about 60+ movies. Take a look at the file and study the structure of the database.
Write queries to answer the following questions.
a. In which year was the movie American Beauty released?
b. Find the movies released in the year 2000.
c. Find the movies released before 2000.
d. Find the movies released after 1990.
e. Find a director of a movie in which Scarlett Johansson appeared.
f. Find an actor who has also directed a movie.
g. Find the movie in which John Goodman and Jeff Bridges were co-stars.
Next, Add rules to the database to do the following,
a. released_after(M, Y) <- the movie was released after the given year.
b. released_before(M, Y) <- the movie was released before the given year.
c. same_year(M1, M2) <- the movies are released in the same year.
d. co_star(A1, A2) <- the actor/actress are in the same movie.
Use these rules to create queries that demonstrate their correctness.
You will hand in your queries, code, and answers for the above.
EXTRA CREDIT
Code the ZOOKEEPER rules in Prolog, Use the following relations/predicates:
isa(x, y): x is a y. For example, isa(x, mammal), or isa(x, cheetah), etc.
has(x, y): x has y. For example, has(swifty, hair), has(swifty, forward_pointed_teeth), etc.
flies(x): x flies
swims(x): x swims
good_flier(x): x is a good flier
lays_eggs(x): x lays eggs
chews_cud(x): x chews cud
color(x, y): x is colored y
After coding all the rules, add the following facts:
Stretch has hair.
Stretch chews cud.
Stretch has long legs.
Stretch has a long neck.
Stretch has tawny color.
Stretch has dark spots.
Swifty has hair.
Swifty has pointed teeth.
Swifty has claws.
Swifty has forward pointing eyes.
Swifty has tawny color.
Swifty has dark spots.
After that, show the results of the following queries:
Is Stretch a giraffe?
Is Swifty a cheetah?
Is Swifty a giraffe?
Is Swifty a mammal?
Is Swifty an ungulate?
Is Swifty a carnivore?
What to hand in:
A printed report containing the output for all of the sections (including the complete code, queries, and responses for the EXTRA CREDIT part of you chose to do it). You report must contain a short reflection/discussion on the exercise.
NOTES:
Please, utilize Lab Hours to get assistance.