computer-scienceautomataautomata-theory

How to find out the language that accepted by below NPDA


I wanna understand how find the language that will be accepted by below NPDA.

M = {Q, Σ, Τ, δ, q0, z, F}
Q is a set of state: {q0, q1, q2}
Σ is alphabet: {a, b}
Τ is stack alphabet: {0, 1, z}
δ is transition function
z is stack start symbol
F is set of final state.

And, it's transition function is below.

δ(q0, a, z) = {(q1 , 0), (q2 , λ)}
δ(q1, b, 0) = {(q1, 1)}
δ(q1, b, 1) = {(q1, 1)}
δ(q1, a, 1) = {(q2, λ)}

Solution

  • Based on these transitions, I will assume that the final state is q2 and it accepts with empty stack (it looks like it gets rid of even the bottom-of-stack symbol z, which is a little unusual for me, but I guess it's fine).

    The transitions are these:

    δ(q0, a, z) = {(q1 , 0), (q2 , λ)}
    δ(q1, b, 0) = {(q1, 1)}
    δ(q1, b, 1) = {(q1, 1)}
    δ(q1, a, 1) = {(q2, λ)}
    

    Let's take them one at a time.

    1. δ(q0, a, z) = {(q1 , 0), (q2 , λ)} means that if we're in the initial state and we see an a, we can either go to state q1 and replace z with 0, or we can get rid of z and go to state q2. This is actually the accepting configuration for the NPDA; that means the NPDA accepts the empty string, and whatever language we determine must also contain that string. Because the only other way out of the initial state q0 is to see an a, we also know that any non-empty strings in our language must begin with a.

    2. δ(q1, b, 0) = {(q1, 1)} means that if we are now in state q1, see a b in the input and have 0 on top of the stack, we can change the stack symbol to 1. We will be in this configuration as soon as we get to state q1 from q0. Note that since no other transition puts a 0 on top of the stack, this is the only time this transition can be used; and indeed it must be used since q1 is not accepting and we must come through this transition to clear the 0 off the top of the stack. So, all strings in the language which are non-empty must begin with ab.

    3. δ(q1, b, 1) = {(q1, 1)} means that if we're in state q1, see a b in the input and have a 1 on top of the stack, we can consume more bs forever. We will remain in this configuration as long as we have more b in the input. We do not necessarily need to come through this state, however: there are other transitions that put 1 on top of the stack and the path to the accepting state may not involve this transition at all. This transition lets us put as many bs as we want after the one required b we saw in the last transition.

    4. δ(q1, a, 1) = {(q2, λ)} means that if we're in stateq1, see anain the input and have a1on top of the stack, we can erase the stack and go to the accepting state. This means that any non-empty string in the language ends with a singlea`.

    To recap:

    1. the empty string is in the language
    2. any non-empty string in the language begins with ab
    3. any non-empty string in the language can have an arbitrary number of bs in the middle
    4. any non-empty string in the language ends with a.

    Putting this all together, we find a regular expression describes the language: e + abb*a. We should not be surprised by this since this NPDA's stack only ever contains zero to two elements in it; because the amount of stack used is constant, the NPDA is equivalent to some DFA and therefore its language must be regular.