Week 4: Proof Strategies

Building Logical Arguments in Mathematics and Computing

Topics:

  • What is a mathematical proof?
  • Direct proof method
  • Proof by contraposition
  • Proof by contradiction
  • Proof by cases
  • How to choose the right strategy

Before We Begin: Quick Recap

What We've Learned (Weeks 1-3)

Week 4 builds directly on the logic foundations from Weeks 1-3. Let's review the key concepts you'll need!

📚 Week 1-2: Propositional Logic

  • Propositions and truth values
  • Logical connectives: ¬, ∧, ∨, →, ↔
  • Truth tables
  • Logical equivalence
  • De Morgan's Laws

📚 Week 3: Predicate Logic

  • Predicates and domains
  • Quantifiers: ∀ (for all) and ∃ (there exists)
  • Negating quantified statements
  • Nested quantifiers

This week (Week 4): We'll use these logical tools to construct mathematical proofs!

Recap: Propositional Logic (Weeks 1-2)

The Five Logical Connectives

Operator Symbol Meaning When True?
NOT ¬p negation When p is false
AND p ∧ q conjunction When both p and q are true
OR p ∨ q disjunction When at least one of p, q is true
IMPLIES p → q implication When p is false OR q is true
IFF p ↔ q biconditional When p and q have same truth value
Critical for Proofs: Remember that p → q is true in three cases:
  • p is true AND q is true
  • p is false AND q is true
  • p is false AND q is false
Only false when p is true and q is false!

Recap: Logical Equivalence (Week 2)

Key Equivalences You'll Use in Proofs

De Morgan's Laws

¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q

Implication

p → q ≡ ¬p ∨ q

Double Negation

¬(¬p) ≡ p

Contrapositive ★

p → q ≡ ¬q → ¬p

This is crucial for proofs!

NOT Equivalent

Converse: p → q ≢ q → p
Inverse: p → q ≢ ¬p → ¬q

Common mistake to avoid!

Example

Statement: If it rains, the ground is wet

Contrapositive (equivalent): If the ground is not wet, it's not raining

Converse (NOT equivalent): If the ground is wet, it's raining

Recap: Quantifiers (Week 3)

Universal and Existential Quantifiers

Universal Quantifier ∀

∀x P(x)

"For all x, P(x) is true"

"Every x has property P"

Example:
∀n ∈ ℤ, n² ≥ 0
"All integers have non-negative squares"

Existential Quantifier ∃

∃x P(x)

"There exists an x such that P(x) is true"

"At least one x has property P"

Example:
∃n ∈ ℤ, n² = 4
"There exists an integer whose square is 4"

Negating Quantifiers (Important for Proofs!)

Statement Negation In English
∀x P(x) ∃x ¬P(x) "Not all x have P" = "Some x doesn't have P"
∃x P(x) ∀x ¬P(x) "No x has P" = "All x don't have P"

Example

Statement: ∀n ∈ ℤ, n² ≥ 0 (All integer squares are non-negative)

Negation: ∃n ∈ ℤ, n² < 0 (Some integer has negative square)

Connecting Logic to Proofs

Types of Mathematical Statements

Type 1: Universal Conditionals (Most Common)

∀x (P(x) → Q(x))

"For all x, if P(x) then Q(x)"

Examples:
  • For all integers n, if n is even then n² is even
  • For all real numbers x, if x > 0 then x² > 0
  • For all lists L, if L is sorted then binary search works on L

Type 2: Existential Statements

∃x P(x) or ¬∃x P(x)

"There exists..." or "There does not exist..."

Examples:
  • There exists a prime number greater than 100
  • There does not exist a largest prime number
  • √2 is irrational (no integers a,b exist such that √2 = a/b)

💻 Programming Connection

Universal statements are like loop invariants: "For all iterations, property P holds"

Existential statements are like search results: "There exists an element satisfying the condition"

From Logic to Proofs

Why Did We Learn All This Logic?

Proofs use the logical structures you've learned to establish truth rigorously.

The Connection:

What You Learned

  • Truth tables define when statements are true
  • Logical equivalences let you rewrite statements
  • Contrapositive: p → q ≡ ¬q → ¬p
  • De Morgan's laws transform negations
  • Quantifiers express "for all" and "there exists"

