Outline. Summary. DFA -> Regex. Finish off Regex -> e-nfa -> NFA -> DFA -> Regex Minimization/equivalence (Myhill-Nerode theorem)

Similar documents
Outline. Nondetermistic Finite Automata. Transition diagrams. A finite automaton is a 5-tuple (Q, Σ,δ,q 0,F)

More on Finite Automata and Regular Languages. (NTU EE) Regular Languages Fall / 41

Finite Automata and Regular Languages

CS 455/555: Finite automata

Computational Models - Lecture 3 1

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Notes on State Minimization

Computational Models - Lecture 3

Computational Models: Class 3

3515ICT: Theory of Computation. Regular languages

What we have done so far

Computational Models - Lecture 4

Fooling Sets and. Lecture 5

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

Regular Expressions and Language Properties

Formal Language and Automata Theory (CS21004)

Computational Models - Lecture 3 1

Lecture 2: Regular Expression

Finite Automata - Deterministic Finite Automata. Deterministic Finite Automaton (DFA) (or Finite State Machine)

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

Theory of Computation

Regular Expressions. Definitions Equivalence to Finite Automata

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

DFA to Regular Expressions

Lexical Analysis. DFA Minimization & Equivalence to Regular Expressions

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

CS20a: summary (Oct 24, 2002)

NPDA, CFG equivalence

COMP4141 Theory of Computation

Advanced Automata Theory 2 Finite Automata

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

COMP-330 Theory of Computation. Fall Prof. Claude Crépeau. Lec. 9 : Myhill-Nerode Theorem and applications

Ogden s Lemma for CFLs

Closure under the Regular Operations

We define the multi-step transition function T : S Σ S as follows. 1. For any s S, T (s,λ) = s. 2. For any s S, x Σ and a Σ,

CS 321 Solutions to Homework 4 Due October 22, 5pm

2. Elements of the Theory of Computation, Lewis and Papadimitrou,

Inf2A: Converting from NFAs to DFAs and Closure Properties

Chapter 6. Properties of Regular Languages

Fall 1999 Formal Language Theory Dr. R. Boyer. 1. There are other methods of nding a regular expression equivalent to a nite automaton in

Theory of Computation 4 Non-Deterministic Finite Automata

UNIT II REGULAR LANGUAGES

DM17. Beregnelighed. Jacob Aae Mikkelsen

Finite Automata and Regular languages

Minimization of DFAs

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

Chapter Five: Nondeterministic Finite Automata

CPSC 421: Tutorial #1

FS Properties and FSTs

Warshall s algorithm

Mergible States in Large NFA

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

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

Properties of Context-Free Languages. Closure Properties Decision Properties

CS154. Non-Regular Languages, Minimizing DFAs

V Honors Theory of Computation

Nondeterministic Finite Automata

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

More on Regular Languages and Non-Regular Languages

Languages. Non deterministic finite automata with ε transitions. First there was the DFA. Finite Automata. Non-Deterministic Finite Automata (NFA)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

DD2371 Automata Theory

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

Computational Theory

1 More finite deterministic automata

Deterministic Finite Automaton (DFA)

Equivalence of Regular Expressions and FSMs

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

CSE 135: Introduction to Theory of Computation Nondeterministic Finite Automata

MINIMIZATION OF DETERMINISTIC FINITE AUTOMATA WITH VAGUE (FINAL) STATES AND INTUITIONISTIC FUZZY (FINAL) STATES

2. Syntactic Congruences and Monoids

Name: Student ID: Instructions:

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CSE 135: Introduction to Theory of Computation Optimal DFA

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CS243, Logic and Computation Nondeterministic finite automata

Nondeterministic Finite Automata

Introduction to Formal Languages, Automata and Computability p.1/51

Inf2A: The Pumping Lemma

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

CS21 Decidability and Tractability

NOTES ON AUTOMATA. Date: April 29,

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Regular Language Equivalence and DFA Minimization. Equivalence of Two Regular Languages DFA Minimization

Regular Expression Unit 1 chapter 3. Unit 1: Chapter 3

Regular Expressions [1] Regular Expressions. Regular expressions can be seen as a system of notations for denoting ɛ-nfa

CS 154 Introduction to Automata and Complexity Theory

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

Discrete Mathematics and Logic II. Regular Sets

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

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

Theory of Computation 3 Deterministic Finite Automata

Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove

CSE 460: Computabilty and Formal Languages. Minimization of FA. S. Pramanik

Computability and Complexity

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

UNIT-VI PUSHDOWN AUTOMATA

The Pumping Lemma and Closure Properties

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

Transcription:

Outline Finish off Regex -> e-nfa -> NFA -> DFA -> Regex Minimization/equivalence (Myhill-Nerode theorem) http://www.cs.caltech.edu/~cs20/a October 9, 2002 1 Summary NFA -> DFA If NFA has states Q, construct a DFA with 2 Q states E-NFA -> DFA Change the transition relation to include epsilon-edges Regex -> e-nfa Construct e-nfa for each regex by structural induction DFA -> regex That s next http://www.cs.caltech.edu/~cs20/a October 9, 2002 2 DFA -> Regex Theorem If L is accepted by a DFA, then L is denoted by a regular expression. Proof Outline: Consider some arbitrary DFA M = (Q, Σ,δ,s,F) Clearly, we want to do induction over something Choices could be Q, whatelse? http://www.cs.caltech.edu/~cs20/a October 9, 2002 3

DFA -> Regex Let Q ={q 1,q 2,...,q n } We'll do induction over k for executions that use only states in {q 1,q 2,...,q k } (this is non-obvious) qi q0 qj States numbered <= k http://www.cs.caltech.edu/~cs20/a October 9, 2002 4 Defining R k ij LetR k ij be the set of all strings x such that δ(q i,x)= q j and for any proper prefix y of x that is not ɛ, δ(q i,y)= q l l k By induction: R 0 ij = { {a δ(qi,a)= q j } if i j {a δ(q i,a)= q j } {ɛ} if i = j R k ij = Rk 1 ik (Rk 1 kk ) R k 1 kj Note that L(M) = f F R n 0f R k 1 ij http://www.cs.caltech.edu/~cs20/a October 9, 2002 5 Constructing the regex Theorem There is a regular expression r k ij that denotes each R k ij Proof By induction on k Note L(M) = r n 0j 1 + +r n 0j m for F ={q j1,...,q jm } http://www.cs.caltech.edu/~cs20/a October 9, 2002 6

