What is Context Free Grammar CFG for the language of all even length strings?
S ⇒ aSa | bSb | aSb | bSa |ε Now we can read any kind of even-length string. For example; To read aa from S ⇒ aSa | bSb | aSb | bSa |ε S ⇒ aSa S⇒aεa S⇒aa
Context Free Grammar CFG for language of all even length a’s defined over {a, b}.
S ⇒ aSa | bS |ε valid strings: aa, aba, abba, abaaa, ……and many more similar strings. invalid strings. invalid strings: a, ab, abb, aaba, ……and many more similar strings. invalid strings.Context Free Grammar CFG for language of all even length b’s defined over {a, b}.
S ⇒ bSb | aS |εCFG for language of all even length a’s defined over {a, b, c}.
S ⇒ aSa | bS |c S |ε valid strings: aa, aba, aca, abca, acba, ……and many more similar strings. invalid strings. invalid strings: a, ba, ca, abc, acbaa, ……and many more similar strings. invalid strings.CFG for language of all even length a’s defined over {a, b, c, d}.
S ⇒ aSa | bS |cS|dS |εContext Free Grammar for language of all even length 0’s defined over {0, 1}.
S ⇒ 0S0b | 1S |εContext Free Grammar for language of all even length 1’s defined over {0, 1}.
S ⇒ 1S1b | 0S |ε
More Examples of CFG
- Intro to Context Free Grammar with 12 Examples
- CFG of Language of all even and odd length palindromes
- Context Free Grammar CFG for language of all even length strings
- CFG for the language of all non Palindromes
- CFG for strings with unequal numbers of a and b
- CFG of odd Length strings {w | the length of w is odd}
- CFG of Language contains at least three 1’s or three a’s {w | w contains at least three 1’s}
- CFG for the language L = 0n1n where n>=1
- CFG for the language L = 0n12n where n>=1
- Write a CFG for the language L = 0n14n where n>=1
- CFG for {an b an+1 | n >=0}
- CFG for {an b an+2 | n >=0}
- CFG for {an b an+3 | n >=0}