1 / 12

Midterm 1 Breakdown

Midterm 1 Breakdown. >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7. Project 1. CS 3240: Languages and Computation. Context-Free Languages. What are Grammars?. A grammar G is defined by (V, T , P, S), where V is a finite set of variables

duer
Download Presentation

Midterm 1 Breakdown

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. Midterm 1 Breakdown >79 3 >29 7 >69 5 >19 5 >59 7 >49 9 >39 7

  2. Project 1

  3. CS 3240: Languages and Computation Context-Free Languages

  4. What are Grammars? • A grammar G is defined by (V, T, P, S), where • V is a finite set of variables • Tis a finite set of terminal symbols • P is a finite set of productions or ules • SV is the special start variable • Each grammar G defines a language L(G), which is the set of strings in T* (=Σ*) that G can generate from S. • Automata are actuated by the transition table, grammars by the production rules.

  5. Context-Free Grammars • A context-free grammar (V, T, P, S) is a grammar where all production rules are of the form: A → x, with AV and x(VT)*A string in (VT)* is called sentential form • E.g., let G = ({S}, {a,b}, P , S) with for P: • S→aSa • S→bSb • S→. • Some derivations from this grammar: • S  aSa  aaSaa  aabSbaa  aabbaa • S  bSb  baSab  baab, and so on. • In general S …. wwR for w{a,b}*.

  6. Beyond regular Languages

  7. Formal definition of CF Grammar & Language

  8. Another CFG Example Consider the CFG G=({S,Z},{0,1}, P, S) with P: S  0S1 | 0Z1 Z 0Z |  What is the language generated by this G? Answer: L(G) = {0i1j | ij } Specifically, S yields the 0j+k1j according to:S  0S1  …  0jS1j  0jZ1j  0j0Z1j …  0j+kZ1j  0j+kε1j = 0j+k1j

  9. Exercise • Design CFGs for the following languages: • { 0n1n : n≥0} • { 0n1m : n,m≥0} • { (0|1)* : # of 0s > # of 1s} • Answers: • S → 0S1 |  • S → 0S | R and R → 1R |  • S → T0T and T → TT | 0T1 | 1T0 | 0 | 

  10. derivations

  11. Leftmost righmost

  12. Sentential forms

More Related