130 likes | 443 Views
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
E N D
Context-Free Languages:Review Chapter 16
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 • mimj for some i, j} • A PDA: • A CFG: • Is L regular?
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 a matching c somewhere in w (and no b or c is considered to match more than one a)}
Is L Regular, Context Free, or Neither? L = {anbm : n + m3 2, n 1, m 1}
An Example L = {aibjck : ki or kj} Construct a context-free grammar for L.
Functions on Languages Again, let L = {aibjck : ki or kj}. Describe precisely the language L = maxstring(L), where: maxstring(L) = {x: xL and (y* (y) (xyL))} Is L = maxstring(L) context free? Are the context-free languages closed under maxstring?
Regular, Context Free or Neither? L1 = {anbmck: mmin(n, k)}. L2 = {anbmck: n = m + k or m = n + k}.