Context-Free Languages
Date: 2021-02-14
title: 'Context-Free Languages' date: '2021-02-14'
Context-Free Languages
Context-Free Grammar (CFG)
is a finite set of variables is a finite set of terminals is a finite set of rules, with each rule being a variable and a string of variables and terminals is the start variable
Say
A language is context free if it can be generated by some context free grammar Ambiguity: A grammar can generate a same string in different ways
Theorem (context free languages): The set of languages recognized by pushdown automata
Pushdown Automata
A pushdown automata is a 6-tuple
is finite set of states is finite input alphabet is finite stack alphabet is the start state is the set of accept states
The process of computation by pushdown automata
starts with and : with start state and empty stack - For
, we have : moves properly according to state, stack and next input symbol
"
To test for an empty stack, placing a $$$ on the stack.
Equivalence with Context free grammars
Corollary: Every regular language is context free.
Pumping lemma for CFLs
Theorem: If a language
- For each
> 0: either or is not emptyset
Idea: Suppose a string

Show a language is context free
- By constructing a context free grammar:
Proof by induction:
Base Case (n=0 or 3): 2nd, 3rd, 4th, 5th rules generate aab, aba, baa,
- Case 1: There is a segment of string in
, called which is in . can be partitioned into concatenated with , where and are in . , by induction hypothesis the first generates and the second generates . - Case 2: There is no segment of
that is in . Suppose the last character is , then this must be counterbalanced by two 's. If the two 's occur before the first two characters, we can split into and and we are back in case 1. - Case 3: There is no segment of
that is in . Suppose the last character is , then this must be counterbalanced by and , and one of them must be the first character. If is first then must be next, . If is the first then an extra must be somewhere in the middle: , where are in . Use .
HW Problems
hw2p4