How You'll Use It

  • → Determine what you need to prove
  • → Transform hard proofs into easier ones
  • → Choose proof by contraposition
  • → Set up proof by contradiction
  • → Know what to assume/prove
This Week's Goal: Learn strategies for proving statements. The logic you learned gives us the rules; now we learn the tactics!

Ready? Let's learn how to prove things! →

Quick Reference: Logical Tools for Proofs

Keep these handy while writing proofs! Bookmark this slide.

Key Equivalences

Contrapositive: p → q ≡ ¬q → ¬p
Implication: p → q ≡ ¬p ∨ q
De Morgan's: ¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
Biconditional: p ↔ q ≡ (p → q) ∧ (q → p)

Quantifier Negations

¬(∀x P(x)) ≡ ∃x ¬P(x)
¬(∃x P(x)) ≡ ∀x ¬P(x)

Common Definitions

  • Even: n = 2k for some integer k
  • Odd: n = 2k + 1 for some integer k
  • Divides: a | b means b = ak for some integer k
  • Rational: r = a/b where a, b ∈ ℤ, b ≠ 0
  • Irrational: Not rational

Remember

  • Converse: q → p (NOT equivalent to p → q)
  • Inverse: ¬p → ¬q (NOT equivalent to p → q)
  • Only contrapositive is equivalent!
💡 Pro Tip: If you get stuck on a proof, try writing the contrapositive or negating the statement to see if it helps!

What is a Proof?

A proof is a logical argument that establishes the truth of a statement beyond any doubt.

A proof consists of:

  1. Assumptions (Hypotheses): What we know to be true
  2. Logical reasoning: Step-by-step deductions using rules of logic
  3. Conclusion: What we want to prove

💻 Programming Analogy

Think of a proof as a program that verifies correctness:

  • Input: Assumptions/hypotheses
  • Process: Logical steps (like code execution)
  • Output: Verified conclusion

Why Proofs Matter in Computing

In Mathematics

  • Establish absolute truth
  • Build on previous knowledge
  • Discover new relationships
  • Understand structure

In Computer Science

  • Verify algorithm correctness
  • Analyze complexity
  • Prove security properties
  • Validate system behavior

Real-World CS Examples

  • Algorithm correctness: Prove that quicksort correctly sorts any list
  • Security: Prove that an encryption scheme can't be broken in polynomial time
  • Databases: Prove that a query optimization preserves query results
  • Networking: Prove that a routing protocol always finds the shortest path

Anatomy of a Theorem

Most theorems have the form: "If P, then Q" written as P → Q

Hypothesis (P)

What we assume is true

Example:

"If n is an even integer..."

Hypothesis: n = 2k for some integer k

Conclusion (Q)

What we want to prove

Example:

"...then n² is even"

Conclusion: n² = 2m for some integer m

Critical Rule: You can ASSUME the hypothesis is true. You must PROVE the conclusion using logical steps.

The Proof Toolbox

We have four main proof strategies to prove P → Q:

Method What You Do When to Use
Direct Proof Assume P is true
→ Show Q must be true
There's a clear path from P to Q
Contraposition Assume ¬Q is true
→ Show ¬P must be true
Easier to work with negations
Contradiction Assume P ∧ ¬Q is true
→ Derive something impossible
Direct path is unclear
Cases Break P into cases
→ Prove Q in each case
P naturally splits into scenarios

Don't worry! We'll explore each method with templates, examples, and strategies.

Method 1: Direct Proof

Direct Proof Strategy: Assume P is true, then use logical steps to show Q must be true.
TEMPLATE: Direct Proof of P → Q

Proof:
1. Assume P is true. [Write what this means]
2. [Logical step 1] because [reasoning]
3. [Logical step 2] because [reasoning]
...
n. Therefore Q is true.
∴ P → Q is established. ∎

💻 Programming Analogy: Forward Execution

Direct proof is like running a program forward:

function prove(P) {
  // Start with P (input/assumption)
  step1 = process(P); // logical deduction
  step2 = process(step1); // another deduction
  ...
  return Q; // arrive at conclusion
}

Direct Proof: Simple Example

