0000
Reverse of grammar and machine
We did a complement of the machine in the previous chapter Design a DFA for Language.
But complement of the machine and the reverser of the machine is not the same concept.
Complement of the machine:
1. Non-final states will be final states
2. Final states will be non-final states
.png)
Reverse of the machine:
Now how we take the reverse of a machine:
.png)
Reverse of the grammar:
.png)
Reverse of the grammar means reverse of language.
Let consider a grammar G which generate a language L = {ab, abb}
Now reverse of the grammar = reverse of language = {ba, bba}
How we do the reverse of the grammar:
1. First we design a machine M of the grammar G.
2. Take a reverse of the machine M.
3. Construct grammar from reverse machine .
Now, this is reverse of the grammar G.
Example:
.png)
.png)
We can remove trap state.
.png)
Equivalent grammar,
.png)
Reverse of machine M:
.png)
Trap state B convert it to dead state at .
Reverse of the grammar
.png)
.png)
.png)
.png)
Or,
.png)
.png)
And the language of this grammar is:
.png)