5

Note that by "two-way pushdown automaton", I mean a pushdown automaton that can move its reading head both ways on the input tape.

I recently had the question of determining the computational power of two-way PDAs in the Chomsky hierarchy. I don't entirely understand two-way PDAs, but I can see how with the ability to read in both directions on the input, it could handle languages of the form $L=\{0^n 1^n 2^n\}$. I can't say that for sure, but it seems that would make it powerful enough to least handle context-sensitive languages.

This is all a guess because I don't know exactly how they work. Can someone explain the process of how a two-way PDA operates, maybe even on my example?

UPDATE:

The model is a generalization of a pushdown automaton in that two-way motion is allowed on the input tape which is assumed to have endmarkers.

Patrick87
  • 12,824
  • 1
  • 44
  • 76
justausr
  • 435
  • 5
  • 11
  • 1
    "I mean a Push Down automata that can move it's reading head two ways on one stack." Are you sure about that? If something has a reading head (i.e. allows you to access elements other than the one which has most recently been added), it's usually not referred to as a stack anymore. (Plus that's not what the term "2-way PDA" usually means.) – sepp2k Mar 23 '12 at 15:56
  • I agree, I'm just repeating what was on my homework last week. I imagine he means take the way a PDA works and give it the possibility of reading both ways. call its datastructure what you will at that point – justausr Mar 23 '12 at 15:58
  • I think the meaning is that the stack is still a stack, but the input is given on a read-only tape, and the head of this tape is not restricted. – Ran G. Mar 23 '12 at 15:59
  • However, if the stack's head is two-ways, then this is not a stack but a tape, and the "PDA" becomes a Turing Machine. Can you edit the question to clarify what is the specific model? – Ran G. Mar 23 '12 at 16:05
  • 2
    @RanG. it looks like you're right. I found a paper on this http://www.sciencedirect.com/science/article/pii/S0019995867903695 I still don't understand how that would work though since input is given sequentially from what I've experienced. – justausr Mar 23 '12 at 16:09
  • 1
    @RanG Actually I don't think what's described here would be a Turing machine. If all you change is replacing the stack of the PDA with a tape, the result will be strictly less powerful than a TM because the input still needs to be read one-character per transition. – sepp2k Mar 23 '12 at 16:19
  • @sepp2k but then you'll just put the input onto the "stack" and continue as TM does ($\epsilon$-moves, for the PDA) – Ran G. Mar 23 '12 at 16:21
  • @RanG. You're right of course. Didn't think that through. – sepp2k Mar 23 '12 at 16:26
  • Only reading with random access does not give you Turing completeness. Writing in LIFO order is certainly a restriction. @justausr I strongly recommend you post the precise definition here. You have to conflicting statements in your question; we can not help you if we do not know what we are talking about. – Raphael Mar 23 '12 at 16:30
  • Assuming the model was not specified in full detail, just with the name "two-way pda", you might list all the possible interpretations, discuss each briefly, pick one and analyze that in more detail (or all in detail if you have the time) -- extra credit! Hint: you found one interpretation in that paper; you started on another with your original interpretation, but you left out one important feature of the model, namely the capabilities of the "stack" head, and that might lead to more than one model. BTW, I am guessing the interpretation intended is the one you found in the Gray etal paper. – David Lewis Mar 23 '12 at 17:12
  • Ah, I see the clarification. Go for it. In the future, the method I suggested is a great way to get the instructor to notice you and give extra credit. In fact, on an exam, if you feel a question is underspecified, "here's my interpretation" is the only way to go. – David Lewis Mar 23 '12 at 17:12
  • Just for clarification, I'm concerned with the interpretation of a 2 way PDA being one that is a normal pda but with two directional reading on the input, enabling the machine to go back over previous characters in its input. We weren't given a definition of one in our assignment or in our book so that was the source of the confusion. – justausr Mar 23 '12 at 17:31

1 Answers1

7

A two-way PDA can accept the canonical context-sensitive language $\{0^{n}1^{n}2^{n} | n \geq 1\}$. Such an automaton could work by checking whether the largest prefix of the form $0^{i}1^{j}$ had $i = j$, using the stack, after which it could empty the stack, and check whether the largest suffix of the form $1^{j}2^{k}$ had $j=k$, again using the stack. So $CFL \subsetneq L(2PDA)$.

In more detail, the 2-way PDA would read from left to right as many 0 symbols as it finds, pushing a 0 onto the stack for each 0 it reads on the input tape. If it reads any 0 symbols and finds a 2 symbol before finding a 1, it crashes. When it gets to a 1, it changes state, and begins reading all the 1 symbols, until it comes to a 2. If it reads a 0 symbol while doing this, it crashes. It pops a 0 symbol from the stack for each 1 it reads on the input tape. If, when it reaches the first 2, the stack is empty, the PDA moves the tape head to the end of the input tape. Otherwise, it crashes. If it encounters any 0s or 1s, it crashes. It then reads the input tape left to right, pushing a 2 for each 2 it reads on the input tape. When it gets to a 1, it switches states and begins reading 1s and popping 2s. If, when it gets to a 0, the stack is empty, the string is accepted.

The machine would crash if the input string weren't a string of 0s, followed by 1s, followed by 2s; and it would have crashed if the longest prefix of 0s and 1s weren't in the canonical CFL $\{0^{n}1^{n}\}$; and it would have crashed if the longest suffix of 1s and 2s weren't in the canonical CFL $\{1^{n}2^{n}\}$. In this case, the ability to rewind the tape allows you to accept languages which are the intersection of CFLs, by essentially stringing PDAs together, and rewinding the tape in between.

Therefore, the languages accepted by two-way PDAs are trivially closed under intersection, a property not shared by languages accepted by regular PDAs.

Patrick87
  • 12,824
  • 1
  • 44
  • 76
  • Is $\mathcal{L}(2\mathrm{PDA})\subseteq \mathrm{CSL}$? – Raphael Mar 23 '12 at 22:04
  • 2
    @Raphael the paper in the 5th comment of the question shows how to convert a 2way-PDA into a deterministic LBA. Thus the answer to your question is yes. – Ran G. Mar 23 '12 at 23:19