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

Similar documents
Proving languages to be nonregular

The Pumping Lemma and Closure Properties

Chapter 2 The Pumping Lemma

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

TDDD65 Introduction to the Theory of Computation

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computer Sciences Department

More on Regular Languages and Non-Regular Languages

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

Notes on Pumping Lemma

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

Finite Automata and Regular languages

We have seen many ways to specify Regular languages. Are all languages Regular languages?

Formal Languages, Automata and Models of Computation

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

Lecture 4: More on Regexps, Non-Regular Languages

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

3515ICT: Theory of Computation. Regular languages

COMP4141 Theory of Computation

UNIT-III REGULAR LANGUAGES

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

More Properties of Regular Languages

Theory of Computation (II) Yijia Chen Fudan University

Intro to Theory of Computation

CSE 105 THEORY OF COMPUTATION

Great Theoretical Ideas in Computer Science. Lecture 4: Deterministic Finite Automaton (DFA), Part 2

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

Finite Automata (contd)

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

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

Fooling Sets and. Lecture 5

CSE 105 Theory of Computation Professor Jeanne Ferrante

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

What we have done so far

How do regular expressions work? CMSC 330: Organization of Programming Languages

Context-Free Languages

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

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

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

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

Sri vidya college of engineering and technology

CSE 105 THEORY OF COMPUTATION

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

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

Context-Free Languages (Pre Lecture)

CS 455/555: Finite automata

CS500 Homework #2 Solutions

CPSC 421: Tutorial #1

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

Computability Theory

CSE 105 THEORY OF COMPUTATION

CS154. Non-Regular Languages, Minimizing DFAs

Name: Student ID: Instructions:

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

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

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

1 More finite deterministic automata

ECS120 Fall Discussion Notes. October 25, The midterm is on Thursday, November 2nd during class. (That is next week!)

V Honors Theory of Computation

1.3 Regular Expressions

Languages, regular languages, finite automata

Context Free Languages. Automata Theory and Formal Grammars: Lecture 6. Languages That Are Not Regular. Non-Regular Languages

Ogden s Lemma for CFLs

Automata: a short introduction

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Applied Computer Science II Chapter 1 : Regular Languages

CSE 105 THEORY OF COMPUTATION

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Properties of Context-Free Languages. Closure Properties Decision Properties

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

Computability and Complexity

Lecture 3: Finite Automata

Computational Models - Lecture 3

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

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

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CSCE 551 Final Exam, Spring 2004 Answer Key

NPDA, CFG equivalence

Ogden s Lemma. and Formal Languages. Automata Theory CS 573. The proof is similar but more fussy. than the proof of the PL4CFL.

Computational Models - Lecture 3 1

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2017

DM17. Beregnelighed. Jacob Aae Mikkelsen

Deterministic Finite Automata (DFAs)

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 5 : DFA minimization

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Theory of Computation

Lecture 4: Finite Automata

Lecture 3: Finite Automata

CS21 Decidability and Tractability

Final exam study sheet for CS3719 Turing machines and decidability.

GEETANJALI INSTITUTE OF TECHNICAL STUDIES, UDAIPUR I

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

Transcription:

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

Objectives Prove the Pumping Lemma, and use it to show that there are non-regular languages Introduce Regular Expression which is one way to describe a language (or a set of strings)

Non-Regular Language? To understand the power of DFA, apart from knowing what it can do, we need to know what it cannot do Let s look at the language B = {0 n 1 n n 0} If we try to find a DFA to recognize B, the DFA needs to keep track of the number of 0 s we have seen so far However, number of 0 s is unlimited there are unlimited number of possibilities So, it is NOT POSSIBLE because the DFA just has FINITE number of states!

Pumping Lemma Theorem: If A is a regular language, then there is a number p (called the pumping length) such that: if s is a string in A of length at least p, then s can be divided into three pieces, s = xyz, satisfying the following three conditions: For each k 0, xy k z2a y 0, and xy p

Pumping Lemma (Proof) Let us assign the pumping length p to be the number of states in the DFA that recognize A Consider the sequence of states that the DFA goes through when reading s = s 1 s 2 s n At the beginning, it is at state r 0 = q start Then, it goes to r 1 after reading s 1, then goes to r 2, then goes to r 3

