Section 3.4

Pushdown Automata

[11/64%]
Show
LaTeX
Example 3.28

Consider the PDA M=({q,p},{a,b,c},{a,b},δ,q,{p})M=(\left\{ q, p\right\} , \left\{ a, b, c\right\} , \left\{ a, b\right\} , \delta , q,\left\{ p\right\} ), where δ\delta is defined as follows:

δ(q,a,ε)={(q,a)},δ(p,a,a)={(p,ε)},δ(q,b,ε)={(q,b)},δ(p,b,b)={(p,ε)},δ(q,c,ε)={(p,ε)}. \begin{array}{ll} \delta (q, a, \varepsilon )=\left\{ (q, a)\right\} , & \delta (p, a, a)=\left\{ (p, \varepsilon )\right\} , \\ \delta (q, b, \varepsilon )=\left\{ (q, b)\right\} , & \delta (p, b, b)=\left\{ (p, \varepsilon )\right\} , \\ \delta (q, c, \varepsilon )=\left\{ (p, \varepsilon )\right\} . & \end{array}

Determine what L(M)L(M) is.

?
Example 3.29

Construct a PDA accepting the language {wwR∣w∈{a,b}∗}\left\{ w w^{R} \mid w \in \left\{ a, b\right\}^{*}\right\}.

?
Example 3.30

Construct a PDA that accepts the language

{aibjck∣i,j,k≥0,i+k=j}. \left\{ a^{i} b^{j} c^{k} \mid i, j, k \geq 0, i+k=j\right\} .
?
Example 3.31

Construct a PDA that accepts the language

L={aibj∣2i≠3j}. L=\left\{ a^{i} b^{j} \mid 2 i \neq 3 j\right\} .
?
Example 3.32

Construct a PDA that accepts the language

