Context-Free Languages

Slides:



Advertisements
Similar presentations
Theory of Computation CS3102 – Spring 2014 A tale of computers, math, problem solving, life, love and tragic death Nathan Brunelle Department of Computer.
Advertisements

Erik Jonsson School of Engineering and Computer Science FEARLESS Engineering CS 4384 – 001 Automata Theory Thursday: Context-Free.
Pushdown Automata Section 2.2 CSC 4170 Theory of Computation.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
CS21 Decidability and Tractability
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture5: Context Free Languages Prof. Amos Israeli.
CS 310 – Fall 2006 Pacific University CS310 Pushdown Automata Sections: 2.2 page 109 October 9, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
Today Chapter 2: (Pushdown automata) Non-CF languages CFL pumping lemma Closure properties of CFL.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
Final Exam Review Cummulative Chapters 0, 1, 2, 3, 4, 5 and 7.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
CSCI 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 2 Context-Free Languages Some slides are in courtesy.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Pushdown.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
CSCI 2670 Introduction to Theory of Computing September 22, 2004.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Context-Free Grammars: an overview
Formal Language & Automata Theory
G. Pullaiah College of Engineering and Technology
Deterministic FA/ PDA Sequential Machine Theory Prof. K. J. Hintz
Context free grammar.
CSE 105 theory of computation
Theory of Computation Lecture #27-28.
AUTOMATA THEORY VI.
Lecture 17 Oct 25, 2011 Section 2.1 (push-down automata)
PARSE TREES.
Context Free Languages
Non-Context-Free Languages
Context-free Languages
CSE 105 theory of computation
CHAPTER 2 Context-Free Languages
Context-Free Grammars
فصل دوم Context-Free Languages
Pushdown automata a_introduction.htm.
CS21 Decidability and Tractability
Context-Free Languages
Chapter 2 Context-Free Language - 01
Decidability and Tractability
… NPDAs continued.
CSE 105 theory of computation
Pushdown automata The Chinese University of Hong Kong Fall 2011
Context-Free Grammars
CSE 105 theory of computation
Presentation transcript:

Context-Free Languages Giorgi Japaridze Theory of Computability Context-Free Languages Chapter 2

A  B A   B  0A1 Terminals: 0,1 Variables: A,B Productions: What is a CFG 2.1.a Giorgi Japaridze Theory of Computability A  B A   B  0A1 Terminals: 0,1 Variables: A,B Productions: Start variable: A Derivation: A  B  0A1  0B1  00A11  0011 A B Parse tree: 0 1 A B 0 1 A 

Our grammar simplified 2.1.b Giorgi Japaridze Theory of Computability A  0A1 A   A  0A1  00A11  000A111  0000A1111  00001111 What language does this grammar produce?

N  men | women | children V  like | hate | respect A more complex CFG 2.1.c Giorgi Japaridze Theory of Computability S  N’_V_N’ N’  N | N_who_V_N’ N  men | women | children V  like | hate | respect S N’ _ V _ N’ N respect N _ who _ V _ N’ children men hate N women

A context-free grammar is a 4-tuple (V,,R,S), where Formal definitions 2.1.d Giorgi Japaridze Theory of Computability A context-free grammar is a 4-tuple (V,,R,S), where 1. V is a finite set called the variables; 2.  is a finite set, disjoint from V, called the terminals; 3. R is a finite set of rules, with each rule being a pair of a variable and a string of variables and terminals; 4. S is an element of V called the start variable. If u,v, and w are strings of variables and terminals and Aw is a rule, we say that uAv yields uwv, written uAv  uwv. x * y means that x=y, or x y, or there are z1,…,zn such that x z1 … zn y. The language produced (defined, described) by the grammar is {w | S * w and w is a string of (only) terminals}. A context-free language is a language produced by some CFG.

Designing context-free grammars Giorgi Japaridze Theory of Computability Design a CFG that produces all regular expressions over the alphabet {0,1}: <RE>  Design a CFG G that produces the union of the languages produced by two given CFGs G1 and G2. G1: A1  w1 … An  wn G2: B1  u1 … Bm  um

Context free versus regular languages Giorgi Japaridze Theory of Computability Theorem. Every regular language is context-free, but not every context-free language is regular. Proof – omitted. Context-free languages Regular languages {0n1n | n0}

languages correspond pushdown automata. 2.2 Giorgi Japaridze Theory of Computability Just as to regular languages correspond finite automata, to context-free languages correspond pushdown automata. This is a new model of computation. What makes a PDA different from NFA is that it has potentially infinite, stack-type (LIFO) memory, where unlimited number of things can be remembered (pushed) and read (popped). A given transition depends on not only the current symbol in the input, but also the symbol currently at the top of the stack. PDAs are still not the most powerful machines. This is because of their limited (LIFO) access to memory. We omit the topic of pushdown automata.

Non-context-free languages Giorgi Japaridze Theory of Computability Just as for regular languages, there is a pumping lemma for context-free languages, used as a tool for proving that a given language is not context-free. We omit this topic, but just remember the following examples of simple NON-CONTEXT-FREE LANGUAGES: {anbncn | n0} {ww | w*} (as long as the alphabet  has at least two symbols)

Regular vs context-free vs computer-recognizable languages Giorgi Japaridze Theory of Computability Computer-recognizable languages Context-free languages Regular languages {anbn | n0} {anbncn | n0}