FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Similar documents
CS 154. Finite Automata vs Regular Expressions, Non-Regular Languages

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

Lecture 4: More on Regexps, Non-Regular Languages

Intro to Theory of Computation

CS 154, Lecture 3: DFA NFA, Regular Expressions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

TDDD65 Introduction to the Theory of Computation

September 11, Second Part of Regular Expressions Equivalence with Finite Aut

Theory of Computation (II) Yijia Chen Fudan University

What we have done so far

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

acs-04: Regular Languages Regular Languages Andreas Karwath & Malte Helmert Informatik Theorie II (A) WS2009/10

Computer Sciences Department

Computational Models - Lecture 3

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

Incorrect reasoning about RL. Equivalence of NFA, DFA. Epsilon Closure. Proving equivalence. One direction is easy:

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

front pad rear pad door

Examples of Regular Expressions. Finite Automata vs. Regular Expressions. Example of Using flex. Application

Computational Models: Class 3

The Pumping Lemma and Closure Properties

Please give details of your calculation. A direct answer without explanation is not counted.

COMP4141 Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

UNIT-III REGULAR LANGUAGES

Finite Automata and Regular languages

Uses of finite automata

More Properties of Regular Languages

Theory of Computation p.1/?? Theory of Computation p.2/?? Unknown: Implicitly a Boolean variable: true if a word is

Name: Student ID: Instructions:

Applied Computer Science II Chapter 1 : Regular Languages

Computational Models Lecture 2 1

Computational Models Lecture 2 1

Formal Languages, Automata and Models of Computation

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

CS 154, Lecture 4: Limitations on DFAs (I), Pumping Lemma, Minimizing DFAs

Outline. CS21 Decidability and Tractability. Regular expressions and FA. Regular expressions and FA. Regular expressions and FA

Proving languages to be nonregular

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Automata Theory. Lecture on Discussion Course of CS120. Runzhe SJTU ACM CLASS

CSE 105 THEORY OF COMPUTATION

Computational Theory

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Exam 1 CSU 390 Theory of Computation Fall 2007

CS21 Decidability and Tractability

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Harvard CS 121 and CSCI E-207 Lecture 6: Regular Languages and Countability

CS154. Non-Regular Languages, Minimizing DFAs

Chapter 2 The Pumping Lemma

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Unit 6. Non Regular Languages The Pumping Lemma. Reading: Sipser, chapter 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Closure under the Regular Operations

Properties of Regular Languages. BBM Automata Theory and Formal Languages 1

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CS 154 NOTES CONTENTS

CSE 105 THEORY OF COMPUTATION

Automata: a short introduction

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) September,

Foundations of

Before we show how languages can be proven not regular, first, how would we show a language is regular?

10. The GNFA method is used to show that

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

CS 154 Introduction to Automata and Complexity Theory

CSE 105 THEORY OF COMPUTATION

Nondeterministic Finite Automata

Nondeterminism. September 7, Nondeterminism

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Sri vidya college of engineering and technology

Theory of Computation (I) Yijia Chen Fudan University

Computational Models - Lecture 3 1

CSE Theory of Computing: Homework 3 Regexes and DFA/NFAs

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Notes on Pumping Lemma

HKN CS/ECE 374 Midterm 1 Review. Nathan Bleier and Mahir Morshed

Automata and Formal Languages - CM0081 Finite Automata and Regular Expressions

Outline. Theorem 1. For every regular expression E, there exists an ε-nfa A such that L(E)=L(A).

Theory of Languages and Automata

Equivalence of DFAs and NFAs

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSci 311, Models of Computation Chapter 4 Properties of Regular Languages

CS 455/555: Finite automata

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Theory of Computation

Nondeterminism and Epsilon Transitions

CSE 105 THEORY OF COMPUTATION

Grade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages

Regular languages, regular expressions, & finite automata (intro) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 Theory of Computation Professor Jeanne Ferrante

Languages, regular languages, finite automata

CISC 4090 Theory of Computation

False. They are the same language.

Clarifications from last time. This Lecture. Last Lecture. CMSC 330: Organization of Programming Languages. Finite Automata.

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

Introduction to Languages and Computation

CS 133 : Automata Theory and Computability

Transcription:

15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

THE PUMPING LEMMA FOR REGULAR LANGUAGES and REGULAR EXPRESSIONS TUESDAY Jan 21

WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w has equal number of occurrences of 01 and 10 } D = { w w has equal number of 1s and 0s}

THE PUMPING LEMMA Let L be a regular language with L = Then there is a positive integer P s.t. if w L and w P then can write w = xyz, where: 1. y > 0 (y isn t ) 2. xy P 3. For every i 0, xy i z L Why is it called the pumping lemma? The word w gets PUMPED into something longer

Proof: Let M be a DFA that recognizes L Let P be the number of states in M Assume w L is such that w P We show: w = xyz 1. y > 0 2. xy P 3. xy i z L for all i 0 r 0 r j r k r w There must be j and k such that j < k P, and r j = r k (why?) (Note: k - j > 0)

Proof: Let M be a DFA that recognizes L Let P be the number of states in M Assume w L is such that w P We show: w = xyz y 1. y > 0 2. xy P 3. xy i z L for all i 0 r 0 r j = r k r w There must be j and k such that j < k P, and r j = r k

