Assignment 3: solution set
prepared by Jalaj Upadhyay
Question 1
(a)
We first give the grammar and then prove the correctness.
S
→
AB
B
→
aBb

C
→
bCc

The correctness of the above grammar can be seen by making the following observation: the grammar
produces a “a” or a “c” if and only if it produces a “b”; therefore,
n
a
(
x
) +
n
c
(
x
) =
n
b
(
x
)
for all
x
∈
L
(
G
)
and no
x /
∈
L
(
G
)
is produced by the grammar. It also produces all set of
a
*
b
*
before producing
b
*
c
*
because
of
S
→
AB.
(b)
We first give the grammar and then prove the correctness.
S
→
aSc

B

C
B
→
bBc

C
C
→
cC

c
Note that
/
∈
G
; therefore, there is no production rule that gives just
as output.
Now we prove the
correctness of the above grammar.
Let us consider any arbitrary word
w
∈
L
. Since it is in
L
, the number of
c
is more than
n
a
(
w
)+
n
b
(
w
)
.
This can be produced by the grammar by first applying
S
→
aSc
,
n
a
(
w
)
times; then
S
→
B
once followed
by
B
→
bBc
,
n
b
(
w
)
times; and finally
B
→
C
once followed by
C
→
cC
to cover the extra
c
0
s.
Now consider any word
w
∈
¯
L
(
w
will have
n
a
(
w
) +
n
b
(
w
)
≥
n
c
(
w
)
. However, it is simple to see that
G
cannot produce such a word because the production rule of
S
and
B
has at least one nonterminal output,
c
; therefore, there is no way a
c
is not produced when an
a
or a
b
is generated.
(c)
Let
A
:=
{
(0
, Z
0
,
0
Z
0
)
,
(1
, Z
0
,
1
Z
0
)
,
(0
,
0
,
00)
,
(0
,
1
,
)
,
(1
,
0
,
)
,
(1
,
1
,
11)
}
and
B
:=
{
(1
, Z
0
,
1
Z
0
)
,
(1
,
0
,
)
,
(1
,
1
,
11)
}
,
where the tuple
(
a, b, c
)
means that if
a
is read and
b
is on the top of the stack, replace it by
c
. A PDA that
accepts
L
is as follow:
(
q
s
,
A
)
‘
q
s
(
q
s
,
B
)
‘
q
1
(
q
1
,
B
)
‘
q
2
(
q
2
,
A
)
‘
q
2
(
q
2
,
(
, Z
0
, Z
0
))
‘
q
f
,
where
(
a, b
)
‘
c
means that move to state
c
when you are in state
a
and the tuple
b
is present. The start state
is
q
s
and the final state is
q
f
.
The automaton accepts by final state.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Winter '08
 JohnWatrous
 Mathematical Induction, Correctness, Formal verification, formal methods, Hoare logic, Proof theory

Click to edit the document details