context free grammar that describes even numbers

487 Views Asked by At

I am learning about context-free grammars and as a toy example I wanted to design one that describes binary digits ending with 0.

My attempt : S -> 1S | 0S | e0 - where e is the empty string. Is this correct?

1

There are 1 best solutions below

0
On

Yes you're attempt seems fine. Try also to write it down formally, so that it is a direct application of the definition.

I would just omit the empty string, since $e0=0$. The way you write it just makes it harder to read and understand.