Proof: Let M be a DFA that recognizes L Let P be the number of states in M Assume w L is such that w P We show: w = xyz y 1. y > 0 2. xy P 3. xy i z L for all i 0 x z r 0 r j = r k r w There must be j and k such that j < k P, and r j = r k

USING THE PUMPING LEMMA Let s prove that B = {0 n 1 n n 0} is not regular Assume B is regular. Let w = 0 P 1 P If B is regular, can write w = xyz, y > 0, xy P, and for any i 0, xy i z is also in B y must be all 0s: Why? xy P xyyz has more 0s than 1s Contradiction!

USING THE PUMPING LEMMA D = { w w has equal number of 1s and 0s} is not regular Assume D is regular. Let w = 0 P 1 P (w is in D!) If D is regular, can write w = xyz, y > 0, xy P, where for any i 0, xy i z is also in D y must be all 0s: Why? xy P xyyz has more 0s than 1s Contradiction!

WHAT DOES D LOOK LIKE? D = { w w has equal number of occurrences of 01 and 10}

WHAT DOES C LOOK LIKE? C = { w w has equal number of occurrences of 01 and 10} = { w w = 1, w = 0, w = or w starts with a 0 and ends with a 0 or w starts with a 1 and ends with a 1 } 1 0 0(0 1)*0 1(0 1)*1

REGULAR EXPRESSIONS (expressions representing languages) σ is a regexp representing {σ} is a regexp representing {} is a regexp representing If R 1 and R 2 are regular expressions representing L 1 and L 2 then: (R 1 R 2 ) represents L 1 L 2 (R 1 R 2 ) represents L 1 L 2 (R 1 )* represents L 1 *

PRECEDENCE *

EXAMPLE R 1 *R 2 R 3 = ( ( R 1 * ) R 2 ) R 3

{ w w has exactly a single 1 } 0*10*

What language does * represent?

What language does * represent? {}

{ w w has length 3 and its 3rd symbol is 0 }

{ w w has length 3 and its 3rd symbol is 0 } (0 1)(0 1)0(0 1)*

{ w every odd position of w is a 1 }

{ w every odd position of w is a 1 } (1(0 1))*(1 )

EQUIVALENCE L can be represented by a regexp L is regular 1. L can be represented by a regexp L is regular 2. L can be represented by a regexp L is a regular language

1. Given regular expression R, we show there exists NFA N such that R represents L(N) Induction on the length of R: Base Cases (R has length 1): σ R = σ R = R =

Inductive Step: Assume R has length k > 1, and that every regular expression of length < k represents a regular language Three possibilities for R: R = R 1 R 2 R = R 1 R 2 R = (R 1 )* (Union Theorem!) (Concatenation) (Star) Therefore: L can be represented by a regexp L is regular

Give an NFA that accepts the language represented by (1(0 1))* 1 1,0

2. L can be represented by a regexp L is a regular language Proof idea: Transform an NFA for L into a regular expression by removing states and re-labeling arrows with regular expressions

NFA Add unique and distinct start and accept states While machine has more than 2 states: Pick an internal state, rip it out and re-label the arrows with regexps, to account for the missing state 0 0 1

NFA Add unique and distinct start and accept states While machine has more than 2 states: Pick an internal state, rip it out and re-label the arrows with regexps, to account for the missing state 01*0

G NFA While machine has more than 2 states: More generally: R(q 1,q 3 ) q 1 R(q 1,q 2 ) R(q 2,q 3 ) q 2 q 3 R(q 2,q 2 )

G NFA While machine has more than 2 states: More generally: R(q 1,q 2 )R(q 2,q 2 )*R(q 2,q 3 ) q 1 q 3 R(q 1,q 3 )

a a,b b q 0 q 1 q 2 q 3 R(q 0,q 3 ) = represents L(N)

a a,b b q 0 q 1 q 2 q 3 R(q 0,q 3 ) = (a*b)(a b)* represents L(N)

Formally: Add q start and q accept to create G (GNFA) Run CONVERT(G): If #states = 2 (Outputs a regexp) return the expression on the arrow going from q start to q accept

Formally: Add q start and q accept to create G (GNFA) Run CONVERT(G): (Outputs a regexp) If #states > 2 select q rip Q different from q start and q accept define Q = Q {q rip } } Defines: G (GNFA) define R as: R (q i,q j ) = R(q i,q rip )R(q rip,q rip )*R(q rip,q j ) R(q i,q j ) (R = the regexps for edges in G ) We note that G and G are equivalent return CONVERT(G )

Claim: CONVERT(G) is equivalent to G Proof by induction on k (number of states in G) Base Case: k = 2 Inductive Step: Assume claim is true for k-1 state GNFAs Recall that G and G are equivalent But, by the induction hypothesis, G is equivalent to CONVERT(G ) Thus: CONVERT(G ) equivalent to CONVERT(G) QED

b a q 1 b a q 2 b a q 3

b a q 1 b b a a q 2 q 3

bb b a q 1 b a a q 2

bb (a ba)b*a q 1 b (a ba)b* (bb (a ba)b*a)* (b (a ba)b*)

Convert the NFA to a regular expression q 1 a, b q 2 b a b b q 3

DFA NFA DEFINITION Regular Language Regular Expression

WWW.FLAC.WS Finish Chapter 1 of the book for next time