A CFG for Strings with Equal Numbers of
a
s and
b
s
•
G
= (
{
S
}
,
{
a, b
}
, R, S
) where
R
has rules:
S
→
ε
S
→
SS
S
→
aSb
S
→
bSa
•
Claim
:
L
(
G
) =
{
x
:
x
has the same # of
a
’s and
b
’s
}
(1)
x
∈
L
(
G
)
⇒
x
has the same # of
a
’s and
b
’s
Pf:
Easy, every RHS has the same number of
a
’s and
b
’s. Formal proof by
induction on length
k
of the derivation.
(2)
x
has the same # of
a
’s and
b
’s
⇒
x
∈
L
(
G
)
Proof:
by induction on

x

(a)

x

= 0: then
x
=
ε
and is generated by a single rule
(b)

x

=
k
+ 2
4 subcases depending on ﬁrst and last symbols of
x
(i)
x
=
ayb
for some
y
∈
Σ
*
:
So

y

=
k
, and
y
has the same # of
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 Logic, Mathematical Induction, Mathematical logic, induction hypothesis, Proof theory, equal numbers

Click to edit the document details