CSCI 2670 Introduction to Theory of Computing September 15, 2004.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
CSCI 2670 Introduction to Theory of Computing October 19, 2005.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
CS5371 Theory of Computation
Homework #5 Solutions 1. True or False a) Regular Languages are always Context-Free Languages True False b) Context Free Languages are always Regular.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
1 CSC 3130: Automata theory and formal languages Tutorial 4 KN Hung Office: SHB 1026 Department of Computer Science & Engineering.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 4 Context-free grammars Jan Maluszynski, IDA, 2007
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Courtesy Costas Busch - RPI1 Non-regular languages.
1 CSCI 3130: Formal Languages and Automata Theory Tutorial 4 Hung Chun Ho Office: SHB 1026 Department of Computer Science & Engineering.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
1 Non-regular languages. 2 Regular languages Non-regular languages.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Lecture 16 Oct 18 Context-Free Languages (CFL) - basic definitions Examples.
CSCI 2670 Introduction to Theory of Computing September 21, 2005.
Tutorial CSC3130 : Formal Languages and Automata Theory Haifeng Wan ( )
CSCI 2670 Introduction to Theory of Computing September 20, 2005.
CSCI 2670 Introduction to Theory of Computing September 21, 2004.
Pushdown Automata (PDAs)
CSCI 2670 Introduction to Theory of Computing September 15, 2005.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Closure.
CSCI 2670 Introduction to Theory of Computing September 22, 2005.
CHAPTER 1 Regular Languages
Cs3102: Theory of Computation Class 8: Non-Context-Free Languages Spring 2010 University of Virginia David Evans.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CSCI 2670 Introduction to Theory of Computing October 12, 2005.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
CSCI 2670 Introduction to Theory of Computing September 23, 2004.
Introduction Finite Automata accept all regular languages and only regular languages Even very simple languages are non regular (  = {a,b}): - {a n b.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
CSCI 2670 Introduction to Theory of Computing September 14, 2005.
Transparency No. 1 Formal Language and Automata Theory Homework 5.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
1 A well-parenthesized string is a string with the same number of (‘s as )’s which has the property that every prefix of the string has at least as many.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Languages and Automata By: Mojtaba Khezrian.
CSCI 2670 Introduction to Theory of Computing September 16, 2004.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
Formal Language & Automata Theory
Standard Representations of Regular Languages
Context-Free Grammars
Context-Free Languages
فصل دوم Context-Free Languages
Elementary Questions about Regular Languages
CSCI 2670 Introduction to Theory of Computing
Pumping Lemma September 29, 2006
CS21 Decidability and Tractability
Chapter 1 Regular Language - 02
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

CSCI 2670 Introduction to Theory of Computing September 15, 2004

Agenda Yesterday –Pumping lemma review Today –Prove the pumping lemma –Introduce context-free grammars

Announcement Quiz tomorrow –CGF parse trees & interpretation –Pumping lemma

Nonregular languages There are many nonregular languages –{0 n 1 n | n  0} –{101,101001, ,…} –{w | w has the same number of 0s and 1s} All regular languages can be generated by finite automata States must be reused if the length of a string is greater than the number of states –If states are reused, there will be repetition

The pumping lemma Theorem: If A is a regular language, then there is a number p where, if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions 1.for each i  0, xy i z is in A 2.|y| > 0, and 3.|xy|  p p is called the pumping length

Proof idea Pumping length is equal to the number of states in the DFA whose language is A –p = |Q| If A accepts a word w with |w| > p, then some state must be entered twice while processing w –Pigeonhole principle

Proof idea 1.for each i  0, xy i z is in A 2.|y| > 0, and 3.|xy|  p x y z

Proof Let A be any regular language Find DFA M=(Q, , ,q 0,F) with L(M)=A Let p=|Q| Let s=s 1 s 2 s 3 …s n be any string in A with |s| = n  p –What if no such s is in A?

Proof (cont.) Let r 1, r 2, r 3, …, r n+1 be the sequence of states entered while processing s –r 1 = q 0 –r n+1  F –r i+1 =  (r i, s i )

Proof (cont.) Consider the first p+1 elements of this sequence –p+1 states must contain a repeated state Let r k be the first state to be repeated and let r t be the second occurance of this state –t  p+1

Proof (cont.) Let x=s 1 s 2 …s k-1, y=s k s k+1 …s t-1, z=s t s t+1 …s n There is an error in the proof on page 79 of Sipser (y is incorrectly defined) –x takes M from r 1 to r k –y takes M from r k to r t –z takes M from r t to r n+1, which is an accept state Since r k and r t are the same state, M must accept xy i z for any i=0, 1, 2, …

Proof (cont.) Have we satisfied the conditions of the theorem? 1.for each i  0, xy i z is in A 2.|y| > 0, and 3.|xy|  p Have we satisfied the conditions of the theorem? 1.for each i  0, xy i z is in A Yes 2.|y| > 0, and Yes since t > k and y=s k s k+1 …s t-1 3.|xy|  p Yes since t  p+1 and xy = s 1 s 2 …s t-1

Regular languages -- Summary Let R be any language. The following are equivalent 1.R is a regular language 2.R = L(M) for some finite automata M, where M is a DFA, an NFA, or a GNFA 3.R is describe by some regular expression 4.R has a pumping length of p If R can be shown not to have a finite pumping length, then R is not regular

Context-free grammars The shortcoming of finite automata is that each state has very limited meaning –You have no memory of where you’ve been – only knowledge of where you are Context-free grammars are a more powerful method of describing languages –Example: {0 n 1 n | n  0} is a CFG

Example CFG Context-free grammars use substitution to maintain knowledge S  (S) S  SS S  () All possible legal parenthesis pairings can be expressed by consecutive applications of these rules Is this a regular language?

Example S  (S) | SS | () (()())(()) S  SS  (S)(S)  (SS)(())  (()())(()) This sequence of substitutions is called a derivation

Parse tree S  (S) | SS | () S SS SS () S )( S ()

Example 2 S  Sb | Bb B  aBb | aCb C  ε Derivation for aaabbbbb S  Sb  Bbb  aaBbbbb  aaaεbbbbb  aBbbb  aaaCbbbbb

Example 2 parse tree S ε S b B b B ab B ab ba C

Example 2 S  Sb | Bb B  aBb | aCb C  ε Question 1: What language does this grammar accept? Answer: {a n b m | m > n > 0} Question 2: Can this CFG be simplified? Answer: yes. Replace B  aCb with B  ab and remove C  ε

Other languages described by CFG’s The foxtrot – A type of Tamil poetry called Venpa Ancient language of Sanscrit –

Tomorrow Formal definition for CFG Designing CFG’s