Contents / Discrete Mathematics / Logic and Proofs
Chapter 1
Logic and Proofs
Propositions and the five connectives; functional completeness of NAND alone; equivalences, contrapositive and vacuous truth; quantifiers and their negation; rules of inference and the classic fallacies; direct proof, contraposition and contradiction with the irrationality of the square root of 2; and induction, strong induction and well-ordering shown to be equivalent.
Introduction
A program either returns the right answer on every input or it does not. Testing it on a thousand inputs establishes something about those thousand inputs and nothing whatever about the thousand-and-first. The only instrument that settles the general case is a proof, and a proof is an object with a grammar: it is built out of statements, combined by a small fixed set of connectives, quantified over domains, and chained together by rules that preserve truth. This chapter is about that grammar.
Two things make the subject unexpectedly concrete for a computer scientist. The first is that the connectives of propositional logic are exactly the gates of a circuit, and the question which gates do I need? has a sharp answer: a single gate type, NAND, suffices to build every boolean function there is. That is a theorem about logic and simultaneously a fact about silicon. The second is that a truth table is a finite object, so every question about a formula in variables — is it a tautology, is it satisfiable, are these two formulas the same? — can be decided by checking rows. Finite does not mean cheap: rows for is more rows than there have been seconds since the Big Bang, and the question of whether satisfiability can be decided substantially faster is the P versus NP problem. But it does mean the semantics of this chapter never requires an act of faith.
The second half turns to proof itself. We isolate the three moves that do almost all the work — direct argument, contraposition, contradiction — and, crucially, prove that they are valid, rather than asserting them. Proof by contradiction is not a convention we agree to; it is a consequence of the truth table for implication. Then comes induction, the one technique genuinely peculiar to the discrete world, in its ordinary and strong forms, together with the well-ordering principle, which turns out to be the same statement wearing a different hat. We finish by dissecting a famous induction that proves all horses are the same colour, because knowing precisely which step of that argument fails is worth more than any number of correct inductions.
Throughout, is the integers and . We work informally, in the sense that our object of study is mathematical reasoning as practised rather than a formal deductive calculus with its own axioms and derivation rules. That formal turn — where "provable" becomes a syntactic notion, and one asks whether it coincides with "true" — belongs to Mathematical Logic, and we will point at the door without walking through it.
1.1Propositions and truth values
Everything begins with a restriction on what counts as a sentence we may reason about.
Definition 1.1 (Proposition). A proposition is a declarative sentence that is either true or false, and not both. Its truth value is (true) or (false). We write propositional variables for propositions whose particular content does not matter.
The definition excludes three large families of English sentences. Questions ("Is prime?") assert nothing. Commands ("Return on failure") assert nothing. Open sentences (" ") assert something only once is supplied; until then they are predicates, which we take up in the section on quantifiers. And a fourth family is excluded for a subtler reason: sentences like "this sentence is false" are declarative and yet cannot consistently be assigned either value. We simply do not admit them. Ruling out self-reference by fiat is a blunt instrument, and the delicate version of the question — what happens to a formal system rich enough to talk about its own provability — is the subject of Gödel's incompleteness theorems in Mathematical Logic.
Example 1.2 (Which sentences are propositions?). Classify each as a proposition (with its truth value) or not: (a) is prime. (b) Every even integer greater than is a sum of two primes. (c) Sort the array. (d) . (e) .
Solution.
- (a) is a proposition, true.
- (b) is a proposition — Goldbach's conjecture. It is either true or false; nobody currently knows which. Being a proposition is about having a truth value, not about our access to it.
- (c) is imperative, so not a proposition.
- (d) is an open sentence: its truth depends on . It becomes a proposition once is fixed, or once it is quantified ("for all integers , " — false, take ... in fact true for integers, but false for reals, take ).
- (e) is a proposition, false. Falsity is no obstacle: a proposition need not be true.
Notation. We reserve and for truth values and use and for them only where the arithmetic is the point, as when counting satisfying assignments. In code the same two values appear as true/false, and the correspondence between a boolean expression in a program and a compound proposition is exact — which is why the laws of this chapter are the laws a compiler uses to simplify a conditional.
A compound proposition built from variables is completely described by what it does to each assignment of truth values to those variables. This is the fundamental finiteness that makes propositional logic decidable.
Definition 1.3 (Truth assignment and truth table). A truth assignment for the variables is a function giving each a value in . The truth table of a compound proposition lists its value under every truth assignment, one assignment per row.
Theorem 1.4 (Size of a truth table). A compound proposition in distinct variables has exactly truth assignments, so its truth table has rows.
Proof. A truth assignment chooses one of two values independently for each of the variables. The choices are unconstrained and independent, so by the multiplication principle the number of assignments is with factors, which is .∎
Intuition. Reading a row of a truth table as an -bit binary string makes the count obvious: the rows of a table for are exactly the eight strings through , and listing them in that order is why the standard layout alternates the last column fastest. A truth table is a complete enumeration of a finite universe of possibilities, which is precisely why it decides every propositional question — and precisely why it is useless for in the hundreds.
Two propositions with the same truth table are indistinguishable by any argument that treats their variables as arbitrary. This suggests counting not formulas but tables, and the count is startling.
Theorem 1.5 (Number of boolean functions). There are exactly distinct functions from to .
Proof. Such a function is determined by its output on each of the inputs, by the theorem Size of a truth table, and conversely any choice of outputs determines a function. Choosing an output is choosing one of two values, and the choices are independent, so the number of functions is raised to the number of inputs, namely .∎
Example 1.7 (Counting three-variable tables). How many distinct compound propositions in the variables are there, up to having the same truth table? How many of those are tautologies, and how many are satisfiable?
Solution.
- By the theorem Number of boolean functions with there are distinct truth tables.
- A tautology is true in every row, which pins down all eight outputs, so there is exactly .
- A proposition fails to be satisfiable only when every output is , again exactly one table, so are satisfiable.
- Note the moral: almost everything is satisfiable, and being a tautology is extraordinarily special. This is why checking satisfiability is the interesting computational problem.
Pitfall. "The same proposition" is ambiguous and the ambiguity matters. As strings, and are different; as functions, they are the same. Every theorem in this chapter is about the functions. Two formulas with identical truth tables are interchangeable inside any larger formula, which is exactly the licence a compiler needs to rewrite a && b as b && a, and exactly the licence it does not have when evaluating a has a side effect.
1.2Connectives, conditionals and functional completeness
Five connectives generate everything we will write.
Definition 1.8 (The five connectives). For propositions and :
- Negation ("not ") is true exactly when is false.
- Conjunction (" and ") is true exactly when both are true.
- Disjunction (" or ") is true exactly when at least one is true. This is the inclusive or.
- Conditional ("if then ") is false exactly when is true and is false, and true otherwise.
- Biconditional (" if and only if ") is true exactly when and have the same truth value.
In we call the antecedent and the consequent.
The first three match ordinary usage closely enough to cause no trouble, with one exception: English "or" is often exclusive ("soup or salad"), and mathematical never is. The exclusive version is a separate connective, , true when exactly one of holds; it is the parity bit, the XOR gate, and the operation that makes a one-time pad work.
The conditional is where every student stumbles, because three of its four rows are true and two of those three feel like cheating.
Definition 1.10 (Vacuous truth). A conditional whose antecedent is false is said to be vacuously true. Its truth value is regardless of .
This convention is not arbitrary, and it is not chosen for convenience. It is forced, in the following precise sense.
Theorem 1.11 (The conditional's truth table is forced). Suppose a binary connective satisfies both of the following:
- From and one may always infer (the rule is sound).
- For every predicate over a domain , the sentence "for all , " is true.
Then agrees with on all four rows.
Proof. Row is settled by condition 1: if is true and is false, then must be false, since otherwise both premises of the rule would be true and we could infer the false .
Row is settled by condition 2. Take any predicate and any with true. Condition 2 makes true, and that is an instance of the connective applied to a true antecedent and a true consequent.
Now the two rows with false antecedent. Take and the predicate " ". Condition 2 makes " " true for every integer , in particular for , where both sides are false; so row is true. For row , take to be " " and to be " ". The sentence "for all integers , " is one we certainly wish to call true, and at its antecedent is false while its consequent is true. So that row is true as well.∎
Intuition. Read as a promise: "if you give me , I will give you . " You have broken the promise only if arrived and did not. If never arrived, the promise stands unbroken — not because you kept it in any interesting sense, but because there is no evidence against it. "Every element of the empty list is negative" is true for the same reason, and any convention that made it false would force us to say the empty list contains a non-negative element.
Example 1.12 (Vacuous truth in a loop invariant). A function scans a list and returns true if every element is even. On the empty list it returns true. Justify this using the conditional's truth table.
Solution.
- The claim is "for every index in the list, the element at is even", which unpacks to " is a valid index element at is even" for every .
- On the empty list no is a valid index, so every antecedent is false.
- Each conditional is therefore vacuously true, and the universally quantified claim holds. Returning
trueis correct, and a loopfor i in list: if odd: return falsefollowed byreturn trueimplements exactly this. - The alternative convention would make the function's answer on the empty list depend on nothing at all in the list, which is the definition of an arbitrary choice.
Definition 1.13 (Tautology, contradiction, satisfiable). A compound proposition is a tautology if it is true under every truth assignment, a contradiction if it is false under every truth assignment, and satisfiable if it is true under at least one. A contingency is a proposition that is neither a tautology nor a contradiction.
Example 1.14 (Classifying by truth table). Classify and , and count the satisfying assignments of .
Solution.
- For the first, suppose it were false under some assignment. Then and are both false, so is true and is false from the first, and is true from the second — a contradiction. Hence it is a tautology.
- For the second, if and both hold then is false, so the conjunction is false; it is a contradiction.
- For the third, of the eight assignments to the formula fails exactly when is true and false, or true and false. Listing: ✓, ✗, ✗, ✗, ✓, ✗, ✓, ✓. So assignments satisfy it.
Now to the structural question. We introduced five connectives, but nothing so far says we needed five. The next theorem shows that any truth table whatsoever can be realised, which will make the reduction to fewer connectives straightforward.
Definition 1.15 (Literal and disjunctive normal form). A literal is a variable or its negation. A compound proposition is in disjunctive normal form (DNF) if it is a disjunction of conjunctions of literals, such as .
Theorem 1.16 (Every truth table has a DNF). Let be any function from to with . Then some compound proposition in disjunctive normal form, using only , and , has truth table .
Proof. If is false on every input, take the proposition , which is a conjunction of literals and so a DNF with one disjunct.
Otherwise, let be the assignments on which is true. For each such assignment define the conjunction
Put . Under an assignment : if for some then is true so is true; if is none of them then every disjunct is false so is false. Thus has truth table , and it uses only , , .∎
Definition 1.17 (Functional completeness). A set of connectives is functionally complete if every boolean function of every arity is the truth table of some proposition built using only connectives from .
Theorem 1.18 (Completeness of NOT and AND). The set is functionally complete. So are and .
Proof. By the theorem Every truth table has a DNF, it is enough to express using and . Compare truth tables of and : the latter is false exactly when is true, that is exactly when and are both false, which is exactly when is false. They agree on all four rows. Replacing every in a DNF by this expression gives a formula over with the same table, so is complete.
For , dually and agree on all four rows, and we rewrite every . For , note and agree: both are false exactly when is false and is false. So expresses , hence expresses everything does.
Finally the remaining two connectives are definable in any of these sets, since has the table of and has the table of .∎
A natural next question is how small a complete set can be. One connective is enough, and the one that works is the gate a chip fabricator would rather build than any other.
Definition 1.19 (NAND and NOR). The Sheffer stroke or NAND is , defined to be false exactly when and are both true; equivalently has the truth table of . The Peirce arrow or NOR is , with the table of .
Theorem 1.20 (NAND alone is functionally complete). The single connective is functionally complete.
Proof. By the theorem Completeness of NOT and AND it suffices to express and using only .
For negation, consider . It is false exactly when and are both true, that is exactly when is true; so has the truth table of .
For conjunction, has the table of , so applying the negation just constructed gives
Every boolean function therefore has a DNF over , which rewrites over , which rewrites over .∎
Remark. The same argument with in place of shows NOR is complete too: is and is . These are the only two binary connectives that are complete on their own, which can be checked by eliminating the other fourteen. The practical consequence is that a chip needs one gate type: a NAND is two transistors in series and two in parallel, and everything from an adder to a flip-flop is built from copies of it.
Example 1.21 (Building XOR from NAND). Express (exclusive or) using only the Sheffer stroke, and check the count of strokes.
Solution.
- is true exactly on and , so a DNF is .
- Write . Then has the table of , and one checks directly that
- Verify on the four rows: at , , so and , and ✓. At , , so and , and ✓. The remaining rows are symmetric.
- The expression uses stroke symbols, and no expression with works — this is the standard four-NAND XOR of digital design.
Proposition 1.22 (A complete set must contain a connective that is false somewhere). The set is not functionally complete.
Proof. Every proposition built from and alone is true under the all-true assignment: this holds for a single variable, and if and are true under that assignment then so are and , so the claim propagates up the structure of the formula. But is false under the all-true assignment. Hence is not expressible, and the set is incomplete.∎
1.3Logical equivalence and the laws of algebra for propositions
Definition 1.23 (Logical equivalence). Propositions and are logically equivalent, written , if they have the same truth value under every truth assignment — equivalently, if is a tautology.
Notation. The symbols and do different jobs. is itself a proposition, with a truth table, which may be true in some rows and false in others. is a claim about those two propositions, made in our own language rather than in the object language, and it is either right or wrong. The same distinction separates from "is identically equal to" in algebra.
Equivalence is what licenses rewriting. If then either may be substituted for the other inside any larger formula without changing its table, because the table of the larger formula depends on its parts only through their tables. The standard rewrites, together, make the propositions into an algebra:
We prove the two families that are used constantly and are most often got wrong.
Theorem 1.24 (De Morgan's laws). For all propositions and ,
Proof. Take the first. The left side is true exactly when is false, that is exactly when it is not the case that both and are true, that is exactly when at least one of , is false. The right side is true exactly when at least one of , is true, that is exactly when at least one of , is false. The two conditions are the same, so the tables agree in all four rows.
For the second, apply the first to and : . Negating both sides and using gives .∎
Intuition. Negation turns the connective inside out. "It is not the case that the file exists and is readable" does not mean the file fails both tests; it means at least one test failed, and you do not know which. Pushing a negation through a compound condition and forgetting to flip to is the single most common bug in a hand-simplified if statement.
Example 1.25 (Negating a guard condition). A program takes a branch when 0 <= i && i < n && a[i] != 0. Write the condition for taking the other branch, with negation applied to the individual comparisons only.
Solution.
- Write for , for , for . The guard is .
- By De Morgan's laws, applied twice, .
- Translating back: or or .
- Note the "or": a single failing test is enough. Writing the negation as and and would describe a condition that never holds.
Next, the three relatives of a conditional. Distinguishing them is the highest-yield piece of vocabulary in the chapter.
Definition 1.26 (Converse, contrapositive, inverse). Given the conditional , its converse is , its contrapositive is , and its inverse is .
Theorem 1.27 (A conditional is equivalent to its contrapositive). For all propositions ,
Proof. Both sides are false in exactly one circumstance. The left side is false precisely when is true and is false. The right side is false precisely when its antecedent is true and its consequent is false, that is when is false and is true. These are the same circumstance, and a proposition that takes the value on exactly the same assignments takes on exactly the same assignments. Hence the tables agree in all four rows.
Alternatively, chain equivalences: .∎
Theorem 1.28 (A conditional is not equivalent to its converse). There exist propositions with true and false. Hence . The same holds for the inverse.
Proof. Take the assignment false, true. Then is true, since its antecedent is false, while has a true antecedent and a false consequent and so is false. One disagreeing row is enough to refute an equivalence.
For the inverse, is the contrapositive of , so by the theorem A conditional is equivalent to its contrapositive it is equivalent to the converse, and therefore fails to be equivalent to on the same row.∎
Example 1.29 (A concrete converse that fails). Let range over the integers, be " is divisible by " and be " is even". Evaluate the conditional, its converse, its contrapositive and its inverse.
Solution.
- : if then is even. True for every .
- The converse : if is even then . False, and is a witness — is even and . This is exactly the assignment false, true used in the theorem A conditional is not equivalent to its converse.
- The contrapositive : if is odd then . True for every , as it must be.
- The inverse : if then is odd. False, again at .
- The pattern to carry away: conditional and contrapositive stand or fall together; converse and inverse stand or fall together; the two pairs are independent.
Pitfall. " only if " means , not . " if " means . English word order is not a reliable guide to which is the antecedent, so translate through the truth conditions: ask which situation the sentence forbids. "You may board only if you have a ticket" forbids boarding without a ticket, so it is board ticket.
Proposition 1.30 (Negating a conditional). For all propositions ,
Proof. is false in exactly one row, the one where is true and is false; so is true in exactly that row. And is true in exactly that row as well. The tables agree.∎
Notice what this says: the negation of a conditional is not a conditional. The denial of "if it compiles then it runs" is not "if it compiles then it does not run"; it is "it compiles and it does not run" — a single counterexample. That asymmetry is why refuting an implication is usually far easier than proving one.
Example 1.31 (Simplifying with the laws). Simplify to a conjunction of literals and a disjunction.
Solution.
- By Negating a conditional, the expression is .
- By De Morgan's laws, .
- So the whole thing is .
- Sanity check on a row: at , , the original is , and the simplified form is ✓.
1.4Predicates and quantifiers
Propositional logic cannot express "every integer has a successor", because the sentence is about all integers at once and propositional variables are atoms with no internal structure. We need variables ranging over a domain, and two operators that bind them.
Definition 1.32 (Predicate). A predicate over a domain assigns to each a proposition . The predicate itself has no truth value; does, for each .
Definition 1.33 (Quantifiers). Let be a predicate over a nonempty domain .
- The universal statement is true if is true for every .
- The existential statement is true if is true for at least one .
A value with false is a counterexample to ; a value with true is a witness for .
Pitfall. The domain is part of the statement, never an afterthought. " " is true over and false over , where is a counterexample. Writing a quantified sentence without saying what ranges over is writing half a sentence.
Over a finite domain the quantifiers are abbreviations: is and is . That is the right mental model, and it immediately predicts how negation behaves.
Theorem 1.34 (De Morgan's laws for quantifiers). For any predicate over any domain ,
Proof. Take the first. Suppose is true. Then is false, so by the definition of it is not the case that holds for every ; hence some has false, that is true, and this witnesses .
Conversely, suppose is true, with witness . Then is false, so does not hold of every element, so is false and is true. The two statements hold under exactly the same circumstances.
For the second law, apply the first to the predicate : . Negating both sides gives .∎
Intuition. To deny "everything works", you need one broken thing. To deny "something works", you must certify that all of them are broken. Negation swaps the quantifier and pushes inward, exactly as it swaps and — which is no coincidence, since over a finite domain the quantifiers are iterated and .
Definition 1.35 (Nested quantifiers). Quantifiers may be applied in sequence, as in , where is a predicate of two variables. The quantifiers are read left to right, and the value chosen for a variable may depend on the variables quantified to its left.
Corollary 1.36 (Negating a nested quantifier string). For a block of quantifiers , the negation is obtained by replacing every with and every with , in place, and negating :
Proof. Induct on the number of quantifiers. For this is exactly the theorem De Morgan's laws for quantifiers.
Suppose it holds for blocks of quantifiers, and consider where is a block of . For each fixed value of , is a statement about the remaining variables, so the case gives . By the inductive hypothesis . Substituting completes the step.∎
Example 1.37 (Negating a limit-style statement). Negate: "for every there exists such that for all , . "
Solution.
- Symbolically, .
- By Negating a nested quantifier string, flip all three quantifiers and negate the core: .
- In words: some is bad, in the sense that however far out you go there is still a later term at distance at least from .
- Notice each flip happens in place; the order of the variables never changes, and stays outermost.
Theorem 1.38 (Order of quantifiers matters). There is a predicate over a domain for which is true and is false. The two are therefore not equivalent.
Proof. Take and the statement .
is true: given any integer , the integer satisfies , so a witness exists for each .
is false: it asserts a single integer exceeding every integer, and taking gives , which is false. So no such exists.
One statement true and the other false is exactly a failure of equivalence.∎
Intuition. In the witness may be chosen after seeing , and may depend on it. In the witness must be committed to first and then work for every . "Every lock has a key" is not "some key opens every lock". Reading the quantifier prefix as an order of play — the moves are the adversary's, the moves are yours — makes the asymmetry hard to forget.
Example 1.39 (Translating and negating a database claim). Let mean "student has submitted assignment ", over students and assignments . Express "some student has submitted every assignment", and its negation, in words.
Solution.
- The claim is .
- Its negation flips both quantifiers: .
- In words: every student has missed at least one assignment — and which assignment they missed may differ from student to student, since is chosen after .
- Contrast with the negation of ("every assignment has been submitted by someone"), which is : some assignment nobody submitted.
Proposition 1.40 (Universal quantification distributes over conjunction only). For predicates over a domain ,
Proof. For the equivalence: if holds for every then in particular holds for every and holds for every , giving the right side. Conversely if both conjuncts on the right hold, then for any both and hold, so does.
For the non-equivalence, let , be " is even" and be " is odd". Every integer is one or the other, so is true; but neither "every integer is even" nor "every integer is odd" is true, so the right side is false.∎
1.5Rules of inference
An equivalence says two statements carry the same information. An inference is different: it takes premises and produces a conclusion that may say strictly less, and the demand on it is only that it never manufactures a falsehood from truths.
Definition 1.41 (Argument and validity). An argument is a list of premises together with a conclusion . It is valid if under every truth assignment making all the premises true, is also true — equivalently, if is a tautology. An argument is sound if it is valid and its premises are in fact true.
Validity is about form and nothing else. A valid argument from false premises can have a false conclusion, and that is no defect in the argument. What a valid argument guarantees is only this: you will never pass from truth to falsehood.
Theorem 1.42 (Modus ponens). The argument with premises and and conclusion is valid.
Proof. Consider any truth assignment making both premises true. Since is true, the row in question has a true antecedent. Since is true and is false exactly when is true and is false, that combination is excluded; so is not false. Hence is true, which is what validity requires.∎
Theorem 1.43 (Modus tollens). The argument with premises and and conclusion is valid.
Proof. By the theorem A conditional is equivalent to its contrapositive, the premise may be replaced by the equivalent without changing any truth value. The argument is then: premises and , conclusion , which is an instance of Modus ponens with for and for . Hence it is valid.∎
Theorem 1.44 (Hypothetical syllogism). The argument with premises and and conclusion is valid.
Proof. Take an assignment making both premises true, and suppose for the sake of the argument that is false under it. Then is true and is false. From true and true, Modus ponens gives true. From true and true, Modus ponens gives true. But is false. So cannot be false under such an assignment, and it is therefore true whenever both premises are.∎
Proposition 1.45 (Affirming the consequent is invalid). The argument with premises and and conclusion is not valid. Neither is the argument with premises and and conclusion .
Proof. Take false and true. Then the premise is true, and is true because its antecedent is false; but the conclusion is false. A single such assignment refutes validity. The same assignment refutes the second argument: is true, is true, and the conclusion is false.∎
Example 1.46 (Diagnosing three arguments). Which of these are valid? (a) If the input is sorted the search returns in ; the search returned in ; therefore the input was sorted. (b) If a number is divisible by it is divisible by ; is not divisible by ; therefore is not divisible by . (c) If it rains the match is cancelled; if the match is cancelled refunds are issued; therefore if it rains refunds are issued.
Solution.
- (a) has the form , , therefore — affirming the consequent, invalid by Affirming the consequent is invalid. A sorted-input guarantee says nothing about unsorted inputs that happen to finish fast, such as a one-element array.
- (b) has the form , , therefore — Modus tollens, valid. It is also sound, since the premise about and is true.
- (c) has the form , , therefore — Hypothetical syllogism, valid. Note it is valid whether or not it ever rains.
Remark. One can go further and ask for a complete list of rules: a fixed finite set from which every valid propositional argument can be derived by pure symbol manipulation, and a theorem saying derivability and validity coincide. Such systems exist, and the theorem is the completeness theorem for propositional logic. Building the calculus and proving that theorem is the business of Mathematical Logic; here we use the rules informally and justify each by its truth table.
1.6Direct proof and proof by contraposition
Almost every theorem worth stating has the form . A direct proof attacks it head on: fix an arbitrary , assume , and derive by a chain of definitions and previously established results. The word arbitrary is carrying the weight — because nothing beyond was assumed about , the argument applies to every element of , and that is how a finite argument establishes an infinite family of statements.
Definition 1.47 (Parity). An integer is even if for some integer , and odd if for some integer . Every integer is exactly one of the two.
Example 1.48 (A direct proof about parity). Prove that the sum of two odd integers is even, and that the product of two odd integers is odd.
Solution.
- Let and be arbitrary odd integers. By the definition of Parity write and with .
- Then . Since is an integer, is even.
- And , with an integer, so is odd.
- The proof used nothing about and beyond oddness, so it holds for every odd pair — including negative ones, since and were allowed to be any integers.
Direct proof runs out of road when the hypothesis is hard to use. "If is even then is even" gives you a fact about , and prying out of it requires the fundamental theorem of arithmetic. The contrapositive hands you odd, which is an immediate construction.
Theorem 1.49 (Validity of proof by contraposition). To prove it suffices to prove .
Proof. Suppose has been established. By the theorem A conditional is equivalent to its contrapositive, , since the contrapositive of is , which is . Logically equivalent statements have the same truth value under every assignment, so is true as well.∎
Proposition 1.50 (Squares and parity). For every integer : if is even then is even.
Proof. We prove the contrapositive: if is odd then is odd, which by Validity of proof by contraposition establishes the claim.
Let be odd, so for some integer . Then
Intuition. Contraposition is not a different logic; it is the same statement read from the other end. The reason it helps so often is purely practical: a negated conclusion is frequently a constructive hypothesis. " is not even" means " ", something you can substitute into an expression, whereas " is even" means " " for an you know nothing about.
Example 1.51 (Choosing between direct and contrapositive). Prove: for integers , if then or .
Solution.
- The conclusion is a disjunction, awkward to produce directly. Negate it: by De Morgan's laws, is .
- So prove the contrapositive: if and then , that is .
- That is immediate: adding the two inequalities gives .
- By Validity of proof by contraposition the original statement follows. Contraposition turned a disjunctive conclusion into a conjunctive hypothesis, which is the general reason to reach for it here.
Definition 1.52 (Proving a biconditional). To prove one proves both and ; each direction may use whichever technique suits it. For a chain it suffices to prove the cycle .
Example 1.53 (A biconditional in two directions). Prove that an integer is odd if and only if is odd.
Solution.
- () If is odd then is odd, proved directly inside Squares and parity.
- () If is odd then is odd. Contrapositive: if is even, , then is even.
- Both directions hold, so the biconditional holds. Note that each direction was proved by a different route; that is normal and is why a biconditional is two theorems.
Pitfall. Proving and then also proving again in different words is not proving a biconditional. Before writing the second half, check that you have genuinely swapped hypothesis and conclusion. The commonest way to lose marks on an "if and only if" is to prove one direction twice.
1.7Proof by contradiction
Contraposition assumes the negation of the conclusion and aims at the negation of the hypothesis. Contradiction is more aggressive: it assumes the negation of the whole statement and aims at anything impossible at all.
Theorem 1.54 (Validity of proof by contradiction). Let be a proposition. If is true for some proposition , then is true.
Proof. The proposition is false under every truth assignment: whichever value takes, one of the two conjuncts is false.
Now suppose is true and suppose, towards the conclusion, that is false. Then is true, and a conditional with true antecedent and true value must have true consequent — by Modus ponens we infer . But that proposition is false under every assignment. So false is impossible, and since takes one of two values, is true.∎
Intuition. A contradiction is the only thing a consistent set of assumptions can never produce. So if your assumptions yield one, at least one of them is wrong — and if every assumption but was already established, the wrong one is . The technique is powerful precisely because the target is so cheap: you may aim at any absurdity, not a specific conclusion, which is why it works on statements that assert non-existence, where there is nothing to construct.
Definition 1.55 (Rational and irrational). A real number is rational if for integers with , and irrational otherwise. Every rational may be written in lowest terms, with and sharing no common factor greater than .
Theorem 1.56 (Irrationality of the square root of two). There is no rational number with . That is, is irrational.
Proof. Suppose, for contradiction, that is rational. Then we may write
Squaring and clearing the denominator gives . Hence is even, and by the proposition Squares and parity, is even. Write with an integer.
Substituting, , so . Hence is even, and by Squares and parity again, is even.
So and are both even, and therefore share the common factor . This contradicts the choice of the fraction in lowest terms. The assumption that is rational is therefore untenable, and by Validity of proof by contradiction no rational squares to .∎
Remark. The lowest-terms hypothesis is doing real work and it is where the finiteness hides. Without it the argument still runs — one gets an infinite descent of positive integers, which is impossible by well-ordering. Both versions ultimately appeal to the fact that a set of positive integers cannot descend forever, the same principle that will underwrite induction in the next section.
Example 1.57 (Contradiction where construction is unavailable). Prove that there is no smallest positive rational number.
Solution.
- Suppose for contradiction that is the smallest positive rational.
- Then is rational, since the rationals are closed under division by , and since .
- But , contradicting the minimality of .
- Hence no smallest positive rational exists. Notice there was nothing to construct here — the statement asserts a non-existence, so contradiction is the natural tool.
Pitfall. Two failure modes look like proof by contradiction and are not. The first is assuming , deriving where was a hypothesis, and calling it a contradiction — that is contraposition, correctly done, and should be written as such; dressing it up as contradiction adds an unused assumption and obscures the argument. The second is deriving something merely surprising rather than logically impossible. "Therefore is very large" is not a contradiction. You must exhibit a proposition and its negation.
1.8Mathematical induction, strong induction and well-ordering
Induction proves infinitely many statements with two finite arguments. It is the characteristic technique of discrete mathematics because its domain is , a set with a starting point and a successor operation and nothing in between.
Theorem 1.58 (Principle of mathematical induction). Let be a predicate over the integers . Suppose
- is true (the base case), and
- for every , (the inductive step).
Then is true for every integer .
Proof. Let be the set of counterexamples, and suppose it is nonempty. Shifting by , the set is a nonempty set of non-negative integers, so by the well-ordering principle it has a least element; hence has a least element .
By hypothesis 1, is true, so and therefore . Then , and by minimality of , so is true. Hypothesis 2 applied at gives , and Modus ponens yields true. But means is false.
So is empty, which says holds for every .∎
Theorem 1.60 (Sum of the first n positive integers). For every integer ,
Proof. Let be the displayed statement.
Base case. For the left side is and the right side is , so holds.
Inductive step. Let and assume , that is . Then
Both hypotheses of the Principle of mathematical induction hold with , so holds for every .∎
Example 1.61 (An inequality by induction). Prove that for every integer , and identify where the inductive hypothesis is used.
Solution.
- Base case : ✓.
- Step: assume for some . Then , where the inductive hypothesis was used to replace .
- Since we have , so .
- By the Principle of mathematical induction, for all . The hypothesis was needed at step 3; the argument would break at , where .
Sometimes alone is not enough and one needs the whole history below . The classic case is a statement about factorisation, where splitting produces two smaller numbers, neither of which is .
Theorem 1.62 (Strong induction). Let be a predicate over integers . Suppose that for every ,
Proof. We derive this from the Principle of mathematical induction applied to a different predicate. Define
Base case. At the hypothesis has an empty conjunction of antecedents, which is vacuously true, so the hypothesis delivers outright. Hence holds.
Inductive step. Assume for some ; that is, holds for all from to . This is exactly the antecedent of the hypothesis at , so follows. Combining with , holds for all from to , which is .
By the Principle of mathematical induction, holds for every . Since implies , the conclusion follows.∎
Remark. Strong induction is therefore not a stronger axiom — it proves nothing that ordinary induction cannot. It is a stronger convenience: the inductive hypothesis you are handed is larger, and you may reach back as far as you like. Note also that a separate base case is usually still written out in practice, because checking that the step really does work at the smallest values is where flawed inductions are caught.
Proposition 1.63 (Every integer above one has a prime divisor). Every integer has a prime divisor.
Proof. By strong induction on . Let and assume every integer with has a prime divisor.
If is prime, then is a prime divisor of itself and we are done. Otherwise is composite, so with integers and . The inductive hypothesis applies to , giving a prime with . Since , transitivity of divisibility gives .
By the theorem Strong induction, every has a prime divisor. Notice that ordinary induction is useless here: knowing about tells us nothing about the factors of .∎
Theorem 1.64 (Well-ordering is equivalent to induction). The following are equivalent over the integers.
- (Well-ordering) Every nonempty set of non-negative integers has a least element.
- (Induction) Any predicate with true and for all holds for all .
Proof. is the proof of the Principle of mathematical induction given above, with : the set of counterexamples is a nonempty set of non-negative integers, so it has a least element, and that least element is neither nor a successor of a non-counterexample.
. Let be a set of non-negative integers with no least element; we show is empty. Let be the statement "no integer with lies in ".
holds: if then would be a least element of , since no non-negative integer is smaller.
Assume . If , then since no is in , every element of is at least , making a least element of — contrary to assumption. So , and with this gives .
By (2), holds for all , so no non-negative integer belongs to , and is empty. Contrapositively, a nonempty such set has a least element.∎
Intuition. The two principles are the same fact about seen from opposite ends. Induction says you can climb the ladder from the bottom; well-ordering says you cannot fall down it forever. Both fail for the rationals in : there is no "next" rational after , and has no least element, which is exactly what the example about the smallest positive rational showed.
An induction that proves something false
Every hypothesis in the Principle of mathematical induction is load-bearing, and the fastest way to feel that is to watch an argument that satisfies neither carefully enough.
Example 1.65 (All horses are the same colour). The following argues that in any set of horses, all the horses have the same colour. Find the error.
Base case. A set of one horse: all its horses trivially share a colour. ✓
Inductive step. Assume any set of horses is monochromatic, and take a set of horses, labelled . The set has horses, so all of them share a colour. The set also has horses, so all of them share a colour. The two sets overlap — lies in both — so the colour of equals the colour of equals the colour of , and all horses share one colour.
Solution.
- The base case is fine, and the inductive step is fine for every . The failure is at exactly one value: .
- At the set has two horses, and . The step's argument needs a horse lying in both and so that the two colours can be identified. Here : the sentence " lies in both" is false, because stops at .
- So the implication was never established, and the chain is broken at its first link. Everything after it — , and so on — is genuinely valid, but there is nothing to propagate, since is false.
- The diagnosis in one line: the inductive step used an unstated hypothesis, , while the base case supplied only . The fix would be to verify directly, which is of course impossible, since says any two horses match.
Pitfall. Whenever an inductive step involves splitting, overlapping, or removing elements, check the step at the smallest value of it is meant to cover, by substituting that number and reading the resulting sentences literally. Arguments that are obviously correct "in general" routinely collapse at or , where a set becomes empty, an overlap disappears, or a sum has no terms.
Summary. The chapter's spine: a compound proposition is determined by a truth table of rows, so there are of them; every table has a DNF, hence and even alone are functionally complete. Equivalence licenses rewriting, and the two rewrites that matter most are De Morgan and contraposition — the latter valid, the converse not. Quantifiers extend this to predicates, with De Morgan reappearing as , and with the order of nested quantifiers carrying real content. The valid inference patterns — modus ponens, modus tollens, hypothetical syllogism — are each read off a truth table. Those tables then justify the proof techniques themselves: contraposition from the contrapositive equivalence, contradiction from the fact that is never true. Finally, induction, strong induction and well-ordering are three presentations of one fact about , and each derives from either of the others.
- Confusing a conditional with its converse. "If then is even" is true; the converse is false at . Only the contrapositive comes free.
- Denying a conditional with another conditional. By Negating a conditional, is , not . Refuting an implication means exhibiting one case, not proving a new implication.
- Refusing vacuous truth. "Every element of the empty set is red" is true. Any other convention would force the empty set to contain a non-red element.
- Forgetting to flip the connective under De Morgan. is . Turning an
&&guard into a negated&&guard is the classic off-by-one-connective bug. - Swapping nested quantifiers. lets depend on ; does not. "Every lock has a key" is not "some key opens every lock", as the theorem Order of quantifiers matters makes precise.
- Negating a quantifier block out of order. Flip each quantifier in place and negate the innermost predicate; never move a variable past another.
- Affirming the consequent. From and , nothing follows about . Validity is a property of the form, and this form has a counterexample row.
- Confusing validity with truth. A valid argument from false premises proves nothing about the world; an invalid argument may still have a true conclusion, by luck.
- Proving a universal statement with an example. One case establishes , never . Conversely, one counterexample refutes completely — no further work is needed.
- Calling a surprise a contradiction. Proof by contradiction needs an explicit . "This makes enormous" is not a contradiction.
- Dressing contraposition up as contradiction. If your contradiction proof assumes and derives , it is a contraposition proof with a spare assumption. Write it as one; it is shorter and clearer.
- Omitting or faking the base case. The step alone proves nothing: " implies " is a perfectly valid step for a false statement.
- Running the inductive step below the range where it works. This is the horses error. Check the step at its smallest , literally.
- Assuming what is to be proved. The inductive hypothesis is , for one fixed unspecified — never for all , and never .
- Reaching for strong induction without needing it, or refusing it when you do. Splitting lands at two arbitrary smaller values, so ordinary induction cannot reach them; a recurrence in alone does not need the stronger form.