Theorem: If n is an even integer, then n² is even.
Proof:
Step 1: Assume n is even.
→ By definition, n = 2k for some integer k
Step 2: Consider n²:
n² = (2k)²
→ Substitute n = 2k
Step 3: Simplify:
n² = 4k²
n² = 2(2k²)
→ Factor out 2
Step 4: Since 2k² is an integer (let's call it m), we have n² = 2m
→ By definition, n² is even
Conclusion: Therefore, if n is even, then n² is even. ∎

Direct Proof: Computing Example

Theorem: If a list L has n elements and we insert one element at the end, the resulting list has n+1 elements.
Proof:
Step 1: Assume list L has n elements.
→ Let L = [e₁, e₂, ..., eₙ] where each eᵢ is an element
Step 2: We perform an insert operation: L.append(x)
→ This creates L' = [e₁, e₂, ..., eₙ, x]
Step 3: Count elements in L':
→ Original n elements + 1 new element = n + 1 elements
Conclusion: Therefore, inserting one element into a list of n elements produces a list of n+1 elements. ∎

Note: This seems obvious, but explicit proofs like this are the foundation for proving complex algorithm properties!

When to Use Direct Proof

Use direct proof when: There's a clear, straightforward path from hypothesis to conclusion.

Good Candidates for Direct Proof:

Examples:

Good for Direct Proof:
  • If n is even, then n+2 is even
  • If x > y and y > z, then x > z
  • If a function is constant, its derivative is zero
Harder for Direct Proof:
  • If n² is even, then n is even
  • √2 is irrational
  • There are infinitely many primes

These often need other methods!

Knowledge Check 1: Direct Proof

Which statement would be EASIEST to prove using direct proof?
A) If n² is odd, then n is odd
B) If n is odd, then n² is odd
C) There is no largest prime number
D) √2 is irrational
Key Insight: Direct proof works best when you can "build forward" from the hypothesis to the conclusion using definitions and algebra.

Method 2: Proof by Contraposition

Key Logical Equivalence: P → Q is logically equivalent to ¬Q → ¬P

Instead of proving "If P then Q", we prove "If not Q, then not P"

Original Statement

If n² is even,
then n is even

P: n² is even
Q: n is even

Contrapositive

If n is not even (odd),
then n² is not even (odd)

¬Q: n is odd
¬P: n² is odd

💻 Programming Analogy: Testing the Opposite

Like testing error conditions instead of success conditions:

// Instead of: "if valid input, then valid output"
// Test: "if invalid output, then invalid input"

if (!isValidOutput(result)) {
  // Prove input must have been invalid
  assert(!isValidInput(input));
}

Contraposition: Proof Template

TEMPLATE: Proof by Contraposition of P → Q

Proof by contraposition:
1. We prove the contrapositive: ¬Q → ¬P
2. Assume ¬Q is true. [Write what this means]
3. [Logical step 1] because [reasoning]
4. [Logical step 2] because [reasoning]
...
n. Therefore ¬P is true.
n+1. Since ¬Q → ¬P, we have established P → Q. ∎
Common Mistake: Don't confuse contrapositive (¬Q → ¬P) with converse (Q → P)!
  • Contrapositive: ¬Q → ¬P (logically equivalent to P → Q)
  • Converse: Q → P (NOT equivalent to P → Q)

Contraposition: Worked Example

Theorem: If n² is even, then n is even.
Proof by contraposition:
Step 1: We prove the contrapositive: "If n is odd, then n² is odd"
→ This is equivalent to the original statement
Step 2: Assume n is odd.
→ By definition, n = 2k + 1 for some integer k
Step 3: Consider n²:
n² = (2k + 1)²
→ Substitute n = 2k + 1
Step 4: Expand:
n² = 4k² + 4k + 1
n² = 2(2k² + 2k) + 1
→ Factor to show form 2m + 1
Step 5: Since 2k² + 2k is an integer (call it m), we have n² = 2m + 1
→ By definition, n² is odd
Conclusion: We proved "If n is odd, then n² is odd" (the contrapositive).
Therefore, "If n² is even, then n is even" is established. ∎

When to Use Contraposition

Use contraposition when: The negations ¬Q and ¬P are easier to work with than P and Q themselves.

Good Candidates for Contraposition:

Example 1

Statement: If n² > 100, then n > 10 or n < -10

Contrapositive: If -10 ≤ n ≤ 10, then n² ≤ 100

The contrapositive is easier - just square the bounds!

Example 2

Statement: If x is irrational, then √x is irrational

