0% found this document useful (0 votes)
21 views12 pages

Exam Solved

Uploaded by

soner.berat eren
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views12 pages

Exam Solved

Uploaded by

soner.berat eren
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

FAU:AI1exam:WS2324:42

Last Name: First Name:

Matriculation Number:

Exam
Artificial Intelligence 1
April 4, 2024

Please ignore the QR codes; do not write on them, they are for grading support

To be used for grading, do not write here


prob. 1.1 2.1 2.2 2.3 3.1 4.1 4.2 5.1 5.2 5.3 6.1 7.1 7.2 Sum grade
total 10 8 6 7 6 5 6 6 8 7 7 6 8 90
reached

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

Solution: For example, [pair(1,1),pair(2,1)].

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.

For the remaining questions, assume we swap the lines 1 and 2.


Explain (in about 2 sentences each) how this change effects program’s of the form foo(s,t) regarding
3. . . . correctness? 2 Points

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: 𝐵, 𝐶, 𝐹, 𝐺

2. Breadth-first search 1 Points

Solution: 𝐵, 𝐶, 𝐸, 𝐹

3. uniform-cost search 2 Points

Solution: 𝐶, 𝐹, 𝐺, 𝐻

4. greedy search 2 Points

Solution: 𝐵, 𝐶, 𝐺, 𝐼

5. 𝐴∗ -search 2 Points

Solution: 𝐶, 𝐹, 𝐻, 𝐺

Problem 2.2 (Search in an Infinite Tree)


Consider an infinite tree defined as follows:

2
FAU:AI1exam:WS2324:42 2 SEARCH

• The root has 1 child.


• Every other node has one more child than its parent.
Explain (in about 2 sentences each) what pitfalls we have to watch for (e.g., correctness, complexity,
completeness, . . . ) when searching in this tree using . . .
1. . . . depth-first search. 3 Points

Solution: The search is not complete because it infinitely recurses along the left-most branch
without ever searching any other parts.

2. . . . breadth-first search. 3 Points

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.

Problem 2.3 (Search Problems)


Consider the family of search problems 𝑃𝑛 given for 𝑛 = 1, 2, … by ⟨𝑆, 𝐴, 𝑇, 𝐼, 𝐺⟩ where
• 𝑆 = {0, 1, … , 𝑛}

• 𝐴 = {𝑓, 𝑏, 𝑠}
• 𝑇 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

2. Under what circumstances does this problem have a solution? 2 Points

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

Solution: 𝐼 is a singleton set.

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

1. Label the nodes I and C with their minimax value. 2 Points

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.

Solution: Any label < 2.

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?

Solution: I, N, O, J, M (or I,J,M)

4 Constraint Satisfaction
Problem 4.1 (Assignments and Solutions)
Consider the CSP given by

4
FAU:AI1exam:WS2324:42 4 CONSTRAINT SATISFACTION

• Variables: {𝑎, 𝑏, 𝑐, 𝑑}

• Domains: 𝐷𝑎 = 𝐷𝑏 = {0, 1, 2, 3} and 𝐷𝑐 = 𝐷𝑑 = {0, 1, 2, 3, 4, 5}


• Constraints:
□ 𝑎<𝑏
□ 𝑏 <𝑑−𝑐
□ 𝑑−𝑎 >3
□ 𝑑 = 2𝑐
1. Check the constraints that make this CSP non-binary. 1 Points

Solution: Only the second one (because it is ternary).

2. Give the unique solution to this CSP. 2 Points

Solution: (𝑎, 𝑏, 𝑐, 𝑑) = (0, 1, 2, 4)

3. Check the true statements: 2 Points


□ The assignment 𝑎 = 0, 𝑏 = 1 is consistent.
□ The assignment 𝑎 = 0, 𝑏 = 1, 𝑐 = 2, 𝑑 = 3 is consistent and total.
□ The assignment 𝑏 = 0, 𝑐 = 2, 𝑑 = 4 is consistent and total.

Solution: Only the first statement is true.

Problem 4.2 (Relating CSP and SAT)


Like in the homework problem, we want to relate CSP and SAT.
Assume a binary CSP with variables 𝑋1 , … , 𝑋𝑛 , a finite domain 𝐷𝑖 for every 𝑋𝑖 , and a constraint 𝐶𝑖𝑗 ⊆
𝐷𝑖 × 𝐷𝑗 for every 1 ≤ 𝑖 < 𝑗 ≤ 𝑛. A solution of this CSP instance is an assignment 𝛼 mapping each 𝑋𝑖
to a value in 𝐷𝑖 .
1. Give an instance of SAT, i.e., a set 𝑃 of propositional variables and a propositional formula 𝐹 over 4 Points
𝑃, that is equivalent to this CSP problem.