L={x∈{a,b}∗∣2#a(x)≠3#b(x)}. L=\left\{ x \in \left\{ a, b\right\} ^{*} \mid 2 \# _{a}(x) \neq 3 \# _{b}(x)\right\} .
?
Example 3.33

Construct a PDA M that accepts the following language:

{w∈{a,b}∗∣#a(w)≤#b(w)≤2#a(w)}. \left\{ w \in \left\{ a, b\right\} ^{*} \mid \# _{a}(w) \leq \# _{b}(w) \leq 2 \# _{a}(w)\right\} .
?
Example 3.34

Construct a PDA MM that accepts the language

L={w∈{a,b}∗∣3#a(w)≤5#b(w)≤4#a(w)}. L=\left\{ w \in \left\{ a, b\right\} ^{*} \mid 3 \# _{a}(w) \leq 5 \# _{b}(w) \leq 4 \# _{a}(w)\right\} .
?
Problem 3.4.1

For each of the following languages LL, construct a PDA to accept LL. In addition, for each given string x∈Lx \in L, show an accepting computation path of your PDA on xx.

?
(a)

{anbm∣m,n≥0,m≠3n};x=a2b4\left\{ a^{n} b^{m} \mid m, n \geq 0, m \neq 3 n\right\} ; x=a^{2} b^{4}.

(b)

{anbm∣0≤2n≤m≤3n};x=a2b5\left\{ a^{n} b^{m} \mid 0 \leq 2 n \leq m \leq 3 n\right\} ; x=a^{2} b^{5}.

(c)

{anbm∣0≤2n≤3m≤4n−2};x=a3b3\left\{ a^{n} b^{m} \mid 0 \leq 2 n \leq 3 m \leq 4 n-2\right\} ; x=a^{3} b^{3}.

(d)

{aibjck∣i,j,k≥0,i+2k=j};x=a3b7c2\left\{ a^{i} b^{j} c^{k} \mid i, j, k \geq 0, i+2 k=j\right\} ; x=a^{3} b^{7} c^{2}.

(e)

{aibjck∣i,j,k≥0,2i+3k≤4j};x=a4b4c2\left\{ a^{i} b^{j} c^{k} \mid i, j, k \geq 0,2 i+3 k \leq 4 j\right\} ; x=a^{4} b^{4} c^{2}.

(f)

{aibjckdl∣i,j,k≥0,i+k≤j+l};x=a2b4c5d3\left\{ a^{i} b^{j} c^{k} d^{l} \mid i, j, k \geq 0, i+k \leq j+l\right\} ; x=a^{2} b^{4} c^{5} d^{3}.

(g)

{aibjckdl∣i,j,k≥0,2i+3k≤4j+l};x=a3b4c4d5\left\{ a^{i} b^{j} c^{k} d^{l} \mid i, j, k \geq 0,2 i+3 k \leq 4 j+l\right\} ; x=a^{3} b^{4} c^{4} d^{5}.

(h)

{w∈{a,b}∗∣2#a(w)+5≤3#b(w)};x=abbabba\left\{ w \in \left\{ a, b\right\}^{*} \mid 2 \#_{a}(w)+5 \leq 3 \#_{b}(w)\right\} ; x=a b b a b b a.

(i)

{w∈{a,b}∗∣2#a(w)≤3#b(w)≤4#a(w)};x=abbaaab\left\{ w \in \left\{ a, b\right\}^{*} \mid 2 \#_{a}(w) \leq 3 \#_{b}(w) \leq 4 \#_{a}(w)\right\} ; x=a b b a a a b.

(j)

{w∈{a,b,c}∗∣#a(w)≤#b(w)+3#c(w)};x=aacabbbaa\left\{ w \in \left\{ a, b, c\right\}^{*} \mid \#_{a}(w) \leq \#_{b}(w)+3 \#_{c}(w)\right\} ; x=a a c a b b b a a.

(k)

{w∈{a,b,c}∗∣2#a(w)≤#b(w)+3#c(w)≤5#a(w)};x=\left\{ w \in \left\{ a, b, c\right\}^{*} \mid 2 \#_{a}(w) \leq \#_{b}(w)+3 \#_{c}(w) \leq 5 \#_{a}(w)\right\} ; x= acabcc.

Problem 3.4.2

In Example 3.32, when we finished processing the input symbols, we move to one of the final states pap_{a} or pbp_{b} if the stack is nonempty. Show that the two separate states are necessary. That is, suppose we merge states pap_{a} and pbp_{b} of Figure 3.15 into a single final state pp, with the instructions

δ(s,ε,a)=δ(s,ε,b)=δ(p,ε,a)=δ(p,ε,b)=(p,ε) \delta (s, \varepsilon , a)=\delta (s, \varepsilon , b)=\delta (p, \varepsilon , a)=\delta (p, \varepsilon , b)=(p, \varepsilon )

Show that, then, the new PDA would accept some strings not in LL.

?
Problem 3.4.3

Show that each of the following variations of the pushdown automaton model is equivalent to our original definition of pushdown automata, in the sense that the class of languages accepted by pushdown automata remains the same.

?
(a)

The PDA is allowed to push two stack symbols into the stack in one move; that is, the transition function δ\delta is a function of the following form:

δ:Q×(Σ∪{ε})×(Γ∪{ε})→2Q×({ε}∪Γ∪Γ2) \delta : Q \times (\Sigma \cup \left\{ \varepsilon \right\} ) \times (\Gamma \cup \left\{ \varepsilon \right\} ) \rightarrow 2^{Q \times \left(\left\{ \varepsilon \right\} \cup \Gamma \cup \Gamma ^{2}\right)}
(b)

The PDA is allowed to push any number of stack symbols into the stack in one move; that is, the transition function δ\delta is a function of the following form:

δ:Q×(Σ∪{ε})×(Γ∪{ε})→2Q×Γ∗. \delta : Q \times (\Sigma \cup \left\{ \varepsilon \right\} ) \times (\Gamma \cup \left\{ \varepsilon \right\} ) \rightarrow 2^{Q \times \Gamma ^{*}}.
(c)

The PDA is required to pop up the top element of the stack at each move and is allowed to push two stack symbols into the stack in one move; that is, the transition function δ\delta is a function of the following form:

δ:Q×(Σ∪{ε})×Γ→2Q×({ε}∪Γ∪Γ2) \delta : Q \times (\Sigma \cup \left\{ \varepsilon \right\} ) \times \Gamma \rightarrow 2^{Q \times \left(\left\{ \varepsilon \right\} \cup \Gamma \cup \Gamma ^{2}\right)}

(We assume that the PDA starts with a special symbol $ in the stack, i.e., the initial configuration is (s,x,$s, x, \$).)

(d)

The PDA accepts an input string as long as it reaches a final state after it finishes reading the input symbols (regardless of whether the stack is empty or not); that is, the PDA accepts a string x∈Σ∗x \in \Sigma^{*} if (s,x,ε)⊢∗(q,ε,γ)(s, x, \varepsilon ) \vdash^{*}(q, \varepsilon , \gamma ) for some q∈Fq \in F and some γ∈Γ∗\gamma \in \Gamma^{*}.

Problem 3.4.4

A PDA M=(Q,Σ,Γ,δ,s,F)M=(Q, \Sigma , \Gamma , \delta , s, F) is a deterministic PDAP D A if no configuration of MM has more than one successor configuration (but a nonfinal configuration may have no successor). For each of Examples 3.28-3.33, do the following:

?
(a)

Determine whether the PDA given in the example is deterministic or not.

(b)

If the answer to (a) is no, then determine whether there is an equivalent deterministic PDA accepting the same language. If yes, present your deterministic PDA; if no, show why not. [Hint: One way of eliminating (part of) nondeterminism in a PDA is to use the PDA model of Exercise 3(c).]