Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
0 of .
Results for:
P. 1

Ratings: 0|Views: 1,004|Likes:

### Availability:

See More
See less

11/26/2013

pdf

text

original

7.1/3a;4c,h;57.2/57.3/1,23. Construct npda’s that accept the following regular languages:a)
L
1
=
L
(
aaa*b
)A npda that accepts a regular language doesn’t need a stack because the language canbe handled by a finite automaton, so we create a npda that simply doesn’t care aboutthe stack.4. Construct npda’s that accept the following languages on
= {
a
,
b
,
c
}.c)
L
= {
a
n
b
m
c
n
+
m
:
n
0
, m
0}Here we need the stack. We need to do two things: make sure the symbols come in thecorrect order and make sure the number of
c
’s is correct. The order is taken care of bythe transitions from state to state. The number of
c
’s is taken care of by pushing asymbol for each
a
or
b
and popping for each
c
and requiring that the stack winds up withonly the start symbol.h)
L
= {
n
a
(
w
) = 2
n
b
(
w
)}In this case we don’t care about the order. We just need to make sure that thenumber of
a
’s is twice the number of
b
’s. This is actually tricky. The idea is topush two symbols for each
b
and pop one symbol for each
a
. Conversely, we couldpush one symbol for each
a
and pop two symbols for each
b
. The problem is bestunderstood by considering
aab
,
baa
, and
aba
. It all depends on what the firstsymbol is. If the first symbol is a
b
then we merely push two symbols onto thestack and wait until they can both be popped off by seeing two
a
’s. If the firstsymbol is an
a
then we would need to push a symbol for the
a
and hope that welater on see another
a
allowing us to pop off two symbols when we encounter the
a,z

1
z b,
1
11
c,
1

λ
c,z

λ
b,z

1
z b,
1
11
c,z

λ
c,
1

λ
a,z
→
a,z
→
a,z
→
b,z
→
a,
1
11

b
. But what if we see a
b
before we see the next
a
(this is the
aba
example in itssimplest form)? There aren’t two symbols on the stack to pop off.5. Construct an npda that accepts the language
L
= {
a
n
b
m
:
n

0,
n

m
}. This machine counts the
a
's by pushing on the stack and matches
b
's by popping. Whenthe stack only contains only
z
,
n
=
m
. So if we see even one more
b
we must accept
a,1
→
11c,1
→
1a,z
→
1z a,1
→

λ
b,1
→
111c,1

1b,z
→
11z
λ
, z
→

λ
λ
, z
→
b,1
→

λ
λ
, z
→
λ
, 1
→

λ

c, 1
→
1c,z
→

z q
0
q
1
q
2
q
4
q
3
Notice how
c
's are specified but have no impact on the stack or on the state,meaning that they are basically ignored. The
q
0
-
q
3
pathway deals with situations where we begin with
b
. We push two1's for each
b
and pop a 1 for each
a
until the stack contains only the startsymbol
z
. At that point we have matched two
a
's for each
b
and arrive backin
q
0
. The
q
0
-
q
1
pathway deals with situations where we begin with
a
. Here wepush a 1 for each
a
and pop two 1's for each
b
(by using temporary state
q
2
to pop the second 1. If this is always possible, we eventually wind up instate
q
2
with the start symbol
z
at the top and can head back to state
q
0
tostart all over again. Notice, however, that we might not have a 1 at the topwhen we get to state
q
2
. This means that we did not have enough
a
's to dothe second pop. So we "play a trick." We push a 1 on the stack and go tothe other pathway, namely to state
q
3
. We arrive there with a single 1 on thestack, needing an
a
. When we get it, we are all matched up and can headback to
q
0
. State
q
0
represents a proper match and lets us go to theaccepting state
q
4
when the string is done.
λ
, z
→
1z a,z
→
1z a,1
→
11b,1
→

λ
b,z
→
λ
,1
→
1b,1
→

λ

b,z
→

z b,z
→

z q
0
q
1
q
2
q
3

## Activity (4)

### Showing

AllMost RecentReviewsAll NotesLikes