TExcelTAD
Home › Discrete Mathematics › Proving Implications and Iff

Proving Implications and Iff

Most theorems have the shape "if PP then QQ", written P→QP \to Q or P  ⟹  QP \implies Q. Others say "PP if and only if QQ", written P↔QP \leftrightarrow Q or P  ⟺  QP \iff Q. This lesson gives the standard templates for proving each kind.

When is an implication true?

P→QP \to Q is false in exactly one situation: PP is true and QQ is false. In particular, an implication with a false hypothesis is true ("vacuously true").

PP QQ P→QP \to Q
T T T
T F F
F T T
F F T

So to prove P→QP \to Q, you only have to deal with the case where PP is true.

Method 1: assume PP, show QQ

Write "Assume PP." Then argue until you reach QQ.

Theorem. If 0≤x≤20 \le x \le 2, then −x3+4x+1>0-x^3 + 4x + 1 > 0.

Proof. Assume 0≤x≤20 \le x \le 2. Then xx, 2−x2 - x and 2+x2 + x are all non-negative, so x(2−x)(2+x)≥0x(2 - x)(2 + x) \ge 0. Expanding, x(4−x2)=−x3+4x≥0x(4 - x^2) = -x^3 + 4x \ge 0. Adding 1 gives −x3+4x+1≥1>0-x^3 + 4x + 1 \ge 1 > 0. ■\blacksquare

The hard part was finding the factorization; the written proof is short. Scratch work is often needed before the clean proof appears.

python · try it yourself
import numpy as np

xs = np.linspace(0, 2, 2001)
vals = -xs ** 3 + 4 * xs + 1
print("minimum on [0, 2]:", round(float(vals.min()), 6), "at x =", float(xs[vals.argmin()]))
minimum on [0, 2]: 1.0 at x = 0.0

The numeric check agrees: the minimum value 1 is reached at both ends of the interval.

Method 2: prove the contrapositive

The contrapositive of P→QP \to Q is ¬Q→¬P\neg Q \to \neg P. They are logically equivalent: both are false exactly when PP is true and QQ is false. Sometimes the contrapositive is much easier.

Theorem. If n2n^2 is even, then nn is even.

Proof. We prove the contrapositive: if nn is odd, then n2n^2 is odd. Let n=2k+1n = 2k + 1. Then n2=4k2+4k+1=2(2k2+2k)+1n^2 = 4k^2 + 4k + 1 = 2(2k^2 + 2k) + 1, which is odd. ■\blacksquare

Starting from "n2n^2 is even" directly gives n2=2mn^2 = 2m, and there is no easy way to get at nn from that. The contrapositive turns it into a computation.

Note: The converse Q→PQ \to P is not equivalent to P→QP \to Q. "If it is a square then it is a rectangle" is true; its converse "if it is a rectangle then it is a square" is false.

python · try it yourself
from itertools import product

imp = lambda a, b: (not a) or b
rows = []
for P, Q in product([True, False], repeat=2):
    rows.append((P, Q, imp(P, Q), imp(not Q, not P), imp(Q, P)))
print("P      Q      P->Q   contra converse")
for r in rows:
    print("  ".join(f"{str(v):5}" for v in r))
print("P->Q equivalent to contrapositive:", all(r[2] == r[3] for r in rows))
print("P->Q equivalent to converse:", all(r[2] == r[4] for r in rows))
P      Q      P->Q   contra converse
True   True   True   True   True
True   False  False  False  True
False  True   True   True   False
False  False  True   True   True
P->Q equivalent to contrapositive: True
P->Q equivalent to converse: False

Proving "if and only if"

P  ⟺  QP \iff Q means both P→QP \to Q and Q→PQ \to P. There are two templates:

  1. Prove both directions separately. Label them "(⇒\Rightarrow)" and "(⇐\Leftarrow)".
  2. Chain of iffs: P  ⟺  R1  ⟺  R2  ⟺  ⋯  ⟺  QP \iff R_1 \iff R_2 \iff \cdots \iff Q, where every step is reversible.

Theorem. For an integer nn, nn is even if and only if n2n^2 is even.

