0

Parsing family of grammars, determine if LR(k)

I have the exact same problem, but my reputation is not enough to comment on that thread, plus the OP hasn't been online in 2 years so I can't ask him personally. So I apologize, but I do have to ask for your help!

Would it be enough to show that the formula works for n = 2, n = 3 (by drawing the automata) and deduct that it must work for any n?

As for the second question, could I follow the same strategy?

Thank you for you time.

Xpl0
  • 167
  • 2
  • 9

1 Answers1

1

No, of course not. If you want to prove that some formula is true for all $n$, it is in general not enough to show that it is true for $n=2$ and $n=3$. That's just wishful thinking.

Consider, for instance, the claim that $n^2+n+41$ is prime for all $n$. You can check it for $n=2$ (sure enough, $2^2+2+41=47$ is prime) and $n=3$ (yup, $3^2+3+41=53$ is prime), and it'll be true for both $n=2$ and $n=3$, but that doesn't mean it's true for all $n$. In fact, it's not true for all $n$: at $n=41$, the corresponding value is not prime (it is divisible by 41).

D.W.
  • 167,959
  • 22
  • 232
  • 500