Constructing the regex { {a Base HaveR 0 ij = δ(qi,a)= q j } if i j {a δ(q i,a)= q j } {ɛ} if i = j { Let r 0 ij = a1 + a 2 + +a p for i j a 1 + a 2 + +a p + ɛ for i = j Step Have R k ij = Rk 1 ik (Rk 1 kk Let r k ij = r k 1 k 1 ik (rkk ) R k 1 kj ) r k 1 kj R k 1 ij + r k 1 ij http://www.cs.caltech.edu/~cs20/a October 9, 2002 7 Minimizing FA Can we prove equivalence of regexs (or their FA)? One method: If each FA can be reduced to a unique minimal form, we can compare the minimal FA http://www.cs.caltech.edu/~cs20/a October 9, 2002 8 Right-invariance Let M = (Q, Σ,δ,s,F) be a DFA For each x,y Σ,letxR M y δ(s, x) = δ(s, y) R M is an equivalence relation: Reflexive xr M x Symmetric If xr M y then yr M x Transitive If xr M y and yr M z,thenxr M z Furthermore if xr M y,thenxzr M yz for any z Σ http://www.cs.caltech.edu/~cs20/a October 9, 2002 9

Right-invariance Furthermore if xr M y,thenxzr M yz for any z Σ Definition For any relation R, if xry implies xzryz, then R is right invariant with respect to concatenation. http://www.cs.caltech.edu/~cs20/a October 9, 2002 10 Equivalence classes of R M L(M) Equivalence classes of R M http://www.cs.caltech.edu/~cs20/a October 9, 2002 11 Myhill-Nerode Theorem (The Myhill-Nerode theorem). The following three statements are equivalent: The set L Σ is accepted by a FA. The set L is the union of some of the equivalence classes of a right-invariant equivalence relation with finite index. Let equivalence relation R L be defined as xr L y iff xz L yz L. ThenR L has finite index. http://www.cs.caltech.edu/~cs20/a October 9, 2002 12

1->2 Let M be a DFA that accepts L. Define R M as before. R M is right invariant R M has finite index because the DFA has only a finite number of states L is the union of the equivalence classes containing some X where δ(s, x) F http://www.cs.caltech.edu/~cs20/a October 9, 2002 13 2->3 Consider some equivalence relation E of finite index, and L is the union of some of its equivalence classes. Prove R L has finite index, where xr L y iff xz L yz L. Suppose xey Since E is right-invariant, then xzeyz Then xz L yz L, andsoxr L y Since xey xr L y,ande has finite index, so does R L http://www.cs.caltech.edu/~cs20/a October 9, 2002 14 3->1 (part 1) First, prove R L is right-invariant. Suppose xr L y;provexwr L yw This means, prove xwzr L ywz for any z Σ But xr L y implies xv L yv L If v = wz,thenxwz L ywz L So xwr L yw http://www.cs.caltech.edu/~cs20/a October 9, 2002 15

3->1 (part 2) Construct DFA M = (Q, Σ,δ,s,F ) from R L Let Q be the set of equivalence classes of L (there are a finite number) Define [x] Q to be the equivalence class containing x Let δ ([x], a) = [xa] Is δ ([x], a) a function? Yes, because R L is right invariant Let s = [ɛ] Let F ={[x] x L} http://www.cs.caltech.edu/~cs20/a October 9, 2002 16 3->1 DFA construction [ε] L(M) [x] [y] [xa] [yb] [xb] [ya] Final state Q' = Equivalence classes of R L http://www.cs.caltech.edu/~cs20/a October 9, 2002 17 Minimization The minimum automaton accepting a language L is unique (up to renaming of states), and is given by the construction in the Myhill-Nerode theorem. http://www.cs.caltech.edu/~cs20/a October 9, 2002 18

Minimization The minimum automaton accepting a language L is unique (up to renaming of states), and is given by the construction in the Myhill-Nerode theorem. An algorithm is a procedure that always terminates (with the right answer) http://www.cs.caltech.edu/~cs20/a October 9, 2002 19 Minimization algorithm Let M = (Q, Σ,δ,s,F) be a DFA. Definep q iff for each x, δ(p, x) F δ(q, x) F. Basic idea: p q if p F and q F Consider r = δ(p, a) and s = δ(q, a) If r s, thenp q Compute the fixpoint http://www.cs.caltech.edu/~cs20/a October 9, 2002 20 Pseudo-code let D ={(p, q) p F q F} do for (p, q) F F (Q F) (Q F) do if δ(p,a),δ(q,a) D for some a then D D (p, q) until D doesn't change any more http://www.cs.caltech.edu/~cs20/a October 9, 2002 21

Finishing up To build the minimal DFA: let [q] ={p (p, q) D} Define δ([q], a) = [δ(q, a)] Remove inaccesible states (states not reachable from the start state) http://www.cs.caltech.edu/~cs20/a October 9, 2002 22 Minimization proof Let M = (Q, Σ,δ,s,F) be the original DFA, Let M = (Q, Σ,δ,s,F ) be the constructed DFA. Q ={[q] q is accessible from s} δ ([q], a) = [δ (q, a)] s = [s] F ={[q] q F} http://www.cs.caltech.edu/~cs20/a October 9, 2002 23 Minimization proof First, δ is a function Second, use induction to show δ ([s], w) = [δ(s, w)], so L(M) = L(M ) Is M minimal? Suppose not; then there are state [p] [q] where δ(s, x) = p and δ(s, y) = q and xr L y. There must be some w that distinguishes p and q (according to the algorithm) If so, xwr L yw is false, which cannot be. http://www.cs.caltech.edu/~cs20/a October 9, 2002 24

Summary FAs/regex are equivalent For each FA there is a unique minimal FA Equivalence of FA is computable To test of FA1=FA2, minimize both and test for equality Remember that the states may have different names, so this may take some time Next: what languages are regular? http://www.cs.caltech.edu/~cs20/a October 9, 2002 25 What languages are not regular? Intuition: since a FA has only finite state, it can remember only a finite number of things Some things we would expect are not regular Balanced parentheses (have to remember an arbitrary nesting depth) Prime numbers Why are multiples of 3 regular? Addition (strings i+j=k ) http://www.cs.caltech.edu/~cs20/a October 9, 2002 26 Regular languages Intuition: if a FA accepts a string that is long enough, it must repeat a state But it can t remember that the state was repeated So it can be forced to repeat the state over and over aj+1,...,ak a1,...,aj ak+1,...,am q0 qj=qk qm http://www.cs.caltech.edu/~cs20/a October 9, 2002 27

Pumping lemma Lemma (the Pumping Lemma) Let L be a regular set. There is a constant n s.t. for any z where z n, then z can be written z = uvw, where uv n v 1 For all i 0, uv i w L n is bounded by Q http://www.cs.caltech.edu/~cs20/a October 9, 2002 28 Proving that a language is not regular Let L be the proposed regular language There is some n, by the pumping lemma Choose a string s, longer than n symbols, in the language L Using the pumping lemma, construct a new string s that is not in the language http://www.cs.caltech.edu/~cs20/a October 9, 2002 29 Balanced parentheses The strings of balanced parentheses are not regular. Proof Let n be the integer in the pumping lemma Consider the string s = ( n+1 ) n+1 Write s = uvw where uv = ( n and w = () n+1 Then s = uv 2 w = ( n+m+1 ) n+1 is in the language for some m>0 s is not balanced http://www.cs.caltech.edu/~cs20/a October 9, 2002 30

Unions Any finite union of regular sets is regular Inifinite unions may not be regular http://www.cs.caltech.edu/~cs20/a October 9, 2002 31 Executions Consider a NFA M = (Q, Σ,δ,s,F) The executions (q 0,c 0 )(q 1,c 1 )...(q n 1,c n 1 )q n are regular http://www.cs.caltech.edu/~cs20/a October 9, 2002 32