Proof. (⇒\Rightarrow) If n=2kn = 2k, then n2=4k2=2(2k2)n^2 = 4k^2 = 2(2k^2) is even. (⇐\Leftarrow) This is the theorem proved above by contrapositive. ■\blacksquare

A chain-of-iffs example: for real numbers, the standard deviation of x1,…,xnx_1, \ldots, x_n is 0   ⟺  \iff the sum of squared deviations is 0   ⟺  \iff every squared deviation is 0 (they are all ≥0\ge 0)   ⟺  \iff every xix_i equals the mean. Each step works in both directions.

In software

A function's documentation often states an implication: "if the input is sorted, then binary_search returns the index of the key or -1". It promises nothing when the input is unsorted, just as P→QP \to Q says nothing when PP is false. Tests for an "iff" property need both directions too: is_valid(x) should accept every valid input and reject every invalid one.

Exercises

Exercise 1: Contrapositive and converse

Write the contrapositive and the converse of "If a number is divisible by 6, then it is divisible by 3". Which of them are true?

Answer

Contrapositive: "If a number is not divisible by 3, then it is not divisible by 6" (true). Converse: "If a number is divisible by 3, then it is divisible by 6" (false, e.g. 9).

Solution

The original is true because 6k=3(2k)6k = 3(2k). The contrapositive is equivalent to it, so it is true too. The converse is a different statement, and 9 is a counterexample: it is divisible by 3 but not by 6.

Exercise 2: Prove by contrapositive

Prove: if a+b≥100a + b \ge 100 for integers a,ba, b, then a≥50a \ge 50 or b≥50b \ge 50.

Answer

Contrapositive: if a<50a < 50 and b<50b < 50, then a≤49a \le 49 and b≤49b \le 49, so a+b≤98<100a + b \le 98 < 100.

Solution

The negation of "a≥50a \ge 50 or b≥50b \ge 50" is "a<50a < 50 and b<50b < 50". Assume that. Since a,ba, b are integers, a≤49a \le 49 and b≤49b \le 49, so

a+b≤49+49=98<100a + b \le 49 + 49 = 98 < 100

which is the negation of the hypothesis. So the contrapositive holds, and with it the theorem. ■\blacksquare

Exercise 3: An iff with divisibility

Prove that an integer nn is divisible by 3 if and only if n2n^2 is divisible by 3. Check the remainders in Python first.

Answer

(⇒\Rightarrow) n=3kn = 3k gives n2=3(3k2)n^2 = 3(3k^2). (⇐\Leftarrow) by contrapositive: if n=3k+1n = 3k + 1 or 3k+23k + 2, then n2≡1(mod3)n^2 \equiv 1 \pmod 3.

Solution
python · try it yourself
for r in range(3):
    print(f"n = 3k + {r}: n^2 mod 3 = {(r * r) % 3}")
n = 3k + 0: n^2 mod 3 = 0
n = 3k + 1: n^2 mod 3 = 1
n = 3k + 2: n^2 mod 3 = 1

(⇐\Leftarrow) If nn is not divisible by 3, then n=3k+1n = 3k + 1 or n=3k+2n = 3k + 2. In the first case n2=9k2+6k+1=3(3k2+2k)+1n^2 = 9k^2 + 6k + 1 = 3(3k^2 + 2k) + 1; in the second n2=9k2+12k+4=3(3k2+4k+1)+1n^2 = 9k^2 + 12k + 4 = 3(3k^2 + 4k + 1) + 1. Either way n2n^2 leaves remainder 1, so it is not divisible by 3. ■\blacksquare

Test yourself

When is P→QP \to Q false?

  1. When PP is false
  2. When QQ is true
  3. When PP is true and QQ is false
  4. When both are false

Which statement is logically equivalent to P→QP \to Q?

  1. Q→PQ \to P
  2. ¬P→¬Q\neg P \to \neg Q
  3. ¬Q→¬P\neg Q \to \neg P
  4. P∧QP \land Q

How many implications do you prove for an 'if and only if' statement (using the two-direction template)?

  1. One
  2. Two
  3. Three
  4. Four