TDDC65 Artificial Intelligence and Lisp TDDA23 Artificial Intelligence and Lisp Written exam

advertisement
Written exam
TDDC65 Artificial Intelligence and Lisp
TDDA23 Artificial Intelligence and Lisp
23 August 2008, 08:00 – 12:00
Points: The exam consists of 5 questions worth 38 points. You will need approximately 16
points to pass the exam.
Auxiliary items: You may bring any kind of generic dictionary to the exam. You may not use
calculators, other books, articles or handwritten notes.
Directions: You can answer in English or Swedish. Use notations and methods that have been
discussed in the course. If an exercise has not been specified completely as you see it, state which
reasonable assumptions you have made. Begin each main question on a new sheet of paper. Write
only on one side of the paper. Write clearly!
Contact: Peter Dalenius will visit the exam hall somwhere between 09:00 and 10:00. He can also
be reached by phone 013-28 14 27 or 070-660 15 64.
Question 1: Lisp programming (10p)
1a (3p) We have created a variable things with information about some objects. What will the
Lisp interpreter return if we enter the following three expressions (exactly as stated) with labels 24 in the example?
CL-USER(1): (setq things '(table chair (box pencil eraser)))
(TABLE CHAIR (BOX PENCIL ERASER))
CL-USER(2): (length things)
???
CL-USER(3): (append '(things) (third things))
???
CL-USER(4): (cons 3 (* 2 7))
???
1b (3p) Write a Lisp function locate that checks if an atom (symbol or number) is present in a
list. Assume that the list does not contain sublists. The function should return T or NIL. The
following examples show how the function should work:
CL-USER(5): (locate 'a '(b a n a n a))
T
CL-USER(6): (locate 'a '(f r u i t))
NIL
CL-USER(7): (locate 'a '())
NIL
1c (3p) Write a Lisp function locate-all that is a more generic version of the previous
function. The first argument should be a predicate function to be applied to all elements. You
should also assume that the list might contain sublists, and process them as well. The function
locate-all should return T if the predicate returns T for at least one element, otherwise NIL.
Here are some examples:
CL-USER(8): (locate-all #'numberp '(a b c (d e f (g 4711 h) i) j k))
T
CL-USER(9): (locate-all #'numberp '(a b c (d e f)))
NIL
1d (1p) What should we give as first argument to locate-all in order to find out if the list
contains an integer (not a float) greater than or equal to 100?
CL-USER(10): (locate-all #'??? '(a b 150.5 c 99 (d 102 e)))
T
Question 2: Logic (12p)
2a (2p) Construct a truth table for the following formula:
(P ∨ Q) ∧ R
2b (2p) Is the formula in 2a satisfiable? Is it valid? Motivate your answer using the truth table.
2c (2p) Prove the following equivalence in a suitable way:
¬(R ∧ ¬S) ≡ R ⇒ S
2d (2p) We have a small and very simple ground moving robot. In every situation there are only
three possible actions for the robot: move 1 dm forward, turn right 90° or turn left 90°. The
robot has two sensors. A proximity sensor tells us if there is an object immediately in front of the
robot and a radio sensor tells us if a desired target is somewhere in a 75° sector in front of the
robot. The software controlling the robot has a knowledge base with the following rules:
A reading from the proximity sensor can only mean that there is an obstacle in front of
the robot.
The robot should go forward if the target is in front and there are no obstacles.
If there is an obstacle in front, the robot should turn right.
If no other action is possible, the robot should turn left.
At a given situation the proximity sensor does not give a reading, but the target seems to be close
by. Translate the knowledge base and the sensor data in this situation into suitable formulas in
propositional logic.
2e (1p) Which action should the robot take in this situation? Use informal reasoning to find a
conclusion.
2f (3p) Prove your claim from the previous question using resolution.
Question 3: Search (8p)
3a (2p) Search strategies differ in the order in which nodes are selected for expansion. We can
easily write a generic search algorithm (which is done in pseudo code in the book) and simply
switch between different ways of inserting new nodes into the queue (where nodes to be
processed are kept). What is the difference between depth first and breadth first search and how does
the insertion of new nodes differ between these algorithms?
3b (2p) In what ways can we measure problem-solving performance for a search strategy? Explain
in a few words each category.
3c (4p) We have a ground moving robot for painting floors. The floor in this case consists only of
two by two squares and the possible actions that the robot can take are limited to painting the
current square or move one step forward, backward, left or right. The robot can never move into
a square that is already painted, so the next step after painting a square must be a move to an
adjacent square that is not painted. Also, the robot can never move outside this limited floor. The
goal is of course to paint the whole floor and in the starting state the floor is completely
unpainted. The robot is located in the upper left corner of the floor at start.
Before we embark on a real world painting trip, we want to solve the problem theoretically using
a search strategy. The strategy chosen is greedy best-first search and the heuristic is h(n) = the number
of squares left to paint.
Draw a complete search tree illustrating the different stages in search for a complete solution.
Use some kind of graphical notation to indicate the current state (where the robot is and which
squares are painted) and label each node with the value of the heuristic function in that node.
Question 4: Planning (4p)
4a (2p) What is the difference between progression and regression search? Also, name at least one
advantage or disadvantage for one of the methods.
4b (2p) TALplanner is a planner developed at IDA that was discussed during the lectures. One
feature of TALplanner is the use of control rules. What is a control rule and what is the point of
using them?
Question 5: Miscellaneous (4p)
5a (2p) Describe briefly the components of situation calculus.
5b (2p) Describe briefly why we might want to use situation calculus. What do we want to reason
about that we can’t in ordinary first order logic?
Appendix
Standard logical equivalences
A∧B≡B∧A
A∨B≡B∨A
((A ∧ B) ∧ C) ≡ (A ∧ (B ∧ C))
((A ∨ B) ∨ C) ≡ (A ∨ (B ∨ C))
¬(¬A) ≡ A
(A ⇒ B) ≡ (¬B ⇒ ¬A)
(A ⇒ B) ≡ (¬A ∨ B)
(A ⇔ B) ≡ ((A ⇒ B) ∧ (B ⇒ A))
¬(A ∧ B) ≡ (¬A ∨ ¬B)
¬(A ∨ B) ≡ (¬A ∧ ¬B)
((A ∧ B) ∨ C) ≡ ((A ∧ B) ∨ (A ∧ C))
((A ∨ B) ∧ C) ≡ ((A ∨ B) ∧ (A ∨ C))
commutativity
associativity
double negation elimination
contraposition
implication elimination
bidirectional elimination
De Morgan
distributivity
Process for converting any propositional formula to CNF
1. Eliminate biconditional
2. Eliminate implication
3. Move negations inwards
4. Distribute ∨ over ∧
Download