Propositions and connectives
A proposition is a sentence that is either true (T) or false (F): “7 is a prime”, “it is raining”, “$x^2 \ge 0$ for all real $x$”. Questions and commands are not propositions. From simple propositions $p$, $q$, $r$ compound ones are built with connectives:
| Symbol | Name | Read | True when … |
|---|---|---|---|
| ¬p | negation | not p | p is false |
| p ∧ q | conjunction | p and q | both are true |
| p ∨ q | disjunction | p or q | at least one is true |
| p ⊕ q | exclusive or | either p or q | exactly one is true |
| p → q | implication | if p, then q | p is false, or q is true |
| p ↔ q | biconditional | p if and only if q | they have the same truth value |
The logical “or” is inclusive: “coffee or tea?” in everyday speech often means “either–or”, but in logic $p \vee q$ is also true when both are true. Aristotle (4th century BC) studied inferences between statements about classes – the syllogisms – while the Stoics, especially Chrysippus, created the first propositional logic. Modern symbolic logic begins with George Boole, who in The Laws of Thought (1854) treated true and false as 1 and 0 and calculated with them like numbers.
Truth tables
A truth table runs through every combination of truth values of the propositions involved: with $n$ variables there are $2^n$ rows. From the table every compound proposition can be classified:
- Tautology – true in every row, whatever $p$ and $q$ mean, e.g. $p \vee \neg p$. Tautologies are the laws of logic.
- Contradiction – false in every row, e.g. $p \wedge \neg p$.
- Contingent proposition – true in some rows and false in others. Whether it is true depends on how the world actually is; logic alone cannot decide.
->, <->, &, | and !. The table shows every sub-expression, and the last column is the whole expression. Notice that an implication and its contrapositive always have the same truth value, whereas the implication and its converse do not. Try a contingent proposition such as $p \to q$ too: the only false row is where $p$ is true and $q$ false.Implication – the awkward one
$p \to q$ is false only when $p$ is true and $q$ is false. In particular “if $p$, then $q$” is true whenever $p$ is false – whatever $q$. That sounds strange (“if the moon is made of cheese, then 2 + 2 = 5” is true), but it is the only choice that makes mathematical theorems usable. The theorem “if $n$ is divisible by 4, then $n$ is even” must be true for all $n$, including $n = 3$ (false premise) and $n = 6$ (false premise, true conclusion). Implication says nothing about cause and effect; it merely rules out one case.
Three related statements belong to an implication: the converse $q \to p$, the inverse $\neg p \to \neg q$ and the contrapositive $\neg q \to \neg p$. Only the contrapositive is equivalent to the original. “All whales are mammals” also means “whatever is not a mammal is not a whale” – but not “all mammals are whales”.
Laws of logic
Boole’s algebra has rules resembling those for numbers, but with some surprises – for instance $p \vee (q \wedge r) = (p \vee q) \wedge (p \vee r)$, which does not hold for plus and times. The most important laws, all of which can be verified with a truth table:
Augustus De Morgan formulated his laws in 1847, the same year Boole published his first book on logic. In everyday language De Morgan’s laws say: “not both rain and sun” is the same as “either no rain or no sun”.
Valid and invalid inferences
An inference is valid if the conclusion is true in every row where all the premises are true. Validity concerns form, not content: a valid inference from false premises may give a false conclusion.
Valid
Modus ponens: $p \to q$, $p$; therefore $q$.
Modus tollens: $p \to q$, $\neg q$; therefore $\neg p$.
Hypothetical syllogism: $p \to q$, $q \to r$; therefore $p \to r$.
Disjunctive syllogism: $p \vee q$, $\neg p$; therefore $q$.
Proof by contradiction: assume $\neg p$ and derive a contradiction; therefore $p$ – this is how Euclid proved that there are infinitely many primes.
Invalid (fallacies)
Affirming the consequent: $p \to q$, $q$; therefore $p$. “If it has rained, the street is wet. The street is wet. Therefore it has rained.” (It might be the street cleaners.)
Denying the antecedent: $p \to q$, $\neg p$; therefore $\neg q$. “If you are Danish, you are European. You are not Danish. Therefore you are not European.”
Logic gates – logic made of electricity
In 1937 Claude Shannon showed in his master’s thesis at MIT that Boole’s algebra exactly describes circuits of relays: switches in series are “and”, switches in parallel are “or”. Today a microprocessor is built from billions of transistors forming logic gates. The NAND gate alone is enough: every other logical function can be built from NAND gates. The half adder adds two binary digits with an XOR gate (the sum) and an AND gate (the carry), and chaining full adders together gives the arithmetic unit of a computer.
Logic and sets – Venn diagrams
To every statement about an element $x$ there corresponds a set: the set of those $x$ for which the statement is true. Then “and” becomes intersection ($A \cap B$), “or” becomes union ($A \cup B$), and “not” becomes the complement ($A^c$, everything in the universe $U$ outside $A$). John Venn introduced the diagrams of overlapping circles in 1880. With three sets the circles divide the universe into $2^3 = 8$ regions – exactly the 8 rows of a truth table with three variables.
Quantifiers – “for all” and “there exists”
Propositional logic cannot express “all men are mortal”. In 1879 Gottlob Frege introduced predicate logic with the quantifiers $\forall$ (for all) and $\exists$ (there exists). Negation swaps them – a version of De Morgan’s law:
To disprove “all swans are white” one black swan is enough; to prove it a thousand white swans are not enough. The order of quantifiers matters: $\forall x\,\exists y: y > x$ (there is no largest number) is true for the real numbers, while $\exists y\,\forall x: y > x$ (there is a number larger than all) is false. This is the logical core of the definitions of limit and continuity.
Wason’s selection task – why logic is hard
In 1966 the psychologist Peter Wason devised an experiment that has since been repeated countless times. Each card has a letter on one side and a number on the other. Which cards must be turned over to decide whether the rule holds? Only about 10 % of participants answer correctly. Dress the same logical task in a social context, and most answer correctly.
The limits of logic
Around 1900 it was hoped that all of mathematics could be derived from logic. In 1901 Bertrand Russell found a paradox: the set of all sets that are not members of themselves – is it a member of itself? In Principia Mathematica (1910–13) Russell and Alfred North Whitehead built a system avoiding the paradox, but in 1931 Kurt Gödel showed that every consistent system strong enough to contain arithmetic contains true statements that cannot be proved within the system. In 1936 Alan Turing showed that there is no mechanical method that can decide whether an arbitrary program halts. Logic is an indispensable tool – but it cannot do everything.
Further reading
- Raymond Smullyan: What Is the Name of This Book? (Prentice-Hall 1978) – logic puzzles about knights who always tell the truth and knaves who always lie
- Paul Tomassi: Logic (Routledge 1999)
- Apostolos Doxiadis and Christos Papadimitriou: Logicomix (Bloomsbury 2009) – a graphic novel about Russell and the foundational crisis of logic
- Ernest Nagel and James R. Newman: Gödel’s Proof (New York University Press 1958, new ed. 2001)
- The pages on probability and contingency tables and tree diagrams