Slide 1

Slide 1 text

Logical Failures Luke Sneeringer @lukesneeringer Saturday, March 16, 13

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Saturday, March 16, 13

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Just Enough Logic A set of statements is valid if the conclusion is true. Saturday, March 16, 13

Slide 8

Slide 8 text

Saturday, March 16, 13

Slide 9

Slide 9 text

Just Enough Logic A statement is valid if its premises and conclusion are true. Saturday, March 16, 13

Slide 10

Slide 10 text

Saturday, March 16, 13

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Some Fallacies Asserting the Consequent Questionable Cause Hasty Generalization False Compromise Regression Fallacy Argument from Fallacy Saturday, March 16, 13

Slide 16

Slide 16 text

ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ Assuming the Consequent Saturday, March 16, 13

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

Saturday, March 16, 13

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ Questionable Cause Saturday, March 16, 13

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ Hasty Generalization Saturday, March 16, 13

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

• • • • • • • • • • • • Pie Town • Truth or Consequences Albuquerque • Saturday, March 16, 13

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ False Compromise Saturday, March 16, 13

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

Saturday, March 16, 13

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

False Compromise Where does this show up in development? Incrementalism (for its own sake). Scheduling & Planning Saturday, March 16, 13

Slide 38

Slide 38 text

ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ Regression Fallacy Saturday, March 16, 13

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

Saturday, March 16, 13

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ Argument from Fallacy Saturday, March 16, 13

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

Contact Luke Sneeringer Twitter: @lukesneeringer E-mail: [email protected] GitHub: github.com/lukesneeringer Saturday, March 16, 13