STEMviz
Mathematics · Algebra, Number Theory and Sequences

Mathematical Logic and Proofs

Master propositional logic (connectives, truth tables, quantifiers) and the four core proof techniques: direct, contrapositive, contradiction, counterexample.

Mathematical Logic and Proofs

Every theorem in this course — every "hence," every "it follows that" — rests on a small number of logical rules that this chapter makes explicit. So far you have manipulated numbers and sets; now the objects of study are statements themselves, and the question is not whether a statement is true, but what it means to know it is true, and how one true statement can be shown to force another. The informal argument in Chapter 1 that 2\sqrt{2} is irrational already used this chapter's central tool — proof by contradiction — without naming it. Here it gets named, and three others besides.

This chapter has two halves. The first half, propositional logic, gives a precise vocabulary for combining and negating statements: connectives, truth tables, and the crucial distinction between a conditional statement and its converse, inverse and contrapositive. The second half turns that vocabulary into a toolkit of proof techniques — direct proof, contrapositive, contradiction, and counterexample — that every later chapter in this course will use without further comment. Have to hand: a willingness to be pedantic about the difference between "if" and "only if," since exam questions are built precisely on that distinction.

1. Propositions and Truth Values

A proposition is a statement that is unambiguously either true or false — never both, never neither. "77 is prime" is a proposition (true). "x+3=10x+3=10" is not a proposition as it stands, because its truth depends on the unspecified value of xx; such a statement is called an open sentence or predicate, and only becomes a proposition once xx is assigned a value or bound by a quantifier (Section 5). "Is 77 prime?" and "Stop!" are not propositions at all — a question or a command carries no truth value.

Propositions versus opinions. "Mathematics is the most interesting subject" is not a proposition, however strongly held — it has no objectively determinable truth value. Every proposition in this course is a precise mathematical or logical claim.

2. Logical Connectives and Truth Tables

Propositions combine into compound statements using connectives. Each connective's meaning is defined completely by a truth table, listing the truth value of the compound statement for every combination of truth values of its parts. With nn basic propositions, a truth table needs 2n2^n rows, since each proposition independently takes one of two values.

Negation, ¬p\neg p ("not pp"), reverses the truth value of pp:

p¬pTFFT\begin{array}{c|c} p & \neg p \\ \hline T & F \\ F & T \end{array}

Conjunction, p∧qp \wedge q ("pp and qq"), is true only when both pp and qq are true:

pqp∧qTTTTFFFTFFFF\begin{array}{cc|c} p & q & p \wedge q \\ \hline T & T & T \\ T & F & F \\ F & T & F \\ F & F & F \end{array}

Disjunction, p∨qp \vee q ("pp or qq"), is true when at least one of p,qp, q is true (the inclusive or — true even when both are true):

pqp∨qTTTTFTFTTFFF\begin{array}{cc|c} p & q & p \vee q \\ \hline T & T & T \\ T & F & T \\ F & T & T \\ F & F & F \end{array}

Negating a conjunction or disjunction follows the same De Morgan pattern met for sets in Chapter 1 — and this is no coincidence, since ∧\wedge behaves exactly like ∩\cap and ∨\vee exactly like ∪\cup:

¬(p∧q)≡(¬p)∨(¬q)¬(p∨q)≡(¬p)∧(¬q)\neg(p \wedge q) \equiv (\neg p) \vee (\neg q) \qquad\qquad \neg(p \vee q) \equiv (\neg p) \wedge (\neg q)

where ≡\equiv denotes logical equivalence: two statements with identical truth tables, true and false in exactly the same cases.

Worked example — negating a compound claim. Negate "the triangle is isosceles and right-angled." Here p=p = "isosceles," q=q = "right-angled." The negation is ¬p∨¬q\neg p \vee \neg q: "the triangle is not isosceles, or it is not right-angled" — not the common wrong guess "the triangle is not isosceles and not right-angled," which would be ¬p∧¬q\neg p \wedge \neg q, a much stronger (and incorrect) claim.

3. The Conditional and Biconditional

The conditional, p⇒qp \Rightarrow q ("if pp then qq," or "pp implies qq"), is the connective most often misjudged. Its truth table:

pqp⇒qTTTTFFFTTFFT\begin{array}{cc|c} p & q & p \Rightarrow q \\ \hline T & T & T \\ T & F & F \\ F & T & T \\ F & F & T \end{array}

The only way for p⇒qp \Rightarrow q to be false is for pp to be true and qq false. Whenever pp is false, the conditional is automatically true, regardless of qq — this is called vacuous truth. "If 55 is even, then 55 is prime" is a true statement, however strange that feels, precisely because its hypothesis is false.

In p⇒qp \Rightarrow q, pp is called a sufficient condition for qq (knowing pp is enough to guarantee qq), and qq is called a necessary condition for pp (if qq fails, pp cannot hold either). The phrase "pp only if qq" means exactly p⇒qp \Rightarrow q — not q⇒pq \Rightarrow p, a distinction that trips up almost every student the first time.

"If" versus "only if." "pp if qq" means q⇒pq \Rightarrow p. "pp only if qq" means p⇒qp \Rightarrow q. The two have opposite direction, despite differing by a single word.

The biconditional, p⇔qp \Leftrightarrow q ("pp if and only if qq," abbreviated "iff"), asserts both directions at once: p⇔qp \Leftrightarrow q is true exactly when pp and qq have the same truth value.

p⇔q  ≡  (p⇒q)∧(q⇒p)p \Leftrightarrow q \;\equiv\; (p \Rightarrow q) \wedge (q \Rightarrow p)

Proving a biconditional therefore generally requires proving two conditionals, one in each direction — a common source of incomplete proofs when a student proves only one half.

4. Converse, Inverse and Contrapositive

Given a conditional p⇒qp \Rightarrow q, three related statements can be formed, and distinguishing them precisely is one of the most heavily examined skills in this chapter:

  • Converse: q⇒pq \Rightarrow p (swap the two parts).
  • Inverse: ¬p⇒¬q\neg p \Rightarrow \neg q (negate both parts, keep the order).
  • Contrapositive: ¬q⇒¬p\neg q \Rightarrow \neg p (swap and negate both parts).

Worked example — building all three. Let p=p = "xx is a multiple of 88," q=q = "xx is even," so p⇒qp \Rightarrow q reads "if xx is a multiple of 88, then xx is even" (true).

  • Converse: "if xx is even, then xx is a multiple of 88" — false (x=2x=2 is even but not a multiple of 88).
  • Inverse: "if xx is not a multiple of 88, then xx is not even" — false (same counterexample, x=2x=2).
  • Contrapositive: "if xx is not even, then xx is not a multiple of 88" — true, and in fact must be true whenever the original statement is.

This last fact is a theorem, not a coincidence, provable by comparing truth tables directly:

p⇒q  ≡  ¬q⇒¬pp \Rightarrow q \;\equiv\; \neg q \Rightarrow \neg p

A conditional and its contrapositive are always logically equivalent; a conditional and its converse (or inverse) are, in general, not. The converse and the inverse are themselves always equivalent to each other, since the inverse is simply the contrapositive of the converse.

5. Quantifiers

A predicate such as "x2≥0x^2 \geq 0" becomes a proposition once a quantifier fixes how many values of xx it must hold for.

The universal quantifier, ∀\forall ("for all"), asserts the predicate holds for every element of a specified domain:

∀x∈R, x2≥0(true)\forall x \in \mathbb{R},\ x^2 \geq 0 \qquad \text{(true)}

The existential quantifier, ∃\exists ("there exists"), asserts the predicate holds for at least one element:

∃x∈R:x2=4(true, e.g. x=2)\exists x \in \mathbb{R} : x^2 = 4 \qquad \text{(true, e.g. } x=2\text{)}

Negating a quantified statement swaps the quantifier and negates the predicate — this is the logical analogue of De Morgan's laws, extended from two propositions to an entire domain:

¬(∀x, P(x))≡∃x, ¬P(x)¬(∃x, P(x))≡∀x, ¬P(x)\neg\big(\forall x,\ P(x)\big) \equiv \exists x,\ \neg P(x) \qquad\qquad \neg\big(\exists x,\ P(x)\big) \equiv \forall x,\ \neg P(x)

In words: to show a "for all" claim is false, it is enough to exhibit one element where the predicate fails — a counterexample. To show a "there exists" claim is false, you must show the predicate fails for every element of the domain — a much stronger requirement.

Worked example — negating a quantified claim. Negate: "∀x∈Z, x2>x\forall x \in \mathbb{Z},\ x^2 > x." The negation is ∃x∈Z:x2≤x\exists x \in \mathbb{Z} : x^2 \leq x. Testing x=1x=1: 12=1≤11^2 = 1 \leq 1, true — so the negation holds, meaning the original universal claim is false, refuted by the single counterexample x=1x=1 (also x=0x=0 works). Notice the original claim is in fact true for every integer except 00 and 11; a single exception anywhere in the domain is enough to falsify a universal statement entirely.

6. Direct Proof

A direct proof of p⇒qp \Rightarrow q assumes pp is true and, through a chain of valid logical steps, deduces that qq must also be true.

Worked example. Prove: if nn is an odd integer, then n2n^2 is odd. Assume nn is odd, so n=2k+1n = 2k+1 for some integer kk. Then

n2=(2k+1)2=4k2+4k+1=2(2k2+2k)+1n^2 = (2k+1)^2 = 4k^2 + 4k + 1 = 2(2k^2+2k) + 1

which is of the form 2m+12m+1 with m=2k2+2k∈Zm = 2k^2+2k \in \mathbb{Z}, hence odd. This completes a direct proof: starting from the hypothesis, pure algebra reached the conclusion.

7. Proof by Contrapositive

Sometimes p⇒qp \Rightarrow q is awkward to prove directly, but its contrapositive ¬q⇒¬p\neg q \Rightarrow \neg p is easy — and since the two are logically equivalent (Section 4), proving one proves the other.

Worked example. Prove: if n2n^2 is even, then nn is even. A direct proof would need to extract a factor of 22 from inside a square root of n2n^2, which is clumsy. Instead prove the contrapositive: if nn is odd, then n2n^2 is odd — which is exactly the direct proof of Section 6. Since ¬q⇒¬p\neg q \Rightarrow \neg p is proved, p⇒qp \Rightarrow q follows automatically.

8. Proof by Contradiction

A proof by contradiction assumes ¬p\neg p (the negation of what is to be proved) and derives a logically impossible consequence — a statement of the form r∧¬rr \wedge \neg r for some rr, which can never be true. Since the assumption ¬p\neg p led to an impossibility, ¬p\neg p must be false, so pp is true.

This is exactly the structure used in Chapter 1 to prove 2\sqrt{2} irrational: assume 2\sqrt{2} is rational (¬p\neg p), derive that the numerator and denominator of its lowest-terms fraction are both even (r∧¬rr \wedge \neg r, since "lowest terms" and "both even" cannot coexist), conclude 2\sqrt{2} is irrational (pp).

When to reach for contradiction. Proof by contradiction is most useful exactly when the conclusion is a negative statement ("2\sqrt{2} is not rational," "there is no largest prime") — negating it produces a positive, workable assumption to reason from.

Worked example — infinitude of primes (Euclid). Prove there is no largest prime number. Assume, for contradiction, that there are only finitely many primes, p1,p2,…,pnp_1, p_2, \ldots, p_n. Consider

N=p1p2⋯pn+1N = p_1 p_2 \cdots p_n + 1

NN is not divisible by any pip_i (dividing NN by pip_i always leaves remainder 11), so either NN itself is prime, or it has a prime factor not in the original list. Either way, a prime exists outside {p1,…,pn}\{p_1,\ldots,p_n\}, contradicting the assumption that the list was complete. Hence there are infinitely many primes.

9. Counterexamples and Proof by Exhaustion

To disprove a universal claim, a single counterexample suffices — Section 5 already showed this. No general argument is needed, only one explicit instance where the predicate fails.

Worked example. Disprove: "every prime number is odd." The counterexample p=2p=2 (prime, but even) suffices to falsify the universal claim entirely.

Proof by exhaustion (or proof by cases) proves a claim by checking every possible case separately, used when the domain splits naturally into a small, finite number of possibilities (e.g. checking a claim about integers separately for the cases "even" and "odd"). It is a direct proof repeated once per case, not a distinct logical mechanism.

10. Common Exam Pitfalls

  • Confusing the converse with the contrapositive. Only the contrapositive is guaranteed logically equivalent to the original conditional; the converse generally is not and must be checked independently.
  • Negating "and" as "and" instead of "or." ¬(p∧q)≡¬p∨¬q\neg(p \wedge q) \equiv \neg p \vee \neg q — the connective flips, exactly as with set complements in Chapter 1.
  • Treating a false hypothesis as making the whole proof false. p⇒qp \Rightarrow q is vacuously true whenever pp is false — this is a feature of the definition, not an error.
  • Proving only one direction of an "if and only if" statement. A biconditional needs both p⇒qp \Rightarrow q and q⇒pq \Rightarrow p established.
  • Trying to disprove an existential (∃\exists) claim with a single counterexample. A single failing case only disproves a universal claim; an existential claim requires showing the predicate fails for every element of the domain.
  • Misreading "only if." "pp only if qq" is p⇒qp \Rightarrow q, not q⇒pq \Rightarrow p — the two directions are easy to swap by mistake.

Summary

  • A proposition has a definite truth value; an open sentence does not, until a value is substituted or a quantifier applied.
  • Connectives: ¬p\neg p (not), p∧qp\wedge q (and, true only if both true), p∨qp\vee q (or, true if at least one true). Logical De Morgan: ¬(p∧q)≡¬p∨¬q\neg(p\wedge q)\equiv \neg p\vee\neg q and ¬(p∨q)≡¬p∧¬q\neg(p\vee q)\equiv\neg p\wedge\neg q.
  • p⇒qp \Rightarrow q is false only when pp is true and qq is false; it is vacuously true whenever pp is false. p⇔q≡(p⇒q)∧(q⇒p)p \Leftrightarrow q \equiv (p\Rightarrow q)\wedge(q\Rightarrow p).
  • Given p⇒qp \Rightarrow q: converse q⇒pq\Rightarrow p, inverse ¬p⇒¬q\neg p\Rightarrow\neg q, contrapositive ¬q⇒¬p\neg q\Rightarrow\neg p. Only the contrapositive is guaranteed equivalent to the original.
  • ¬(∀x,P(x))≡∃x,¬P(x)\neg(\forall x, P(x)) \equiv \exists x, \neg P(x) and ¬(∃x,P(x))≡∀x,¬P(x)\neg(\exists x, P(x)) \equiv \forall x, \neg P(x). A universal claim is disproved by one counterexample; an existential claim requires ruling out every case.
  • Proof techniques: direct proof (assume pp, deduce qq); proof by contrapositive (prove ¬q⇒¬p\neg q\Rightarrow\neg p instead); proof by contradiction (assume ¬p\neg p, reach an impossibility r∧¬rr\wedge\neg r); disproof by counterexample; proof by exhaustion (check every case).