Tutorial 6
Logical conditionals
Boolean conditional
We’ve interpreted the conditional symbol → using the Booleans NOT and OR. But we could also have directly defined a Boolean function IF with the following truth-table:
Note that X IF Y is the conditional from the value of X to the value
of Y to make the reading of the Boolean align with its natural reading.
Find a representation of this Boolean function using only NOT and AND. That is find a Boolean expression exp in the two variables X and Y, which contains only the Boolean functions NOT and AND, and which meets the specification that for all values of X and Y, we have:
exp = X IF Y.Verify your work! That is don’t just provide an expression, but show that for all values of X and Y the above equation holds.
Solution
The most straightforward solution is:
NOT(Y AND (NOT X))Here’s a truth-table to show that NOT(Y AND (NOT X)) = X IF Y:
Equivalence
Remember the truth-table for XNOR from the last exercise set:
Find a formula representation of this Boolean truth-function using only the
propositional variables p and q and the connectives ∧ and →! That is, find a formula A satisfying these constraints such that, for all assignments v of truth-values to p and q, we have:
v(A) = v(p) XNOR v(q).Verify your work! That is don’t just provide a formula, but show that for each assignment the above equation holds.
Solution
One of the conceptually clearest solutions is the formula:
(p → q) ∧ (q → p)Here’s a truth-table to verify our work:
Conditional inferences
Check the following conditional inferences for deductive validity using
SAT-solving. You can use truth-tables or resolution, as you prefer.
-
(RAIN→WIND), ¬RAIN ∴ ¬WIND -
(RAIN→WIND) ∴(¬WIND → ¬RAIN) -
(¬ RAIN→ RAIN) ∴RAIN -
(RAIN →( SUN → RAINBOW)) ∴ ((RAIN ∧ SUN) → RAINBOW) -
¬ (RAIN → WIND) ∴ RAIN
Document your work carefully, that is explain each step you’re carrying out,
and why the work you did shows that the inference in question is valid or invalid.
Solution
-
(RAIN→WIND), ¬RAIN ⊭ ¬WIND. We show this using resolution.The aim is to show that
{(RAIN→WIND), ¬RAIN , ¬¬WIND }is satisfiable.First, we transform into CNF. The conditional becomes ¬ RAIN ∨ WIND
usingr₀, and¬¬WIND }becomesWINDusingr₁.This leaves us with the sets
No resolution is possible, and we can read off a counter-model where{ ¬RAIN, WIND } { ¬ RAIN } { WIND }.v(RAIN) = 0andv(WIND) = 1. -
(RAIN→WIND) ⊨(¬WIND → ¬RAIN). We show this using resolution.The aim is to show that
{ (RAIN→WIND), ¬(¬WIND → ¬RAIN) }is unsatisfiable.First, we transform into CNF, beginning by transforming the conditionals using
r₀, giving us¬RAIN∨WINDand¬(¬¬WIND ∨ ¬RAIN).Applying
r₁andr₃recursively to the latter, we obtain ¬WIND ∧ RAIN. This gives us the sets:.{ ¬ RAIN, WIND } { ¬ WIND } { RAIN }We derive the empty set
{ }in two steps:-
With
{ ¬ RAIN, WIND }and{ ¬ WIND }, we resolve to{ ¬ RAIN}. -
With
{ ¬ RAIN}and{ RAIN }, we resolve to the empty set { } proving the unsatisfiability of the set.
-
-
(¬ RAIN→ RAIN) ⊨RAIN. We show this using truth-tables.The aim is to show that
{(¬ RAIN→ RAIN), ¬RAIN }is unsatisfiable. Here’s the truth-table to the effect:
In fact, you can see that
¬RAIN → RAINis equivalent toRAIN. In logical theory, this is called Clavius' Law (opens in a new tab) . -
(RAIN →( SUN → RAINBOW)) ⊨ ((RAIN ∧ SUN) → RAINBOW). We use resolution.The task is to show that
is not satisfiable.{ (RAIN →( SUN → RAINBOW)), ¬ ((RAIN ∧ SUN) → RAINBOW) }First, we transform to CNF. Recursively applying
r₀, we getfrom¬RAIN ∨ ¬ SUN ∨ RAINBOWRAIN →( SUN → RAINBOW).For the second formula,
we get¬ ((RAIN ∧ SUN) → RAINBOW),using¬ (¬(RAIN ∧ SUN) ∨ RAINBOW)r₀and thenusing¬¬(RAIN ∧ SUN) ∧ ¬RAINBOW)r₂Finally,r₁gives us:RAIN ∧ SUN ∧¬RAINBOWThis gives us the sets:
{¬RAIN, ¬ SUN, RAINBOW } { RAIN } { SUN } {¬RAINBOW }The derivation of
{ }using resolution is a simple, three-step affair:-
{¬RAIN, ¬ SUN, RAINBOW}and{ RAIN }give us{¬ SUN, RAINBOW}. -
{¬ SUN, RAINBOW}and{ SUN }give us{ RAINBOW } -
{ RAINBOW }and{¬RAINBOW }give us{ }.
-
-
¬ (RAIN → WIND) ⊨ RAIN, which we show using truth-tables.The aim is to show that
{¬ (RAIN → WIND), ¬ RAIN }is unsatisfiable.Here’s the table:
Since there’s no row where both
¬ (RAIN → WIND)and¬ RAINare1, the set is unsatisfiable.
Valid inference and conditionals
There’s a deep connection between deductively valid inference in Boolean logic and material conditionals, which is given by the following important equivalence:
P₁, P₂, … ⊨ C if and only if not-SAT{¬((P₁∧ P₂ ∧… )→ C)}-
A logical formula
Ais called a logical truth iff for all assignmentsvof truth-values to its propositional variables, the formula is true, i.e.v(A) = 1. Verify that the simple formulais a logical truth in this sense.(RAIN ∨ ¬RAIN) -
Rephrase the right-hand side of the above equivalence in terms of the logical truth rather than unsatisfiability.
-
Give an argument that the above equivalence is true.
Hint: To do so, you need to use the general form of the reduction of valid inference to unsatisfiability, which we’ve discussed in the lecture
Think about what the latter condition means for the truth of the corresponding conditional.P₁, P₂, … ⊨ C if and only if not-SAT { P₁, P₂, … , ¬C }
Solution
-
We could do a truth-table, but let’s do a step-by step calculation, instead, where we go through the two possibilities:
v(RAIN) = 1or v(RAIN) = 0:- If
v(RAIN) = 1, thenv(RAIN ∨¬RAIN) = v(RAIN) OR v(¬RAIN)= …
.... = v(RAIN) OR (NOT v(RAIN)) = 1 OR (NOT 1) = 1 OR 0 = 1- If
v(RAIN) = 0, thenv(RAIN ∨¬RAIN) = v(RAIN) OR v(¬RAIN)= …
.... = v(RAIN) OR (NOT v(RAIN)) = 0 OR (NOT 0) = 0 OR 1 = 1So, in all possible cases, we have
v(RAIN ∨¬RAIN) = 1. - If
-
First, note that
not-SAT{¬((P₁∧ P₂ ∧… )→ C)}means that the formula¬((P₁∧ P₂ ∧… )→ C)is unsatisfiable, meaning it has value0under every valuation. But the formula starts with a¬and soBut if we know that this expression evaluates tov(¬((P₁∧ P₂ ∧… )→ C)) = NOT v((P₁∧ P₂ ∧…)→ C)0under each valuation, this means that v((P₁∧ P₂ ∧… )→ C) = 1 under each valuation. In other words,is a logical truth. This gives us an alternative criterion for valid inference according to which:(P₁∧ P₂ ∧… )→ CThis criterion shows the particularly deep connection between valid inference and conditionals.P₁, P₂, … ⊨ C if and only if (P₁∧ P₂ ∧… )→ C is a logical truth -
This is the hardest part and requires more advanced logical reasoning. One way to proceed is to start from the known criterion that
Let’s think about not-SAT { P₁, P₂, … , ¬C }. This means that for each valuation, eitherP₁, P₂, … ⊨ C if and only if not-SAT { P₁, P₂, … , ¬C }.v(P₁) = 0, v(P₂) = 0, … ,orv(¬C) = 0. Using transformations, we can see that(P₁∧ P₂ ∧…)→ Cis equivalent to¬P₁ ∨¬P₂ ∨ … ∨C.That is:Using the recursive rules, we get:v((P₁∧ P₂ ∧… )→ C) = v(¬P₁ ∨¬P₂ ∨ … ∨C).But ifv(¬P₁ ∨¬P₂ ∨ … ∨C) = (NOT v(P₁)) OR (NOT v(P₂)) OR … OR v(C)v(P₁) = 0, then(NOT v(P₁)) OR (NOT v(P₂)) OR … OR v(C) = …… = (NOT 0) OR (NOT v(P₂)) OR … OR v(C) = …Similarly, if… = 1 OR OR (NOT v(P₂)) OR … OR v(C) = 1v(P₂) = 0, then(NOT v(P₁)) OR (NOT v(P₂)) OR … OR v(C) = …… = (NOT v(P₂)) OR (NOT 0) OR … OR v(C) = …And so on. Finally, if… = 1 OR OR (NOT v(P₂)) OR … OR v(C) = 1v(¬C) = 0, thenv(C) = 1and so(NOT v(P₁)) OR (NOT v(P₂)) OR … OR v(C) = …Since these are all the possibilities if not-SAT { P₁, P₂, … , ¬C }, we know that… = (NOT v(P₁)) OR (NOT v(P₂)) OR … OR 1 = 1.v((P₁∧ P₂ ∧… )→ C) = 1for all valuations. By similar reasoning, we can see that ifv((P₁∧ P₂ ∧… )→ C) = 1for all valuations, then not-SAT { P₁, P₂, … , ¬C } since otherwise, there would be a valuationvwithv((P₁∧ P₂ ∧… )→ C) = 0.
Chaining
Consider the following KB:
RAIN → CLOUDS(CLOUDS ∧ SNOW) → STORMRAIN → PUDDLESPUDDLES → HUMIDHUMID → CLOUDSSUN → DRY(WIND ∧ SNOW) → DRIFTING
We add to this KB the following two facts:
RAIN, SNOW-
Run the forward-chaining and the backward-chaining algorithm to show that we can derive
STORMfrom the KB. That is, describe the steps you’d take for each algorithm one-by-one, and why at some point you hit the termination condition. -
Use the example to illustrate how forward-chaining can find shorter derivations than backward-chaining.
-
Use both forward and backward-chaining to show that we can’t derive
DRIFTINGfrom the KB using the facts. Does one algorithm outperform the other?
Solution
-
Our goal is to derive
STORM. The facts areRAINandSNOW. First, we use forward chaining:-
So, in the first iteration, we run through all the conditionals and see if we can derive anything from those facts using
genMP. We come across the two conditionalsRAIN →CLOUDSandRAIN→PUDDLES. We deriveCLOUDSandPUDDLESand add them to our facts. But our goal is not reached. -
So, in the second step, the facts are
RAIN, SNOW, CLOUDS,andPUDDLES. Again, we check the conditionals for possibleMPapplications and find(CLOUDS ∧ SNOW) → STORMandPUDDLES → HUMID. We derive bothSTORMandHUMID. Our goal is reached and we terminate the search.
Next, we use backward chaining:
-
Our goal is
STORM, so we inspect the conditionals until we find one that containsSTORMas the consequent. We find (CLOUDS ∧ SNOW)→STORM. We recognize thatSNOW is already among our facts, so we replace the goalSTORMtemporarily withCLOUDS. Since we still have goals, we continue. -
We inspect the rules for one with
CLOUDSin the consequent and findRAIN → CLOUDS. SinceRAINis among our facts, we have no goals left and terminate the search.
Both algorithms lead to the same result and, in fact, give the same derivation.
-
-
In the forward-chaining algorithm, there were no choices involved and we simply looked through all chainings of
MPby length until we found one. Since we went through the derivations by length starting with the shortest derivations, we were guaranteed to come across the shortest derivation first (if there is one).For backward-chaining, finding this particular derivation depended on the order in which we looked through the rules. If, for some implementation reason, we would have first come across
HUMID → CLOUDSin the second step, we would have addedHUMIDto our goals rather thanRAIN. Then, we’d have continued two more iterations going throughPUDDLES→HUMIDandRAIN→PUDDLESuntil we hit a known fact. This would have led to a much longer derivation. This means that with backward-chaining, whether we come across the shortest derivation first, highly depends on external factors, like the ordering of the conditionals in ourKB. -
To test this with forward-chaining, we go through all possible derivations. We’ve described the first two steps above, which gave us
STORMandPUDDLES. Continuing further, we deriveHUMIDusingPUDDLESandPUDDLES →HUMIDand thenCLOUDSfromHUMIDandHUMID→CLOUDS. At this point, we haveRAIN, SNOW, STORM, PUDDLES, HUMID,andCLOUDSamong our facts and can’t applygenMPanymore. SinceDRIFTINGisn’t among these facts, we conclude it can’t be derived.With backward-chaining, instead, we check for conditionals involving
DRIFTINGin the consequent and only find(WIND ∧SNOW → DRIFTING). This addsWINDto our goals, sinceSNOWis already a fact. In the second iteration, we can’t find a conditional that hasWINDin the consequent, so we terminate our search and conclude thatDRIFTINGcan’t be derived.Here, backward-chaining was way more efficient. This is because forward-chaining needs to go through all possible derivations to determine whether there is one, which derives our desired goal. Backward-chaining is more “surgical” in that it only looks through promising candidates and terminates earlier because there are none.
Planning
We’ve made things more difficult for by introducing a third block into the puzzle:
Adjust our planning solution to accommodate the more complicated setup. That is:
-
Determine how we need to adjust the language to accommodate the third block?
-
Which rules do we need to add to our KB to accommodate the third block?
-
Represent the initial setup state and the goal state in the language.
-
Find a model that satisfies the KB, as well as the setup and goal state. Then read off a course of action. You don’t need to do this formally—using resolution or chaining—but just find such a model using human intelligence.
Solution
-
On the language side, we need to add all the instances of the schemata
On(X,Y,t), Stack(X,Y,t), Unstack(X,Y,t)forX,Y∈{R,G,B}andt∈{0, 1, 2, …}, where the statements involvingBrepresent the facts involving the new blue block. -
In terms of the rules, all previous rules can remain the same just involving
B, so¬On(X,X)forX∈{R,B,G}, and so on. We do need to add principles that exclude new weird configurations that are logically possible, such asOn(R,G,t)∧On(G, B,t)∧On(B,R,t)for some timet. Our previous rules only excluded 2-step loops, likeOn(R,G,t)∧On(G,R,t), but not 3-step loops like the one above. We could just add the schema:On(X,Y,t)∧On(Y, Z,t)→¬On(Z,X,t)There is one kind of rule that we would need to include concerning the actions that wasn’t relevant before. Now that there are three blocks, we should watch out that we can only unstack one block from another if there’s no other block on the top. That is, we need to postulate,
Unstack(R,G,t)→¬On(B,R,t)Unstack(R,B,t)→¬On(G,R,t)Unstack(G,B,t)→¬On(R,G,t)...Similarly, we can only stack one block on top of another, if there’s no other block on top yet:
Stack(R,G,t)→¬On(B,G,t)Stack(R,B,t)→¬On(G,B,t)...The persistence conditions remain the same.
-
Our set-up, then is:
On(G,B,0)∧On(B,R,0)And the goal state is:
On(B,G,t)∧On(G,R,t)for some suitable
t. As you can see, we can achieve this fort=4(five steps). -
Here’s one strategy. I only note the relevant formulas, all unnamed formulas are assumed to be false:
-
First step:
-
State:
On(G,B,0), On(B,R,0) -
Action:
Unstack(G,B,0)(possible because neitherOn(R,G,0)norOn(B,G,0))
-
-
Second step:
-
State:
¬On(G,B,1), On(B,R,1) -
Action:
Unstack(B,R,1)(possible because now¬On(G,B,1))
-
-
Third step:
-
State:
¬On(G,B,2), ¬On(B,R,2) -
Action:
Stack(B,R,2)(possible because at this point neitherOn(G,R,2)norOn(B,R,2))
-
-
Fourth step:
-
State:
On(B,R,3), ¬On(B,R,3) -
Action:
Stack(G,B,3)
-
-
Fifth step:
- State:
On(G,B,4), ¬On(B,R,4)
- State:
-
You can straightforwardly check that all conditions are satisfied.
Discussion
Check out the Wason selection task (opens in a new tab) on Wikipedia.
Some researchers have argued that the experiment shows that people don’t reason with the material conditional in this case. Do you agree? Why?