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

Similar documents
CS21 Decidability and Tractability

TDDD65 Introduction to the Theory of Computation

Theory of Computation (II) Yijia Chen Fudan University

CS 154, Lecture 3: DFA NFA, Regular Expressions

CS21 Decidability and Tractability

What we have done so far

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

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

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

Finite Automata and Regular languages

CS 154. Finite Automata, Nondeterminism, Regular Expressions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

V Honors Theory of Computation

Theory of Languages and Automata

CS 455/555: Finite automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

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

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

Computational Models: Class 3

Computability and Complexity

CSE 105 THEORY OF COMPUTATION

Closure under the Regular Operations

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

Chapter Five: Nondeterministic Finite Automata

Nondeterministic Finite Automata

Theory of Computation (I) Yijia Chen Fudan University

Computational Theory

Computational Models - Lecture 3

CS21 Decidability and Tractability

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

Nondeterministic Finite Automata

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

Lecture 4: More on Regexps, Non-Regular Languages

CSE 105 THEORY OF COMPUTATION

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

Computer Sciences Department

COM364 Automata Theory Lecture Note 2 - Nondeterminism

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

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

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

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

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

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

10. The GNFA method is used to show that

Applied Computer Science II Chapter 1 : Regular Languages

Name: Student ID: Instructions:

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

CSCE 551 Final Exam, Spring 2004 Answer Key

CSE 105 THEORY OF COMPUTATION

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

Lecture 4: Finite Automata

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

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Formal Languages, Automata and Models of Computation

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

(Refer Slide Time: 0:21)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Fooling Sets and. Lecture 5

Intro to Theory of Computation

Automata: a short introduction

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

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

Lecture 3: Finite Automata

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

CS154. Non-Regular Languages, Minimizing DFAs

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Lecture 3: Nondeterministic Finite Automata

Lecture 17: Language Recognition

Computational Models Lecture 2 1

CHAPTER 1 Regular Languages. Contents

Lecture 3: Finite Automata

Proofs, Strings, and Finite Automata. CS154 Chris Pollett Feb 5, 2007.

Non-deterministic Finite Automata (NFAs)

CISC 4090 Theory of Computation

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Theory of computation: initial remarks (Chapter 11)

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

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

CPSC 421: Tutorial #1

Automata and Computability. Solutions to Exercises

Nondeterminism. September 7, Nondeterminism

Practice Final Solutions

Theory of computation: initial remarks (Chapter 11)

Examples from Elements of Theory of Computation. Abstract. Introduction

Intro to Theory of Computation

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata (cont )

Computational Models Lecture 2 1

CSE 105 THEORY OF COMPUTATION

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

CSE 105 THEORY OF COMPUTATION

September 7, Formal Definition of a Nondeterministic Finite Automaton

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

CSE 105 THEORY OF COMPUTATION

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

Transcription:

Outline CS21 Decidability and Tractability Lecture 4 January 14, 2019 FA and Regular Exressions Non-regular languages: Puming Lemma Pushdown Automata Context-Free Grammars and Languages January 14, 2019 CS21 Lecture 4 1 January 14, 2019 CS21 Lecture 4 2 Theorem: a language L is recognized by a FA if and only if L is described by a regular exression. Must rove two directions: ( ) L is recognized by a FA imlies L is described by a regular exression ( ) L is described by a regular exression imlies L is recognized by a FA. ( ) L is recognized by a FA imlies L is described by a regular exression Proof: given FA M that recognizes L, we will 1. build an equivalent machine Generalized Nondeterministic Finite Automaton (GNFA) 2. convert the GNFA into a regular exression January 14, 2019 CS21 Lecture 4 3 January 14, 2019 CS21 Lecture 4 4 GNFA definition: it is a NFA, but may have regular exressions labeling its transitions GNFA accets string w Σ* if can be written w = w 1 w 2 w 3 w k where each w i Σ*, and there is a ath from the start state to an accet state in which the i th transition traversed is labeled with R for which w i L(R) Recall ste 1: build an equivalent GNFA Our FA M is a GNFA. We will require normal form for GNFA to make the roof easier: single accet state q accet that has all ossible incoming arrows every state has all ossible outgoing arrows; excetion: start state q 0 has no self-loo January 14, 2019 CS21 Lecture 4 5 January 14, 2019 CS21 Lecture 4 6 1

converting our FA M into GNFA in normal form: On to ste 2: convert the GNFA into a regular exression 0 0,11 ε if normal-form GNFA has two states: ε R M ε the regular exression R labeling the single transition describes the language recognized by the GNFA January 14, 2019 CS21 Lecture 4 7 January 14, 2019 CS21 Lecture 4 8 if GNFA has more than 2 states: how to reair the transitions: for every air of states q i and q j do q i R 4 q j (R 1 )(R 2 )*(R 3 ) (R 4 ) select one ; delete it; reair transitions so that machine still recognizes same language. reeat until only 2 states. R 1 q i q j R 2 R 3 January 14, 2019 CS21 Lecture 4 9 January 14, 2019 CS21 Lecture 4 10 summary: FA M k-state GNFA (k-1)-state GNFA (k-2)-state GNFA 2-state GNFA R want to rove that this rocedure is correct, i.e. L(R) = language recognized by M FA M equivalent to k-state GNFA i-state GNFA equivalent to (i-1)-state GNFA (we will rove ) 2-state GFNA equivalent to R Claim: i-state GNFA G equivalent to (i-1)- state GNFA G (obtained by removing ) Proof: if G accets string w, then it does so by entering states: q 0, q 1, q 2, q 3,, q accet if none are then G accets w (see slide) else, break state sequence into runs of : q 0 q 1 q i q j q accet transition from q i to q j in G allows all strings taking G from q i to q j using (see slide) thus G accets w January 14, 2019 CS21 Lecture 4 11 January 14, 2019 CS21 Lecture 4 12 2

