COMP9414/9814 Artificial Intelligence
Review Questions on Prolog Programming - Part 1
This is a voluntary quiz to help you decide whether you have
understood some of the major concepts from this topic. It carries
- What are the differences between a procedural programming
language and a declarative programming language? Is Prolog
procedural or declarative?
- Given the file
described in lectures, what solutions will Prolog find to the query
studies(henry, What). ?
Work out the answer yourself from the list of facts, and then check
your answer using the Prolog interpreter.
- Write a query which will answer the question: "What student(s)
in year 2 study 9414?" using the facts in
will the answer be?
- Write a rule to define the property of being in year 1 and enrolled
in a course. The header comment would be:
% year1stud(Student, Course) succeeds if Student is in year 1
% and Student is studying Course.
Now write a rule that defines the property of being in year 1 and
enrolled in any course but we don't care what. The header comment would be:
% enrolledyear1stud(Student) succeeds if Student is in year 1
% and Student is studying something, as opposed to being on leave, say.
Try this second one two ways - using a don't-care variable, and using
a normal variable in place of the don't care variable. Load both versions
into Prolog and check for warning messages. If you don't understand
the warning message, read about
singleton variables in the Prolog Dictionary.
- Write rules to define a bad dog. A dog is bad if
it bites the postman, chews the newspaper, or chases the cat. Make up
your own predicates for biting and chewing and chasing.
- Invent Prolog structures to describe a person. The person should have
family name, a given name, and a middle initial (think George W Bush).
They should also have a date of birth, an address, and a star-sign (like
Aries or Libra or Leo).
The address should consist of a country, a state, a town or suburb,
and a street address, which should consist of an apartment number,
a street number, a street name, and a street type (like Avenue or
Road or Street). If they live in a house, not a block of flats, use
0 for the apartment number. Write down the structure that describes you.
Solutions: don't read until you've
tried the questions yourself!
Bill Wilson's contact info
UNSW's CRICOS Provider No. is 00098G