CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 0 · Foundations

Lesson 0.2.3 · Item 4 of 91

Proof techniques

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. Name the three properties of an equivalence relation.
    Stuck? Peek at 0.2.2 Functions, relations and equivalence classes
    • Relation ⊆ A × B. Function: every input exactly one output. Partial function: some inputs have none.
    • #functions A→B = |B|^|A|. #one-to-one (|A| ≤ |B|) = |B|·(|B|−1)···. #relations on n-set = 2^(n²).
    • Equivalence = reflexive + symmetric + transitive. Classes partition the set; number of classes = index.
    • Finer relation (refinement) ⇒ more classes; every fine class sits inside a coarse class.

    Read lesson 0.2.2

  2. |{∅, {∅}}| = ?
    Stuck? Peek at 0.2.1 Sets
    • x ∈ A (element) vs X ⊆ A (subset). ∅ ⊆ every set. A = B ⇔ A ⊆ B and B ⊆ A.
    • A ∪ B, A ∩ B, A − B = A ∩ B̅, A̅ = U − A. De Morgan: (A∪B)̅ = A̅∩B̅, (A∩B)̅ = A̅∪B̅.
    • |A ∪ B| = |A| + |B| − |A ∩ B|. |A × B| = |A|·|B|. |P(A)| = 2^|A|.
    • |∅| = 0, |{∅}| = 1, P(∅) = {∅}.

    Read lesson 0.2.1

  3. Which question needs unbounded memory: “contains x?” or “more x’s than y’s?”
    Stuck? Peek at 0.1.1 What “computation” means
    • Machine: reads a finite input symbol by symbol, changes mode, ends with yes (accept) / no (reject) — or may never end.
    • Decision problem: a question whose answer is yes or no for every input.
    • Machines differ by memory: finite modes → pile of plates → endless notebook → beyond all machines.
    • Finite memory works iff the fact you must carry stays bounded (even/odd, remainder, “seen x?”). Unbounded counts/comparisons break it.

    Read lesson 0.1.1

The Hook

A friend claims: “I built a tiny machine with a fixed number of modes that checks whether brackets are balanced, for any length of code.” You suspect it’s impossible — but suspicion isn’t enough. You need an argument so airtight that it covers every machine anyone could ever build. That is a proof, and TOC questions on GATE regularly ask you to recognise which proof pattern is being used.

Predict First

Statement: “If it rained, the road is wet.” Which of these says exactly the same thing? (a) If the road is wet, it rained. (b) If the road is not wet, it did not rain. (c) If it did not rain, the road is not wet.

Core Concept

Prediction check

Answer: (b). That is the contrapositive, always equivalent to the original. (a) is the converse and (c) is the inverse; both can be false (a tanker could have wet the road).

Original
rain ⇒ wet road
Contrapositive
not wet ⇒ no rain
Converse
wet ⇒ rain (a tanker?)
Inverse
no rain ⇒ not wet
Green says the same thing as the original; red does not.

Implication

P ⇒ Q (“if P then Q”): whenever P is true, Q is true. It is false only when P is true and Q is false.
PQP ⇒ Q
TTT
TFF
FTT
FFT

When P is false the implication is automatically true (“vacuously true”). P ⇔ Q (“if and only if”, iff) means both P ⇒ Q and Q ⇒ P.

PQP ⇒ Q
TTT
TFF
FTT
FFT
The promise is broken only when P happened and Q did not.

Converse, inverse, contrapositive

  • Converse: Q ⇒ P. Not equivalent.
  • Inverse: not P ⇒ not Q. Not equivalent (it is the converse’s contrapositive).
  • Contrapositive: not Q ⇒ not P. Always equivalent to P ⇒ Q.

Why it matters: a famous TOC theorem has the shape “if a language is handled by a finite-memory machine, then property X holds.” We use its contrapositive: “if property X fails, then no finite-memory machine handles it.” That is how we prove limits.

L handled by finite memory
P
theorem
property X holds
Q
but
we observe X fails
¬Q
contrapositive
no finite machine exists
¬P
The exact pattern used to prove limits of machines in Phase 2.