Pumping Lemma (Proof) When it has finished reading s p, one of the state has been visited at least two times (why?) That is, r i = r j, for some 0 i j p Now, let x = s 1 s 2 s i, y = s i+1 s i+2 s j, and z = s j+1 s j+2 s n We can check that xy k z2a for all k 0 (why?) Also, y 0 and xy p (why?)

Use of Pumping Lemma (Example 1) Lemma: The language B = {0 n 1 n n 0} is not regular. How to prove? Use Pumping Lemma By contradiction Proof:Assume that B is regular. Then

Use of Pumping Lemma (Example 1) Then, let p be the pumping length We know that 0 p 1 p is in B By pumping lemma, we know that 0 p 1 p can be divided into three parts, xyz, such that y 0, xy p, and xy k z is in B for all k 0 In this case, y consists of all 0 s and at least 1 zero (why??) xyyz is in B, but xyyz has more 0 s than 1 s Contradiction occurs!

Use of Pumping Lemma (Example 2) Lemma: The language C = { w w has an equal number of 0s and 1s } is not regular. How to prove?

Use of Pumping Lemma (Example 2) Proof 1: Similar to Example 1. Let s = 0 p 1 p and apply pumping lemma. Proof 2: We use the fact: the class of regular languages is closed under intersection (will be proved in tutorial next Tue). That is, If A and B are regular languages, then A\Bis also a regular language.

Use of Pumping Lemma (Example 2: Proof 2) Let A = { 0 m 1 n m, n 0} Note that A is regular (why?) Now, assume that C is regular. Then, it implies that C\ A is regular However, C\A={0 n 1 n n 0}, which is not regular Thus, contradiction occurs (where?). So, C is not regular

Use of Pumping Lemma (Example 2) In Proof 1, we choose s = 0 p 1 p, we can apply pumping lemma successfully and prove that C is not regular However, if we unluckily choose s = (01) p, using pumping lemma may not give contradiction (E.g., x =, y = 01, z = (01) p-1, then every xy k z is in C) So, if you fail on first attempt, don t give up, try another one!

Use of Pumping Lemma (Example 3) Lemma: The language F = { ww w2 {0,1}* } is not regular. How to prove?

Use of Pumping Lemma (Example 4) Lemma: The language {1 n2 n 0} is not regular. Proof: Let p be the pumping length. Let s = 1 p2. By pumping lemma, we have xyz = p 2. Also, 0 y xy p. p 2 xyyz p 2 + p (p+1) 2 Contradiction occurs (where??)

Use of Pumping Lemma (Example 5) Lemma: The language E = { 0 i 1 j i j } is not regular. Proof: Let s = 0 p+1 1 p. By pumping lemma, we can divide s into xyz such that y consists of all 0 s and y 0. Then, xz2e but xz does not have more 0s than 1s Contradiction occurs

Regular Expression In arithmetic, we can use the operations + and x to build up expressions, such as (5+3) x 4 The value of this expression is 32 Similarly, we can use regular operations to build up regular expressions, such as (0[ 1)0* The value of this expression is a set of strings (or a language)

What does (0[1)0* mean? The symbols 0 and 1 are shorthand for the set {0} and {1} So, (0[1) means ( {0}[{1} ) 0* means {0}*, whose value is the language consisting of all strings with any number of 0s Just like x in arithmetic expression, the concatenation symbol o is often omitted So, ( 0[1)0* means ( 0[1) o 0* This expression describes the set of strings that start with a 0 or a 1, which is followed by any number of 0s

What does the following regular expressions mean? 0*10* *1 * *001 * 1*(01 + )* ( )* (0[ ) 1* 1*; Binary strings containing exactly one 1 Any strings containing 1 Any strings containing 001 Binary strings with 1 following each 0 Any strings with even length 01*[ 1* Empty set (no strings) Note: The notation R + means RR*

Next time Formally define regular expression We will also show that (1) Language recognized by DFA can be described by Regular Expression (2) Language described by Regular Expression can be recognized by DFA