q i R 4 q j (R 1 )(R 2 )*(R 3 ) (R 4 ) q i R 4 q j (R 1 )(R 2 )*(R 3 ) (R 4 ) R 1 R 3 q i q j R 1 R 3 q i q j R 2 R 2 January 14, 2019 CS21 Lecture 4 13 January 14, 2019 CS21 Lecture 4 14 Proof (continued): if G accets string w, then every transition from q i to q j traversed in G corresonds to either a transition from q i to q j in G or transitions from q i to q j via in G In both cases G accets w. Conclude: G and G recognize the same language. January 14, 2019 CS21 Lecture 4 15 Theorem: a language L is recognized by a FA iff L is described by a regular exr. Languages recognized by a FA are called regular languages. Rehrasing what we know so far: regular languages closed under 3 oerations NFA recognize exactly the regular languages regular exressions describe exactly the regular languages January 14, 2019 CS21 Lecture 4 16 Limits on the ower of FA Is every language describable by a sufficiently comlex regular exression? If someone asks you to design a FA for a language that seems hard, how do you know when to give u? Is this language regular? {w : w has an equal # of 01 and 10 substrings} January 14, 2019 CS21 Lecture 4 17 Limits on the ower of FA Intuition: FA can only remember finite amount of information. They cannot count languages that entail counting should be non-regular Intuition not enough: {w : w has an equal # of 01 and 10 substrings} = 0Σ*0 1Σ*1 but {w: w has an equal # of 0 and 1 substrings} is not regular! January 14, 2019 CS21 Lecture 4 18 3

Limits on the ower of FA How do you rove that there is no Finite Automaton recognizing a given language? Non-regular languages Puming Lemma: Let L be a regular language. There exists an integer ( uming length ) for which every w L with w can be written as w = xyz such that 1. for every i 0, xy i z L, and 2. y > 0, and 3. xy. January 14, 2019 CS21 Lecture 4 19 January 14, 2019 CS21 Lecture 4 20 Non-regular languages Using the Puming Lemma to rove L is not regular: assume L is regular then there exists a uming length select a string w L of length at least argue that for every way of writing w = xyz that satisfies (2) and (3) of the Lemma, uming on y yields a string not in L. contradiction. January 14, 2019 CS21 Lecture 4 21 Theorem: L = {0 n 1 n : n 0} is not regular. Proof: let be the uming length for L choose w = 0 1 w = xyz, with y > 0 and xy. January 14, 2019 CS21 Lecture 4 22 3 ossibilities: in each case, uming on y gives a string not in language L. Theorem: L = {w: w has an equal # of 0s and 1s} is not regular. Proof: let be the uming length for L choose w = 0 1 w = xyz, with y > 0 and xy. January 14, 2019 CS21 Lecture 4 23 January 14, 2019 CS21 Lecture 4 24 4

3 ossibilities: first 2 cases, uming on y gives a string not in language L; 3 rd case a roblem! recall condition 3: xy since w = 0 1 we know more about how it can be divided, and this case cannot arise: so we do get a contradiction. conclude that L is not regular. January 14, 2019 CS21 Lecture 4 25 January 14, 2019 CS21 Lecture 4 26 Theorem: L = {0 i 1 j : i > j} is not regular. Proof: let be the uming length for L choose w = 0 +1 1 w = 000000000 01111111 1 +1 w = xyz, with y > 0 and xy. 1 ossibility: uming on y gives strings in the language (?) this seems like a roblem Lemma states that for every i 0, xy i z L xy 0 z not in L. So L not regular. January 14, 2019 CS21 Lecture 4 27 January 14, 2019 CS21 Lecture 4 28 Proof of the Puming Lemma Let M be a FA that recognizes L. Set = number of states of M. Consider w L with w. On inut w, M must go through at least +1 states. There must be a reeated state (among first +1). x y January 14, 2019 CS21 Lecture 4 29 z M FA Summary A roblem is a language A comutation receives an inut and either accets, rejects, or loos forever. A comutation recognizes a language (it may also decide the language). Finite Automata erform simle comutations that read the inut from left to right and emloy a finite memory. January 14, 2019 CS21 Lecture 4 30 5

FA Summary The languages recognized by FA are the regular languages. The regular languages are closed under union, concatenation, and star. Nondeterministic Finite Automata may have several choices at each ste. NFAs recognize exactly the same languages that FAs do. FA Summary Regular exressions are languages built u from the oerations union, concatenation, and star. Regular exressions describe exactly the same languages that FAs (and NFAs) recognize. Some languages are not regular. This can be roved using the Puming Lemma. January 14, 2019 CS21 Lecture 4 31 January 14, 2019 CS21 Lecture 4 32 6