502 - KRR - June 2012 - Answer - BB
502 - KRR - June 2012 - Answer - BB
502 - KRR - June 2012 - Answer - BB
Examiner: K. Shaalan
INSTRUCTIONS TO CANDIDATES
Each part of a question carries a weight and the marks are shown at the side of
the respective part. The total marks of the exam are 100.
Model Answer
Explain what is meant by each of the following (in one or two sentences each):
Answer:
a) Symbolic logic is the study of symbolic abstractions that capture the formal
features of logical inference.
b) The facts in the world to which the sentences refer.
c) An inference procedure is sound if it generates only entailed sentences.
d) An inference procedure is complete if it can generate all entailed
sentences.
e) A logic in which adding a sentence to the set of given sentences never
invalidates a previously derived sentence
(¬ A ∨ B) ∧ (¬ B ∨ C) ∧ A
Answer:
a)
(C ∧ D) ∨ (E → F)
= (C ∧ D) ∨ (¬ E ∨ F)
= (C ∨ (¬ E ∨ F)) ∧ (D ∨ (¬ E ∨ F))
= (C ∨ ¬ E ∨ F) ∧ (D ∨ ¬ E ∨ F)
b)
1
To prove C, we assume that ¬ C and derive a contradiction using the resolution
rule. We therefore have the following:
(¬ A ∨ B) ∧ (¬ B ∨ C) ∧ A ∧¬ C
Answer:
a) x N(x, Rasha)
b) x (P(x) ∧ ¬ B(x) → y (C(y) → k(x,y)))
c) x (B(x) → ¬ K(x,x))
d) x (P(x) → y (P(y) ∧ N(x,y) ∧ G(y)))
e) x y (P(x) ∧ A(y) ∧ ¬ K(x,y ) → ¬ G(y))
Consider the following maze in which the successors of a cell include any
adjacent cell in the directions North, South, East, and West of the current cell,
except at the boundary of the maze or when a barrier (thick line) exists. For
example, successors(m) = {d,n,g}. Assume each type of move (N,S,E,W) has
cost 1.
A B
C D E
F S H K M N
P Q R T G
2
The problem is to find a path from cell S to cell G. Assuming children are always
expanded in the order East, South, West, North, then Breadth-First Search
(without duplicates) would visit cells in the order: SHFKPCQARBTDG. If a search
method needs to break ties, expand first the node corresponding to the letter
closest to the front of the alphabet. Consider the following map (not drawn to
scale)
For parts (a-c) below, what is the order of nodes expanded (plus the goal node if
it is found) by each of the following search methods?
Answer:
a) Depth first search
A B
C D E
F S H K M N
P Q R T G
S H K C A B DE N M G
b) Greedy Search
A h=4 B h=3
S H K C A B D MG
c) A* Search
3
A h=4 g=4 B h=3
P h=4 g=2 Q h=3 g=3 R h=2 g=4 T h=1 g=5 G h=0 g=6
SH KCF PQ RT G
5 Logic Programming (10 points)
Answer:
quick_sort([X|Xs],Ys):-
partition(Xs,X,Littles,Bigs),
quick_sort(Littles,Ls),
quick_sort(Bigs,Bs),
append(Ls,[X|Bs],Ys).
quick_sort([],[]).
partition([X|Xs],Y,[X|Ls],Bs):-
X =<Y,
partition(Xs,Y,Ls,Bs).
partition([X|Xs],Y, Ls, [X|Bs]):-
X >Y,
partition(Xs,Y,Ls,Bs).
partition([],Y, [], []).
b) (5 points) Define the predicate pre_order(Tree, List) which, given a binary tree
Tree, returns the pre-order traversal of Tree as List. The pre-order traversal of
the tree of the empty tree nil is the empty list []. The pre_order traversal of the
tree tree(Value, Left, Right) is obtained by concatenating the one-element list
[Value], the traversal of Left and the traversal of Right, in this order. For example,
?- pre_order( tree(4, tree(6, nil, tree(5, nil, nil )), tree(1, nil, tree(2, nil, nil ))), List).
List = [4,6,5,1,2]
4
Answer:
pre_order(nil, []).
pre_order(tree(Root, LT, RT), [Root | Rest]) :-
pre_order(LT, LTNodes),
pre_order(RT, RTNodes),
append(LTNodes, RTNodes, Rest).
Consider the simple map colouring problem described in the figure below. Each
node represents a country, which can take one of the colours: red, blue, or green
(or r, b and g for short). A constraint between two nodes requires that no two
linked countries can be assigned the same colour.
X1
X2 X3 X4
Show how this problem can be solved using the minimum remaining value (MRV)
heuristic. When multiple variables have the same number of remaining values,
use the degree heuristic as a tie-breaker. When this is not enough, choose
variables according to numerical order (e.g. x1 before x2). When selecting values
to assign to variables, use the following order of preference: r, g, b. Show the
final solution as well as all intermediate steps, explaining why each value
assignment has been made.
Answer
The MRV heuristic chooses the variable with the least number of remaining
values. The degree heuristic chooses the variable with the biggest number of
constraints. We start with all variables having full domains.
X1 X2 X3 X4
Degree 2 Degree 2 Degree 3 Degree 1
Step RV RV RV RV
1 r,g,b r,g,b r,g,b r,g,b
2 r,g,b r,g,b r r,g,b
3 g,b g,b r g,b
4 g g,b r g,b
5 g b r g,b
6 g b r g,b
7 g b r g
5
Here's an explanation of the various steps:
1. This is our starting point.
2. Each variable has the same domain size, so we cannot apply the MRV
heuristic. So we use the degree heuristic. Variable x3 is involved in most
number of constraints (it is of degree 3). We assign it value r (since this
value is higher in the order of preference).
3. Update the remaining values (RV) of other variables, eliminating r from all
variables connected to x3 (i.e. all other variables).
4. Now, variables x1, x2 and x4 all have 2 remaining values. Among those,
x1 and x2 have degree 2, while x4 is of degree 1. Among x1 and x2, we
choose x1 according to numerical order, and assign it value g.
5. Update the RVs of other variables, eliminating g from those connected to
x1, namely x2.
6. Now, the only remaining value for x2 is b. No change needed.
7. Finally, x4 is assigned the value g.
smart ¬smart
study ¬study study ¬study
Prepared .432 .16 .084 .008
¬ prepared .048 .16 .036 .072
Full joint distribution for the dentist domain
Answer:
This question tests the students' understanding of random variables, full joint
distributions, and conditional probability:
a) P(smart) = .432 + .016 + .016 + .048
b) P(prepared ∧ smart) = .432 + .016
c) P(prepared | smart) = P(prepared ∧ smart) / P(smart)
= (.432 + .016) / (.432 + .016 + .016 + .048)
6
8 Bayesian Networks (10 points)
Answer:
a)
i. No, since H and S are linked by an arc
ii. Yes, asserted by the local semantics: a node is conditionally
independent of its nondescendants given its parents.
iii. No, because arcs alone do not deny independence (the CPT can deny
it, however).
b) Using the Chain rule:
P (x1, . . . , xn) = ∏in= 1 P(xi|parents(Xi))