# Problem Solving and Logic

Most people do not think logically. Even many of the statements made by Mister Spock in Star Trek were not actually logical. One important step in problem solving is to make sure that you actually solve the correct problem and that means making sure that you understand exactly what it is that you are being asked to solve. You need to look beyond what is being asked for and confirm what is actually wanted.

To illustrate how the problem you are being asked to solve may not be what you think it is let's look at a computing joke.

The programmer's wife tells him "Run to the store and pick up a loaf of bread. If they have eggs, get a dozen". The programmer comes home with a dozen loaves of bread.

In this joke the programmer has 'solved the problem' exactly as his wife specified. Unfortunately for him his wife didn't specify the problem properly and what she actually wanted wasn't what she asked for.

While this joke presents a rather trivial problem it highlights an important issue. The person presenting the problem to you almost certainly does not think logically and so will have presented the problem in a way that may be open to interpretation. The very first step in solving the problem is to make sure that you actually understand the problem. In the joke the wife has logically asked for a dozen loaves of bread if the store has any eggs but that isn't what she meant to ask for. The programmer ought to have clarified the problem by asking if she really meant a dozen loaves of bread or whether perhaps she meant a dozen eggs instead. Only by asking questions about the information presented can you determine what the real problem to be solved is.

Having determined that you have the problem correctly defined you can use logic as one of your approaches to solving the problem. Sometimes not knowing the answer to one part of the problem will actually get you a step closer to solving the problem.

Let's look at another computer joke.

Three logicians walk into a bar. The bartender asks "Do you all want a drink?". The first logician replies "I don't know". The second replies "I don't know". The third replies "Yes".

In this joke the first two logicians cannot solve the problem because they don't have enough information. Their answers though provide the third with the information needed to solve the problem. This illustrates how even a partial solution to a problem makes progress toward getting a solution to the whole problem. In the joke the problem is the quite trivial one of whether all three want a drink. Now you might assume that they do as otherwise why are they all walking into a bar but there is nothing logical about that assumption. One of the three may simply be accompanying the other two so that they can continue a discussion while the other two have a drink. Making this type of assumption in your problem solving may result in your solution failing when what you have assumed turns out not to be true. In clarifying this problem you'd need to ask whether it needs to cater for people entering the bar who don't want a drink.

In this joke each of the three knows whether they want a drink or not as they enter the bar but makes no assumptions about whether either of the other two do or don't want a drink. Each thinks logically and answers based on what they know. The first two cannot give a 'yes' answer because neither of them know whether the third logician does or doesn't want a drink. The third can give a 'yes' answer because the answers the others gave means that the third does know from logic that all three want a drink.

This particular joke is in computer terms a simple 'A and B and C' test which will only be true (answer 'yes') if A, B and C are all true (all want a drink). If any of the three don't want a drink then the answer to the question is 'no'. That neither of the first two knows the answer to the whole question means that both of them want a drink because otherwise the one who didn't want a drink would be able to answer 'no' instead of not knowing.

This joke also illustrates how what appears to be an indivisible problem can in fact be divided into parts where each part might not be able to solve the whole problem but where even a 'don't know' from one part makes progress toward the solution. Working out a partial solution that sometimes solves the whole problem is better than no solution at all. Also as this joke illustrates, combining partial solutions together can eventually provide the entire solution even though each partial solution can only solve the problem a part of the time. In this joke if the bartender were also a logician and was the only one to hear each answer then each of the three answers would be "I don't know" as each of the three only knows the entire answer if the answer is 'no'. With this particular problem, three 'I don't know' answers is the equivalent of a 'yes'.

Computers work logically. They do exactly what they are told. To be able to most effectively solve problems using a computer you too need to think logically. What is logical is not always what people would expect. In the book "The Moon is a Harsh Mistress" by Robert Heinlein the computer leading the revolution is constantly giving odds on their chance of success. When the next step has a low probability of success the quoted odds go down. This is an example of Heinlein not thinking logically when he wrote the book. If the carrying out of that step were a part of the original plan then its chance of success or failure is logically included in the odds for overall success from the start. Only where they don;t succeed with one of the steps in the original plan and need to switch to plan B would the odds of overall success go down (and logically the odds would have to go down in that case as otherwise plan B ought to be plan A). In Star Trek Mister Spock's supposed logic often neglects to take into account many of the known facts relating to the particular problem - especially the way that the human crew members can be expected to act or react to the situation. It is not logical that Mister Spock could spend that much time living and working with the human crew without his learning how they are likely to react in a range of situations and so be able to take that into account. The thing is that Heinlein and the science fiction writers responsible for the Star Trek episodes did not think logically when they wrote. Unlike computer programmers they didn't have to.

This article written by Stephen Chapman, Felgall Pty Ltd.