{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

l13 - Lecture 13 Context-free Grammars David Dill...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 13: Context-free Grammars. David Dill Department of Computer Science 1
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Outline Context-free grammars Derivations and parse trees ambiguity CF Pumping Lemma 2
Image of page 2
Context-Free Languages Regular languages have many wonderful properties, but not all languages are regular. Next, we’ll study a more powerful class of languages, the context-free languages . Context-free languages were identified in the 1950’s by linguist Noam Chomsky, as a natural place in a hierarchy of languages, which included the regular languages. 3
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Formal Definition of Context-Free Grammars A context-free grammar (CFG) is a 4-tuple ( V, T, P, S ) V is a finite set of non-terminal symbols , T is a finite set of variables (AKA terminal symbols ), P V × ( V T ) * is a finite set of productions , and S V is the Sentence symbol V and T must be disjoint sets. Productions are written A aBc . A is the left-hand side (LHS), also called the head , and aBc is the right-hand side (RHS), also called the body. 4
Image of page 4
Notation a, b, c, 0 , 1 , . . . are terminals A, B, S, . . . are non-terminals w, x, y, z are terminal strings ( T * ) α, β, γ are strings of terminals and/or non-terminals ( ( V T ) * ). Several productions with common heads can be combined: A a | Aa | bAb 5
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Derivations The language of a given CFG, G = ( V, T, P, S ) , can be characterized using the concept of a derivation . Def Derivation step : αAβ = αγβ whenever A γ is in P .
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern