1 / 33

Erik Jonsson School of Engineering and Computer Science

Erik Jonsson School of Engineering and Computer Science. CS 4384 – 0 01. Automata Theory. http://www.utdallas.edu/~pervin. Thursday: Context-Free Languages Sections 3.1-3.3. Tuesday 2-25-14. FEARLESS Engineering. EXAMINATION ANSWERS. Regular Languages. ANSWERS.

weylin
Download Presentation

Erik Jonsson School of Engineering and Computer Science

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. Erik Jonsson School of Engineering and Computer Science CS 4384– 001 Automata Theory http://www.utdallas.edu/~pervin Thursday: Context-Free Languages Sections 3.1-3.3 Tuesday2-25-14 FEARLESS Engineering

  2. EXAMINATION ANSWERS Regular Languages ANSWERS

  3. Distinguished States

  4. Distinguished States

  5. Context-free Languages Chapter Three Tuesday 2-25

  6. A context-free grammar (CFG) G is a quadruple (V, Σ, R, S) where • V: a set of non-terminal symbols (Variables) • Σ: a set of terminals (V ∩ Σ = Ǿ) (Alphabet) • R: a set of rules (R: V → (V UΣ)*) • S: a start symbol (a variable) Definition

  7. If R: A → B, then xAyxBy and we say that xBy is derived from xAy using rule R. • If s ··· t, then we write s * t. • A string x in Σ* is generated by G=(V,Σ,R,S) if S * x. • L(G) = { x in Σ* | S * x}. How do we use rules?

  8. G = ({S}, {0,1}. {S → 0S1 | ε }, S) • ε in L(G) because S ε . • 01 in L(G) because S 0S1 01. • 0011 in L(G) because S 0S1 00S11 0011. • 0 1 in L(G) because S * 0 1 . • L(G) = {0 1 | n > 0} n n n n n n Example

  9. A context-free grammar is “context-free’’ because we can use a rule R no matter what the context. E.g., (M&S P.89, Def. 3.1.2) from the rule R: A -> w, we can derive from the string uAv in one step the string uwv, no matter what the context (that is, for any strings u and v). Context-free

  10. Palindromes

  11. Any positive even number of a’s with any number of b’s anywhere

  12. G = (V, ∑, R, E) V = {E, T, F} ∑= {x, 1, 2, +, *, (, )} R = { E -> E + T | T; T -> T * F | F; F -> (E) | x1 | x2 } Expressions, Terms, Factors Parsing Expressions

  13. Parse Tree

  14. Closure Properties

  15. For every regular language L, there exists a CFG G (in fact a Regular Grammar) such that L=L(G). Theorem

  16. For every regular language L, there exists a CFG G such that L=L(G). Proof. Let L=L(M) for a DFA M=(Q, Σ, δ, s, F). Construct a CFG G=(V, Σ, R, S) as follows. V = Q, Σ = Σ, R = { q → ap | δ(q, a) = p } U { f → ε | f in F}, S = q0. Theorem x1 xn S x1q1 x1x2q2 ··· x1…xnf x1…xn f=qn s q1

  17. Regular Grammars Note: A -> a is unnecessary

  18. What's wrong with (ab)*a*?

  19. Simplified and Normal Forms

More Related