START WELL TO END WELL
+92 340 1501700 startwelleducationbhimber@gmail.com Mon – Sat: 8:00 AM – 2:00 PM
Startwell Education logo
StartwellEducation
Discrete Structures · Lecture 8

Proof by Contraposition

Week 3, slot 2 · CLO-2 · Bloom C3 · Prerequisite: Lectures 3 and 7 · Reference: Rosen 7th, Logic and Proofs

Learning objectives

  1. Explain why p → q and ¬q → ¬p are interchangeable.
  2. Decide when contraposition is easier than a direct proof.
  3. Write a complete proof by contraposition.
  4. Prove biconditionals by proving both directions.

Roman Urdu. Kabhi p → q ko seedha sabit karna mushkil hota hai. Lecture 3 se hum jante hain ke p → q aur ¬q → ¬p barabar hain, is liye hum ¬q maan kar ¬p tak pohanchte hain. Isay proof by contraposition kehte hain.

Core concepts

Method. To prove p → q: (1) assume ¬q; (2) show ¬p; (3) conclude ¬q → ¬p, hence p → q, because the two are equivalent.

When to use it. When q is a negative or "not" statement, or when ¬q gives a clean algebraic form (for example "n is even" gives n = 2k) while p is hard to unpack.

Biconditionals. To prove p ↔ q, prove p → q and q → p. To prove several statements are equivalent, prove a cycle of implications.

Misconception. Contraposition is not the converse. Proving ¬p → ¬q is not enough.

Worked examples

Example 1 (basic). Theorem. If 3n + 2 is odd, then n is odd. Contrapositive: if n is even, then 3n + 2 is even. Proof: n = 2k, so 3n + 2 = 6k + 2 = 2(3k + 1), which is even. ∎

Example 2 (intermediate). Theorem. If n² is even, then n is even. Contrapositive: if n is odd, then n² is odd. This was proved in Lecture 7, Example 2. ∎ A direct attempt would need to take a square root, which is awkward. This is the kind of case where contraposition is clearly better.

Example 3 (advanced). Theorem. If n = ab with a and b positive integers, then a ≤ √n or b ≤ √n. Contrapositive: if a > √n and b > √n, then n ≠ ab. Proof: multiplying the two inequalities (all numbers positive), ab > √n · √n = n, so ab ≠ n. ∎ Computing meaning: to find a factor of n it is enough to test divisors up to √n.

Example 4 (computing). A rule says "if the request is authorised, it carries a valid token." The contrapositive "if the token is invalid, deny the request" is the check that is actually coded. The two statements are logically the same rule.

Computer science connection

Security checks written as "deny unless…"; trial division up to √n in primality tests (Module 7); proving program properties by showing that any violation implies a precondition failure.

Key takeaways

  • p → q ≡ ¬q → ¬p, so proving either proves both.
  • Contraposition beats a direct proof when ¬q is easier to use than p.
  • Do not confuse contrapositive with converse.

Roman Urdu. Contraposition mein ¬q maan kar ¬p sabit karte hain. Yeh tab asaan hota hai jab q "not" wala statement ho. Converse (q → p) sabit karna contraposition nahi hai.

Five revision questions

  1. State the contrapositive of "If n² is odd then n is odd."
  2. Prove: if 5n + 3 is even, then n is odd.
  3. Prove: if ab is odd, then a and b are both odd.
  4. Why does Example 3 imply a primality test only needs to check up to √n?
  5. Outline how to prove "n is even if and only if n² is even."

Homework. Prove by contraposition: (a) if 7n + 4 is even, then n is even; (b) for real x and y, if x + y ≥ 2 then x ≥ 1 or y ≥ 1. Then prove that n is even if and only if n² is even.

Quiz

p → q ki contrapositive?

All lectures

  1. Lecture 0: Discrete vs Continuous
  2. Lecture 1: Propositions and Connectives
  3. Lecture 2: Truth Tables, Tautologies and Contradictions
  4. Lecture 3: Logical Equivalence and the Laws of Logic
  5. Lecture 4: Predicate Logic and Quantifiers
  6. Lecture 5: Rules of Inference
  7. Lecture 6: Logical Arguments and Puzzle Solving
  8. Lecture 7: Direct Proof and Proof by Implication
  9. Lecture 8: Proof by Contraposition
  10. Lecture 9: Proof by Contradiction
  11. Lecture 10: Mathematical Induction
  12. Lecture 11: Strong Induction
  13. Lecture 12: Applications of Proofs and Proof Strategy
Admissions Open

Give your child the right start.

Seats are limited. Visit our campus, meet our teachers and see why families trust Startwell Education.