Let and let .
Which of the following constraints ensure(s) that the language is context-free?
View worked solution
Answer: A;C;D
To determine which constraints ensure that is a context-free language (CFL), we analyze the dependencies between the symbol counts:
- Option A (): This relation can be rewritten as . We can construct a Pushdown Automaton (PDA) using a single stack to keep track of the difference. Alternatively, we can partition this into two context-free cases: (which yields strings of the form ) and (yielding ). Both cases are context-free, so their union is also a CFL.
- Option B ( and ): This requires matching 's with 's, and 's with 's. These are cross-serial dependencies ( and ). A PDA cannot handle overlapping matches, making this language non-context-free.
- Option C ( and ): This requires matching the outermost symbols ( with ) and the innermost symbols ( with ). These are nested dependencies, which perfectly match the LIFO structure of a stack. The language is generated by the CFG: Thus, it is a CFL.
- Option D (): Here, the total number of prefix symbols ( and ) must equal the total number of suffix symbols ( and ). A PDA can simply push all 's and 's onto the stack, and then pop one symbol for each incoming and . Since a PDA can accept this language, it is a CFL.
Free practice · Your answers on this page are not saved.
