NFAs continued, Closure Properties of Regular Languages

Similar documents
NFAs continued, Closure Properties of Regular Languages

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Non-deterministic Finite Automata

Finite-State Automata: Recap

Non-deterministic Finite Automata

Deterministic Finite Automata

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

CHAPTER 1 Regular Languages. Contents

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Finite Automata-cont d

Fundamentals of Computer Science

Homework 3 Solutions

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Lecture 08: Feb. 08, 2019

CMSC 330: Organization of Programming Languages

Lecture 09: Myhill-Nerode Theorem

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

CISC 4090 Theory of Computation

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

Harvard University Computer Science 121 Midterm October 23, 2012

Regular expressions, Finite Automata, transition graphs are all the same!!

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

Nondeterminism and Nodeterministic Automata

In-depth introduction to main models, concepts of theory of computation:

Formal Language and Automata Theory (CS21004)

Convert the NFA into DFA

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Some Theory of Computation Exercises Week 1

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

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

Formal Languages and Automata

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Minimal DFA. minimal DFA for L starting from any other

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

Lexical Analysis Finite Automate

1 From NFA to regular expression

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Designing finite automata II

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014

3 Regular expressions

Java II Finite Automata I

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

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

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

State Minimization for DFAs

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

More on automata. Michael George. March 24 April 7, 2014

Let's start with an example:

1 Nondeterministic Finite Automata

Chapter 2 Finite Automata

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

Thoery of Automata CS402

FABER Formal Languages, Automata and Models of Computation

Lexical Analysis Part III

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

Name Ima Sample ASU ID

CS375: Logic and Theory of Computing

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

Languages & Automata

ɛ-closure, Kleene s Theorem,

Formal languages, automata, and theory of computation

1.4 Nonregular Languages

Closure Properties of Regular Languages

CS 330 Formal Methods and Models

Lecture 6 Regular Grammars

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

First Midterm Examination

GNFA GNFA GNFA GNFA GNFA

Tutorial Automata and formal Languages

Closure Properties of Regular Languages

Lecture 9: LTL and Büchi Automata

Worked out examples Finite Automata

Deterministic Finite-State Automata

Regular Languages and Applications

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Coalgebra, Lecture 15: Equations for Deterministic Automata

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Today s Topics Automata and Languages

Transcription:

Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31

Regulr Lnguges, DFAs, NFAs Theorem Lnguges ccepted y DFAs, NFAs, nd regulr expressions re the sme. DFAs re specil cses of NFAs (trivil) NFAs ccept regulr expressions (we sw lredy) DFAs ccept lnguges ccepted y NFAs (tody) Regulr expressions for lnguges ccepted y DFAs (lter in the course) Sriel Hr-Peled (UIUC) CS374 2 Fll 2017 2 / 31

Regulr Lnguges, DFAs, NFAs Theorem Lnguges ccepted y DFAs, NFAs, nd regulr expressions re the sme. DFAs re specil cses of NFAs (trivil) NFAs ccept regulr expressions (we sw lredy) DFAs ccept lnguges ccepted y NFAs (tody) Regulr expressions for lnguges ccepted y DFAs (lter in the course) Sriel Hr-Peled (UIUC) CS374 2 Fll 2017 2 / 31

Prt I Equivlence of NFAs nd DFAs Sriel Hr-Peled (UIUC) CS374 3 Fll 2017 3 / 31

Equivlence of NFAs nd DFAs Theorem For every NFA N there is DFA M such tht L(M) = L(N). Sriel Hr-Peled (UIUC) CS374 4 Fll 2017 4 / 31

Forml Tuple Nottion for NFA Definition A non-deterministic finite utomt (NFA) N = (Q, Σ, δ, s, A) is five tuple where Q is finite set whose elements re clled sttes, Σ is finite set clled the input lphet, δ : Q Σ {ɛ} P(Q) is the trnsition function (here P(Q) is the power set of Q), s Q is the strt stte, A Q is the set of ccepting/finl sttes. δ(q, ) for Σ {ɛ} is suset of Q set of sttes. Sriel Hr-Peled (UIUC) CS374 5 Fll 2017 5 / 31

