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
21 December 2007, 14:00 – 18:00
Points: The exam consists of 10 questions worth 40 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 at approximately 15:00. He can also be reached
by phone 013-28 14 27 or 070-660 15 64.
Question 1 (3p)
We have created a variable database with a number of names. What will the Lisp interpreter
return if we enter the following three expressions (exactly as stated) with labels 2-4 in the
example?
CL-USER(1): (setq database '(paul john liza samantha))
(PAUL JOHN LIZA SAMANTHA)
CL-USER(2): (length (rest database))
???
CL-USER(3): (cons 'saint (list (first database)))
???
CL-USER(4): '(append (list 'banana) database)
???
Question 2 (3p)
Write a Lisp function number-of that counts the number of elements of a certain type in an
ordinary list. The following examples show how the function should work:
CL-USER(5): (number-of '(a b a a c d a) 'a)
4
CL-USER(6): (number-of '(1 2 3 4 5 1 2) 3)
1
CL-USER(7): (number-of '(la la la) 42)
0
Question 3 (3p)
3a (2p) Write a Lisp function number-of-generic that is a more generic version of the previous
function. The second argument should instead be a predicate function. The function numbershould count the number of elements for which the predicate function returns true.
of-generic
CL-USER(8): (number-of-generic '(a 4 b 1 c 5) #'numberp)
3
CL-USER(9): (number-of-generic '(nil t nil t) #'null)
2
3b (1p) What should we give as second argument to number-of-generic in order to count all
numbers in the interval 1-9?
CL-USER(4): (number-of-generic '(1 15 6 37 42 9) ???)
3
Question 4 (4p)
4a (2p) Construct a truth table for the following formula:
(P ∨ Q) ⇒ (P ∧ R)
4b (2p) Is the formula in 4a satisfiable? Is it valid? Motivate your answer using the truth table.
Question 5 (6p)
5a (2p) Translate the following four sentences into suitable propositional formulas:
Lucy: Paul always work on Saturdays.
Tim: On Saturdays Paul reads books or watches TV or cooks.
Lucy: Paul reads books and does not watch TV on Saturdays.
Tim: When Paul does not work, he does not watch TV either.
5b (1p) Assume that Lucy always lies and that Tim always tells the truth. Use informal reasoning
to find out what Paul does on Saturdays.
5c (3p) Prove your claim from 5b using resolution.
If necessary, you will find standard logical equivalences in the appendix.
Question 6 (2p)
A problem-solving agent solves problems by using different search techniques. What do we need
to know in order to specify such a search problem?
Question 7 (7p)
7a (4p) A* is an informed search strategy that is optimal, but only if the heuristic function is
admissible. Explain the underlined terms briefly, i.e. answer the following questions:
What do we mean by informed search?
What is an optimal search algorithm?
What is a heuristic?
What does admissible mean?
7b (3p) Prove that A* is optimal if we use an admissible heuristic!
Question 8 (2p)
Describe briefly one of the restrictions (assumptions about the world) that we have to make
when using classical planning.
Question 9 (6p)
Distributing Christmas presents to the children of the world takes a lot of planning. The picture
shows a simplified problem that Santa might encounter: Before he can take off, he has to load
the presents (A, B and C) onto the sleigh.
A
B
C
Santa has a little helper that can hold one present at a time. Presents cannot be stacked on top of
each other. Besides being held by the helper, presents can be on the floor or on the sleigh. The
sleigh is magical, so it can hold an infinite number of presents, even if it doesn’t look like it.
Describe this planning domain, either using PDDL or predicate logic.
Which predicates (describing the world) do we need?
Which are the possible operators/actions?
What is the initial state of the problem instance in the picture?
What is the desired goal state?
If you make additional assumptions about the domain, be sure to state them.
Question 10 (4p)
10a (2p) Describe briefly the (representational) frame problem.
10b (2p) Describe briefly the ramification problem.
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