16.412J/6.834J Intelligent Embedded Systems: Problem Set #3 Solutions
16.412J/6.834J Intelligent Embedded Systems: Problem Set #3 Solutions
a. A B C D
b. A B
c. A B C
A B C D A B C D
F F F F F
F F F T F
F F T F F
F F T T T
F T F F F
F T F T F
F T T F F
F T T T T
T F F F F
T F F T F
T F T F F
T F T T T
T T F F T
T T F T T
T T T F T
T T T T T
Therefore, there are 7 models for which proposition a. is true.
b. The truth table showing which models are true is as follows:
A B C D A B
F F F F F
F F F T F
F F T F F
F F T T F
F T F F T
F T F T T
F T T F T
F T T T T
T F F F T
T F F T T
T F T F T
T F T T T
T T F F T
T T F T T
T T T F T
T T T T T
A B A B
F F T
F T F
T F F
T T T
Therefore, the truth table showing which models are true is as follows:
A B C D A BC
F F F F T
F F F T T
F F T F F
F F T T F
F T F F F
F T F T F
F T T F F
F T T T F
T F F F F
T F F T F
T F T F F
T F T T F
T T F F F
T T F T F
T T T F T
T T T T T
Solution
Propositional Encoding
Mustard _ dining R4
Dining _ adjacent R5
Plum _ adjacent R8
Dining _ a djacen t Kitchen _ a djacen t Livin
Dining _ a djacen t Livin g _ adja cen t Kitch
Kitch en _ a djacen t Livin g _ adja cent Dinin
R9
M us ta rd _ d in in g Plu
M us ta rd _ d in in g Bu
M us ta rd _ l i vi ng Plu
M u s ta rd _ l i vi ng Bu t
M u s ta rd _ ki t ch en Bu
M ust a rd _ ki t ch en P
R10
R12
R13
bu tler _ d in ing butler _ livin g bu tler _ ki
b utler _ din ing butler _ livin g bu tler _ ki
b utler _ din ing bu tler _ living bu tler _ ki
R14
Proof
R15
Mustard _ living
R17
and
Mustard _ kitchen
R18
Resolving these with R10, and using And-Elimination again yields
Plum _ living Butler _ kitchen
Butler _ living Plum _ kitchen
R19
R20
and
butler _ living R24
Proof.
a. Let Si,j be true iff square [i,j] contains a snake. Suppose that [1,1] is the
lower-left corner square of the grid ([2,1] is the square directly to the left, [1,2] is
the square directly above, etc.). Write the assertion that there are exactly two
snakes adjacent to [1,1] as a sentence involving some Si,j propositions.
Now, the first term is just S12 , and because this is in CNF form, any clause
containing S12 can be eliminated. Also, tautologies can be eliminated.
Therefore, this whole expression reduces to
S12 S 22 S 21 S 22 S 21 3.3
This makes sense; it expresses an xor relation if S12 is true. Now, combining
this with the third term of 3.1 yields
S12 S 22 S 21 S12 S 22 S 21
S 22 S12 S 22 S 21
S 21 S12 S 21 S 22
3.5
The first term can be removed due to the fourth term, and the last term can be
removed because it is identical to the fourth. This results in
S12 S 22 S 21
S 22 S12 S 22 S 21
S 21 S12
3.6
This makes intuitive sense. The first term ensures that at most two of the three
propositions are true. The last three terms ensure that at least two of the three
propositions are true.
b. Generalize this by explaining how to construct a CNF sentence asserting that
k of n neighbors contain snakes.
Thus, the clauses that restrict the minimum to be k would be combinations of the
n neighbor propositions taken (n – k + 1) at a time. Similarly, the clauses that
restrict the maximum to be k would be combinations of the n neighbor negation
propositions taken (n – (n – k) + 1) = (k + 1) at a time.
3.7
C1
C2
B S
Thus, the bull is in square [1,1]. Cowboy C1 is in [1,3], and cowboy C2 is in [3,2].
A snake is known to be in [3,1].
The bull is trying to escape, and the cowboys are trying to prevent this. The bull
is hemmed in (by mountains to the south and west), so it cannot move off the
board. It has to try to go to the upper right, and it will be successful if it is able to
reach one of the squares on the top row or right column ([1,3], [2,3], [3,3], [3,2],
or [3,1]).
The bull can only move to squares directly adjacent to the one it is on; it cannot
move diagonally. It cannot move onto a square occupied by a snake or a
cowboy. Assume that the cowboys and snakes cannot move from the squares
they are currently in.
Suppose that cowboy C1 and C2 each have exactly 1 snake adjacent to them.
Write a propositional sentence, in CNF form, that expresses the constraints of
this situation, and expresses the constraints that allow the bull to be unblocked.
U 12 U 13 U 22 U 23 U 32
U 21 U 31 U 22 U 23 U 32
3.8
U 12 U 21
U 21 U13 U 22 U 23 U 21 U 13 U 22 U 32
U 12 U 31 U 22 U 23 U 12 U 31 U 22 U 32
3.9
U 13 U 31 U 22 U 23 U 13 U 31 U 22 U 32
This should be conjoined with a set of clauses that express that a square is
unblocked if it doesn’t have a snake or cowboy:
S11 C11 U 11
S12 C12 U 12
S13 C13 U 13
S 21 C 21 U 21
S 22 C 22 U 22
S 23 C 23 U 23
S 31 C31 U 31
S 32 C32 U 32
S 33 C33 U 33
3.10
d. Implement WALKSAT and use it to find models that satisfy the propositional
sentence written in part c. Use the programming language of your choice for this
implementation. Please include comments in your code. Feel free to discuss the
algorithms with other students; however, please do not share code.
Email code (both source and executable) to the TA as a zip file. Also, include
any data files needed to reproduce results.
e. Suppose that the situation changes and that cowboy C1 now has 2 snakes
adjacent to him. Write a propositional sentence expressing this new situation.
Run your WALKSAT implementation using this new sentence. Explain what
happens.
The WALKSAT algorithm does not finish because the problem is infeasible.
Problem 4 – Model-based Diagnosis
Consider the mixing process shown in the following diagram.
A B
filterA filterB
f1 f2
LS1
Mixing
Tank
f3
v1
Two fluids, A and B, are passed through filters, filterA and filterB, and then flow
into the mixing tank. The mixture flows out via valve v1 which is always open.
The level sensor, LS1, indicates whether the level in the mixing tank is within its
nominal range.
More precisely, here are the CNF clauses for this model.
Here, F1, F2, and F3 are the flows, and LN is the proposition that the tank level is
in its nominal range. LS1NOM is the proposition that the tank level sensor
indicates that the tank is in its nominal range. G(<component>) is a proposition
used to indicate that the component is good.
Now, suppose you make the observation that the level sensor indicates that the
tank level is not in its nominal range. This is expressed as
LS1NOM
4.10
A. For this part, assume there is a single fault, and use constraint suspension to
find a diagnosis.
Generate the list of suspected faulty components. To do this, assume that all
components are working correctly. Perform unit propagation using the
observable stated above and the clauses describing the behavior of the full
model.
List the set of propositions assigned true, false, or both using unit propagation.
List conflicts derived from unit propagation. A conflict arises when a proposition
is deduced to be both true and false. The conflict is the list of component modes
used to derive this inconsistency. This is your list of suspects.
Assuming components are working correctly, resolving 4.10 with 4.9 yields
LN 4.11
F1 4.12
F2 4.13
F3 4.14
This makes intuitive sense. If the valve is stuck closed, for example, the tank
level will be too high. If the filters are clogged, the tank level will be too low. If
the tank has a leak, the tank level will be too low. Or, everything might be OK
except that the level sensor is faulty.
B. Test each suspect for consistency. For each suspect, suspend its
constraints, by removing the clauses that model its behavior. Then apply
WALKSAT to test consistency (you may do this manually, or you may use the
program you wrote in problem 3). List each suspect that is consistent. If a
suspect is consistent, then list a satisfying assignment for that suspect.
Suspending constraints for any of the components eliminates the conflict. Thus,
each component being not good is a possible diagnosis.
C. Let’s assume now that flow sensors are added to measure flows F1, F2, and
F3.
The following clauses are added to the model to represent these sensors.
G FS1 F1 FS1FLOW
G FS1 F1 FS1FLOW
G FS 2 F 2 FS 2 FLOW
G FS 2 F 2 FS 2 FLOW
G FS 3 F 3 FS 3FLOW
G FS 3 F 3 FS 3FLOW
Also, we will now consider multiple faults. We will use conflict directed A* search
to generate the most likely diagnoses.
Please refer to
“Conflict-directed A* and its Role in Model-based Embedded Systems”
(Williams and Ragno)
for details on this algorithm. In particular, refer to pgs. 12 – 24.
where Pi is the PMF denoting the probability that component i is in each of its
modes.
filter – 0.5%
tank - .1%
flow sensor – 2%
level sensor – 1%
valve – 0.2%
LS1NOM
FS1FLOW
The last four of these are valid diagnoses. Search efficiency is therefore 66%.