CS103
HO#38
SlidesCFLs, Turing Machines
5/4/11
1
Example 2.37.
B = { a
n
b
n
c
n
 n
0 } is not contextfree.
Assume B is CF.
Let s = a
p
b
p
c
p
, where p is the pumping length.
a
p
b
p
c
p
We don’t know exactly where vxy falls, but vxy
p and vy
0.
Consider uv
2
xy
2
z
If v and y each contain just one type of symbol, pumping s unbalances
the number of a's, b's, and c's.
If v or y contains 2 or more different symbols, pumping s gets symbols
out of order.
So s cannot be pumped, and B is not contextfree.
Suppose s = uvxyz
Typo in Sipser:
Page 125, third and fourth lines of the third paragraph.
Change
so it must contain a path from the root to a leaf of length
to
so its longest path from the root to a leaf has length
Get the whole list at:
http://wwwmath.mit.edu/~sipser/itocerrs2.1.html
More About Grammars
How should we interpret a rule like
A
ε
?
A rule is a variable [the LHS] and a string of variables and terminals
[the RHS].
The rule above appears to be like
A
b where b is a terminal
(i.e., b
).
But
ε
is not a symbol, it is the empty string.
Some languages
with "
ε
productions " contain the empty string
and some do not.
The language S
aS 
ε
is a* and contains the empty string.
The language S
Xa
X
aX  bX 
ε
does not contain the empty string.
More About Grammars
The following theorem is due to BarHillel, Perles, and Shamir:
If L is a CFL generated by a CFG that includes
ε
productions, then
there is a different CFG that has no
ε
productions that generates
either the whole of L (if
ε
is not in L) or the language of all strings
in L that are not
ε
.
Example:
S
Xa
X
aX  bX 
ε
The language generated is (a
b)*a
Alternate grammar:
S
Xa  a
X
aX  bX  a  b
More About Grammars
We can separate the terminals and nonterminals in productions.
If L is a CFL generated by a CFG, then there is a another CFG
that generates all strings in L that are not
ε
and whose productions
are of one the following two forms:
Nonterminal
string of only nonterminals
Nonterminal
one terminal
We can do this by
adding a rule of the second form for each
terminal, with a new nonterminal on the left
in every rule with both terminals and nonterminals on
the right, replace the terminals with the appropriate
nonterminals
More About Grammars
Example:
S
Na
N
c  b
Becomes
S
NA
N
c  b
A
a
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentCS103
HO#38
SlidesCFLs, Turing Machines
5/4/11
2
More About Grammars
A more useful form of grammar is Chomsky Normal Form (CNF)
If L is a CFL generated by a CFG, then there is a another CFG
that generates all strings in L that and whose productions
are of one the following three forms:
Nonterminal
string of two nonterminals
Nonterminal
one terminal
Start variable
ε
Theorem 2.9
Any contextfree language is generated by a contextfree
grammar in Chomsky Normal Form.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 PLUMMER
 languages, Formal language, Turing Machines, Formal languages

Click to edit the document details