Contrapositive: If √x is rational, then x is rational

Working with "rational" definitions is easier!

Knowledge Check 2: Contraposition

What is the contrapositive of: "If a function is differentiable, then it is continuous"?
A) If a function is continuous, then it is differentiable
B) If a function is not continuous, then it is not differentiable
C) If a function is not differentiable, then it is not continuous
D) A function is differentiable and not continuous
Remember: Contrapositive = Negate both + Reverse direction
P → Q becomes ¬Q → ¬P

Method 3: Proof by Contradiction

Contradiction Strategy: Assume the statement is FALSE, then show this leads to an impossible situation.

To prove P → Q by contradiction:

  1. Assume P is true AND Q is false (assume P ∧ ¬Q)
  2. Use logical reasoning to derive something impossible
  3. Conclude that our assumption must be wrong
  4. Therefore P → Q must be true

💻 Programming Analogy: Debugging by Contradiction

Like debugging by assuming "the bug doesn't exist":

// Assume: "My code is correct" (no bug)
// But then we observe: program crashes (contradiction!)
// Conclusion: There must be a bug

assert(codeIsCorrect); // Assume true
result = runProgram();
if (result == CRASH) { // Contradiction!
  // Our assumption must be wrong
  conclusion = "Code has a bug";
}

Contradiction: Proof Template

TEMPLATE: Proof by Contradiction of P → Q

Proof by contradiction:
1. Assume P is true. [Write what this means]
2. Assume Q is false (i.e., ¬Q is true). [Write what this means]
3. [Logical step 1] because [reasoning]
4. [Logical step 2] because [reasoning]
...
n. But this means [something impossible / contradicts step X]
n+1. This is a contradiction!
n+2. Therefore our assumption was wrong, and Q must be true when P is true.
∴ P → Q is established. ∎
What counts as a contradiction?
  • Showing both R and ¬R are true (direct contradiction)
  • Showing something impossible like 0 = 1
  • Contradicting a known fact or one of your assumptions
  • Just showing something unexpected or surprising

Classic Example: √2 is Irrational

Theorem: √2 is irrational (cannot be written as a/b where a, b are integers).
Proof by contradiction:
Step 1: Assume √2 is rational.
→ Then √2 = a/b where a, b are integers with no common factors (reduced form)
Step 2: Square both sides:
2 = a²/b² so 2b² = a²
→ Therefore a² is even
Step 3: Since a² is even, a must be even.
→ So a = 2k for some integer k
Step 4: Substitute back:
2b² = (2k)² = 4k²
b² = 2k²
→ Therefore b² is even, so b is even
Step 5: Contradiction! Both a and b are even, so they have common factor 2.
→ But we assumed a/b was in reduced form (no common factors)
Conclusion: Our assumption must be wrong. √2 cannot be rational. ∎

Contradiction vs Contraposition

What's the Difference?

Aspect Contraposition Contradiction
What you assume Assume ¬Q only Assume P AND ¬Q
What you prove Show ¬P follows Show impossibility follows
Equivalent to ¬Q → ¬P (P ∧ ¬Q) → False
Feels like Proving a different statement Showing assumption is impossible

Same Theorem, Different Approaches

Theorem: If n² is even, then n is even

  • Contraposition: Assume n is odd → Show n² is odd
  • Contradiction: Assume n² is even AND n is odd → Derive contradiction

Both work! Contraposition is cleaner here. Contradiction is overkill.

When to Use Contradiction

Use contradiction when: There's no clear direct path, and negations don't help either.

Good Candidates for Contradiction:

Classic Contradiction Examples:

Existence/Non-existence:
  • There are infinitely many primes
  • There is no largest integer
  • No integer satisfies x² = 2
Uniqueness:
  • A system has at most one solution
  • The identity element is unique
  • The limit is unique
Overuse Alert: Don't use contradiction when contraposition is cleaner! Save it for when you really need it.

Knowledge Check 3: Contradiction

You want to prove: "There is no largest prime number." Which method is most appropriate?
A) Direct proof
B) Contraposition
C) Contradiction
D) Proof by cases

The Actual Proof (Simplified)

Assume there is a largest prime p.

Consider N = (2 × 3 × 5 × ... × p) + 1 (product of all primes up to p, plus 1)

