PyCon 2013
March 16, 2013
930

# Logical Failures by Luke Sneeringer

A fun, light-hearted look into the basics of symbolic logic, and an exploration of some errors we sometimes make as developers, and how to identify and recognize them.

March 16, 2013

## Transcript

2. ### A question... Linda is 31 years old, single, outspoken, and

very bright. She majored in philosophy. As a student, she was deeply concerned with issues of discrimination and social justice, and also participated in anti-nuclear demonstrations. Which is more likely? Linda is a bank teller. Linda is a bank teller, and active in the feminist movement. Saturday, March 16, 13

4. ### Why? No conjunction can be more probable than any of

its conjuncts. But, lots of people miss this question 90% 10% Bank Teller Bank Teller & Feminist Saturday, March 16, 13
5. ### Why this Talk? All programmers are professional logicians. But logical

mistakes are easy to make. Understanding how we make logical errors will help you avoid those traps, making you a better programmer. Saturday, March 16, 13
6. ### Just Enough Logic Most formal logic languages look a lot

like programming. two values: True and False some operators: not, and, or, xor if, iff Saturday, March 16, 13
7. ### Just Enough Logic A set of statements is valid if

the conclusion is true. Saturday, March 16, 13

9. ### Just Enough Logic A statement is valid if its premises

and conclusion are true. Saturday, March 16, 13

11. ### Validity A statement is valid if there can exist no

situation such that: the premises are true ...and the conclusion is false A statement is sound if the statement is valid and the premises are true. Saturday, March 16, 13
12. ### Validity In logic, you’re almost always concerned with validity, not

soundness. But remember, validity does not entail truth: Invalid conclusions may be true. Valid conclusions may be untrue. Saturday, March 16, 13
13. ### Necessity & Sufficiency Necessary conditions are conditions for a statement

such that if any condition is not met, the statement cannot be true. Sufficient conditions are conditions for a statement such that if all of the conditions are met, the statement must be true. Saturday, March 16, 13
14. ### Epistemology Epistemology is the study of how we know what

we know. A true belief backed by faulty reasoning is still true. It’s just not justified. The goal of this talk is identification of epistemic irresponsibility. Saturday, March 16, 13
15. ### Some Fallacies Asserting the Consequent Questionable Cause Hasty Generalization False

Compromise Regression Fallacy Argument from Fallacy Saturday, March 16, 13

March 16, 13
17. ### Asserting the Consequent Given a conditional, incorrectly concluding its converse.

First, a fun Latin term: modus ponens. If P, then Q Assume P Conclude Q Saturday, March 16, 13
18. ### Asserting the Consequent The inverse of this is also true.

modus tollens If P, then Q Assume not Q Conclude not P Saturday, March 16, 13
19. ### Asserting the Consequent But the converse isn’t! If P, then

Q Assume not P; Conclude not Q If P, then Q Assume Q; Conclude P At least, these are not necessarily true (and thus, not valid). Saturday, March 16, 13
20. ### Asserting the Consequent “If it’s raining, then the (uncovered) grass

will be wet.” Valid: “The grass is not wet; therefore, it is not raining.” Invalid: “The grass is wet; therefore, it is raining.” Invalid: “It is not raining; therefore, the grass is dry.” Saturday, March 16, 13

22. ### Asserting the Consequent Where does this come up in programming?

Analysis of the state of any system or process. Logic errors in code itself. Saturday, March 16, 13

16, 13
24. ### Questionable Cause Actually a group of informal fallacies, centered around

misidentifying causes. The most common: P occurred, then Q occurred. Therefore, P caused Q. Latin: post hoc ergo propter hoc Saturday, March 16, 13
25. ### Questionable Cause “We never had any problem with the air

conditioner until you moved into the house!” Perhaps the tenant did not change the filter. Perhaps something within the A/C failed independently. Sequence is a necessary but insufficient condition for causality. Saturday, March 16, 13
26. ### Questionable Cause Where does this hit us as developers? Troubleshooting

A problem followed a code change, therefore that code must be the cause. That code hasn’t changed, therefore it cannot be the cause. Saturday, March 16, 13
27. ### Questionable Cause Sometimes our reasoning also causes us to miss

third causes. “The car had a pile of empty beer cans, then was in an accident. Therefore, the pile of empty beer cans caused the accident.” Almost every memory problem I’ve debugged, ever. Saturday, March 16, 13

16, 13
29. ### Hasty Generalization Reaching a conclusion with insufficient evidence. “3 is

prime, 5 is prime, 7 is prime, therefore all odd numbers are prime.” Saturday, March 16, 13
30. ### • • • • • • • • • •

• • Pie Town • Truth or Consequences Albuquerque • Saturday, March 16, 13
31. ### Hasty Generalization Programmers do this in several cases: Making conclusions

about the fitness of a block of code. “It works on my machine.” User inputs: how much code breaks because we get an input we didn’t expect? Saturday, March 16, 13
32. ### Hasty Generalization What about the fitness of our tools? Fitness

to solve one problem does not imply fitness to solve another. Examples Relational databases v. NoSQL Web frameworks Saturday, March 16, 13

16, 13
34. ### False Compromise Assuming that a compromise between two statements is

correct. If John wants to build a bridge across a 10-mile river, and I don’t You don’t build half the bridge. Saturday, March 16, 13

36. ### False Compromise Sometimes median statements are meritorious. The same is

true for median solutions in development. But the mere presence of two (or more) “extreme” statements is an insufficient condition. Saturday, March 16, 13
37. ### False Compromise Where does this show up in development? Incrementalism

(for its own sake). Scheduling & Planning Saturday, March 16, 13

16, 13
39. ### Regression Fallacy Another misattribution of causality. When a statistically extreme

circumstance occurs, it is usually followed by a return to normal circumstances. Regression fallacy is misinterpreting this return to normalcy as being the result of a response. Saturday, March 16, 13

41. ### Regression Fallacy Often installed after a series of traffic fatalities.

They’re often credited for reduced accidents as incidents return to a normal rate. In fact, traffic light cameras have no effect on accidents. Saturday, March 16, 13
42. ### Regression Fallacy Programmers can make the exact same mistake. Observe

an extreme situation (high CPU, high memory). Take supposedly corrective action. Observe reversion to the mean. Credit corrective action. Saturday, March 16, 13

March 16, 13
44. ### Argument From Fallacy Concluding that, because an argument is invalid,

its conclusion must be false. Invalid arguments may nonetheless have true conclusions. Saturday, March 16, 13
45. ### Argument From Fallacy Take what you learn here, expand it,

and learn to spot poor reasoning. But when you find a good conclusion backed up with poor reasoning... Don’t throw out the conclusion Correct the reasoning; understand the real reason why the conclusion is true. Saturday, March 16, 13

March 16, 13