Overview
1. What is an agent in artificial intelligence?
2. What are the properties of environments?
3. Find the results of the following arithmetic expressions in Prolog.
?- ABC is 3+9.
?- 1+4 is Y.
?- A = 1+1.
?- C is +(4,7).
?- 7 is 5+2.
?- M is -(2,3).
?- N is -(-(5,3),1).
?- X is 11 mod 7.
?- Z is (2^3)^2.
?- X is 1*2, Y is X*2.
4. Find the head and tail parts of the following lists in Prolog.
a) [1, 2, 3, 4].
b) [A, [a, b, c], 9].
5. Take an integer from the end user in Prolog. Then, calculate the result of the x^2 – 4x + 9 mathematical expression again in Prolog. 6.
6. Apply (write) the following student-teacher example with facts and rules in Prolog.
%Facts:
studies(charlie, csc135). % charlie studies csc135
studies(olivia, csc135). % olivia studies csc135
studies(jack, csc131). % jack studies csc131
studies(arthur, csc134). % arthur studies csc134
teaches(kirke, csc135). % kirke teaches csc135
teaches(collins, csc131). % collins teaches csc131
teaches(collins, csc171). % collins teaches csc171
teaches(juniper, csc134). % juniper teaches csc134
%Rules:
professor(X, Y) :- teaches(X, C), studies(Y, C).
% X is a professor of Y if X teaches C and Y studies C.
% (Here X is a professor, Y is a student and C is a course and X, Y, C are variables)
Then, write the following two queries in Prolog.
What does charlie study?
Who are the students of professor kirke?