2

I am familiar with describing Regular Expressions but when it comes to describing CFG I get confused. Do you describe it in words like you would regular expressions or do you do something like this ?

this is the CFG I am trying to describe

S -> SS 
S -> XXX 
X -> aX| Xa| b

I was thinking something like this

S-> SS
  ->XXXS
  ->aXXXs
  ->abXXS
  ->abXXS
  ->abXAXS
  ->abbaXS
  ->abbabS
  ->abbabS
  ->abbabXXX
  ->abbabbXX
  ->abbabbbX
  ->abbabbbb
  ->abbabbbb
Dana
  • 355
  • 2
  • 5
  • 13
  • 3
    That's not a description of the langauge: it's an example of a single string in the language. A description of a language would be something like "All strings containing twice as many $a$s as $b$s" or "All strings of even length containing three $b$s". – David Richerby Apr 08 '14 at 21:48
  • Yes, you describe it in words. What you are thinking of is how to derive a single string in a CFG. – Tushar Apr 08 '14 at 22:00
  • The CFG is a description! What do you mean by "description", then? Can you give an example for regular langages? (The language generated by this grammar is regular, I think.) – Raphael Apr 08 '14 at 22:53
  • @Raphael I was thinking something like David did... – Dana Apr 08 '14 at 23:05
  • @DavidRicherby how did you get three b's ? – Dana Apr 08 '14 at 23:06
  • @Dana Those were just examples; they weren't intended to be descriptions of the specific language you posted. – David Richerby Apr 08 '14 at 23:07
  • @Raphael There is a simple description of the language in this case. In fact, it's decided by a DFA with four states, and there is also a simple English description. – Yuval Filmus Apr 08 '14 at 23:23

1 Answers1

1

Hint: How many $b$s are there in each word generated by this grammar?

Guidance: What is the language generated by $X$? What is the language generated by $XXX$? What is the language generated by $S$?

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503