1
$\begingroup$

I'm new to push down automata and I don't know how to find one for following language:

$$L=(w \in A^∗:|w|_a=|w|_b) \enspace.$$

Also I have to prove that my construction is correct. Can anyone show me how it's done or give me an example?

  • 0
    What does $|w|_a$ and $|w|_b$ mean?2017-01-24
  • 0
    the number of "a" 's and the number of "b" 's in the word has to be equal2017-01-24

1 Answers 1

1

Assume w.l.o.g. $A = \{a,b\}$. Informally, we can build a PDA that has two "counting" states, in its first state it pushes a symbol on its stack for each $a$ its reads, and pop it for each $b$, in the other state it works the other way around, i.e. it pushes a symbol for each $b$ and pops one for each $a$. And each time its stack is empty, the state it takes after reading the next symbol is either the first state if its reads an $a$ next, or the second otherwise.

For the formal construction, as according to the cited defintion from wikipedia we cannot test for an empty stack in the course of the computation we use a special symbol $\gamma_0$ that is always on the bottom of the stack, and instead of acceptance by empty stack as written in the informal description above the PDA accepts if the start stack symbol is read, we are not in the start state and we have processed all symbols of the input.

Let $\mathcal M = (Q, A, \Gamma, \delta, q_a, \gamma_0, F)$ be a pushdown automaton, where $\Gamma = \{\gamma_0, \gamma\}$ and $Q = \{q_a, q_b\}, F = \{q_a, q_b\}$ with transitions \begin{align*} & (q_a, a, \gamma_0, q_a, \gamma\gamma_0) \\ & (q_a, b, \gamma_0, q_b, \gamma\gamma_0) \\ & (q_a, a, \gamma, q_a, \gamma\gamma) \\ & (q_a, b, \gamma, q_a, \varepsilon) \\ & (q_b, a, \gamma, q_b, \varepsilon) \\ & (q_b, b, \gamma, q_b, \gamma\gamma) \\ & (q_b, b, \gamma_0, q_b, \gamma\gamma_0) \\ & (q_b, a, \gamma_0, q_a, \gamma\gamma_0). \end{align*} Then \begin{align*} L(\mathcal M) & = \{ w \in A^{\ast} \mid (q_a, w, \gamma_0) \vdash_{\mathcal M}^{\ast} (q, \varepsilon, u), q \in F, u \in \Gamma^{\ast} \} \\ & = \{ w \in A^{\ast} \mid (q_a, w, \gamma_0) \vdash_{\mathcal M}^{\ast} (q, \varepsilon, \gamma_0), q \in F \} \\ & = \{ w \in A^{\ast} \mid |w|_a = |w|_b \}. \end{align*} Note that it does not matters if we use $q_a$ or $q_b$ as the start state. For the proof that this construction is correct, note that if the PDA accepts a word the only points where it can change its state are when $\gamma_0$ is the only stack symbol, and by construction this occurs when up to this point, the number of $a$ equals out the number of $b$'s by corresponding push/pop operations, hence at the end the number of $a$'s and $b'$ must equal out. For the other direction assume $w$ has an equal number $a$'s and $b$'s, then write $w = w_1 w_2 \cdots w_k$ where each $w_i$ has nonempty length $|w_i| > 0$ and is such that every prefix of it has an unequal number of $a$'s and $b'$, i.e. $w_i = a^n b^n$ or $w_i = b^n a^n$. Then it is easy to see that the PDA works through this word where between the $w_i$ it has only $\gamma_0$ on its stack, and while processing some $w_i$ it is either in state $q_a$ or $q_b$ and processing them correctly according to their form. $\square$