Lecture 16: ContextFree Languages
David Dill
Department of Computer Science
1
Outline
•
Contextfree languages.
2
ContextFree Languages
Regular languages have many wonderful properties, but not all languages are
regular.
Next, we’ll study a more powerful class of languages, the
contextfree langauges
.
Contextfree languages were identified in the 1950’s by linguist Noam Chomsky,
as a natural place in a hierarchy of languages, which included the regular
languages.
3
Formal Definition of ContextFree Grammars
A CFG is a 4tuple
(
V, T, P, S
)
•
V
is a finite set of
nonterminal symbols
,
•
T
is a finite set of
variables
(AKA
terminal symbols
),
•
P
⊆
V
×
(
V
∪
T
)
*
is a finite set of
productions
, and
•
S
∈
V
is the
Sentence symbol
V
and
T
must be disjoint sets.
Productions are written
A
→
aBc
.
A
is the lefthand side (LHS), also called the
head
, and
aBc
is the righthand side (RHS), also called the
body.
4
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentNotation
a, b, c,
0
,
1
, . . .
are
terminals
A, B, S, .
. .
are
nonterminals
w, x, y, z
are
terminal strings
(
T
*
)
α, β, γ
are
strings of terminals and/or nonterminals
(
(
V
∪
T
)
*
).
Several productions with common heads can be combined:
A
→
a

Aa

bAb
5
Outline
•
Language of a grammar
•
Ambiguity
•
Push Down Automata introduction
This is the end of the preview.
Sign up
to
access the rest of the document.
 Winter '08
 Motwani,R
 Computer Science, Formal language, Formal grammar, Automata theory, Contextfree grammar, parse tree, R R R R R R R

Click to edit the document details