Automata theory, Create CFG for a language

213 Views Asked by At

Create a CFG for the following languages:

a) $\{a^m b^m ... a^k b^k \mid \text{for $m, ..., k$ is positive integers}\}$

b) $\{w ∈ \{a,b\}^* \mid \text{$w$ contains more $a$ than $b$}\}$

c) $\{w ∈ \{a,b\}^* \mid \text{$w$ is a palindrome}\}$

My answers:

a) $S \to aSb \mid \varepsilon$

b) $S \to aSb \mid A A \mid aA \mid \varepsilon$

c) $S \to aSa \mid bSb \mid \varepsilon$

According to the answer sheet these are wrong. So how am I supposed to think here? Can you give me some tips how to solve it?

1

There are 1 best solutions below

0
On

(a) It is difficult to understand your question. What is the meaning of the suspension points?

(b) How do you obtain $baa$ with your solution?

(c) How do you obtain $aba$ with your solution?