Skip to main content
added 89 characters in body; edited title
Source Link
Yuval Filmus
  • 279.1k
  • 27
  • 316
  • 512

What is the grammar for language $L=$L=\{a^nb^m : n \neq m-11\}$?

What is the grammar for language $L = \{ a^nb^m : n\neq m-1\}$?

I only know I have to write grammar for both $ n<m-1 $ and $ n>m-1 $, so this is what I wrote:

for n<m-1
S->Abb
A->aAb|lambda

for n>m-1
S->aaA
A->aAb|lambda
  • For $n<m-1$: \begin{align} &S\to Abb \\ &A\to aAb \mid \lambda \end{align}

  • For $n>m-1$: \begin{align} &S\to aaA \\ &A\to aAb \mid \lambda \end{align}

Yet I can not mix them and get a correct grammergrammar for it$L$.

What is the grammar for language $L={a^nb^m : n \neq m-1}$?

What is the grammar for language $L = \{ a^nb^m : n\neq m-1\}$?

I only know I have to write grammar for both $ n<m-1 $ and $ n>m-1 $, so this is what I wrote:

for n<m-1
S->Abb
A->aAb|lambda

for n>m-1
S->aaA
A->aAb|lambda

Yet I can not mix them and get a correct grammer for it.

What is the grammar for language $L=\{a^nb^m : n \neq m-1\}$?

What is the grammar for language $L = \{ a^nb^m : n\neq m-1\}$?

I only know I have to write grammar for both $ n<m-1 $ and $ n>m-1 $, so this is what I wrote:

  • For $n<m-1$: \begin{align} &S\to Abb \\ &A\to aAb \mid \lambda \end{align}

  • For $n>m-1$: \begin{align} &S\to aaA \\ &A\to aAb \mid \lambda \end{align}

Yet I can not mix them and get a correct grammar for $L$.

Tweeted twitter.com/StackCompSci/status/967021522656415744
update for mathjax in header question
Source Link
Hendrik Jan
  • 31.1k
  • 1
  • 54
  • 108

What is the grammar for language $L={a^nb^m : n!=m \neq m-1}$?

What is the grammar for language $L = \{ a^nb^m : n!=m-1\}$$L = \{ a^nb^m : n\neq m-1\}$?

I only know I have to write grammar for both $ n<m-1 $ and $ n>m-1 $, so this is what I wrote:

for n<m-1
S->Abb
A->aAb|landa>aAb|lambda

for n>m-1
S->aaA
A->aAb|landa>aAb|lambda

Yet I can not mix them and get a correct grammer for it.

What is the grammar for language $L={a^nb^m : n!=m-1}$?

What is the grammar for language $L = \{ a^nb^m : n!=m-1\}$?

I only know I have to write grammar for both $ n<m-1 $ and $ n>m-1 $, so this is what I wrote:

for n<m-1
S->Abb
A->aAb|landa

for n>m-1
S->aaA
A->aAb|landa

Yet I can not mix them and get a correct grammer for it.

What is the grammar for language $L={a^nb^m : n \neq m-1}$?

What is the grammar for language $L = \{ a^nb^m : n\neq m-1\}$?

I only know I have to write grammar for both $ n<m-1 $ and $ n>m-1 $, so this is what I wrote:

for n<m-1
S->Abb
A->aAb|lambda

for n>m-1
S->aaA
A->aAb|lambda

Yet I can not mix them and get a correct grammer for it.

What is the grammar for language L=$L={a^nb^m : n!=m-1}$?

Source Link
parvin
  • 629
  • 2
  • 8
  • 12
Loading