1

I am on a fool's errand trying to construct a Pushdown automaton for the non-context-free language L={a^(n)b^(n)c^(n)|n>=1} and thought of two approaches.

First approach:-

I thought that for every 'a' in string I will push 3 'a' into the stack and for every 'b' in the string, I will pop 2 'a' from the stack now for every 'c' in the string I will still have 1 'a' in the stack.

Problem with the First approach:- the language generated becomes something like this L={a^(p)b^(m)c^(n)| p>=1 and could not determine how m and n can be defined}

Second approach:-

We know that L={ a^(n)b^(m)c^(m)d^(n) | n>=0 } is a context-free language and L={ wxw | w∈(a,b)* } is also context-free language.

So, I thought L={ a^(n)b^(m)b^(m)c^(n) | n>=1 and m=floor((n+1)/2) }

Problem with the Second approach:- don't know if we can calculate floor(n+1/2) in the PDA without disturbing the elements of the stack.

Please help in determining how m and n can be defined in the first approach and how can I find floor((n+1)/2) in the PDA.

JFLAP files available for both if needed.

Community
  • 1
  • 1
NeoR
  • 353
  • 2
  • 9
  • 27

2 Answers2

1

One reason you've not managed to construct a pushdown automaton for this language, is because there isn't any. The Bar Hillel pumping lemma shows this.

To outline the proof, suppose it can be done. Then, for some p, each string larger than p can be partitioned to uvwxy, s.t.,

  • |vwx| < p

  • |vx| > 1

  • uvnwxny is also accepted by the automaton, for any n.

The first rule implies that vwx can't span the three regions, only at most two (for large enough strings). The second and third rules now imply that you can pump so that the un-spanned region is smaller than the at least one of the other regions.

Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
  • Yes I know how pumping lemma works but like I said fool's errand and if it's successful then pumping lemma will fail. – NeoR Oct 29 '16 at 15:57
  • ?! Good luck. I suppose once you're done, you'll ask about your search for integer *a, b, c*, s.t., *a^3 + b^3 = c^3*, and ask for guidelines how to look for them. – Ami Tavory Oct 29 '16 at 18:16
  • What about 2 way PDA iy should be possible with that – NeoR Oct 29 '16 at 18:22
  • @NeoR With a deque (double ended queue), this is possible. Start by placing a separator element. Then, for each *a*, push it both before and after the separator. Then, for each *b*, pop from one side until reaching the separator. Finally, for each *c*, pop from the other side until reaching the separator. – Ami Tavory Oct 29 '16 at 18:37
  • not trying to write a code but rather design an actutal state machine.So help process keeping that in mind. – NeoR Oct 30 '16 at 11:42
  • uploaded the subsection at http://stackoverflow.com/questions/40408858/what-is-the-language-of-the-pushdown-automaton-for-the-given-image – NeoR Nov 03 '16 at 18:33
1

As Ami Tavory points out, there is no PDA for this language because this language is not context-free. It is easy to recognize this language if you use a queue instead of a stack, use two stacks, or use a Turing machine (all equivalent).

Queue machine:

  1. Enqueue as as long as you see as, until you see a b.
  2. Dequeue as and enqueue bs as long as you see bs, until you see a c
  3. Dequeue bs as long as you see cs.
  4. Accept if you end this process with no additional input and an empty queue.

Two-stack PDA:

  1. Use the first stack to make sure a^n b^n by pushing a when you see an a and popping a when you see a b;
  2. Use the second stack to make sure b^n c^n by pushing b when you see a b and popping b when you see a c;
  3. Accept if both stacks are empty at the end of this process.

Turing machine:

  1. Ensure a^n ... c^n by replacing each a with A and erasing a matching c;
  2. Ensure A^n b^n by erasing matching pairs of A and b;
  3. Accept if at the end of this process you have no more A and no more b, i.e., the tape has been completely cleared.
Patrick87
  • 27,682
  • 3
  • 38
  • 73
  • Firstly again I would like to point out "Fool's errand" and second i know PDA does not exists so please read the question description fully. – NeoR Nov 02 '16 at 12:37
  • Maybe i need to update the question by adding the JFlap images – NeoR Nov 02 '16 at 12:38
  • @NeoR You might consider changing the title to reflect your actual question and putting your actual question near the top of the question body, with any explanation or motivating discussion below it. – Patrick87 Nov 02 '16 at 15:19
  • @NeoR I'd make it two questions, one for each approach. The first question is "what strings does this PDA accept"; the second one is "is this language context free". The answer to the second one will be no and the reason will be that it is equivalent to the non-context-free language `a^n b^n c^n`. The first question might have a more interesting answer depending on what you consider interesting. – Patrick87 Nov 02 '16 at 15:28
  • I have uploaded a new question at http://stackoverflow.com/questions/40408858/what-is-the-language-of-the-pushdown-automaton-for-the-given-image – NeoR Nov 03 '16 at 18:33