1
$\begingroup$

NFA diagram

I am trying to work out how I would (1) describe the language of the automaton by means of a regular expression and (2) describe the language of the automaton by means of a context-free grammar.

I am not really sure how to start with either of these. Any help would be greatly appreciated.

1 Answers 1

0

Your automaton accepts any word, for if $w = 1^n$ with $n \ge 0$ then it cycles into the first state, but by the $\varepsilon$-move you reach the accepting state. Otherwise $w$ has $k > 0$ zeros. Then the automaton first processes all the leading $1$'s, jumping into the final state and processing all the $0$'s, whereas when it reads the last zero it jump (non-deterministically) into the start state again, where the cycle repeats. Anyway at any point it is also into an accepting state, either by non-determinism or by the $\varepsilon$-move (surely, which is also some kind of non-determinism).

After this observation it is quite easy to give a grammar: $S \to 0S \mid 1S \mid \varepsilon$ will work.