Properties of Context-Free Languages 
Emptiness Problem 
We learned to eliminate useless symbols and productions from a CFG. We can use this to solve the emptiness problem for CFGs. Apparently, if the start symbol is useless, then the language generated by the CFG is empty. Otherwise, the language is nonempty.
Membership Problem 
We want to determine whether a given string 
CYK Algorithm We denote 
- Basis: 
 - Induction: 
 
Finally, we check whether the start symbol is in 
The CYK algorithm can be implemented in a three level nested loop. We show a pseudocode below:
for i = 1 to n
    X[i][i] = {A | A -> a[i] in P}
    
for l = 2 to n
    for i = 1 to n-l+1
        j = i + l - 1
        for k = i to j-1
            for each production A -> BC in P
                if B in X[i][k] and C in X[k+1][j]
                    add A to X[i][j]
if S in X[1][n]
    return "yes"
else
    return "no"2
3
4
5
6
7
8
9
10
11
12
13
14
Infiniteness Problem 
The idea is essentially the same as the regular language. We can use the pumping lemma for CFLs to prove that a language is infinite. The proof is similar to the regular language case.
The conclusion is that if a string in the language of the length between 
Closure Properties 
CFLs are closed under union, concatenation, and Kleene star. Also, they are closed under homomorphism, inverse homomorphism, and intersection with regular languages. But not under intersection, difference, and complementation.
However, A CFL is closed under intersection with a regular language. The proof is simple. We can imagine a DFA and PDA running in parallel. But from the outside, the multiple machines can be regarded as only a single PDA.

Two in Parallel
