1

I am new to CFG's, Can someone give me tips in creating CFG that generates some language

For example

$L =\{ w v w^R \mid v,w\in \{a,b\}^*\wedge|v| \text{ is even } \}$, where $w^R$ is the reverse of string $w$.

I'm having trouble understanding the language .. I want to build DFA to convert it

babou
  • 19,645
  • 43
  • 77

2 Answers2

3

Mmmm.

Let me note that in fact $L =\{ w v w^R \mid v,w\in \{a,b\}^*\wedge|v| \text{ is even } \}$ equals $\{ v \mid v \in \{a,b\}^*\wedge|v| \text{ is even } \}$.

Al strings in $L$ are of even length, and conversely all strings of even length can be otained by taking $w=\varepsilon$.

That should help.

Hendrik Jan
  • 31,459
  • 1
  • 54
  • 109
2

Hints:

  1. Construct a non-terminal $V$ and appropriate productions so that $V$ generates all strings of even length.

  2. Create productions so that your starting symbol $S$ generates $wVw^R$ for all $w$. To accomplish that, modify a grammar for $ww^R$.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514