Solution:
𝑃 = {𝑃𝑖𝑣 ∶ 1 ≤ 𝑖 ≤ 𝑛, 𝑣 ∈ 𝐷𝑖 }
⋀ ⋀
𝐹= 𝐴𝑖 ∧ 𝐵𝑖𝑗
1≤𝑖≤𝑛 1≤𝑖<𝑗≤𝑛

where ⋁ ⋀
𝐴𝑖 = 𝑃𝑖𝑢 ∧ ¬(𝑃𝑖𝑢 ∧ 𝑃𝑖𝑣 )
𝑢∈𝐷𝑖 𝑢,𝑣∈𝐷𝑖 ,𝑢≠𝑣

(expresses that 𝐴𝑖 has has exactly one value)



𝐵𝑖𝑗 = 𝑃𝑖𝑢 ∧ 𝑃𝑗𝑣
(𝑢,𝑣)∈𝐶𝑖𝑗

5
FAU:AI1exam:WS2324:42 5 LOGIC

(expresses that 𝐶𝑖𝑗 is satisfied)

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 𝛼.

Solution: 𝜑(𝑃𝑖𝑣 ) = 𝑇 iff 𝑣 = 𝛼(𝑋𝑖 )

5 Logic
Problem 5.1 (Propositional
( Logic) ) ( )
Consider the formula 𝐴 = (𝑝 ∨ 𝑞) ⇒ (𝑝 ∧ 𝑞) ∧ (𝑝 ∨ ¬𝑞) ⇒ (𝑝 ∨ ¬𝑟) using propositional variables
𝑝, 𝑞, 𝑟.

1. Give all satisfying assignments for 𝐴. 2 Points

Solution: ⟨𝜑(𝑝), 𝜑(𝑞), 𝜑(𝑟)⟩ ∈ {⟨𝐹, 𝐹, 𝐹⟩, ⟨𝑇, 𝑇, 𝐹⟩, ⟨𝑇, 𝑇, 𝑇⟩}

2. Give a formula in DNF that is equivalent to 𝐴. 2 Points

Solution: (𝑝 ∧ 𝑞 ∧ ¬𝑟) ∨ (¬𝑝 ∧ ¬𝑞 ∧ ¬𝑟) ∨ (𝑝 ∧ 𝑞 ∧ 𝑟)


(This can be read off off the list of satisfying assignments. Reading off a faulty list was also
accepted.)

3. Turn 𝐴 into a theorem by replacing exactly one occurrence of a connective with a different con- 2 Points
nective.

Solution: Change the ∧ in the middle to ∨.


(Reasoning: Neither conjunct of 𝐴 is a theorem, so changing a connective inside one conjunct
cannot suffice. So we need to change the ∧. Replacing with ∨ or ⇒ has the best chance of
producing a theorem because they are true more often than ∧. Only ∨ works.)

Problem 5.2 (Modeling in First-Order Logic)


Consider the following situation:
• Some individuals are persons, some are animals.
• Persons and animals may like other persons or animals.
• Alice is a person, and she likes the animal Bubbles.
• For every person or animal, we can obtain its mother.
1. Model this situation in first-order logic by giving a signature, i.e., a list of function/predicate 4 Points
symbols with arity.

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: E.g., 𝐷 = ℕ, 𝐼(𝐴) = 0, 𝐼(𝐵) = 1, 𝐼(𝑚)(𝑛) = 𝑛 + 2, 𝐼(𝑝) = 𝑒𝑣𝑒𝑛, 𝐼 𝑎 = 𝑜𝑑𝑑,


𝐼(𝑙) = {(0, 1)} ∪ {(𝑛 + 2, 𝑛) ∶ 𝑛 ∈ ℕ}.

Problem 5.3 (Tableaux Calculus)


Consider the following tableau where 𝐴 = (𝑝 ∧ 𝑞) ∨ (¬𝑝 ∧ ¬𝑞).

𝐴𝐹
(𝑝 ∧ 𝑞)𝐹
(¬𝑝 ∧ ¬𝑞)𝐹
𝑝𝐹 𝑞𝐹
(¬𝑝)𝐹 (¬𝑞)𝐹 (¬𝑝)𝐹 (¬𝑞)𝐹
𝑝𝑇 𝑞𝑇 𝑝𝑇 𝑞𝑇

1. How can you tell that this tableau is saturated? 2 Points

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

3. Give the fully saturated tableau for the root 𝐴𝑇 . 3 Points

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.

