Unable to construct Context-free Grammar from Pushdown Automaton

920 Views Asked by At

I have a problem in constructing a Context-free Grammar for the Language $$L = \{a^mb^n : m≠n,m>0,n>0\} .$$ Though I can able to construct a Pushdown Automata.

pda

I can construct a CFG, but it accepts both $m \neq n$ and $m=n$. My CFG is:

$S \to aS/Sb/aSb/aab/abb $.

I cannot able to consturct the CFG to accept for $m \neq n$ alone.

1

There are 1 best solutions below

2
On BEST ANSWER

How about

S ::= aSb | A | B
A ::= a | Aa
B ::= b | Bb