Skip to main content

Subsection 3.4.5 A Really Useful Problem Solving Technique – Debugging

It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth.

Sherlock Holmes in The Beryl Coronet

Consider a very common problem-solving scenario:

Something doesn’t work.

Your job is to fix it. Before you can fix it, you have to figure out the cause of the problem.

We do this kind of reasoning every day. It’s also a powerful tool for programmers who have to debug their code.

A useful strategy is:

  1. Make a list of possible causes.

  2. Consider the items on the list one at a time:

    1. If this item appears to be the cause, move on to fix the problem

    2. If this item doesn’t appear to be the cause, winnow the list by removing this item.

  3. Hope that you don’t winnow the list down to empty before finding the cause.

Disjunctive Syllogism is what lets us do this.

Problem: The lamp won’t turn on.

Let’s give names to the following statements:

Plugged: The lamp is plugged in.

Power: The power is on to the outlet.

Bulb: The bulb is okay.

Broken: The lamp is broken.

Then we might make this claim if we observe that our lamp isn’t working and we believe that there are four possible causes of the problem:

\(\neg Plugged \vee (\neg Power \vee (\neg Bulb \vee Broken)) \)

(In everyday reasoning, we would skip the parentheses. Later, we will too. But for now, each instance of or must have exactly two arguments. So we’ll write it this way and just list the possible causes in the order in which we plan to check them.)

We can now proceed to diagnose the problem. We check that the power is plugged in. It is.

So we reason:

\(Plugged  (Power  (Bulb  Broken)) \)

Plugged

\(Power  (Bulb  Broken) \) Disjunctive Syllogism

Next, suppose that we check that the power is on by plugging something else into the outlet. It works. So we reason:

\(\neg Power \vee (\neg Bulb \vee Broken) \)

Power

\(\neg Bulb \vee Broken \) Disjunctive Syllogism

And so forth.