Pushdown Automata



Shared context
Target L={0ⁿ1ᵐ:n≤m≤2n}, with n,m nonnegative. Use labels d,u/v to consume d and replace entire stack u by v; stack top is at left.
Answer & solution
Answer: Push one X per 0; nondeterministically consume either one or two 1s per X using three states. (no official key was published)
1. Use states p (initial zero-reading phase), q (one-reading phase), r (one more 1 required for the current X). Start with empty stack. Edges: p→p: 0,s/Xs; p→q: ε,s/s; q→q: 1,Xs/s; q→r: 1,Xs/Xs; r→q: 1,Xs/s. There are no other edges. Accept only when all input is consumed and the stack is empty, in any state.
2. The zero phase pushes n copies of X. After the ε transition to q, no transition reads a zero, so every accepted word has form 0ⁿ1ᵐ.
3. For each X, q may consume one 1 and pop immediately, or consume one 1 without popping, enter r, and require a second 1 to pop and return to q. State r cannot have an empty stack because its entry edge requires and retains an X.
4. If k of the n markers use the two-symbol option, total ones are m=n+k with 0≤k≤n. Conversely any m in [n,2n] is realized by selecting k=m−n markers for that option.
5. The empty word is correctly accepted for n=m=0. A nonempty all-zero word leaves markers, a leading 1 has no applicable pop, and extra 1s cannot be read after the last marker disappears. This verifies the boundary cases without a bottom-marker convention.