N is not divisible by any prime ≤ p (leaves remainder 1)

So either N is prime (larger than p) or has a prime factor larger than p

Contradiction! There must be a prime larger than p.

Method 4: Proof by Cases

Cases Strategy: When the hypothesis P naturally splits into different scenarios, prove Q separately for each case.

If P ≡ P₁ ∨ P₂ ∨ ... ∨ Pₙ, to prove P → Q:

  1. Identify all cases that cover P completely
  2. Prove P₁ → Q
  3. Prove P₂ → Q
  4. ...
  5. Prove Pₙ → Q
  6. Conclude P → Q is true

💻 Programming Analogy: Switch Statement

function prove(input) {
  switch(input.type) {
    case TYPE_A:
      // Prove Q for case A
      return proveForCaseA(input);
    case TYPE_B:
      // Prove Q for case B
      return proveForCaseB(input);
    case TYPE_C:
      // Prove Q for case C
      return proveForCaseC(input);
  }
  // All cases covered → Q proven!
}

Proof by Cases: Template

TEMPLATE: Proof by Cases

Proof:
1. We consider all possible cases for P:
   Case 1: P₁
   Case 2: P₂
   ...
   Case n: Pₙ

2. Case 1 (P₁):
   [Proof that P₁ → Q]
   Therefore Q holds in Case 1.

3. Case 2 (P₂):
   [Proof that P₂ → Q]
   Therefore Q holds in Case 2.

...

n+1. Since Q holds in all cases, P → Q is established. ∎
Critical: Your cases must be:
  • Exhaustive: Cover all possibilities (P₁ ∨ P₂ ∨ ... ∨ Pₙ ≡ P)
  • Clear: Each case should be well-defined
  • Cases can overlap (doesn't matter as long as all covered)

Proof by Cases: Example

Theorem: For any integer n, the value n(n+1) is even.
Proof by cases:
Setup: Any integer n is either even or odd. We consider both cases.
Case 1: n is even
→ Then n = 2k for some integer k
n(n+1) = 2k(2k+1) = 2[k(2k+1)]
→ This is 2 times an integer, so n(n+1) is even
Case 2: n is odd
→ Then n = 2k+1 for some integer k, so n+1 = 2k+2 = 2(k+1) is even
n(n+1) = (2k+1) · 2(k+1) = 2[(2k+1)(k+1)]
→ This is 2 times an integer, so n(n+1) is even
Conclusion: In both cases, n(n+1) is even. Since every integer is either even or odd, the theorem is proved for all integers. ∎

When to Use Proof by Cases

Use proof by cases when: The hypothesis naturally splits into distinct scenarios that are easier to handle separately.

Common Situations:

Math Examples

  • Prove |xy| = |x||y|
    (4 cases: x,y signs)
  • Prove max(a,b) + min(a,b) = a+b
    (2 cases: a≥b or a

CS Examples

  • Algorithm correctness on empty, single-element, and multi-element lists
  • Network protocol behavior in connected vs disconnected state
💡 Tip: If you find yourself saying "Well, it depends on whether..." — you probably need proof by cases!

The Proof Strategy Decision Tree

I need to prove: P → Q
Does P naturally split into 2+ cases?
↓ YES
Use PROOF BY CASES
Prove Q separately for each case
↓ NO
Can you see a clear path from P to Q?
↓ YES
Use DIRECT PROOF
Start with P, deduce Q step-by-step
↓ NO
Are ¬Q and ¬P easier to work with?
↓ YES
Use CONTRAPOSITION
Prove ¬Q → ¬P instead
↓ NO
Use CONTRADICTION
Assume P ∧ ¬Q, derive impossibility

Quick Reference: Choosing Your Method

If you see... Try this first Why
"For any even/odd integer..." Cases Natural split into even/odd
"If A and B, then C"
(multiple conditions)
Direct Combine conditions forward
"If n² has property X, then n has property X" Contraposition Easier to work with n than n²
"X is irrational/impossible" Contradiction Hard to prove "not something"
"There are infinitely many..." Contradiction Assume finitely many → contradiction
"There is exactly one..." Contradiction
(for uniqueness)
Assume two different ones → contradiction
"If x > y, then..." Direct Can use inequality algebra
You're stuck! Try contrapositive Different perspective often helps

Practice: Choose the Method

Problem: Prove that for any integer n, the value n³ - n is divisible by 3.

Step 1: Analyze the statement

  • Hypothesis P: n is an integer
  • Conclusion Q: n³ - n is divisible by 3

Step 2: Which method to use?

Think: Does n naturally split into cases?

Yes! When dividing by 3, any integer n leaves remainder 0, 1, or 2.

  • Case 1: n = 3k (divisible by 3)
  • Case 2: n = 3k+1 (remainder 1)
  • Case 3: n = 3k+2 (remainder 2)

→ Use PROOF BY CASES!

Try working through each case on your own, then check the next slide for the full proof!

Practice Solution: Proof by Cases

Theorem: For any integer n, n³ - n is divisible by 3.
Setup: Any integer n has form 3k, 3k+1, or 3k+2 for some integer k.
Case 1: n = 3k
n³ - n = (3k)³ - 3k = 27k³ - 3k = 3(9k³ - k) divisible by 3
Case 2: n = 3k+1
n³ - n = (3k+1)³ - (3k+1)
= 27k³ + 27k² + 9k + 1 - 3k - 1
= 27k³ + 27k² + 6k
= 3(9k³ + 9k² + 2k) divisible by 3
Case 3: n = 3k+2
n³ - n = (3k+2)³ - (3k+2)
= 27k³ + 54k² + 36k + 8 - 3k - 2
= 27k³ + 54k² + 33k + 6
= 3(9k³ + 18k² + 11k + 2) divisible by 3
Conclusion: n³ - n is divisible by 3 in all cases. ∎

Practice: Another Example

Problem: Prove that if the product xy is even, then x is even or y is even (or both).

Step 1: Analyze

  • Hypothesis P: xy is even
  • Conclusion Q: x is even OR y is even

Step 2: Which method?

Which proof method would work best here?
A) Direct proof
B) Contraposition
C) Contradiction
D) Proof by cases

