-1

The language is: {0n1m|n=2m}

I need to give a CFG based on this language, and I can't figure it out. It's been an hour and I am extremely frustrated, anyone got any hints/lead-way?

rici
  • 234,347
  • 28
  • 237
  • 341
bob afro
  • 213
  • 1
  • 2
  • 10
  • If I were you I'd start out by writing the pattern/outcome when m = 1, 2, 3... until you see what's happening, then start from there, if I'm not mistaken you can do this with 2 productions? – Jackie Jones Feb 29 '16 at 04:49
  • Please just give me the answer it's due in 10 minutes! – bob afro Feb 29 '16 at 04:51
  • I can't just give you the answer, but look at it this way, you have 001, 000011, 000000111..., so you can start with base pattern and keep inserting the same pattern in the middle. – Jackie Jones Feb 29 '16 at 04:51
  • What do you mean? ELI5 – bob afro Feb 29 '16 at 04:53
  • What would be the base pattern? the base of the problem is you have two 0s for every 1. You know that the 0s are always on the left and the 1s on the right, so you can insert between the two. – Jackie Jones Feb 29 '16 at 04:54
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/104824/discussion-between-bob-afro-and-jackie-jones). – bob afro Feb 29 '16 at 04:54
  • Please let us know what have you tried yet – Nehal Feb 29 '16 at 04:58

1 Answers1

1

Good question. Here is a start. Step 1: write down the start variable. Step 2: Find var that is written down and a rule that has that var as the left hand side. Replace the var with the right hand side of the rule. Step 3: repeat 2 until no more var remain.