Solution: 𝑐 ⊓ ∃𝑚−1 .𝑠 ⊑ ∃𝑚−1 .𝑖

3. Calculate the translation to first-order logic of 𝑠 ⊑ (∀𝑚.∃𝑚.𝑝). 2 Points

Solution: ∀𝑥.𝑠(𝑥) ⇒ ∀𝑦.𝑚(𝑥, 𝑦) ⇒ ∃𝑧.𝑚(𝑦, 𝑧) ∧ 𝑝(𝑧)

4. Given a model ⟨𝐷, J−K⟩, define an appropriate case of the interpretation mapping for the formula 2 Points
∀𝑟−1 .𝐶.

Solution: J∀𝑟−1 .𝐶K = {𝑢 ∈ 𝐷 | for 𝑣 ∈ 𝐷, if (𝑣, 𝑢) ∈ J𝑟K, then 𝑣 ∈ J𝐶K}

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.

2. Assume the gripper can hold up to 1 ball at a time. 2 Points


Potential heuristic: ℎ(𝑠) = 4 ⋅ 𝑠𝐴 .

Solution: Not admissible. Counter-example: 𝑠𝐴 = 1, 𝑠𝐵 = 𝑛 − 1, robot in room A (holding 0


balls). ℎ∗ (𝑠) = 3 < 4 = ℎ(𝑠) because the robot must perform 3 actions for the last ball (pick up,
move, release).

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: Not admissible. Counter-example: 𝑠𝐴 = 0, 𝑠𝐵 = 𝑛 − 2, robot in room B (holding 2


balls). Then ℎ∗ (𝑠) = 1 < 2 = ℎ(𝑠).

Problem 7.2 (Relaxation)


We want to solve a STRIPS planning task.

1. Explain (in about 2 sentences) the purpose of relaxed planning. 2 Points

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.

Now consider a concrete task given by a finite set 𝐵 of size 𝑛 and


• facts: 𝑖𝑛𝐴(𝑏), 𝑖𝑛𝐵(𝑏), ℎ𝑒𝑙𝑑(𝑏) for 𝑏 ∈ 𝐵, 𝑅𝑓𝑟𝑒𝑒, 𝑅𝑖𝑛𝐴, 𝑅𝑖𝑛𝐵
• actions

action precondition add list delete list


𝑚𝑜𝑣𝑒𝐴 𝑅𝑖𝑛𝐵 𝑅𝑖𝑛𝐴 𝑅𝑖𝑛𝐵
𝑚𝑜𝑣𝑒𝐵 𝑅𝑖𝑛𝐴 𝑅𝑖𝑛𝐵 𝑅𝑖𝑛𝐴
𝑝𝑖𝑐𝑘𝑢𝑝(𝑏) 𝑅𝑖𝑛𝐴, 𝑅𝑓𝑟𝑒𝑒, 𝑖𝑛𝐴(𝑏) ℎ𝑒𝑙𝑑(𝑏) 𝑅𝑓𝑟𝑒𝑒, 𝑖𝑛𝐴(𝑏)
𝑟𝑒𝑙𝑒𝑎𝑠𝑒(𝑏) 𝑅𝑖𝑛𝐵, ℎ𝑒𝑙𝑑(𝑏) 𝑖𝑛𝐵(𝑏), 𝑅𝑓𝑟𝑒𝑒 ℎ𝑒𝑙𝑑(𝑏)

• initial state 𝐼: 𝑖𝑛𝐴(𝑏) for 𝑏 ∈ 𝐵, 𝑅𝑓𝑟𝑒𝑒, 𝑅𝑖𝑛𝐴


• goal state: 𝑖𝑛𝐵(𝑏) for 𝑏 ∈ 𝐵

3. Let ℎ+ be the heuristic obtained from the delete-relaxation. Give the value of ℎ+ (𝐼). 2 Points

Solution: 2𝑛 + 1 (𝑚𝑜𝑣𝑒𝐵 , 𝑝𝑖𝑐𝑘𝑢𝑝(1), 𝑟𝑒𝑙𝑒𝑎𝑠𝑒(1), … , 𝑝𝑖𝑐𝑘𝑢𝑝(𝑛), 𝑟𝑒𝑙𝑒𝑎𝑠𝑒(𝑛))

4. Let ℎ+ be the heuristic obtained from the only-adds-relaxation. Give the value of ℎ+ (𝐼). 2 Points

Solution: 𝑛 (𝑟𝑒𝑙𝑒𝑎𝑠𝑒(1), … , 𝑟𝑒𝑙𝑒𝑎𝑠𝑒(𝑛))

10

You might also like