The contrapositive transforms this into a much easier statement! See next slide...

Practice Solution: Contraposition

Theorem: If xy is even, then x is even or y is even.
Strategy: Prove the contrapositive
Original: "If xy is even, then (x is even OR y is even)"
Contrapositive: "If (x is odd AND y is odd), then xy is odd"
Proof by contraposition:
Step 1: Assume x is odd AND y is odd.
→ Then x = 2k+1 and y = 2m+1 for some integers k, m
Step 2: Consider xy:
xy = (2k+1)(2m+1)
= 4km + 2k + 2m + 1
= 2(2km + k + m) + 1
→ This has the form 2n+1 where n = 2km+k+m
Step 3: Therefore xy is odd.
Conclusion: We proved "If (x odd AND y odd), then xy odd".
By contraposition, "If xy even, then (x even OR y even)" is established. ∎

Common Mistakes to Avoid

Mistake #1: Reasoning Backwards

❌ WRONG:
Prove: If n is even, then n² is even

"Proof": Assume n² is even. Then n² = 2k...
Therefore n is even. ∎

Problem: You started with the CONCLUSION and worked to the HYPOTHESIS. That's backwards!

CORRECT (Direct):
Assume n is even. Then n = 2k for some integer k.
Therefore n² = (2k)² = 4k² = 2(2k²).
Since 2k² is an integer, n² is even. ∎
Remember: In direct proof, start with P (hypothesis) and end with Q (conclusion).

Common Mistakes to Avoid

Mistake #2: Assuming What You're Proving

❌ WRONG (Circular Reasoning):
Prove: If n is even, then n+2 is even

"Proof": Since n is even and n+2 is even, they're both even. ∎

