COMP 3803 - Assignment 3
COMP 3803 - Assignment 3
• Your assignment must be submitted as one single PDF file through cuLearn.
• Late assignments will not be accepted. I will not reply to emails of the
type “my internet connection broke down at 23:57” or “my scanner stopped
working at 23:58”, or “my dog ate my laptop charger”.
• You are encouraged to collaborate on assignments, but at the level of discussion only.
When writing your solutions, you must do so in your own words.
• Past experience has shown conclusively that those who do not put adequate effort into
the assignments do not learn the material and have a probability near 1 of doing poorly
on the exams.
• When writing your solutions, you must follow the guidelines below.
Question 2: Give context-free grammars that generate the following languages. For each
case, justify your answer.
(2.1) {02n 1n |n ≥ 0}. The set Σ of terminals is equal to {0, 1}.
(2.2) {w|w starts and ends with different symbols}. The set Σ of terminals is equal to
{0, 1}.
(2.3) {w| w is a palindrome}. The set Σ of terminals is equal to {0, 1}.
A palindrome is a string w having the property that w = wR , i.e., reading w from left to
right gives the same result as reading w from right to left. For example, the four binary
strings , 1, 0110, and 10101 are palindromes.
(2.4) {am bn cn |m ≥ 0, n ≥ 0}. The set Σ of terminals is equal to {a, b, c}.
1
Question 3: Let L and L0 be context-free languages over the same alphabet Σ.
(3.1) Prove that the union L ∪ L0 of L and L0 is also context-free.
(3.2) Prove that the concatenation LL0 of L and L0 is also context-free.
(3.3) Prove that the star L∗ of L is also context-free.
L = {am bn cn |m ≥ 0, n ≥ 0}
L0 = {am bm cn |m ≥ 0, n ≥ 0}
is context-free.
(6.1) Argue that the intersection of two context-free languages is not necessarily context-free.
(You may use any result that was proven in class.)
(6.2) Argue that the complement of a context-free language is not necessarily context-free.