Exam Solved
Exam Solved
Matriculation Number:
Exam
Artificial Intelligence 1
April 4, 2024
Please ignore the QR codes; do not write on them, they are for grading support
i
FAU:AI1exam:WS2324:42
In the course Artificial Intelligence I/II we award bonus points for the first student
who reports a factual error in an old exam. (Please report spelling/formatting errors
as well.)
ii
FAU:AI1exam:WS2324:42 2 SEARCH
1 Prolog
Problem 1.1 (Analyzing a Prolog Program)
Consider the following Prolog program:
1 foo([X|_],X).
2 foo([_|L],X) :- foo(L,X).
3
4 good([], _, _).
5 good([X|Xs], Ys, XYs) :- goodX(X, Ys, XYs), good(Xs, Ys, XYs).
6
7 goodX(X, Ys, [pair(X,Y)|_]) :- foo(Ys, Y).
8 goodX(X, Ys, [_|XYs]) :- goodX(X, Ys, XYs).
1. Give a value for xys such that the query good([1,2], [1,2], xys) returns true. 3 Points
2. Which definition from the course does the program good(Xs,Ys,XYs) implement? 3 Points
Solution: It checks if a variable with domain Xs is arc-consistent with respect to a variable with
domain Ys under a constraint given by the list of pairs XYs.
Solution: It has no effect. foo outputs only true/false and has no side-effects, so the order of
cases does not matter.
4. . . . efficiency? 2 Points
Solution: Due to Prolog’s depth-first search behavior, it will first traverse the entire list without
doing anything, and then backtrack to check the second case for each element of the list. The is
still linear but much slower. It also requires linear space instead of constant space.
2 Search
Problem 2.1 (Search Algorithms)
Consider the following directed graph:
1
FAU:AI1exam:WS2324:42 2 SEARCH
𝐴 ∶ 10
6 1
3
𝐵∶4 𝐶∶6
2
1 6
2
𝐸∶7 𝐹∶6 𝐺∶4
1
1 1 4
8
𝐷∶7 𝐻∶3 𝐼∶0
1 5
Every node is labeled with 𝑛 ∶ ℎ(𝑛) where 𝑛 is the identifier of the node and ℎ(𝑛) is the heuristic for
estimating the cost from 𝑛 to a goal node.
Each node’s children are ordered alphabetically.
Every edge is labeled with its actual cost.
Assume you have already expanded the node 𝐴. List the next 4 nodes (i.e., excluding 𝐴) that will be
expanded using the respective algorithm.
If there is a tie, break it using alphabetical order.
1. Depth-first search 1 Points
Solution: 𝐵, 𝐶, 𝐹, 𝐺
Solution: 𝐵, 𝐶, 𝐸, 𝐹
Solution: 𝐶, 𝐹, 𝐺, 𝐻
Solution: 𝐵, 𝐶, 𝐺, 𝐼
5. 𝐴∗ -search 2 Points
Solution: 𝐶, 𝐹, 𝐻, 𝐺
2
FAU:AI1exam:WS2324:42 2 SEARCH
Solution: The search is not complete because it infinitely recurses along the left-most branch
without ever searching any other parts.
Solution: Because the number of nodes at depth 𝑛 is 𝑛!, the search would be very slow for deep
nodes. The queue of unexpanded nodes would run out of memory already at low depths.
• 𝐴 = {𝑓, 𝑏, 𝑠}
• 𝑇 is given by
– 𝑇(𝑓, 𝑥) = {𝑥 ⊕ 2}
– 𝑇(𝑏, 𝑥) = {𝑥 ⊖ 2}
– 𝑇(𝑠, 𝑥) = {𝑥 2 } ∩ 𝑆
where ⊕ and ⊖ are addition/subtraction modulo 𝑛.
• 𝐼 = {0}
• 𝐺 = {𝑛 − 1}
1. For 𝑛 = 19, give the result of applying the action sequence 𝑓, 𝑓, 𝑠 in state 0. 2 Points
Solution: 16
Solution: If 𝑛 is odd.
3. For 𝑛 = 15, explain what is special about applying the action sequence 𝑓, 𝑓, 𝑠 to state 0. 2 Points
Solution: The third action in the sequence is not applicable because 𝑇(𝑠, 4) = ∅.
3
FAU:AI1exam:WS2324:42 4 CONSTRAINT SATISFACTION
4. Explain (in 1 sentence) why this problem represents a fully observable environment. 1 Points
3 Adversarial Search
Problem 3.1 (Minimax)
Consider the following minimax game tree for the maximizing player’s turn. The values at the leaves
are the static evaluation function values of those states; some of those values are currently missing.
B C D
E F G H I J K L M
8 9 2 7 6 1 2
N O
3 5
Solution: I: 5, C: 2
2. If possible, label the node E with an evaluation function value that results in the player definitely 2 Points
choosing move C (no matter how ties are broken).
Otherwise, argue why that is impossible.
3. Now assume E is labeled with 5, and we use 𝛼𝛽-pruning. We expand child nodes in alphabetical 2 Points
order. Which nodes would be pruned?
4 Constraint Satisfaction
Problem 4.1 (Assignments and Solutions)
Consider the CSP given by
4
FAU:AI1exam:WS2324:42 4 CONSTRAINT SATISFACTION
• Variables: {𝑎, 𝑏, 𝑐, 𝑑}
Solution:
𝑃 = {𝑃𝑖𝑣 ∶ 1 ≤ 𝑖 ≤ 𝑛, 𝑣 ∈ 𝐷𝑖 }
⋀ ⋀
𝐹= 𝐴𝑖 ∧ 𝐵𝑖𝑗
1≤𝑖≤𝑛 1≤𝑖<𝑗≤𝑛
where ⋁ ⋀
𝐴𝑖 = 𝑃𝑖𝑢 ∧ ¬(𝑃𝑖𝑢 ∧ 𝑃𝑖𝑣 )
𝑢∈𝐷𝑖 𝑢,𝑣∈𝐷𝑖 ,𝑢≠𝑣
5
FAU:AI1exam:WS2324:42 5 LOGIC
2. To show the equivalence, for every assignment 𝛼 for the CSP instance, give an assignment 𝜑 2 Points
for the SAT instance defined in the previous subproblem such that 𝐹 is satisfied under 𝜑 iff all
constraints are satisfied under 𝛼.
5 Logic
Problem 5.1 (Propositional
( Logic) ) ( )
Consider the formula 𝐴 = (𝑝 ∨ 𝑞) ⇒ (𝑝 ∧ 𝑞) ∧ (𝑝 ∨ ¬𝑞) ⇒ (𝑝 ∨ ¬𝑟) using propositional variables
𝑝, 𝑞, 𝑟.
Solution: ⟨𝜑(𝑝), 𝜑(𝑞), 𝜑(𝑟)⟩ ∈ {⟨𝐹, 𝐹, 𝐹⟩, ⟨𝑇, 𝑇, 𝐹⟩, ⟨𝑇, 𝑇, 𝑇⟩}
3. Turn 𝐴 into a theorem by replacing exactly one occurrence of a connective with a different con- 2 Points
nective.
6
FAU:AI1exam:WS2324:42 5 LOGIC
Solution:
• nullary function symbols: 𝐴 (for Alice), 𝐵 (for Bubbles)
• unary function symbols: 𝑚 (for mother)
• unary predicate symbols: 𝑝 (for person), a (for animal)
• binary predicate symbols: 𝑙 (for like)
2. State formulas over your signature that capture the following properties: 2 Points
1. Every individual is a person or an animal but not both.
2. Every mother likes their offspring.
Solution:
1. ∀𝑥.𝑝(𝑥) ∨ 𝑎(𝑥), ∀𝑥.¬(𝑝(𝑥) ∧ 𝑎(𝑥))
2. ∀𝑥.𝑙(𝑚(𝑥), 𝑥)
3. Give a model over your signature, i.e., a domain 𝐷 and an interpretation 𝐼(𝑠) for every func- 2 Points
tion/predicate symbol, in which all properties from the above subproblem hold.
𝐴𝐹
(𝑝 ∧ 𝑞)𝐹
(¬𝑝 ∧ ¬𝑞)𝐹
𝑝𝐹 𝑞𝐹
(¬𝑝)𝐹 (¬𝑞)𝐹 (¬𝑝)𝐹 (¬𝑞)𝐹
𝑝𝑇 𝑞𝑇 𝑝𝑇 𝑞𝑇
Solution: For every node, all subnodes resulting from applying the respective tableau rule are
already on the branches emanating from it.
2. Explain how, using the tableau, we can find all satisfying assignments for 𝐴. 2 Points
Solution: Each branch that cannot be closed induces a falsifying assignment for 𝐴 (because we
started with 𝐴𝐹 ) by collecting the atomic formulas on it. Counting branches left to right, branch
1 can be closed on 𝑝 and branch 4 on 𝑞. Branch 2 yields 𝜑(𝑝) = 𝐹, 𝜑(𝑞) = 𝑇, and branch 3 yields
𝜑(𝑝) = 𝑇, 𝜑(𝑞) = 𝐹.
The satisfying assignments are the other assignments, i.e., 𝜑(𝑝) = 𝜑(𝑞) = 𝑇 and 𝜑(𝑝) = 𝜑(𝑞) =
𝐹.
7
FAU:AI1exam:WS2324:42 6 KNOWLEDGE REPRESENTATION
Solution:
𝐴𝑇
𝑝 ∧ 𝑞𝑇 ¬𝑝 ∧ ¬𝑞𝑇
𝑝𝑇 ¬𝑝𝑇
𝑞𝑇 ¬𝑞 𝑇
𝑝𝐹
𝑞𝐹
6 Knowledge Representation
Problem 6.1 (ALC)
Consider the following description logic signature
• concept symbols: 𝑖 (for instructor), 𝑠 (for student), 𝑐 (for course), 𝑝 (for program)
• role symbol 𝑚 (for is-member-of) used for
– instructors giving a course
– students taking a course
– students being enrolled in a program
– courses being part of a program
We use an extension of ALC, in which there are dual roles: there is a role 𝑚−1 that captures the relation
has-as-member, e.g., 𝑀𝐾 𝑚 𝐴𝐼 iff 𝐴𝐼 𝑚−1 𝑀𝐾.
1. Give an axiom for the above signature that captures that instructors can only be members of 1 Points
courses.
Solution: 𝑖 ⊑ ∀𝑚.𝑐
2. Give an axiom for the above signature that captures: courses that are taken by a student, must 2 Points
be given by an instructor.
4. Given a model ⟨𝐷, J−K⟩, define an appropriate case of the interpretation mapping for the formula 2 Points
∀𝑟−1 .𝐶.
8
FAU:AI1exam:WS2324:42 7 PLANNING
7 Planning
Problem 7.1 (Admissible Heuristics in Gripper)
Consider the following situation from the homeworks:
• We have two rooms, A and B, one robot initially located in room A, and 𝑛 balls that are initially
located on the floor in room A.
• The goal is to have all balls on the floor in room B.
• The robot can move between the rooms and has a gripper for picking up and releasing balls.
Moving, picking up, and releasing are one action each.
Given state 𝑠, we write 𝑠𝐴 and 𝑠𝐵 for the number of balls on the floor in room A or B, i.e., 𝑛 − 𝑠𝐴 − 𝑠𝐵
is the number of balls held by the robot.
For each of the following heuristics, argue (by informal proof or counter-example) whether they are
admissible.
1. Assume the gripper can hold up to 1 ball at a time. 2 Points
Potential heuristic: ℎ(𝑠) = 𝑛 − 𝑠𝐵 .
Solution: Admissible. ℎ∗ (𝑠) > 𝑛 − 𝑠𝐵 = ℎ(𝑠) because every ball not yet in room B requires at
least one release action.
3. Assume the gripper can hold up to 2 balls at a time, which are picked up in one action and 2 Points
released in one action.
Potential heuristic: ℎ(𝑠) = 𝑛 − 𝑠𝐵 .
Solution: A relaxed problem is easier to solve than the original problem. Then the length of its
optimal plan of the relaxed problem can be used as a heuristic for the original problem.
9
FAU:AI1exam:WS2324:42 7 PLANNING
2. Explain (in about 2 sentences) why it is bad to relax too much or too little. 2 Points
Solution: If we relax too little, the relaxed problem is still too difficult to solve. If we relax too
much, the relaxed problem is so easy that it does not induce a useful heuristic.
3. Let ℎ+ be the heuristic obtained from the delete-relaxation. Give the value of ℎ+ (𝐼). 2 Points
4. Let ℎ+ be the heuristic obtained from the only-adds-relaxation. Give the value of ℎ+ (𝐼). 2 Points
10