Upload
lawrence-ferguson
View
80
Download
2
Embed Size (px)
DESCRIPTION
Context-Free Languages: Review. Chapter 16. Languages and Machines. Regular and CF Languages. Regular LanguagesContext-Free Languages ● regular exprs.● context-free grammars ● or ● regular grammars ● = DFSMs● = NDPDAs ● recognize● parse - PowerPoint PPT Presentation
Citation preview
Context-Free Languages:Review
Chapter 16
Languages and Machines
Regular and CF Languages
Regular Languages Context-Free Languages
● regular exprs. ● context-free grammars ● or● regular grammars● = DFSMs ● = NDPDAs● recognize ● parse● minimize FSMs ● find unambiguous grammars
● reduce nondeterminism in PDAs ● find efficient parsers
● closed under: ● closed under: ♦ concatenation ♦ concatenation ♦ union ♦ union ♦ Kleene star ♦ Kleene star ♦ complement ♦ intersection ♦ intersection w/ reg. langs● pumping theorem ● pumping theorem● D = ND ● D ND
Example
{bam1bam2bam3… bamn : n 2, m1, m2, …, mn 0, and
mi mj for some i, j}
A PDA:
A CFG:
Is L regular?
L = {aibj: j = 4i + 2}
Is L Regular, Context Free, or Neither?
L = {x xneg : x {0, 1}*}.
xneg = x with all 0’s replaced by 1’s and 1’s replaced by 0’s.
Is L Regular, Context Free, or Neither?
L = {w {0, 1}* : k (w is a binary encoding, leading zeros allowed, of 2k+1)}
Is L Regular, Context Free, or Neither?
L = {w {a, b, c}* : every a has a matching b and amatching c somewhere in w (and no b or c is consideredto match more than one a)}
Is L Regular, Context Free, or Neither?
L = {anbm : n + m 3 2, n 1, m 1}
An Example
L = {aibjck : k i or k j}
Construct a context-free grammar for L.
Functions on Languages
Again, let L = {aibjck : k i or k j}.
Describe precisely the language L = maxstring(L), where:
maxstring(L) =
{x: x L and (y * (y ) (xy L))}
Is L = maxstring(L) context free?
Are the context-free languages closed under maxstring?
Regular, Context Free or Neither?
L1 = {anbmck: m min(n, k)}.
L2 = {anbmck: n = m + k or m = n + k}.