Extending the trnsition function to strings Definition For NFA N = (Q, Σ, δ, s, A) nd q Q the ɛrech(q) is the set of ll sttes tht q cn rech using only ɛ-trnsitions. Definition Inductive definition of δ : Q Σ P(Q): if w = ɛ, δ (q, w) = ɛrech(q) if w = where Σ δ (q, ) = p ɛrech(q) ( r δ(p,) ɛrech(r)) if w = x, δ (q, w) = p δ (q,x)( r δ(p,) ɛrech(r)) Sriel Hr-Peled (UIUC) CS374 6 Fll 2017 6 / 31

Forml definition of lnguge ccepted y N Definition A string w is ccepted y NFA N if δ N (s, w) A. Definition The lnguge L(N) ccepted y NFA N = (Q, Σ, δ, s, A) is {w Σ δ (s, w) A }. Sriel Hr-Peled (UIUC) CS374 7 Fll 2017 7 / 31

Simulting n NFA y DFA Think of progrm with fixed memory tht needs to simulte NFA N on input w. Wht does it need to store fter seeing prefix x of w? It needs to know t lest δ (s, x), the set of sttes tht N could e in fter reding x Is it sufficient? Yes, if it cn compute δ (s, x) fter seeing nother symol in the input. When should the progrm ccept string w? If δ (s, w) A. Key Oservtion: A DFA M tht simultes N should keep in its memory/stte the set of sttes of N Thus the stte spce of the DFA should e P(Q). Sriel Hr-Peled (UIUC) CS374 8 Fll 2017 8 / 31

Simulting n NFA y DFA Think of progrm with fixed memory tht needs to simulte NFA N on input w. Wht does it need to store fter seeing prefix x of w? It needs to know t lest δ (s, x), the set of sttes tht N could e in fter reding x Is it sufficient? Yes, if it cn compute δ (s, x) fter seeing nother symol in the input. When should the progrm ccept string w? If δ (s, w) A. Key Oservtion: A DFA M tht simultes N should keep in its memory/stte the set of sttes of N Thus the stte spce of the DFA should e P(Q). Sriel Hr-Peled (UIUC) CS374 8 Fll 2017 8 / 31

Simulting n NFA y DFA Think of progrm with fixed memory tht needs to simulte NFA N on input w. Wht does it need to store fter seeing prefix x of w? It needs to know t lest δ (s, x), the set of sttes tht N could e in fter reding x Is it sufficient? Yes, if it cn compute δ (s, x) fter seeing nother symol in the input. When should the progrm ccept string w? If δ (s, w) A. Key Oservtion: A DFA M tht simultes N should keep in its memory/stte the set of sttes of N Thus the stte spce of the DFA should e P(Q). Sriel Hr-Peled (UIUC) CS374 8 Fll 2017 8 / 31

Simulting n NFA y DFA Think of progrm with fixed memory tht needs to simulte NFA N on input w. Wht does it need to store fter seeing prefix x of w? It needs to know t lest δ (s, x), the set of sttes tht N could e in fter reding x Is it sufficient? Yes, if it cn compute δ (s, x) fter seeing nother symol in the input. When should the progrm ccept string w? If δ (s, w) A. Key Oservtion: A DFA M tht simultes N should keep in its memory/stte the set of sttes of N Thus the stte spce of the DFA should e P(Q). Sriel Hr-Peled (UIUC) CS374 8 Fll 2017 8 / 31

Simulting NFA Exmple the first revisited Previous lecture.. Rn NFA (N1) A B C D E on input. t = 0: t = 1: A B C D E t = 2: A B C D E t = 4: t = 5: A B C D E A B C D E t = 3: A B C D E A B C D E Sriel Hr-Peled (UIUC) CS374 9 Fll 2017 9 / 31

Exmple: DFA from NFA NFA: (N1) A B C D E DFA: A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E A B C D E Sriel Hr-Peled (UIUC) CS374 10 Fll 2017 10 / 31

Suset Construction NFA N = (Q, Σ, s, δ, A). We crete DFA M = (Q, Σ, δ, s, A ) s follows: Q = P(Q) s = ɛrech(s) = δ (s, ɛ) A = {X Q X A } δ (X, ) = q X δ (q, ) for ech X Q, Σ. Sriel Hr-Peled (UIUC) CS374 11 Fll 2017 11 / 31