Direct proof

Assume P, chain true steps, arrive at Q. Example: “if n is even then n² is even”: n = 2k ⇒ n² = 4k² = 2(2k²), even. ∎

n even
assume P
n = 2k
definition
n² = 2(2k²)
algebra
n² even
Q ✓
Direct proof: a chain of true steps from P to Q.

Proof by contradiction

To prove S: assume S is false, deduce something impossible, conclude S must be true.

Classic: there are infinitely many primes. Suppose only finitely many: p₁,…,pₖ. Let N = p₁·p₂···pₖ + 1. Dividing N by any pᵢ leaves remainder 1, so no pᵢ divides N; but N > 1 has some prime factor — a prime not in our “complete” list. Contradiction. ∎

Almost every “no machine can do this” proof in TOC is a proof by contradiction: suppose a machine exists… then something impossible follows.

flowplay illustration
Proof by contradiction, one step at a time.

Counterexample

To show a claim “for all x, …” is false, one example where it fails is enough. To show it is true, examples are never enough — you need a proof.

Claim
“every prime is odd”
One counterexample
2 — the claim is dead
A thousand examples
3, 5, 7, … prove nothing
Universal claims: examples never prove; one counterexample kills.

Mathematical induction

To prove a statement S(n) for all n ≥ 0:

  1. Base case: prove S(0).
  2. Inductive step: assume S(k) (the inductive hypothesis), prove S(k+1).

Like dominoes: the first falls, and each one knocks the next. Example: 1 + 2 + … + n = n(n+1)/2. Base n=1: 1 = 1·2/2 ✓. Step: (1+…+k) + (k+1) = k(k+1)/2 + (k+1) = (k+1)(k+2)/2 ✓. ∎

Strong induction assumes S(0),…,S(k) all hold to prove S(k+1). Later we will induct on the length of the input to prove a machine is correct: “after reading any k symbols the machine is in the right mode”.

flowplay illustration
Induction = dominoes.

Putting it together

  • Only the contrapositive (¬Q ⇒ ¬P) is equivalent to P ⇒ Q; converse and inverse are traps.
  • Impossibility proofs assume the machine exists, then reach a contradiction.
  • Induction = base case + step; you will induct on input length to prove machines correct.

Visual

       P ⇒ Q  ≡  ¬Q ⇒ ¬P            (contrapositive — SAME meaning)
       Q ⇒ P  ≡  ¬P ⇒ ¬Q            (converse ≡ inverse — a DIFFERENT statement)

 Proof by contradiction            Induction (dominoes)
 ┌──────────────────────┐          S(0) ─► S(1) ─► S(2) ─► S(3) ─► ...
 │ assume NOT S         │           ▲       each arrow = "S(k) ⇒ S(k+1)"
 │      ⋮ valid steps   │         base
 │ reach impossibility  │
 │ ∴ S is true          │
 └──────────────────────┘

Worked Examples

Easy

Write the contrapositive of “If a machine has only 2 modes, it cannot check whether length is a multiple of 3.”

Show the full solution

“If a machine can check whether length is a multiple of 3, then it does not have only 2 modes” (i.e., it has some other number of modes — in fact at least 3).

Medium

Prove by induction: 2⁰ + 2¹ + … + 2ⁿ = 2ⁿ⁺¹ − 1.

Show the full solution

Base n=0: 1 = 2¹ − 1 ✓. Step: assume the sum up to 2ᵏ is 2ᵏ⁺¹ − 1. Add 2ᵏ⁺¹: 2ᵏ⁺¹ − 1 + 2ᵏ⁺¹ = 2·2ᵏ⁺¹ − 1 = 2ᵏ⁺² − 1 ✓. ∎ (Useful later: the number of inputs of length ≤ n over two symbols is exactly this sum.)

GATE-level

Theorem T: “If L has property R, then L has property X.” You know some L does not have property X. What can you conclude? What if you know L has X?

Show the full solution

