Intuition The ONE core idea
Both a grammar (a recipe that builds strings by nesting rules inside rules) and a pushdown automaton (a machine with a single stack of scratch symbols) carry exactly one kind of memory: a stack , where the last thing you put down is the first thing you take back off. Because grammar-nesting and stack-behaviour are the same shape, a language can be built by a grammar if and only if a one-stack machine can recognise it.
This page is the ground floor. The parent topic throws a lot of notation at you: V , Σ , R , S , δ , Γ , Z 0 , A pq , ⇒ ∗ , ε . We define each one from zero , anchor it to a picture, and say why the topic needs it — in an order where every item leans only on the ones before it.
Definition Symbol, alphabet, string
A symbol is a single indivisible mark, like a or b.
An alphabet is a finite bag of allowed symbols. We write it Σ (the Greek capital "sigma"). Read Σ as "the set of input letters this machine is allowed to read."
A string is a finite row of symbols written left to right, like aabb .
Definition The empty string
ε
ε (Greek "epsilon") is the string with zero symbols in it — a row of length 0 . It is not a blank symbol; it is the absence of any symbol. Think of it as an empty row of boxes.
Why the topic needs ε . In Direction 1 the PDA applies a grammar rule without reading any input — that "read nothing" is written ε . In Direction 2 the rule A pp → ε means "go nowhere, read nothing." If you don't have a name for "the string of length zero," you cannot write either.
ε is not a space and not "0".
Why it feels right: it prints as almost nothing.
The fix: ε has length 0 . A space would be a real symbol of length 1 . Concatenating ε onto any string w leaves w unchanged: εw = w ε = w .
Definition The Kleene star
Σ ∗
Σ ∗ means "every string you can build from the alphabet Σ , including ε ." The little star ∗ reads as "any number of these, zero or more."
Picture Σ ∗ as an ever-growing list: first ε , then all length-1 strings, then all length-2 strings, forever.
( V ∪ Σ ) ∗
The symbol ∪ ("union") means "throw both bags together into one bag." So V ∪ Σ is "variables and terminals mixed together" (defined in §4). Then ( V ∪ Σ ) ∗ is "any finite row of variables and terminals." This is exactly what a grammar rule's right-hand side looks like — a mix such as a S b .
Why the topic needs ∗ . A grammar rule A → α says α is some string of variables-and-terminals; that "some string, any length" is precisely what ∗ captures.
Everything in this topic rides on one data structure. Meet it before any automaton.
Intuition Why a stack = nesting = recursion
Watch what a stack does when you push A , then push B , then must pop them: you get B out before A . That is exactly how nested boxes open — the inner box first, the outer box last. Grammar rules nest the same way: an expansion happening inside another expansion must finish first. So a stack is the physical shape of recursion. This single sentence is the whole reason CFGs and PDAs are equal.
Why the topic needs it. In Direction 1 the stack literally stores "the part of the string I still owe you." In Direction 2, a balanced push-then-pop on the stack is the bracket structure that a grammar variable expands into.
Now we can read the parent's grammar tuple, piece by piece.
Definition The four parts of a CFG
V = the set of variables (also called non-terminals). These are placeholders — jobs still to be done. Written as capitals like S , A , B . Picture: labelled empty boxes waiting to be filled.
Σ = the set of terminals — the actual output letters (from §1), like a , b . Picture: finished, sealed tiles.
R = the set of rules (also "productions"). Each rule is A → α : "a box labelled A may be replaced by the row α ."
S = the start variable , the one box you begin with. Picture: the outermost box.
Definition Sentential form
A sentential form is any half-finished row of variables and terminals you reach while replacing boxes — e.g. aa S bb . When every box is gone and only terminals remain, you have a finished string .
⇒ and many steps ⇒ ∗
α ⇒ β ("single arrow") means "apply exactly one rule to α and you get β ."
α ⇒ ∗ β ("arrow with a star") means "apply zero or more rules to get from α to β ." The star, again, is "any number of times, including none."
Picture a chain of pictures: S ⇒ a S b ⇒ aa S bb ⇒ aabb . Each arrow is one box being replaced.
Definition Leftmost derivation
A leftmost derivation always expands the left-most remaining box first. See Leftmost Derivations and Parse Trees . This matters because the PDA in Direction 1 reads input left to right, so it must expand in that same order to keep input and stack aligned.
Why the topic needs ⇒ ∗ . The variable A pq in Direction 2 is defined by A pq ⇒ ∗ w — "A pq can be rewritten, in some number of steps, into the pure string w ." No star arrow, no way to state that meaning.
Definition States, start state, accept states
Q = the finite set of states — the machine's "mood" or "mode." Picture: labelled circles.
q 0 ∈ Q = the start state , where the machine begins (the symbol ∈ means "is a member of"). Picture: the circle with an incoming arrow from nowhere.
F ⊆ Q = the set of accept (final) states (⊆ means "is a subset of," i.e. F is some of the circles). Picture: double-ringed circles.
Definition The transition function
δ
δ (Greek "delta") is the rule book of the machine: "in this situation, here are the moves I'm allowed." For a PDA a situation is a triple (current state, input symbol or ε , symbol on top of stack) , and each allowed move gives (next state, string to push) .
The parent writes moves like δ ( q , ε , A ) ∋ ( q , α ) . Decode it: in state q , reading nothing (ε ), with A on top of the stack, one allowed outcome (∋ means "contains as a member") is: stay in q and push α .
Definition Nondeterminism
The ∋ (rather than = ) is the whole point: δ hands back a set of possible moves, so the machine may have several legal choices at once. This is nondeterminism — the machine "guesses," and it accepts if any guess-path succeeds. See Deterministic PDAs and DCFLs for why removing this guessing weakens the machine.
Γ and Z 0
Γ (Greek capital "gamma") = the stack alphabet — the kinds of plates you're allowed to push. It can differ from the input alphabet Σ .
Z 0 ∈ Γ = the initial stack symbol , the single plate already on the stack before any input arrives (a "floor marker"). Picture: the bottom plate that tells you "the stack is empty above me."
Why two alphabets? The machine reads input letters (Σ ) but may want to remember them using different scratch symbols (Γ ). Keeping them separate lets the stack store bookkeeping (like grammar variables) that never appears in the input.
Definition Pushdown automaton, whole
A PDA (see Pushdown Automata ) is a finite-state machine (§6) bolted onto a stack (§3). Each step it may read one input symbol (or ε ), it pops the top stack symbol, and it pushes a (possibly empty) string of stack symbols — all dictated by δ . It is a 7 -tuple gathering every part above.
Definition Two ways to accept
Accept by final state: when the input is fully read and the machine sits in a state from F .
Accept by empty stack: when the input is fully read and the stack is completely empty.
These two modes recognise the same class of languages, so the parent freely picks whichever is handier — final state for Direction 2's construction, empty stack for the single-state Direction 1 PDA.
You now have every piece to read Direction 2's key invention.
A pq
A pq is a grammar variable named after two states p and q . Its meaning is a promise:
A pq ⇒ ∗ w ⟺ M can go from state p to state q reading w with net-zero (balanced) stack change.
"Balanced" = the stack ends at the same height it started and never dips below that height in between. Picture a valley: you go down (push), wander, and come back up to the starting rim (pop), never crossing below the rim.
Why the topic needs it. This is the bridge that turns "a run of the machine" into "an expansion of a grammar box." Because a balanced dip is a nesting shape (§3), it is exactly what a CFG variable can generate — that is the entire trick of Direction 2.
symbols and empty string eps
PDA states delta Gamma Z0
variable A_pq balanced run
Equivalence of CFGs and PDAs
Read top to bottom: raw symbols build strings; strings and the star give both grammars and the stack picture; the stack + states make a PDA; grammars + arrows give derivations; and the balanced-run variable A pq fuses machine-runs with grammar-boxes, delivering the equivalence in the parent topic .
Cover the right side and answer each before moving on.
What is ε and what is its length? The empty string; length 0 (not a space, not the number zero).
What does Σ ∗ mean? Every string over alphabet Σ , of any length including ε .
State the LIFO rule of a stack in one line. The last symbol pushed is the first one popped; you can only touch the top.
Why does a stack model recursion/nesting? Inner (last-pushed) items must be finished/popped before outer ones — the exact order nested boxes open.
Name the four parts of a CFG G = ( V , Σ , R , S ) . Variables, terminals, rules, start variable.
What does the bar ∣ mean in a rule? "Or" — alternative right-hand sides for the same variable.
What does α ⇒ ∗ β mean? You can get from α to β by applying zero or more rules.
What is a leftmost derivation? One that always expands the left-most remaining variable first.
In δ ( q , ε , A ) ∋ ( q , α ) , decode every part. In state q , reading nothing, with A on top, one allowed move is: stay in q and push α .
Why is ∋ used instead of = for δ ? δ returns a set of moves — nondeterminism, several legal choices at once.
What are Γ and Z 0 ? The stack alphabet, and the single initial bottom-of-stack symbol.
Name the two acceptance modes and their relation. By final state and by empty stack; they recognise the same language class.
What does A pq ⇒ ∗ w mean? M runs from state p to state q on input w with balanced, net-zero stack usage.
Recall One-line summary
Grammar-nesting and stack-LIFO are the same shape; every symbol above (V , Σ , R , S , δ , Γ , Z 0 , A pq ) exists to write down that one match.