4.6.1Theory of Computation

Alphabet, string, language — formal definitions

2,028 words9 min readdifficulty · medium

1. Alphabet

WHY finite & non-empty? If Σ\Sigma were infinite, a finite machine could never "know" all its inputs. If Σ\Sigma were empty, you could write nothing — a useless theory.


2. String (word)

WHY define length recursively (Derivation from scratch)

We want concatenation length to add up: xy=x+y|xy| = |x| + |y|. Build w|w| so this is forced.

Base: ε=0|\varepsilon| = 0 — empty string has nothing to count. Step: a non-empty string is "some string xx, then one more symbol aa": w=xaw = xa. xa=x+1|xa| = |x| + 1 Unrolling w=a1a2anw = a_1 a_2 \dots a_n gives w=1+1++1n=n|w| = \underbrace{1+1+\dots+1}_{n} = n. ✔

This makes (Σ,concat)(\Sigma^*, \text{concat}) a monoid with identity ε\varepsilon.


3. Counting all strings: Σ\Sigma^* and Σ+\Sigma^+

Figure — Alphabet, string, language — formal definitions

4. Language


5. Operations on languages (sets of strings)


Worked examples


Recall Feynman: explain to a 12-year-old (hidden — try first!)

Think of an alphabet as a box of letter-stamps (say only 0 and 1). A string is one word you stamp out, like 0110 — and you're even allowed to stamp nothing, that blank word is called ε\varepsilon. A language is a club: it's a list of which words are allowed in. The empty club \varnothing lets nobody in. A different club {ε}\{\varepsilon\} lets in exactly one member — the blank word. Computers are basically bouncers checking "is this word in the club?"


Flashcards

What three properties define an alphabet Σ\Sigma?
A finite, non-empty set of symbols.
Define a string over Σ\Sigma.
A finite ordered sequence of symbols from Σ\Sigma (possibly empty).
What is ε\varepsilon and its length?
The empty string (zero symbols); ε=0|\varepsilon|=0.
Recursive definition of string length.
ε=0|\varepsilon|=0 and xa=x+1|xa|=|x|+1.
What is Σ\Sigma^*?
The set of all finite strings over Σ\Sigma, including ε\varepsilon.
What is Σ+\Sigma^+ and its relation to Σ\Sigma^*?
All non-empty strings; Σ=Σ+{ε}\Sigma^*=\Sigma^+\cup\{\varepsilon\}.
How many strings of length kk over Σ\Sigma?
Σk|\Sigma|^{k} (each of kk positions has Σ|\Sigma| choices).
Definition of a language LL over Σ\Sigma.
Any subset LΣL\subseteq\Sigma^*.
Difference between \varnothing and {ε}\{\varepsilon\}?
\varnothing has 0 strings (=0|\varnothing|=0); {ε}\{\varepsilon\} has 1 string ({ε}=1|\{\varepsilon\}|=1).
Is Σ\Sigma^* countable or uncountable?
Countably infinite (only finite-length strings; list by shortlex order).
Define L1L2L_1L_2 (concatenation of languages).
{xy:xL1, yL2}\{xy : x\in L_1,\ y\in L_2\}.
What is \varnothing^*?
{ε}\{\varepsilon\}, because L0={ε}L^0=\{\varepsilon\} is always included.
Length of wnw^n?
nwn\,|w|.
Is concatenation commutative? Associative?
Not commutative (011001\ne10); associative ((xy)z=x(yz)(xy)z=x(yz)).
What is (xy)R(xy)^R equal to?
yRxRy^R x^R.

Connections

  • Regular Languages — the first restricted class of languages LΣL\subseteq\Sigma^*.
  • Finite Automata (DFA NFA) — machines that decide membership in a language.
  • Regular Expressions — algebra built on \cup, concatenation, * over Σ\Sigma.
  • Context-Free Grammars — generate languages beyond regular.
  • Countability and Diophantine Diagonalization — why 2Σ2^{\Sigma^*} is uncountable ⇒ undecidable languages exist.
  • Pumping Lemma — uses string length & concatenation structure proved here.

Concept Map

finite non-empty set of

ordered sequence forms

special case

measured by

length is

glue two strings

forms structure

repeat n times

reverse order

set of strings

all strings over

subset of

Alphabet Sigma

Symbols

String w

Empty string epsilon

Length w

Concatenation xy

Monoid identity epsilon

Powers w^n

Reversal w^R

Language

Sigma star

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Theory of Computation ki saari building teen floor par khadi hai: Alphabet, String, Language. Alphabet matlab Σ\Sigma — ek finite aur non-empty set of symbols, jaise {0,1}\{0,1\}. Ye tumhare Lego bricks hain. String matlab in bricks ko ek line mein jodke banaya gaya ek word, jaise 0110. Aur ek special string hoti hai ε\varepsilon (empty string) jismein koi symbol nahi hota, length 00. Language matlab in strings ka koi bhi set — yaani LΣL\subseteq\Sigma^*. Bas itna hi, koi rocket science nahi.

Sabse zyada confusion teen cheezon mein hoti hai: ε\varepsilon, {ε}\{\varepsilon\} aur \varnothing. Yaad rakho box wala funda — \varnothing ek khaali dabba hai (0 strings), {ε}\{\varepsilon\} ek dabba hai jismein ek blank kaagaz pada hai (1 string), aur ε\varepsilon khud wo blank kaagaz hai (ek string). Inko same samajhna sabse common galti hai exam mein.

Counting ka logic simple: length kk ki strings kitni? Har position par Σ|\Sigma| choices, kk positions, toh multiply karke Σk|\Sigma|^k. Isliye binary mein length-3 ki 23=82^3=8 strings hoti hain. Aur Σ\Sigma^* infinite zaroor hai par countable hai, kyunki saari strings finite-length hain — length ke order mein list kar sakte ho.

Ye foundation kyun matter karta hai? Aage jo bhi padhoge — DFA, NFA, regex, grammar, Turing machine — har machine basically ek hi sawaal puchhti hai: "Kya ye string is language ke club mein allowed hai ya nahi?" Toh agar alphabet-string-language clear hai, toh poora ToC chapter butter ki tarah smooth chalega.

Go deeper — visual, from zero

Test yourself — Theory of Computation

Connections