Suset Construction NFA N = (Q, Σ, s, δ, A). We crete DFA M = (Q, Σ, δ, s, A ) s follows: Q = P(Q) s = ɛrech(s) = δ (s, ɛ) A = {X Q X A } δ (X, ) = q X δ (q, ) for ech X Q, Σ. Sriel Hr-Peled (UIUC) CS374 11 Fll 2017 11 / 31

Suset Construction NFA N = (Q, Σ, s, δ, A). We crete DFA M = (Q, Σ, δ, s, A ) s follows: Q = P(Q) s = ɛrech(s) = δ (s, ɛ) A = {X Q X A } δ (X, ) = q X δ (q, ) for ech X Q, Σ. Sriel Hr-Peled (UIUC) CS374 11 Fll 2017 11 / 31

Suset Construction NFA N = (Q, Σ, s, δ, A). We crete DFA M = (Q, Σ, δ, s, A ) s follows: Q = P(Q) s = ɛrech(s) = δ (s, ɛ) A = {X Q X A } δ (X, ) = q X δ (q, ) for ech X Q, Σ. Sriel Hr-Peled (UIUC) CS374 11 Fll 2017 11 / 31

Exmple No ɛ-trnsitions 0, 1 0, 1 q 0 1 q 1 0, 1 0, 1 {q 1 } {} 0 0, 1 {q 0 } 1 {q 0,q 1 } Figure 4: NFA N Figure 5: DFA det(n) equivlent to N l now prove tht the DFA defined ove is correct. Tht is. L(N) =L(det(N)) d to show 8w 2. det(n) ccepts w i N ccepts w 8w 2. det(n) (s 0,w) 2 A 0 i N (s, w) \ A 6= ; 8w 2. det(n) (s 0,w) \ A 6= ; i N (s, w) \ A 6= ; the induction proof to go through we need to strengthen the clim s follows. 8w 2. det(n) (s0,w)= N (s, w) ords, this sys tht the stte of the DFA fter reding some string is exctly the set of sttes the e in fter reding the sme string. oof of the strengthened sttement is y induction on w. Sriel Hr-Peled (UIUC) CS374 12 Fll 2017 12 / 31