Problem: You ASSUMED "n+2 is even" (the thing you're trying to prove!)

CORRECT:
Assume n is even. Then n = 2k for some integer k.
Therefore n+2 = 2k+2 = 2(k+1).
Since k+1 is an integer, n+2 is even. ∎
Key Check: Before using a fact, ask yourself: "Have I PROVEN this, or am I ASSUMING it?"

Common Mistakes to Avoid

Mistake #3: Confusing Contrapositive and Converse

Statement Form Equivalent to P → Q?
Original P → Q Yes (it's itself!)
Contrapositive ¬Q → ¬P YES
Converse Q → P NO
Inverse ¬P → ¬Q NO
Example:
  • Original: If it rains, the ground is wet (P → Q)
  • Contrapositive (equivalent): If the ground is not wet, it's not raining (¬Q → ¬P)
  • Converse (NOT equivalent): If the ground is wet, it's raining (Q → P)
    The ground could be wet from a sprinkler!
Remember: Only the contrapositive is equivalent! Proving the converse proves a DIFFERENT statement.

Writing Clear Proofs

Proofs Are Communication

A proof is not just for you — it's for your reader! Make it easy to follow.

DO

  • State what you're proving
  • Clearly identify your method
  • Explain each logical step
  • Use words, not just symbols
  • State your conclusion explicitly
  • Use "Therefore", "Hence", "Thus"
  • Number or label your steps

DON'T

  • Skip steps because they're "obvious"
  • Write only equations with no explanation
  • Assume the reader knows what you're thinking
  • Leave out justifications
  • End abruptly without conclusion
  • Use vague words like "clearly" or "obviously"
  • Mix up proof methods
The Golden Rule: If you can't easily follow your own proof a week later, it's not clear enough!

All Four Proof Templates

DIRECT PROOF
1. Assume P is true. [State what this means]
2. [Logical steps with reasons]
3. Therefore Q is true. ∎
CONTRAPOSITION
1. We prove ¬Q → ¬P.
2. Assume ¬Q is true. [State what this means]
3. [Logical steps with reasons]
4. Therefore ¬P is true.
5. By contraposition, P → Q is established. ∎
CONTRADICTION
1. Assume P is true. [State what this means]
2. Assume Q is false (¬Q is true). [State what this means]
3. [Logical steps with reasons]
4. But this contradicts [something]!
5. Therefore our assumption was wrong, and P → Q holds. ∎
PROOF BY CASES
1. Identify cases: P₁, P₂, ..., Pₙ that cover all possibilities.
2. Case 1: Assume P₁. [Prove Q]
3. Case 2: Assume P₂. [Prove Q]
...
n+1. Since Q holds in all cases, P → Q is established. ∎

Special Case: Equivalence Proofs (P ↔ Q)

To prove P ↔ Q (P if and only if Q):
You must prove BOTH directions:
1. P → Q ("if P then Q")
2. Q → P ("if Q then P")
TEMPLATE: Equivalence Proof

Proof:
We must prove both directions.

(→) Forward direction: Assume P, prove Q.
[Proof of P → Q using any method]

(←) Backward direction: Assume Q, prove P.
[Proof of Q → P using any method]

Since both directions hold, P ↔ Q is established. ∎

💻 Programming Analogy

Like proving two functions are inverses:

// To prove f and g are inverses:
// 1. Show: f(g(x)) = x for all x
// 2. Show: g(f(x)) = x for all x
// Both directions needed!

Equivalence Proof Example

Theorem: For an integer n, n is odd if and only if n² is odd.
Proof:
(→) Forward direction: If n is odd, then n² is odd.
Assume n is odd, so n = 2k+1 for some integer k.
Then n² = (2k+1)² = 4k² + 4k + 1 = 2(2k²+2k) + 1.
Therefore n² is odd.
(←) Backward direction: If n² is odd, then n is odd.
We prove the contrapositive: If n is even, then n² is even.
Assume n is even, so n = 2k for some integer k.
Then n² = (2k)² = 4k² = 2(2k²).
Therefore n² is even. By contraposition, if n² is odd, then n is odd.
Conclusion: Both directions proven. Therefore n is odd ↔ n² is odd. ∎

Final Knowledge Check

You need to prove: "For all integers n, if n³ is even, then n is even."
Which method would you choose?
A) Direct proof
B) Contraposition
C) Contradiction
D) Proof by cases
True or False: Proving the converse of a statement also proves the original statement.
A) True
B) False

Key Takeaways

What You Should Remember

1. A proof is a logical argument
Start with assumptions, use logical reasoning, reach a conclusion.
2. Four main proof strategies
• Direct: P → Q straightforward
• Contraposition: ¬Q → ¬P when negations are easier
• Contradiction: P ∧ ¬Q → impossible when stuck
• Cases: Split P into scenarios
3. Choose strategically
Use the decision tree! The right method makes proofs much easier.
4. Write clearly
Proofs are communication. Explain your reasoning in words, not just symbols.
5. Common pitfalls
• Don't reason backwards
• Don't assume what you're proving
• Don't confuse contrapositive and converse
• Don't skip steps

