Recall warm-up
- Is ε in L⁺ when ε ∉ L?
Stuck? Peek at 0.3.3 Operations on languages
- L₁L₂ = {xy}; L{ε} = L; L∅ = ∅; not commutative.
- L⁰ = {ε}; L* = ⋃Lⁿ (n≥0); L⁺ = LL*; L* = L⁺ ∪ {ε}; (L*)* = L*.
- ∅* = {ε} = {ε}*; ∅⁺ = ∅.
- L̅ = Σ* − L (include ε!). (L₁L₂)ᴿ = L₂ᴿL₁ᴿ.
- Counting: C(n,r); fixed positions 2^(free); inclusion–exclusion; complement counting.
- Over {a,b}, how many strings of length ≤ 3?
Stuck? Peek at 0.3.2 Σᵏ, Σ*, Σ⁺ and languages
- |Σᵏ| = |Σ|ᵏ; Σ⁰ = {ε}; Σ* = ⋃ Σᵏ (k ≥ 0); Σ⁺ = Σ* − {ε}.
- #strings of length ≤ n over k symbols = (kⁿ⁺¹ − 1)/(k − 1); binary: 2ⁿ⁺¹ − 1.
- Language = any subset of Σ*. ∅ (no strings) ≠ {ε} (one string). Exactly r of one symbol in length n (binary): C(n, r).
- Shortlex order lists every string at a finite position.
- What does the pigeonhole principle guarantee for an n-mode machine reading n symbols?
Stuck? Peek at 0.2.4 Pigeonhole principle
- n + 1 objects in n boxes ⇒ some box has ≥ 2.
- N objects in k boxes ⇒ some box has ≥ ⌈N/k⌉. To force m in a box: (m−1)k + 1 objects.
- Machine with n modes, input length ≥ n ⇒ some mode repeats ⇒ a loop in the input.
The Hook
“Is 91 a prime number?” sounds like a question about numbers, not strings. But a computer only ever sees strings — 91 arrives as the characters 1011011 in binary. So the question becomes: is the string 1011011 in the set of strings that encode primes? Every yes/no problem turns into a membership question about a language. This is the bridge that makes TOC work.
Predict First
The problem “is this binary number even?” is the same as membership in which language over {0,1}? Describe it by a simple property of the string.
Core Concept
Prediction check
A binary number is even exactly when its last bit is 0. So the language is {w ∈ {0,1}⁺ | w ends with 0}. A deep-sounding arithmetic question became a one-glance property of the string.
Encoding
To feed any object to a machine, write it as a string: a number in binary, a list as symbols separated by commas, a graph as a list of edges, even a whole program as its source text. We write ⟨X⟩ for “the string that encodes X”.
Problem = language
This is called the membership problem: given a string w, is w ∈ L? “The machine accepts L” means: it says yes on every w ∈ L and does not say yes on any w ∉ L.
Examples
- PALINDROME = { w ∈ {a,b}* | w = wᴿ }.
- BALANCED = strings of ( and ) where brackets match properly.
- EQUAL = { w ∈ {a,b}* | |w|ₐ = |w|_b }.
- DIV3 = binary strings whose value is divisible by 3.
From Lesson 0.1.1 you already know which of these feel “finite-memory”: DIV3 only needs the remainder (3 possibilities). BALANCED and EQUAL need an unbounded count. PALINDROME needs to remember the whole first half. Phases 1–3 make these intuitions precise.
| Language | fact to carry while reading | finite memory? |
|---|---|---|
| DIV3 | remainder 0, 1 or 2 | yes |
| BALANCED | opens − closes (unbounded) | no |
| EQUAL | #a − #b (unbounded) | no |
| PALINDROME | the whole first half | no |
The roadmap from here
Each phase introduces a machine with more memory and asks: which languages can it accept?
- Finite-memory machines (Phase 1–2).
- Machines with a pile of plates (Phase 3).
- Machines with an endless notebook (Phase 4).
- Languages no machine can handle (Phase 5).
Putting it together
- Any object can be encoded as a string ⟨X⟩.
- A yes/no problem is the language of its yes-instances; solving it = answering membership.
- Which machine can solve it depends on the memory needed — the rest of the course.
Visual
problem language (set of yes-strings)
┌──────────────────────┐ ┌──────────────────────────────────┐
│ is n even? │ ───► │ { w ∈ {0,1}⁺ : w ends in 0 } │
│ is it a palindrome? │ ───► │ { w : w = wᴿ } │
│ brackets balanced? │ ───► │ { (), (()), ()(), ... , ε } │
└──────────────────────┘ └──────────────────────────────────┘
solve problem ≡ build a machine M with "M says yes on w" ⇔ w ∈ LWorked Examples
Write the problem “does the input contain the letter c?” over Σ = {a,b,c} as a language.
Show the full solution
L = { w ∈ Σ* | |w|_c ≥ 1 } = Σ*cΣ* — strings of the form (anything) c (anything).
Is the string 1001 in DIV3? Is 110?
Show the full solution
1001₂ = 9 → divisible by 3 → yes. 110₂ = 6 → yes. 111₂ = 7 would be no.
L = { w ∈ {a,b}* : |w|ₐ = 2|w|_b }. Which of ε, aab, aba, ab, aaabb are in L?
Show the full solution
ε: 0 = 0 ✓. aab: 2 = 2·1 ✓. aba: 2 = 2·1 ✓. ab: 1 ≠ 2 ✗. aaabb: 3 ≠ 4 ✗. So ε, aab, aba. Note ε satisfies every “count equals count” condition — check it every time.
GATE Traps
- ε is in many “count” languages (0 = 0). Always test ε.
- “The machine accepts L” requires both directions: yes on all of L and no yes outside L.
- Encodings matter only up to “reasonable”: binary vs decimal does not change which problems are solvable.
Memory Hook
Every question is a guest list: the language is the list, and the machine is the bouncer checking names at the door.
Connect the Dots
Phase 0 is complete. You know the objects (strings, languages) and the tools (sets, functions, equivalence classes, proofs, pigeonhole, graphs). Phase 1 builds the first real machine: one with a fixed, finite set of modes — and gives those modes their proper name.
Self-Test
- MCQ
The problem “is the binary number divisible by 2?” corresponds to which language over {0,1}?
- strings starting with 0
- strings ending with 0
- strings with even length
- strings with an even number of 1s
- MSQ
L = { w ∈ {a,b}* : |w|ₐ = |w|_b }. Which strings are in L?
- ε
- abba
- aab
- baab
- NAT
How many strings of length 4 over {a,b} are in L = { w : |w|ₐ = |w|_b }?
Write your answer before opening the key.
- MCQ
“Machine M accepts language L” means:
- M says yes to some strings of L
- M says yes to exactly the strings of L
- M says no to all strings outside L only
- M runs forever on strings of L
Rule Card
- Problem P ↔ language L_P = {⟨x⟩ : answer yes}. ⟨X⟩ = string encoding of X.
- Solving P = machine M with: M says yes on w ⇔ w ∈ L_P (membership).
- Always test ε against count conditions.
Concept Ledger
- encoding ⟨X⟩
- problem as a language L_P
- membership problem (is w ∈ L?)
- machine accepts a language (exactly the strings of L)
Answer Vault
Reveal answers when you’re ready
Warm-up answers
- No.
- 15.
- Some mode repeats (n+1 moments, n modes).
Self-test answers
- B — Parity is decided by the last bit.
- A: Leading digit is irrelevant.
- C: Length is unrelated to value parity.
- D: 11₂ = 3 has two 1s but is odd.
- ABD — Equal counts; ε has 0 and 0.
- C: 2 a’s, 1 b.
- 6 — Choose 2 positions for a: C(4,2) = 6.
- B — Yes on all of L and on nothing else.
- A: Must be all of L.
- C: Only half the requirement.
- D: That gives no verdict.
Flashcards
- What does “M accepts L” mean?
Reveal answer
M says yes on every string in L and on no string outside L. - Binary numbers divisible by 2 as a language?
Reveal answer
Strings ending in 0. - Membership problem?
Reveal answer
Given w, decide whether w ∈ L.