CSCE 625

advertisement
CSCE 420 - Homework #3
due: Thurs, Mar 21, 2013
1. You are the proprietor of Sammy’s Sport Shop. You have just received a shipment of
three boxes filled with tennis balls. One box contains only yellow tennis balls, one box
contains only white tennis balls, and one contains both yellow and white tennis balls. You
would like to stock the tennis balls in appropriate places on your shelves. Unfortunately,
the boxes have been labeled incorrectly; the manufacturer tells you that you have exactly
one box of each, but that each box is definitely labeled wrong.
Given the initial (incorrect) labeling of the boxes above, and the three observations, use
Propositional Logic to derive the correct labeling of the middle box.
a) Write down a knowledge base (set of propositional rules/sentences) that describes all
the background knowledge and constraints about this problem.
 Do it in a general and complete way (such as what observing a white ball drawn
from box 2 implies, that at most one box can contain yellow balls, etc.).
 Do not include derived knowledge that depends on the particular labeling of this
instance shown above. Think of this knowledge base as a 'basis set' that could be
used make inferences from any way the boxes could be labeled.
 Use propositional symbols in the following form: O1Y means a yellow ball was
drawn (observed) from box 1, L1W means box 1 was initially labeled white, and
C1B means box 1 actually contains both types of tennis balls.
 Finally, add the facts describing this particular situation to the knowledge base:
{O1Y, O2W, O3Y, L1W, L2Y, L3B}
// what observations imply
O1YC1YC1B (c), O1WC1WC1B
O2YC2YC2B, O2WC2WC2B (d)
O3YC3YC3B, O3WC3WC3B (f)
// labels are wrong
L1YC1Y, L1WC1W, L1BC1B
L2YC2Y, L2WC2W, L2BC2B
L3YC3Y, L3WC3W, L3BC3B (a)
// there is at least 1 box of each color
C1YC1WC1B, C2YC2WC2B, C3YC3WC3B
// no 2 boxes have the same contents
C1YC2YC3Y, C1WC2WC3W, C1BC2BC3B (e)
C2YC1YC3Y, C2WC1WC3W, C2BC1BC3B
C3YC2YC1Y (b), C3WC2WC1W, C3BC2BC1B
b) Use Natural Deduction to prove that box 2 contains white tennis balls (i.e. generate the
sentence C2W using rules of inference).
proof of KB |= C2W by natural deduction:
1. from O3Y and (f) derive C3YvC3B by MP
2. from L3B and rule (a) above derive ~C3B by MP
3. from 1 and 3 derive C3Y by reso.
4. from 3 and (b) derive ~C1Y~C2Y by MP
5. from O1Y and (c) derive C1Y v C1B by MP
6. from 4 derive ~C1Y by AndElim
7. from 5 and 6 derive C1B by resol.
8. from O2W and (d) derive C2W v C2B by MP
9. from 7 and (e) derive ~C2B ~C3B
10. from 9 derive ~C2B
11. from 8 and 10 derive C2W by reso.
c) Show that box 2 must contain white balls via a Resolution Refutation proof (requires
converting the sentences to CNF).
// just the sentences I need...
O3WC3WC3B (f) =>
0. O3WC3WC3B
O1YC1YC1B (c) =>
1. O1YC1YC1B
O2WC2WC2B (d) =>
2. O2WC2WC2B
L3BC3B (a) =>
3. L3BC3B
C1BC2BC3B (e) => 4a. C1BC2B, 4b. C1BC3B
C3YC2YC1Y (b) => 5a. C3YC2Y, 5b. C3YC1Y
6. O1Y, // facts become unit clauses
7. O2W,
8. O3Y,
9. L1W,
10. L2Y,
11. L3B,
12. C2W // negation of query
13. C3YC3B [res, 8, 0]
14. C3B [res, 11, 3]
15. C3Y [res, 13, 14]
16. C1Y [res, 15, 5b]
17. C1YC1B [res, 6, 1]
18. C1B [res, 16, 17]
19. C2B [res, 18, 4a]
20. C2WC2B [res, 7, 2]
21. C2W [res, 19, 20]
22.  [res, 21, 12]
2. Convert the following set of sentences to CNF and trace the DPLL algorithm on them
to show it is satisfiable by finding a model.




Number your clauses.
Show which clauses are satisfied on each iteration.
Indicate when you use the Pure Symbol or Unit Clause heuristics.
Indicate which clauses is violated when backtracking occurs.
¬A¬B
AB
BD
¬AD
¬B¬C
BC
C(¬A¬B)
(¬A¬B)C
converted to CNF:
1. ¬A¬B
2. AB
3. BD
4. ¬AD
5. ¬B¬C
6. BC
7a. ¬C¬A
7a. ¬C¬B
8. ABC
iter 1: {} D is a pure symbol, force it to be True
iter 2: {D=T}
nothing else is pure; can ignore clauses 3 & 4
there are no unit clauses; therefore try A=T
iter 3: {D=T,A=T}
2 & 8 are satisfied;
clause 1 becomes unit clause, forces B=F
iter 4: {D=T, A=T, B=F}
6 becomes unit clause, forces C=T
iter 5: 7a is violated, BACKTRACK
go back to iter 2 (most recent choicepoint) and try A=F
iter 6: {D=T, A=F}
2 becomes unit, forces B=T
iter 7: {D=T, A=F, B=T}
5 becomes unit, forces C=F
iter 8:{D=F, A=F, B=T, C=F}: complete truth assignment; all clauses satisfied
clauses satisfied on iteration number...
2
3
4
5
6
7
D=T D=T D=T back D=T D=T
A=T A=T track A=F A=F
B=F
B=T
clause
1
2
3
4
5
6
7a
7b
8
~A v
~B
AvB
~B v D
~A v D
~B v
~C
BvC
~C v
~A
~C v
~B
AvBvC
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
8
D=T
A=F
B=T
C=F
x
x
x
x
Download