TC

  • Ambiguity
  • Closure properties of context-free grammars
  • Chomsky Normal Form & depuration of grammars
  • exercises on Regular languages (Homework 1)

March 10, 2026

Quiz 1

Which of the following sentences is false?

  1. (a + b)^∗a^∗ and ((a + b)a)^∗ generate the same language
  2. ((a + b)a)^∗ and (aa + ba)^∗ generate the same language
  3. ((a + b)a)^∗ generates the language reverse of the one generated by (a(a + b))^*
  4. (a + b)^∗a^∗ and (a^∗b)^∗a^∗ generate the same language

Quiz 2

Given the following equation between languages X = (a + \lambda)X + b\ , which of the following sentences is false?

  1. X=a^*b is a solution
  2. X=a^*b^* is a solution
  3. X=a^*b^+ is a solution
  4. X=a^+b^+ is a solution

Quiz 3

Given L=\{w\in \{0,1\}^* \mid \mathrm{value}_2(w)\in 3\mathbb N\}. Consider the sets

\{0,1\}\qquad \{0,1,10\}\qquad\{0,1,10,11\}

How many of them are L-distinguishible?

  1. 0
  2. 1
  3. 2
  4. 3

A set S is L-distinguishible if for every pair of distinct words w_1,w_2\in S, there is a word z s.t. exactly one between w_1z and w_2z is in L.

Quiz 4

You want to show that L=\{a^nb^m \mid n\neq m\} is not a regular language applying the pumping lemma directly to L.

Given the pumping length p, you choose a word w as in the argument to apply the pumping lemma. Which of the following possibilities has a chance to make the rest of the argument correct?

  1. w=a^{p!}b^{p+p!}
  2. w=a^{p+1}b^{p}
  3. w=a^pb^{p+p!}
  4. w=a^{p}b^{p+1}

Ambiguity

Can a language be ambiguous?

No. Only grammars can be ambiguous or not.
Languages could be inherently ambiguous if they are context-free but every grammar generating them is ambiguous.
Classic example: \{a^ib^jc^k \mid i=j \lor j=k\}

When is a context-free grammar ambiguous?

There is no algorithm that always terminates and tells us whether a given grammar is ambiguous or not.

Closure properties of CFL

CFL are closed under

  • union
  • concatenation
  • Kleene star
  • reversal
  • homomorphism
  • inverse homomorphism
  • intersection with a regular language

CFL are not closed under

  • complement
  • intersection

Chomsky Normal Form

A CFG G is in Chomsky Normal Form if all rules are of the form

  • A\to BC, where A,B,C are non-terminals, or
  • A\to a, where a is a terminal symbol,
  • or S\to \lambda, if \lambda is in the language we want to generate, and S is the start symbol.

Theorem 1 Every CFG G can be put in Chomsky Normal Form. (how?)

Depuration of CFGs: CFGs can be further simplified ensuring every non-terminal can eventually produce a word only made of terminals, and all non-terminals can be reached from the start symbol (how?).

exercises from Homework 1

Upcoming classes

Tomorrow
  • Context-Free Languages
  • exercises on RACSO
Next Tuesday
  • \{a^nb^nc^n\mid n\in \mathbb N\} is not context-free
  • exercises on Context-Free languages (Homework 1)