1 / 12

Context-Free Languages: Review

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

Télécharger la présentation

Context-Free Languages: Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Context-Free Languages:Review Chapter 16

  2. Languages and Machines

  3. 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

  4. Example • {bam1bam2bam3… bamn : n 2, m1, m2, …, mn 0, and • mimj for some i, j} • A PDA: • A CFG: • Is L regular?

  5. L = {aibj: j = 4i + 2}

  6. 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.

  7. Is L Regular, Context Free, or Neither? L = {w {0, 1}* : k (w is a binary encoding, leading zeros allowed, of 2k+1)}

  8. 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)}

  9. Is L Regular, Context Free, or Neither? L = {anbm : n + m3 2, n 1, m 1}

  10. An Example L = {aibjck : ki or kj} Construct a context-free grammar for L.

  11. 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?

  12. Regular, Context Free or Neither? L1 = {anbmck: mmin(n, k)}. L2 = {anbmck: n = m + k or m = n + k}.

More Related