HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Can there be 'dead states' in a context-free grammar?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
canfreedeadstatesgrammarcontextthere

Problem

Can a context-free grammar include "dead states" from an automaton, such as

$$G = \big(\{a, b, c\}, \{A, B, C\}, \{A\to aB, B\to b, B\to C, C\to cC\}, A\big)\,?$$

The production rules $B\to C$ and $C\to cC$ will loop forever and never generate a word. Is this allowed or MUST production rules end with an terminal at some point?

Solution

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.

Context

StackExchange Computer Science Q#69215, answer score: 24

Revisions (0)

No revisions yet.