If L lacks X: by the contrapositive (¬X ⇒ ¬R), L does not have R. If L has X: nothing — concluding R would be the converse, which T does not promise. This exact situation appears with a famous tool you will meet in Phase 2: passing its test does not prove anything; failing it does.

GATE Traps

  • Converse error: from P ⇒ Q and Q, you cannot conclude P.
  • An implication with a false “if” part is TRUE (vacuous truth).
  • Examples never prove a “for all” claim; one counterexample disproves it.
  • In induction you must use the hypothesis S(k) in the step; otherwise the step is not an induction step.

Memory Hook

Contrapositive = “flip and negate” (both sides swap places and both get a NOT). Converse = just flip — and flipping alone lies.

Connect the Dots

We now have the logic to prove limits. One counting fact powers the most famous limit proof in this subject: if you have more items than boxes, two items share a box. That’s the pigeonhole principle — next.

Self-Test

  1. MCQ

    Which is logically equivalent to “If x is in A, then x is in B”?

    1. If x is in B, then x is in A
    2. If x is not in B, then x is not in A
    3. If x is not in A, then x is not in B
    4. x is in A and x is in B
  2. MCQ

    P ⇒ Q is false exactly when:

    1. P false, Q false
    2. P false, Q true
    3. P true, Q false
    4. P true, Q true
  3. MSQ

    Which arguments are valid?

    1. P ⇒ Q, P; therefore Q
    2. P ⇒ Q, ¬Q; therefore ¬P
    3. P ⇒ Q, Q; therefore P
    4. P ⇒ Q, ¬P; therefore ¬Q
  4. NAT

    In an induction proof that S(n) holds for all n ≥ 3, what value of n does the base case check?

    Write your answer before opening the key.

  5. MCQ

    A proof begins “Suppose such a machine exists with k modes…” and ends “…which is impossible.” Which technique is it?

    1. Direct proof
    2. Induction
    3. Contradiction
    4. Counterexample

Rule Card

  • P ⇒ Q false only when P true, Q false. Contrapositive ¬Q ⇒ ¬P ≡ original. Converse/inverse are NOT.
  • Contradiction: assume ¬S, derive the impossible. Used for “no machine can…” proofs.
  • Induction: base S(n₀) + step S(k) ⇒ S(k+1). Strong induction assumes all S(≤k).
  • One counterexample kills a “for all”. Examples never prove it.

Concept Ledger

  • implication P ⇒ Q
  • if and only if ⇔
  • converse, inverse, contrapositive
  • vacuous truth
  • direct proof
  • proof by contradiction
  • counterexample
  • mathematical induction (base case, inductive step, hypothesis)
  • strong induction

Answer Vault

Reveal answers when you’re ready

Warm-up answers

  1. Reflexive, symmetric, transitive.
  2. 2.
  3. “More x’s than y’s?” — it needs the difference of counts.

Self-test answers

  1. B — Contrapositive: ¬Q ⇒ ¬P.
    • A: Converse — not equivalent.
    • C: Inverse — not equivalent.
    • D: A conjunction, a different claim.
  2. C — The only falsifying row: the promise P held but Q failed.
    • A: Vacuously true.
    • B: Vacuously true.
    • D: True.
  3. AB — A is modus ponens; B uses the contrapositive (modus tollens).
    • C: Converse error.
    • D: Inverse error.
  4. 3 — The base case is the smallest value the claim covers.
  5. C — Assume the opposite, derive an impossibility.
    • A: A direct proof assumes P and derives Q, no contradiction.
    • B: No base case or step.
    • D: A counterexample disproves a universal claim with one instance.

Flashcards

  1. Which statement is equivalent to P ⇒ Q?
    Reveal answerIts contrapositive ¬Q ⇒ ¬P.
  2. When is P ⇒ Q false?
    Reveal answerOnly when P is true and Q is false.
  3. Two parts of an induction proof?
    Reveal answerBase case, and inductive step (assume S(k), prove S(k+1)).
  4. From “P ⇒ Q” and “Q”, can you conclude P?
    Reveal answerNo — that is the converse error.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.