Czy gramatyka bezkontekstowa może zawierać „martwe stany” z automatu, np
will loop forever and never generate a word. Is this allowed or MUST production rules end with an terminal at some point?
Czy gramatyka bezkontekstowa może zawierać „martwe stany” z automatu, np
will loop forever and never generate a word. Is this allowed or MUST production rules end with an terminal at some point?
Context-free grammars are allowed to contain unproductive rules. This is accepted, because every CFG generates the same language as some proper CFG which contains no unproductive rules, no empty string productions, and no cycles; so it is safe to assume that a CFG is proper without loss of generality.
Yes of course. Every NFA can be written as a CFG. And building a DFA with a 'dead state' (the term I was taught, is 'sink') is trivial.
Example:
Analogous to the NFA with only one non-accepting starting state and only a self-transition withϵ .
źródło