Exmple s 0 = N (s, ) A 0 = {X Q X \ A 6= ;} 0 ({q 1,q 2,...q k},)= N (q1,) [ N (q2,) [ [ N (qk,) or more concisely, 0 (X, ) = [ N (q, ) No ɛ-trnsitions An exmple NFA is shown in Figure 4 long with the DFA det(n) in Figure 5. q2x 0, 1 0, 1 {q 1} {} 0, 1 0, 1 q 0 1 q 1 0 0, 1 {q 0} 1 {q 0,q 1} Figure 4: NFA N Figure 5: DFA det(n) equivlent to N We will now prove tht the DFA defined ove is correct. Tht is Lemm 4. L(N) =L(det(N)) Proof. Need to show 8w 2. det(n) ccepts w i N ccepts w 8w 2. det(n) (s 0,w) 2 A 0 i N (s, w) \ A 6= ; 8w 2. det(n) (s 0,w) \ A 6= ; i N (s, w) \ A 6= ; Agin for the induction proof to go through we need to strengthen the clim s follows. 8w 2. det(n) (s0,w)= N (s, w) SrielIn Hr-Peled other words, (UIUC) this sys tht the stte of thecs374 DFA fter reding13 some string is exctly the set of sttes Fll the2017 13 / 31

Incrementl construction Only uild sttes rechle from s = ɛrech(s) the strt stte of M ε q 1 0 q 0 1 ε q 3 {q 0, q 1} 1 0 {q 2,q 3} 0, 1 0, 1 0, 1 {} q 2 {q 3} δ (X, ) = q X δ (q, ) Sriel Hr-Peled (UIUC) CS374 14 Fll 2017 14 / 31

Incrementl lgorithm Build M eginning with strt stte s == ɛrech(s) For ech existing stte X Q consider ech Σ nd clculte the stte Y = δ (X, ) = q X δ (q, ) nd dd trnsition. If Y is new stte dd it to rechle sttes tht need to explored. To compute δ (q, ) - set of ll sttes reched from q on string Compute X = ɛrech(q) Compute Y = p X δ(p, ) Compute Z = ɛrech(y ) = r Y ɛrech(r) Sriel Hr-Peled (UIUC) CS374 15 Fll 2017 15 / 31

Proof of Correctness Theorem Let N = (Q, Σ, s, δ, A) e NFA nd let M = (Q, Σ, δ, s, A ) e DFA constructed from N vi the suset construction. Then L(N) = L(M). Stronger clim: Lemm For every string w, δ N (s, w) = δ M (s, w). Proof y induction on w. Bse cse: w = ɛ. δ N (s, ɛ) = ɛrech(s). δ M (s, ɛ) = s = ɛrech(s) y definition of s. Sriel Hr-Peled (UIUC) CS374 16 Fll 2017 16 / 31

Proof of Correctness Theorem Let N = (Q, Σ, s, δ, A) e NFA nd let M = (Q, Σ, δ, s, A ) e DFA constructed from N vi the suset construction. Then L(N) = L(M). Stronger clim: Lemm For every string w, δ N (s, w) = δ M (s, w). Proof y induction on w. Bse cse: w = ɛ. δ N (s, ɛ) = ɛrech(s). δ M (s, ɛ) = s = ɛrech(s) y definition of s. Sriel Hr-Peled (UIUC) CS374 16 Fll 2017 16 / 31

Proof continued Lemm For every string w, δ N (s, w) = δ M (s, w). Inductive step: w = x (Note: suffix definition of strings) δ N (s, x) = p δ N (s,x) δ N (p, ) y inductive definition of δ N δ M (s, x) = δ M (δ M (s, x), ) y inductive definition of δ M By inductive hypothesis: Y = δ N (s, x) = δ M (s, x) Thus δ N (s, x) = p Y δ N (p, ) = δ M(Y, ) y definition of δ M. Therefore, δ N (s, x) = δ M(Y, ) = δ M (δ M (s, x), ) = δ M (s, x) which is wht we need. Sriel Hr-Peled (UIUC) CS374 17 Fll 2017 17 / 31

Proof continued Lemm For every string w, δ N (s, w) = δ M (s, w). Inductive step: w = x (Note: suffix definition of strings) δ N (s, x) = p δ N (s,x) δ N (p, ) y inductive definition of δ N δ M (s, x) = δ M (δ M (s, x), ) y inductive definition of δ M By inductive hypothesis: Y = δ N (s, x) = δ M (s, x) Thus δ N (s, x) = p Y δ N (p, ) = δ M(Y, ) y definition of δ M. Therefore, δ N (s, x) = δ M(Y, ) = δ M (δ M (s, x), ) = δ M (s, x) which is wht we need. Sriel Hr-Peled (UIUC) CS374 17 Fll 2017 17 / 31

Proof continued Lemm For every string w, δ N (s, w) = δ M (s, w). Inductive step: w = x (Note: suffix definition of strings) δ N (s, x) = p δ N (s,x) δ N (p, ) y inductive definition of δ N δ M (s, x) = δ M (δ M (s, x), ) y inductive definition of δ M By inductive hypothesis: Y = δ N (s, x) = δ M (s, x) Thus δ N (s, x) = p Y δ N (p, ) = δ M(Y, ) y definition of δ M. Therefore, δ N (s, x) = δ M(Y, ) = δ M (δ M (s, x), ) = δ M (s, x) which is wht we need. Sriel Hr-Peled (UIUC) CS374 17 Fll 2017 17 / 31

Proof continued Lemm For every string w, δ N (s, w) = δ M (s, w). Inductive step: w = x (Note: suffix definition of strings) δ N (s, x) = p δ N (s,x) δ N (p, ) y inductive definition of δ N δ M (s, x) = δ M (δ M (s, x), ) y inductive definition of δ M By inductive hypothesis: Y = δ N (s, x) = δ M (s, x) Thus δ N (s, x) = p Y δ N (p, ) = δ M(Y, ) y definition of δ M. Therefore, δ N (s, x) = δ M(Y, ) = δ M (δ M (s, x), ) = δ M (s, x) which is wht we need. Sriel Hr-Peled (UIUC) CS374 17 Fll 2017 17 / 31

Proof continued Lemm For every string w, δ N (s, w) = δ M (s, w). Inductive step: w = x (Note: suffix definition of strings) δ N (s, x) = p δ N (s,x) δ N (p, ) y inductive definition of δ N δ M (s, x) = δ M (δ M (s, x), ) y inductive definition of δ M By inductive hypothesis: Y = δ N (s, x) = δ M (s, x) Thus δ N (s, x) = p Y δ N (p, ) = δ M(Y, ) y definition of δ M. Therefore, δ N (s, x) = δ M(Y, ) = δ M (δ M (s, x), ) = δ M (s, x) which is wht we need. Sriel Hr-Peled (UIUC) CS374 17 Fll 2017 17 / 31

Prt II Closure Properties of Regulr Lnguges Sriel Hr-Peled (UIUC) CS374 18 Fll 2017 18 / 31

Regulr Lnguges Regulr lnguges hve three different chrcteriztions Inductive definition vi se cses nd closure under union, conctention nd Kleene str Lnguges ccepted y DFAs Lnguges ccepted y NFAs Regulr lnguge closed under mny opertions: union, conctention, Kleene str vi inductive definition or NFAs complement, union, intersection vi DFAs homomorphism, inverse homomorphism, reverse,... Different representtions llow for flexiility in proofs Sriel Hr-Peled (UIUC) CS374 19 Fll 2017 19 / 31

Regulr Lnguges Regulr lnguges hve three different chrcteriztions Inductive definition vi se cses nd closure under union, conctention nd Kleene str Lnguges ccepted y DFAs Lnguges ccepted y NFAs Regulr lnguge closed under mny opertions: union, conctention, Kleene str vi inductive definition or NFAs complement, union, intersection vi DFAs homomorphism, inverse homomorphism, reverse,... Different representtions llow for flexiility in proofs Sriel Hr-Peled (UIUC) CS374 19 Fll 2017 19 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exmple: PREFIX Let L e lnguge over Σ. Definition PREFIX(L) = {w wx L, x Σ } Theorem If L is regulr then PREFIX(L) is regulr. Let M = (Q, Σ, δ, s, A) e DFA tht recognizes L X = {q Q s cn rech q in M} Y = {q Q q cn rech some stte in A} Z = X Y Crete new DFA M = (Q, Σ, δ, s, Z) Clim: L(M ) = PREFIX(L). Sriel Hr-Peled (UIUC) CS374 20 Fll 2017 20 / 31

Exercise: SUFFIX Let L e lnguge over Σ. Definition SUFFIX(L) = {w xw L, x Σ } Prove the following: Theorem If L is regulr then PREFIX(L) is regulr. Sriel Hr-Peled (UIUC) CS374 21 Fll 2017 21 / 31

Prt III Regex to NFA Sriel Hr-Peled (UIUC) CS374 22 Fll 2017 22 / 31

Stge 0: Input A B C, Sriel Hr-Peled (UIUC) CS374 23 Fll 2017 23 / 31

Stge 1: Normlizing A B C, 2: Normlizing it. ǫ init A B C ǫ + AC Sriel Hr-Peled (UIUC) CS374 24 Fll 2017 24 / 31

Stge 2: Remove stte A ǫ init A B C ǫ AC + init ǫ A B C ǫ AC + Sriel Hr-Peled (UIUC) CS374 25 Fll 2017 25 / 31

Stge 4: Redrwn without old edges init B C ǫ AC + Sriel Hr-Peled (UIUC) CS374 26 Fll 2017 26 / 31

Stge 4: Removing B init B init B C ǫ + AC C ǫ + AC Sriel Hr-Peled (UIUC) CS374 27 Fll 2017 27 / 31

Stge 5: Redrw init + C ǫ + AC Sriel Hr-Peled (UIUC) CS374 28 Fll 2017 28 / 31

Stge 6: Removing C init + init ( + )( + ) ǫ + C ǫ + AC C ǫ + AC Sriel Hr-Peled (UIUC) CS374 29 Fll 2017 29 / 31

Stge 7: Redrw init ( + )( + ) AC Sriel Hr-Peled (UIUC) CS374 30 Fll 2017 30 / 31

Stge 8: Extrct regulr expression init ( + )( + ) AC Thus, this utomt is equivlent to the regulr expression ( + )( + ). Sriel Hr-Peled (UIUC) CS374 31 Fll 2017 31 / 31