推下自动机

时间:2011-12-02 18:32:33

标签: theory automata computation

为语言设计下推自动机a ^ n b c ^ n + 2,n> 0 我被要求为上述语言实现自动机..请帮帮忙?

我每次将(a)推到堆栈时尝试弹出2(c)s,但似乎不能使用奇数个(a)s ....

1 个答案:

答案 0 :(得分:2)

你必须以正常方式处理a,即每个人从你堆叠A的磁带中读取,直到你读完a,如果你读取ab,则保持堆栈顶部不变,最后你必须处理所有的C。过渡功能是:

(q0, a, Z) = (q0, AZ)
(q0, a, A) = (q0, AA)
(q0, b, A) = (q1, A)
(q1, c, A) = (q1, epsilon) (until the amount of a's are equal to the amount of c's)
(q1, c, Z)= (q2, Z) (read the first extra c)
(q2, c, Z)= (q3, Z) (read the second extra c)
(q3, epsilon, Z)= (qf, Z) (qf is the final state)

PDA的图形表示是:

enter image description here