How to Get Better at Proofs

Proofs Are a Skill — Practice Makes Perfect

📚 Practice Strategies

  • Read proofs: Study well-written proofs in your textbook (Rosen Ch 1.7-1.8)
  • Copy and understand: Write out example proofs by hand until you understand each step
  • Try variations: Change the statement slightly and prove the new version
  • Explain to others: If you can teach it, you understand it
  • Start simple: Master easy proofs before tackling complex ones

💻 Learning Proofs Is Like Learning to Code

  • First: Read and understand existing code (proofs)
  • Next: Modify existing code (adapt proof templates)
  • Then: Write from scratch with references
  • Finally: Write independently

You wouldn't expect to write complex programs after one lecture — same with proofs!

Be patient with yourself! Proof-writing is one of the hardest skills in mathematics, but it's incredibly valuable for computer science.

Proof "Debugging" Checklist

Before You Submit Your Proof

Verification Checklist

☐ Did I clearly state what I'm proving?
Start with "Theorem:" or "Claim:" or "We prove:"
☐ Did I identify my proof method?
"By direct proof...", "By contraposition...", "By contradiction...", "By cases..."
☐ Did I state my assumptions clearly?
"Assume P is true. This means...", "Let n be even, so n = 2k..."
☐ Did I justify each logical step?
Don't just write equations — explain WHY each step follows
☐ Did I reach the correct conclusion?
End with "Therefore Q is true" or "Hence P → Q is established"
☐ Did I mark the end?
Use ∎ or Q.E.D. to signal completion
☐ Can I follow my own reasoning?
Read it out loud. If it doesn't make sense to you, it won't to your reader!

Proofs in Computer Science

Why This Matters for Your Career

Algorithm Design

  • Correctness: Prove your algorithm produces correct output
  • Termination: Prove it always finishes
  • Complexity: Prove runtime bounds

Example: Prove binary search finds the target or returns "not found" in O(log n) time

Software Verification

  • Security: Prove no unauthorized access
  • Safety: Prove system can't enter bad state
  • Correctness: Prove code matches specification

Example: Prove a cryptographic protocol prevents eavesdropping

Database Systems

  • Prove query optimizations preserve results
  • Prove transactions maintain consistency
  • Prove concurrency control prevents conflicts

Networking & Distributed Systems

  • Prove routing protocols find shortest path
  • Prove consensus algorithms reach agreement
  • Prove distributed systems handle failures
The Big Picture: Proofs let you KNOW your system works, not just BELIEVE it works. This is critical for safety-critical systems, security, and mission-critical applications.

Looking Ahead

Next Steps in Your Discrete Math Journey

This Week (Week 4):
Practice basic proof techniques on simple theorems about integers, divisibility, even/odd numbers.

🔜 Coming Soon

  • Week 5-6: Mathematical Induction
    A powerful technique for proving statements about all natural numbers
  • Week 7+: Sets and Relations
    Proving properties of sets, functions, and mathematical structures
  • Later: Combinatorics and Graph Theory
    Counting arguments and proofs about discrete structures

💻 The Skills Build On Each Other

Think of proof techniques as:

  • Week 4: Learning basic syntax and control structures
  • Weeks 5-6: Learning loops and recursion (induction)
  • Later weeks: Applying these to build complex programs (complex proofs)

Week 4 Summary

What We Covered

Recap (Weeks 1-3)
Logic foundations you needed
What is a proof?
Logical argument from assumptions to conclusion
Direct proof
Assume P → show Q directly
Contraposition
Prove ¬Q → ¬P instead
Contradiction
Assume P ∧ ¬Q → derive impossibility
Proof by cases
Split P into scenarios, prove each
Decision tree
How to choose the right method
Common mistakes
What to avoid in your proofs

Your Action Items

  1. Review the logical foundations (Slides 2-8) if needed
  2. Complete the tutorial worksheet problems
  3. Practice writing proofs using all four methods
  4. Read Rosen sections 1.7-1.8 for more examples
  5. Start thinking about proofs in your coding projects!
Remember: Proofs are hard, but you CAN learn this!
Come to office hours if you're stuck. Practice makes perfect. 🚀
1 / 45