How statement and proof provenance work
The first chip identifies the source of the statement or construction; the second identifies the source of its local proof or verification.
- Literature-sourced: the exact statement appears in a cited source; only wording and notation differ.
- AI-adapted: a semantically identical restatement of literature-sourced material, modulo indexing, notation, and boundary cases adopted by the library.
- AI-generated: a genuinely novel statement formulated by AI, with no source for the claim itself.
These labels describe origin, not correctness: citations and verification chips remain separate evidence.
Pushdown Automata and Context-Free Languages
1 · Prerequisites
- Construction of the Natural Numbers
- Context-Free Grammars and Normal Forms
- Countability and Uncountability
- Finite Counting, Factorials and Binomial Coefficients
- Formal Languages, Encodings, and Decision Problems
- Linear Recurrences and Rational Generating Functions
- Ramsey Theory
- Relations, Functions, and Quotients
- The ZFC Axioms and the Basic Set Constructions
2 · Summary
This page defines PDA runs and the two standard acceptance modes, proves the two machine-translation theorems connecting PDA's and context-free grammars, and then isolates the deterministic branch through unique computations, unambiguity, and complement closure after the endmarker and loop repairs.
3 · Logical flowchart
4 · Definitions, theorems and proofs
Nondeterministic pushdown automata
Definition
Let be an input alphabet. A nondeterministic pushdown automaton (PDA) over is a septuple such that:
- is a finite set of states.
- is a finite stack alphabet.
- is the start state.
- is the initial stack symbol.
- is the set of accepting states.
- assigns to each triple a finite set of pairs .
The intended meaning of is that, when the machine is in state with top stack symbol , it may read if or read nothing if , pop , replace it by the word , and move to state .
Remarks
-
The stack is the extra memory absent from finite automata.
-
Nondeterminism means that several pairs may be enabled from the same triple .
PDA configurations and one-step moves
Definition
Fix a PDA .
A configuration of is a triple where is the current state, is the unread input, and is the current stack content. We read the leftmost symbol of as the top of the stack.
There is a one-step move when , and there is a one-step move when .
Write for the reflexive-transitive closure of .
Acceptance by final state for a PDA
Definition
Let be a PDA.
A word is accepted by final state when there exist and such that
The set of words accepted in this sense is denoted .
Acceptance by empty stack for a PDA
Definition
Let be a PDA.
A word is accepted by empty stack when there exists a state such that
The set of words accepted in this sense is denoted .
Acceptance by final state and by empty stack are equivalent for PDAs
Statement
For every PDA, the language it accepts by final state is accepted by some PDA by empty stack, and the language it accepts by empty stack is accepted by some PDA by final state.
Facts & Assumptions
Given: A PDA over .
By Acceptance by final state for a PDA, final-state acceptance means that some computation consumes the whole input and ends in an accepting state.
By Acceptance by empty stack for a PDA, empty-stack acceptance means that some computation consumes the whole input and empties the stack.
Proof
For final-state to empty-stack, adjoin a fresh bottom marker below the original stack and a fresh drain state . Whenever the simulated machine reaches an accepting state after consuming all input, the new machine takes an -move to and in state repeatedly pops the entire remaining stack, including . By [L1] and [L2], the new machine accepts exactly the same words, now by empty stack.
For empty-stack to final-state, adjoin a fresh start state , a fresh bottom marker , and a fresh accepting state . The new machine first pushes the old initial symbol above , then simulates , and the only way to enter is by an -move that pops after the simulated stack has become empty and the input has been fully consumed. By [L1] and [L2], this converts empty-stack acceptance into equivalent final-state acceptance.
The two constructions from steps 1.1 and 1.2 prove both directions of the equivalence.
Every context-free grammar has an equivalent PDA
Statement
Let be a context-free grammar. Then there exists a PDA such that
Facts & Assumptions
Given: A context-free grammar .
By The language generated by a CFG, is the set of terminal words derivable from the start variable .
By Leftmost and rightmost derivations, a leftmost derivation rewrites the leftmost variable at each production step.
By Acceptance by empty stack for a PDA, a PDA accepts by empty stack exactly when some full computation consumes the input and empties the stack.
Proof
Define a one-state PDA whose initial stack symbol is . If the top stack symbol is a variable and is a production of , the machine has an -move replacing by ; if the top stack symbol is a terminal , the machine may read an input symbol and pop it.
Every leftmost derivation of a word in yields an accepting computation of : keep the current sentential form on the stack, use the step from 1.1 to expand its leftmost variable exactly as the derivation does, and then match terminals against the input once only terminals remain on top. Therefore [L1], [L2], and [L3] give .
Conversely, every accepting computation of determines a leftmost derivation in , because the only -moves replace the current top variable by the right-hand side of one production and the only input-consuming moves match the current top terminal against the next input symbol. Reading those stack-replacement moves in order reconstructs a leftmost derivation of the accepted word. Hence .
Steps 2.1 and 2.2 prove .
The PDA fragment variable
Definition
Let be a PDA that accepts by empty stack.
For states and a stack symbol , the fragment variable denotes the language of words such that for every stack suffix ,
Thus describes exactly the words that remove the top symbol , change state from to , and leave the rest of the stack untouched.
PDA fragment variables compose
Statement
Let be a PDA that accepts by empty stack.
- If is in the language of and is in the language of , then removes the stack prefix while changing state from to and leaving the remaining stack untouched.
- Conversely, consider a computation starting at , and let be its first configuration whose stack is exactly . Then there are words and a state such that , , and . The two split points are the first moments when and then are exposed.
Facts & Assumptions
Given: A PDA that accepts by empty stack.
By The PDA fragment variable , means that for every stack suffix one has .
Proof
Assume and , and let be any stack suffix. Then [L1] gives and also . Concatenating these two computations yields .
Conversely, let be the first configuration with stack in a computation starting at . Before that point there is a first configuration whose stack is ; write it as and write , where is the input prefix consumed before it is reached and is consumed between the two first-exposure configurations. The computation therefore contains . Neither segment inspects the suffix before its endpoint. Hence the same transition sequences work above every stack suffix , giving and . By [L1], and .
Therefore fragment computations compose exactly by concatenating the consumed words and, conversely, by splitting at the first moment when the lower stacked symbol is exposed.
Every PDA has an equivalent context-free grammar
Statement
For every PDA there exists a context-free grammar built from fragment variables such that where is the empty-stack PDA obtained from by the acceptance-mode conversion.
Facts & Assumptions
Given: A PDA .
By Acceptance by final state and by empty stack are equivalent for PDAs, there is an empty-stack PDA with the same accepted language as .
By The PDA fragment variable , the variable denotes the words that remove while taking the machine from state to state and leaving the lower stack unchanged.
By PDA fragment variables compose, fragment computations concatenate to remove a stacked pair, and conversely a computation removing a stacked pair splits at the first moment when the lower symbol is exposed.
By The language generated by a CFG, a grammar generates exactly the terminal words derivable from its start symbol.
Proof
By [L1], replace by an equivalent empty-stack PDA . Refining its transitions if necessary, we may assume that every move of pops one symbol, reads either one input symbol or , and pushes either nothing, one symbol, or two symbols; a longer push is replaced by a short chain of fresh intermediate states.
Build a grammar whose variables are the fragment symbols for states and stack symbols , and whose start symbol branches over all variables . For each normalized transition of with , add the matching productions: if , add ; if , add for every state ; if , add for every pair of states . When , omit that leading terminal.
Every derivation in yields an accepting computation of by induction on the derivation tree of a fragment variable . The production chosen at the root records the first normalized move from state with top symbol . If the production is terminal or , that move already removes . If it has one fragment variable, the induction hypothesis supplies the computation removing the pushed symbol. If it has two fragment variables, the induction hypotheses supply computations removing the two pushed symbols, and [L3] composes them into one computation removing the original pushed pair. Therefore every word derived from lies in that fragment language, and the start productions give .
Conversely, consider a fragment computation and induct on its number of steps. Let its first normalized move be determined by a transition with and . If , that one move already removes , so step 2.1 contributes the corresponding terminal or production. If , the remaining computation removes above , so the induction hypothesis derives the remaining input from , and step 2.1 prepends the production with the leading terminal omitted when . If , then [L3] splits the remaining computation at the first moment when is exposed on top of , yielding a state and a decomposition of the remaining input into words and with and . The induction hypothesis derives from and from , so step 2.1 gives a derivation of from . Applying this to start configurations shows .
Steps 3.1 and 3.2 give , and [L1] then yields .
PDAs recognize exactly the context-free languages
Statement
A language over a finite alphabet is context-free if and only if some PDA recognizes it.
Facts & Assumptions
Given: A language over a finite alphabet .
By Every context-free grammar has an equivalent PDA, every context-free grammar has an equivalent PDA.
By Every PDA has an equivalent context-free grammar, every PDA has an equivalent context-free grammar.
Proof
If is context-free, choose a grammar generating . Then [L1] gives a PDA recognizing the same language.
If some PDA recognizes , then [L2] gives a context-free grammar generating that same language.
Therefore is context-free if and only if some PDA recognizes it.
Deterministic pushdown automata and deterministic context-free languages
Definition
A deterministic pushdown automaton (DPDA) is a PDA with a distinguished endmarker such that:
- for each state , stack symbol , and , at most one pair lies in ;
- if some -move is enabled from , then no input-reading move is enabled from that same pair .
The machine recognizes a language by final state when it accepts exactly the marked inputs in the sense of Acceptance by final state for a PDA.
A language is deterministic context-free when some DPDA recognizes it.
Remarks
-
The endmarker is not part of the language alphabet. It is an auxiliary symbol used to force the machine to detect the end of the real input.
-
Determinism forbids branching on an input symbol or on , as well as the simultaneous availability of an -move and an input-reading move from the same state/top-of-stack pair.
A DPDA has at most one computation on each input
Statement
Let be a DPDA. For every marked input , any two finite computations of starting from the initial configuration on are comparable by extension. Consequently, there is at most one maximal computation on that marked input.
Facts & Assumptions
Given: A DPDA and an input word .
By Deterministic pushdown automata and deterministic context-free languages, once the current state and top stack symbol are fixed, there is at most one enabled move, and an enabled -move excludes all simultaneous input-reading moves.
By PDA configurations and one-step moves, a computation is a sequence of one-step moves between configurations.
Proof
From any configuration of , the pair consisting of the current state and top stack symbol determines at most one legal next step by [L1].
Therefore two computations on the same input and with the same initial configuration must agree on their first move whenever either has a first move. Repeating the same argument after each common prefix shows inductively that they agree step by step for as long as both are defined.
Thus any two finite computations from the initial configuration are comparable by extension. Their union, when the computation continues indefinitely, or their common terminal extension, when it halts, is the unique maximal computation on .
If a PDA has at most one accepting computation on each word, the standard PDA-to-CFG construction is unambiguous
Statement
Let be a PDA such that every word has at most one accepting computation in . Then the fragment-variable grammar from the standard PDA-to-CFG construction is unambiguous.
Facts & Assumptions
Given: A PDA with at most one accepting computation on each word.
By Ambiguous grammars, unambiguous grammars, and inherently ambiguous languages, a grammar is unambiguous when each generated word has exactly one leftmost derivation.
By Every PDA has an equivalent context-free grammar, the standard grammar is built from fragment variables and generates exactly the language of .
Proof
In the grammar , every production choice records one concrete local decision in an accepting computation of : either one normalized PDA move, or one split state used to divide a two-symbol fragment into two smaller fragments. Thus a leftmost derivation of a word in determines an accepting computation of on that word.
Conversely, the accepting computation of a word determines all of those local choices uniquely, because the first moment when each top stack symbol disappears fixes the fragment split and therefore fixes the next production in the fragment-variable grammar. So one accepting computation determines exactly one leftmost derivation in .
If some generated word had two different leftmost derivations in , steps 1.1 and 2.1 would yield two different accepting computations of on that word, contradicting the hypothesis. Therefore [L1] shows that is unambiguous.
Deterministic context-free languages are unambiguous
Statement
Every deterministic context-free language has an unambiguous context-free grammar.
Facts & Assumptions
Given: A deterministic context-free language .
By Deterministic pushdown automata and deterministic context-free languages, some DPDA recognizes .
By A DPDA has at most one computation on each input, computations of a DPDA on one marked input are linearly ordered by extension and have at most one maximal computation.
By If a PDA has at most one accepting computation on each word, the standard PDA-to-CFG construction is unambiguous, a PDA with at most one accepting computation on each word yields an unambiguous fragment-variable grammar for the same language.
Proof
Choose a DPDA recognizing by [L1].
Form an equivalent DPDA that records whether the endmarker has been consumed. Before it simulates in a pre-endmarker copy of the state set; a transition consuming enters the post-endmarker copy; and all subsequent -moves remain in that copy. Declare a post-endmarker copy accepting exactly when its underlying state lies in , and delete every outgoing move from those accepting copies. This preserves determinism by [L1]: it only duplicates states and removes moves.
The machine recognizes the same language as . Indeed, an accepting computation of has consumed the marked input and hence reaches a post-endmarker accepting copy in ; conversely, every accepting copy projects to an accepting configuration of . Halting at the first such copy does not change whether that configuration is reachable.
Every accepting computation of is maximal because its accepting states have no outgoing moves. By [L2], there is therefore at most one accepting computation on each marked input.
Applying [L3] to yields an unambiguous context-free grammar generating its language, which is by step 3.1. Therefore every deterministic context-free language is unambiguous.
Deterministic context-free languages are closed under complement
Statement
If is deterministic context-free, then is also deterministic context-free.
Facts & Assumptions
Given: A deterministic context-free language .
By Deterministic pushdown automata and deterministic context-free languages, some DPDA recognizes on marked inputs .
The standard DPDA complementation construction first modifies a DPDA so that it reads the endmarker before accepting and has no dead-end or spurious-loop behavior, and then swaps the terminal accept/reject outcomes; the resulting DPDA recognizes exactly the marked complement. This is the construction proved in Kozen's Supplementary Lecture F and in Lewis-Papadimitriou Theorem 3.7.1.
Proof
Choose a DPDA recognizing by [L1].
Apply the complementation construction from [F1] to . It produces a DPDA over the same alphabet that accepts exactly the marked words not accepted by .
Because recognizes exactly the marked complement of the language of , it recognizes . Therefore is deterministic context-free.
FALSE: swapping the accepting states of a DPDA automatically complements its language
Statement
False claim: once a language is recognized by a DPDA, one complements the language simply by declaring the old nonaccepting states to be accepting and the old accepting states to be nonaccepting.
Facts & Assumptions
Given: A DPDA with one state , bottom marker , no accepting states, and one transition , so the machine loops forever without reading input.
The statement refuted is: swapping the accepting states of a DPDA automatically complements its language.
By Deterministic pushdown automata and deterministic context-free languages, a DPDA may have an enabled -move as its unique move from a configuration.
By Deterministic context-free languages are closed under complement, complementation of DPDA languages requires an explicit construction, not merely a relabeling of states.
Refutation
The displayed machine recognizes the empty language, because on every marked input it follows the unique -loop forever and never reaches an accepting final state.
If we merely declare the state to be accepting, the machine still follows exactly the same infinite -loop on every marked input, so it still recognizes the empty language. In particular, it does not recognize the complement .
This contradicts [A1]. The complement theorem [L2] needs the endmarker and loop repairs; naive state swapping does not suffice.
FALSE: acceptance by final state and by empty stack are literally identical
Statement
False claim: for a fixed PDA, acceptance by final state and acceptance by empty stack are the same condition with no machine conversion.
Facts & Assumptions
Given: A PDA whose start state is accepting, whose initial stack symbol is , and which has no transitions at all.
The statement refuted is: for one fixed PDA, final-state acceptance and empty-stack acceptance are literally identical.
By Acceptance by final state for a PDA, the empty word is accepted by final state whenever the start state is already accepting.
By Acceptance by empty stack for a PDA, empty-stack acceptance requires a computation that consumes the input and empties the stack.
By Acceptance by final state and by empty stack are equivalent for PDAs, every language accepted in either mode is accepted by some PDA in the other mode; this language-class equivalence does not assert that the two modes agree for one fixed PDA.
Refutation
In the displayed PDA, the empty word is accepted by final state in zero moves because the start state is accepting.
The same machine does not accept the empty word by empty stack, because the stack begins with and there is no transition that removes it. So the required empty-stack configuration never occurs.
Thus the two acceptance notions differ on this fixed machine, contradicting [A1]. The correct general statement is the language-class equivalence from [L3].
5 · Examples, counterexamples and false statements
None yet.
Sources
- Jean Gallier and Jocelyn Quaintance, Introduction to the Theory of Computation: Some Notes for CIS511
- Dexter C. Kozen, Automata and Computability
- Alfred V. Aho, COMS W3261 Lecture 8: Pushdown Automata
- Jean Gallier and Jocelyn Quaintance, Introduction to the Theory of Computation
- Harry R. Lewis and Christos H. Papadimitriou, Elements of the Theory of Computation, Theorem 3.7.1