Recall warm-up
- 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.
- |{∅, {∅}}| = ?
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(∅) = {∅}.
- 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.
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).
Implication
| P | Q | P ⇒ Q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
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.
| P | Q | P ⇒ Q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
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.
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. ∎
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.
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.
Mathematical induction
To prove a statement S(n) for all n ≥ 0:
- Base case: prove S(0).
- 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”.
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
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).
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.)
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
- MCQ
Which is logically equivalent to “If x is in A, then x is in B”?
- If x is in B, then x is in A
- If x is not in B, then x is not in A
- If x is not in A, then x is not in B
- x is in A and x is in B
- MCQ
P ⇒ Q is false exactly when:
- P false, Q false
- P false, Q true
- P true, Q false
- P true, Q true
- MSQ
Which arguments are valid?
- P ⇒ Q, P; therefore Q
- P ⇒ Q, ¬Q; therefore ¬P
- P ⇒ Q, Q; therefore P
- P ⇒ Q, ¬P; therefore ¬Q
- 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.
- MCQ
A proof begins “Suppose such a machine exists with k modes…” and ends “…which is impossible.” Which technique is it?
- Direct proof
- Induction
- Contradiction
- 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
- Reflexive, symmetric, transitive.
- 2.
- “More x’s than y’s?” — it needs the difference of counts.
Self-test answers
- B — Contrapositive: ¬Q ⇒ ¬P.
- A: Converse — not equivalent.
- C: Inverse — not equivalent.
- D: A conjunction, a different claim.
- C — The only falsifying row: the promise P held but Q failed.
- A: Vacuously true.
- B: Vacuously true.
- D: True.
- AB — A is modus ponens; B uses the contrapositive (modus tollens).
- C: Converse error.
- D: Inverse error.
- 3 — The base case is the smallest value the claim covers.
- 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
- Which statement is equivalent to P ⇒ Q?
Reveal answer
Its contrapositive ¬Q ⇒ ¬P. - When is P ⇒ Q false?
Reveal answer
Only when P is true and Q is false. - Two parts of an induction proof?
Reveal answer
Base case, and inductive step (assume S(k), prove S(k+1)). - From “P ⇒ Q” and “Q”, can you conclude P?
Reveal answer
No — that is the converse error.