0

I am studying pushdown automata for a course and I've reached a conceptual plothole.

Does the stack basically have infinite memory or only space for a single symbol?

If I have the following string:

abba And the following rules with q6 as my acceptance state:

(q0,a,Z)=(q1,a)
(q1,b,a)=(q2,b)
(q2,b,b) = (q3,b)
(q3,a,b) = (q4,a)
(q4,lambda,a)=(q5,lambda)
(q5,lambda,a)=(q5,lambda)
(q5,lambda,b)=(q5,lambda)
(q5,lambda,Z)=(q6,lambda)

In the states my stack looks like this:
q0: Z
q1: aZ
q2: baZ
q3: bbaZ
q4: abbaZ
q5: Z because eventually everything is popped
q6: Z

Is this the proper transformation of the stack? Basically every push it grows indefinitely? Or should every push swap with the current top?

For example the states would like:
q0: Z
q1: aZ
q2: bZ
q3: bZ
q4: aZ
q5: Z
q6: Z

Callat
  • 2,928
  • 5
  • 30
  • 47
  • 1
    The former: the stack has infinite capacity. – Welbog Mar 20 '17 at 14:25
  • So then the tuple on the left side is not interpreted as popping from the string and popping from the stack? – Callat Mar 20 '17 at 14:29
  • It's usually interpreted as looking at the current input character and the topmost value of the stack. It doesn't always pop from the stack. Your notation is different from what I've seen in the past. If your question is just about notation, then I suggest you take it up with whoever specified that notation. Notation I'm familiar with is like this: `(original state, read character or lambda, top of stack character or lambda) -> (new state, new top of stack)`. So if I wanted to read an `a` and a `Z` and push an `a` onto the stack, I'd write it like this: `(q0, a, Z) -> (q1, aZ)`. – Welbog Mar 20 '17 at 14:36
  • The way you have it notated, to me, looks like you're swapping. The end result of `(q0, a, Z) -> (q1, a)` would be a stack containing only `a` (no `Z`). But your notation may differ from what I'm familiar with. – Welbog Mar 20 '17 at 14:38
  • Thanks. One more question in terms of lambda on the right side. That corresponds to pop. Or remove the current top from the stack. Or does that mean not pushing anything to the stack? – Callat Mar 20 '17 at 14:38
  • I would interpret that as a pop, but it's not up to me; it's up to whoever came up with this notation. – Welbog Mar 20 '17 at 14:40

0 Answers0