0

I have a question about designing a pushdown automata for the language:

L = { w in {a, b}* : 2n_a(w) <= n_b(w) <= 3n_a(w) }

In other words, the number of b's in w is "between" 2 times the number of a's and three times the number of a's.

I'm confused about this question: I know (hopefully!) how to design the PDA to accept the language when the number of b's is equal to twice the number of a's or 3 times the number of a's separately.

This language seems to be an intersection of those, but I don't think there's a simple way to use the intersection to create a PDA. How can we incorporate the fact that the number can be between two values.

ANY help is much appreciated...

P.S. If you can also give the context-free grammar (and also explanation), it would be very very helpful also.

P.P.S: Also, if anyone can provide a link to somehow show how to construct context-free grammars step by step, I would really need it. (I found a link to regular grammars for regular expressions, but for context-free grammars, when I try to follow the variables and see that one variable goes to itself, or goes to another variable, which goes back to the initial variable, I REALLY get confused.)

Tripp Kinetics
  • 5,178
  • 2
  • 23
  • 37
Farzad
  • 1,770
  • 4
  • 26
  • 48
  • The intersection of `{w in {a, b}* | 2 n_a(w) = n_b(w)}` and `{w in {a, b}* | 3 n_a(w) = n_b(w)}` is the set containing only the empty string, since no other string can satisfy both equalities. You probably meant to write the intersection of `2 n_a(w) <= n_b(w)` and `n_b(w) <= 3 n_a(w)`. In any event, the set of CFLs (or PDAs) is not closed under intersection, so there is no general algorithm for constructing a PDA which is the intersection of two PDAs. – rici Jun 10 '14 at 19:02
  • Yes, I meant the intersection between the two languages containing the inequality... Sorry if I wrote in a way that confused you, and thanks for the answer – Farzad Jun 10 '14 at 19:19

1 Answers1

0

You need to make your PDA so that every a pushes two b's or three b's. For example, a String with 3 a's and 8 b's: first a pushes 3 b's, second a pushes 3 b's, third a pushes 2 b's.

I think this CFG covers all the cases: S -> aB|Ba|EOS B -> SbSbS|SbSbSbS

This means that for every a, there are two b's or three b's.

https://www.youtube.com/watch?v=AbbZVvQkees This is a great youtube channel for PDA's.

Addie
  • 127
  • 1
  • 1
  • 8
  • Thanks for the link, I really need to check it out... I'm TOTALLY LOST on these grammars and stuff... – Farzad Jun 10 '14 at 19:34