Chap. 2 Finite Automata

Similar documents
Chap. 2 Finite Automata

Chap. 2 Finite Automata

Finite Automata. BİL405 - Automata Theory and Formal Languages 1

Automata and Formal Languages - CM0081 Determinist Finite Automata

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

Automata and Formal Languages - CM0081 Non-Deterministic Finite Automata

Theory of Computation

CS Pushdown Automata

Algorithms for NLP

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,

CS 455/555: Finite automata

Lecture 1: Finite State Automaton

Finite Automata. Theorems - Unit I SUSAN ELIAS. Professor Department of Computer Science & Engineering Sri Venkateswara College of Engineering

3515ICT: Theory of Computation. Regular languages

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

Chapter Two: Finite Automata

Lecture 5: Minimizing DFAs

CS 154. Finite Automata, Nondeterminism, Regular Expressions

Introduction to Finite-State Automata

Finite Automata and Regular languages

Lecture 3: Nondeterministic Finite Automata

CS243, Logic and Computation Nondeterministic finite automata

Nondeterministic Finite Automata

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Decision, Computation and Language

Course 4 Finite Automata/Finite State Machines

What we have done so far

Finite Automata and Regular Languages

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

Chapter Five: Nondeterministic Finite Automata

Classes and conversions

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Theory of Computation (I) Yijia Chen Fudan University

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

COM364 Automata Theory Lecture Note 2 - Nondeterminism

Lecture 2: Regular Expression

CS 581: Introduction to the Theory of Computation! Lecture 1!

CS 154, Lecture 3: DFA NFA, Regular Expressions

Non-deterministic Finite Automata (NFAs)

COMP4141 Theory of Computation

CSC173 Workshop: 13 Sept. Notes

CMSC 330: Organization of Programming Languages. Theory of Regular Expressions Finite Automata

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

Chapter 5. Finite Automata

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

Formal Language and Automata Theory (CS21004)

Lecture 4 Nondeterministic Finite Accepters

Inf2A: Converting from NFAs to DFAs and Closure Properties

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

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

C2.1 Regular Grammars

C2.1 Regular Grammars

UNIT-II. NONDETERMINISTIC FINITE AUTOMATA WITH ε TRANSITIONS: SIGNIFICANCE. Use of ε-transitions. s t a r t. ε r. e g u l a r

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Deterministic Finite Automaton (DFA)

Page 1. Compiler Lecture Note, (Regular Language) 컴파일러입문 제 3 장 정규언어. Database Lab. KHU

Chap. 7 Properties of Context-free Languages

Subset construction. We have defined for a DFA L(A) = {x Σ ˆδ(q 0, x) F } and for A NFA. For any NFA A we can build a DFA A D such that L(A) = L(A D )

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

Nondeterministic Finite Automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Sri vidya college of engineering and technology

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

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

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

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

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

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

Finite Automata. Wen-Guey Tzeng Computer Science Department National Chiao Tung University

Computational Models - Lecture 3

Nondeterministic Finite Automata

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

Nondeterministic Finite Automata

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

Automata and Languages

Finite Automata. Seungjin Choi

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

September 7, Formal Definition of a Nondeterministic Finite Automaton

CISC 4090 Theory of Computation

Extended transition function of a DFA

E.g. The set RE of regular expressions is given by the following rules:

Nondeterministic Finite Automata. Nondeterminism Subset Construction

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

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

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

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

Finite Automata and Formal Languages TMV026/DIT321 LP4 2012

Recitation 2 - Non Deterministic Finite Automata (NFA) and Regular OctoberExpressions

Chapter 2. Finite Automata. (part A) (2015/10/20) Hokkaido, Japan

Constructions on Finite Automata

컴파일러입문 제 3 장 정규언어

Uses of finite automata

Constructions on Finite Automata

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

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

Finite Automata and Regular Languages (part III)

Chap. 1.2 NonDeterministic Finite Automata (NFA)

Chapter 6: NFA Applications

Transcription:

Chap. 2 Finite Automata 2.1 An Informal Picture of Finite Automata (See 2nd Edition) A man with a wolf, goat, and cabbage is on the left bank of a river A boat carries one man and only one of the other three. The wolf eats the goat without the man. The goat eats the cabbage without the man. Is it possible to cross the river without the goat or cabbage being eaten? states: occupants of each bank after a crossing 16 subsets of the man(m), wolf(w), goat(g), and cabbage(c). 16 states: mwgc-, WC-mG,, -mwgc input symbol: four ways of crossing the river A man crosses alone(m) with the wolf(w), goat(g), or cabbage(c). input string: a sequence of crossings (input symbols = {m, w, g, c}) state transition: From a state to another state by an input symbol (crossing) 9/14/17 Kwang-Moo Choe 1

mcgw- m,c,w,g -mcgw g g m,c,w m-cgw mc-gw mw-cg m,c,w g g CW-mG m m mg-cw m mcw-g m c c w w W-mCG mgw-c w w m m m G-mCW C-mGW g g g g m mcg-w c c 9/14/17 Kwang-Moo Choe 2

2.2 Deterministic Finite Automata(DFA) 2.2.1 Definition of a DFA A deterministic finite automaton A = (Q, T,, q 0, F) consists of: 1. A finite set of states, denoted Q, 2. A finite set of input symbols, denoted T, in the text 3. A transition function, : Q T Q Let p, q Q, and a T, if we write (q, a) = p, meaning that when current state is in q and input symbol is a, the current state is changed to p, and input symbol is changed to the next(right) one. 4. A start(initial) state, q 0 Q, and 5. A set of final or accepting states, F Q. A DFA A = (Q, T,, q 0, F) five-tuple notation 9/14/17 Kwang-Moo Choe 3

2.2.2 How a DFA Processes Strings How a DFA decides whether or not accept a input string(sequence of input symbols) Suppose a 1 a 2 a n is a sequence of input symbols 1. We start out the DFA with in its start state q 0. 2. We consult the transition function,, with current state and current input symbol, assume in the first trial (q 0, a 1 ) = q 1, 3. Repeat this step with the next state q 1 and the next input symbol a 2. Assume (q 1, a 2 ) = q 2, (q 2, a 3 ) = q 3,, (q n-1, a n ) = q n. 4. Finally, check if (q n-1, a n ) = q n F or not. If q n F, accept a 1 a 2 a n. If q n F does not accept a 1 a 2 a n. ( ( ( (q 0, a 1 ), a 2 ), ), a n-1 ), a n ) = q n where (q i-1, a i ) = q i for 1 i n. 9/14/17 Kwang-Moo Choe 4

function DFA( D = (Q:set of states, T:set of symbols, : Q Q, q 0 Q, F Q); x = a 1 a 2 a n T * ) /* (D; x T * ) are two formal parameters */ /* D has five tuples, D = (Q, T,, q 0, F) */ return {D accept x, D accept x} q Q, i N; /* q and i are two local variables */ q, i := q 0, 1; do i n if (q, a i ) q, i := (q, a i ), i+1 (q, a i ) return D accept x fi od if q F return D accept x q F return D accept x fi end function DFA. 9/14/17 Kwang-Moo Choe 5

2.2.3 Simple notations for DFA s Example 2.2 Let T = {0, 1} and L = {x01y T * x, y T * }. substring 01. (0 1) * 01(0 1) *. 1. Transition diagram Figure 2.4 in p. 48. 1 0 0, 1 0 q 0 q 1 1 q 2 State q 0 : initial state If it sees 0, go to a new state q 1. If it sees 1 stay in the state q 0. It has never seen 0. State q 1 : The last symbol it has seen is 0. If it sees 1, go to a new state q 2. If it sees 0, stay in the state q 1. State q 2 : It has ever seen is 01. final state Whether it sees 0 or 1, stay in the state q 2. 9/14/17 Kwang-Moo Choe 6

2. Transition table Figure 2.5 in p. 49. 0 1 q 0 q 1 q 0 q 1 q 1 q 2 * q 2 q 2 q 2 Formal definition of DFA D D = (Q, T,, q 0, F) where 1. Q = {q 0, q 1, q 2 } 2. T = {0, 1} 3. = { (q 0, 0)=q 1, (q 0, 1)=q 0, (q 1, 0)=q 1, (q 1, 1)=q 2, (q 2, 0)=q 2, (q 2, 1)=q 2 } 4. q 0 Q 5. F = {q 2 } 9/14/17 Kwang-Moo Choe 7

2.2.4 Extend the domain of transition function from symbols to strings : Q T Q ^: Q T * Q ^(q, ) = B q basis ^(q, xa) = R ( ^(q, x), a) recursion (2.1) q Q, x T *, a, xa T +. ^(q 0, a 1 a 2 a n ) = R ( ^(q 0, a 1 a 2 a n-1 ), a n ) 1st recursion = R ( ( ^(q 0, a 1 a 2 a n-2 ), a n-1 ), a n ) 2nd recursion = R = R ( ( ( ( ^(q 0, ), a 1 ), a 2 ), ), a n-1 ), a n ) n-th recursion = B ( ( ( (q 0, a 1 ), a 2 ), ), a n-1 ), a n ) basis We may use * instead of ^ to show that the 2nd domain of is T *. 9/14/17 Kwang-Moo Choe 8

Example 2.4 in p. 50. 1 q 0 1 q 1 0 0 Even numbers of 0 s and even numbers of 1 s. q 2 2.2.5 The Language of DFA We define the language of a DFA D = (Q, T,, q 0, F), L(D), L(D) = {w T * * (q 0, w) F}. L(D) T * or L(D) 2 T*. 0 1 1 0 q 3 9/14/17 Kwang-Moo Choe 9

Def. A Class of Regular languages Let L be a language. If L = L(A) for some DFA A, then we say L is a regular language. A class of regular languages type-3 languages in Chomsky s language hierarchy Automata M 1 M 2 DFA L L L L Languages 2 T* regular L Def. Equivalence of two Automata Let M 1 and M 2 be two automata. We say two automata M 1 and M 2 are equivalent, if L(M 1 ) = L(M 2 ) = L. 9/14/17 Kwang-Moo Choe 10

DFA: : Q T Q q Q, a T, (q, a) Q. (total) function q Q, a T \ (q, a). partial function If A = (Q, T,, q 0, F) be a FA with : Q T \ Q partial function, L(A) = L(B) for DFA B = (Q {d}, T,, q 0, F) where d Q, DFA but partial function: : Q T Q { }. = { (q, a) = d (q, a) Q} { (d, a) = d a T} d: dead state in B is the DFA(with total function) but? : Q T Q. Dead state: m cgw, mc gw, mw cg state in the 1st Example. eliminate the state and relevant transition functions partial function. DFA with partial function can be considered as a DFA. 9/14/17 Kwang-Moo Choe 11

2.3 Nondeterministic Finite Automata(NFA) 2.3.1 An Informal View of NFA Example 2.9 An NFA accepting all strings that ends in 01(postfix 01). Fig. 2.9(p. 56) 0, 1 0 q 0 q 1 1 q 2 Consider an input string 00101 {0, 1} *. q 0 0 q 1 0 X(stuck) q 0 0 q 0 0 q 1 1 q 2 0 X(stuck) q 0 0 q 0 0 q 0 1 q 0 0 q 0 1 q 0 F(fail) q 0 0 q 0 0 q 0 1 q 0 0 q 1 1 q 2 F(success) 9/14/17 Kwang-Moo Choe 12

2.3.2 Definition of NFA A = (Q, T,, q 0, F) is a nondeterministic finite automaton(nfa), if 1. Q is a finite set of states, 2. T is a finite set of input symbols, 3. is a transition function, : Q T 2 Q. If q Q, a T, and {p 1, p 2,, p n } Q (1 i n, p i Q) then we write (q, a) = {p 1, p 2,, p n }, meaning that when current state is in q and input symbol is a, the state may be changed to any one of p 1, p 2,, p n, and input symbol is changed to the next(right) one. 4. q 0 Q is a start state, and 5. F Q is a set of final or accepting states. 9/14/17 Kwang-Moo Choe 13

2.3.3 The Extended Transition Function DFA: : Q T Q Definition * : Q T * Q ^: Q * Q in the text NFA: : Q T 2 Q Definition : 2 Q T 2 Q (1) set extension in this lecture * : 2 Q T * 2 Q (2) string extension in this lecture ^: Q * 2 Q in the text Two step extensions 1. Set extension: : We extend the 1st domain of to set of states. : 2 Q T 2 Q. Let P Q. Then we define (P, a) = {q Q p P, q (p, a)} or = p P (p, a) We may write (p, a) instead of ({p}, a) when needed. 9/14/17 Kwang-Moo Choe 14

2. String extension: * (same as ^ = * ) * : 2 Q T * 2 Q. * (P, ) = B P basis * (P, wa) = R ( * (P, w), a) recursion P Q(or P 2 Q ), w T *, a T, wa T +. We may write and * instead of and * since. 2.3.4 The Language of an NFA Let N = (Q,,, q 0, F) be an NFA. Then the language defined by the NFA N, denoted as L(N) is, L(N) = {w T * * (q 0, w) F }. L(N) T * or L(N) 2 T*. 9/14/17 Kwang-Moo Choe 15

2.3.5 Equivalence of DFA and NFA Example 2.10 NFA of Fig. 2.9(p. 56) postfix 01. 0, 1 0 q 0 q 1 1 q 2 Transition table for NFA 0 1 q 0 {q 0, q 1 } {q 0 } (q 0, 0) = {q 0, q 1 }: NFA q 1 {q 2 } * q 2 Transition table for subsets of NFA 2 3 = 8 subset-states(see Fig. 2.12) 0 1 0 1 {q 0, q 1 } {q 0, q 1 } {q 0, q 2 } {q 0 } {q 0, q 1 } {q 0 } * {q 0, q 2 } {q 0, q 1 } {q 0 } {q 1 } {q 2 } * {q 1, q 2 } {q 2 } * {q 2 } * {q 0, q 1, q 2 } {q 0, q 1 } {q 0, q 2 } 9/14/17 Kwang-Moo Choe 16

Starting from {q 0 } See Fig. 2.14 in p. 63. 0 1 0 1 {q 0 } {q 0, q 1 } {q 0 } [ ] [0] [ ] {q 0, q 1 } {q 0, q 1 } {q 0, q 2 } [0] [0] [01] * {q 0, q 2 } {q 0, q 1 } {q 0 } * [01] [0] [ ] Only 3 subset-states are reachable from the initial state {q 0 }. Renaming of states {q 0 } [ ], {q 0, q 1 } [0], and {q 0, q 2 } [01]. 1 0 [ ] 0 [0] 1 0 [01] 1 Fig. 2.14 DFA from NFA Fig. 2.9.(postfix 01) 9/14/17 Kwang-Moo Choe 17

Subset Construction(NFA DFA) Q D = 2 Q N. Given an NFA N = (Q N, T, N, q 0N, F N ), construct an equivalent DFA D = (Q D,, D, q 0D, F D ) such that L(D) = L(N). 1. Q D = {P P Q N } = 2 Q N. 3. D (P, a) = {q Q N p P Q N, q N (p, a)} Q N or Q D. or = p P N (p, a) or = N (P, a) set extension of N. D (P, a) = N (P, a) or D = N for short, where D : Q D T Q D and N : 2 Q N T 2 Q N(Q D = 2 Q N). 4. q 0D ( Q D ) = {q 0N }( Q N ). 5. F D = {F Q D F F N } 9/14/17 Kwang-Moo Choe 18

Thm. 2.11 L(D) = L(N) in the above subset construction Proof * D (q 0D, w) = N * ({q 0N }, w) for all w *. D * : Q D T * Q D (= 2 Q N * 2 Q N). N * : 2 Q N T * 2 Q N. We may use q 0N instead of {q 0N }. Induction on w. basis: Let w = 0, * D (q 0D, ) = * D ({q 0N }, ) = {q 0N }= ^N ({q 0N }, ). induction: Let w = xa where a T, x T *, and w T +. ( w = x + 1) * D (q 0D, xa) = D ( * D ({q 0N }, x), a) by string extension of * D. = N ( D * ({q 0N }, x), a) by subset construction = N ( N * ({q 0N }, x), a) by induction hypothesis = N * ({q 0N }, xa) by string extension of N *. D * (q 0D, x) F D, if and only if, N * (q 0, x) F N. L(D) = L(N). 9/14/17 Kwang-Moo Choe 19

Thm. 2.12 A language L is defined by some DFA, if and only if L is defined by some NFA.(NFA DFA) Proof: (If) subset construction(nfa DFA) Thm. 2.11 (Only if) NFA can easily simulate DFA(DFA NFA). Let a DFA D = (Q, T, D, q 0, F). We define an NFA(Q, T, N, q 0, F) N (q, a) = {p D (q, a) = p}. Proof for w *, if and only if, ^ D (q, w) = p, then ^D (q, w) = {p}. L is regular, iff L = L(N) for some NFA N. Automata NFA N DFA D L L L L L L Languages 2 T* regular L 9/14/17 Kwang-Moo Choe 20

2.3.6 A Bad Case for the Subset Construction See Ex. 2.13 (p64-65) (0+1) * 1(0+1) n-1. The state of DFA summarizes the information concerning past inputs that is needed to determine the behaviour of the automata on subsequent inputs. Aho and Ullman in the 2nd Edition. [(0+1) * ] 1 [(0+1) * 1] 0 [(0+1) * 10] 0 [(0+1) * 100] * [(0+1) * 10 n-2 0] * [(0+1) * 10 n-2 1] 1 [(0+1) * 101]...... 1 [(0+1) * 11] 0 [(0+1) * 110]... * [(0+1) * 11 n-2 0] 1 [(0+1) * 111] * [(0+1) * 11 n-2 1] 9/14/17 Kwang-Moo Choe 21

2.4 An Application: Text Search Read text 2.5 Finite Automata with Epsilon-Transitions A = (Q, T,, q 0, F) is a fa with epsilon transition( -NFA), if Q, T, q 0, and F are same as NFA, but 3. is a transition function, : Q (T { }) 2 Q. If q Q and {p 1, p 2,, p n } Q, then we write (q, ) = {p 1, p 2,, p n }, meaning that when current state is in q and regardless of input symbol the state may be changed to any one of p 1, p 2,, p n, and next input symbol is not changed. Ex. 2.16 in Fig. 2.18 for an -NFA accepting decimal numbers in p. 73. Ex. 2.17 in Fig. 2.19 for an -NFA accepting keywords web and ebay in p. 73. 9/14/17 Kwang-Moo Choe 22

2.5.3 Epsilon-closure basis: q * (q) (same as ECLOSE(q) in the text) recursion: If p * (q), and r (p, ), then r * (q). Example 2.19 in p. 74. Why * (q) instead of ECLOSE(q) Let = {(p, q) Q Q q (p, )}. Then Q Q(a binary relation on Q) and ECLOSE(q) = * (q) reflexive-transitive closure of. 9/14/17 Kwang-Moo Choe 23

2.5.4 The Extended Transition and Language for -NFA s NFA: : Q T 2 Q. -NFA: : Q (T { }) 2 Q. Let s divide of -NFA into 1 and 0 (= ). 1 : Q T 2 Q. 0 : Q { } 2 Q. = 1 0. 1 : is same as in NFA, we use instead of 1, since 1 =. 0 f what is the bijection f? We use instead of 0. = {(p, q) Q Q q (p, )} binary relation on Q. * = i N i 0 Q Q binary relation on Q., * : Q 2 Q. function from Q to 2 Q. 9/14/17 Kwang-Moo Choe 24

Let s extend the domain of (= 1 ),, and * from state to set of states. Let P Q, we define : 2 Q T 2 Q. (P, a) = {q Q p P, (p, a) = q} or = p P (p, a) We may write (p, a) instead of ({p}, a) when needed. We may write (P, a) instead of (P, a) when needed. : 2 Q 2 Q. (P) = {q Q p P, (p) = q} or = p P (p) * : 2 Q 2 Q. * (P) = {q Q p P, * (p) = q} = p P * (p) We write (P) instead of (P) and * (P) instead of * (P). 9/14/17 Kwang-Moo Choe 25

Let s extend the 2nd domain of from symbol to strings. * : 2 Q T * 2 Q. * (P, ) = B * (P) basis * (P, wa) = R * ( ( * (P, w), a)) recursion P Q(or P 2 Q ), w *, a T, wa T +. n (q 0, a 1 a 2 a n ) = R * ( ( n-1 (q 0, a 1 a 2 a n-1 ), a n )) 1st recursion = R * ( ( * ( ( n-2 (q 0, a 1 a 2 a n-2 ), a n-1 )), a n )) 2nd recursion = R = R * ( ( * ( ( * ( ( * ( ( 0 (q 0, ), a 1 )), a 2 )), )), a n-1 )), a n )) n-th = B * ( ( * ( ( * ( ( * ( ( * (q 0 ), a 1 )), a 2 )), )), a n-1 )), a n )) basis n = * * * = * ( * ) n = * ( 1 ) n. where 1 = *. * = i N 0 i = *. 9/14/17 Kwang-Moo Choe 26

2.5.5 Eliminating -Transitions Given an -NFA E = (Q E, T, E, q 0E, F E ), construct the equivalent DFA D = (Q D, T, D, q 0D, F D ) such that L(D) = L(N). 1. Q D = {P P Q E } = 2 Q E. 3. q 0D = * ({q 0E }) 4. D (P, a) = * ( E (P, a)) set extension of E and -closure( 1 = * ) where P Q E (P Q D ), a T, and D (P, a) Q E (or D (P, a) Q D ) 5. F D = {F Q D F F E } Theorem 2.22 A language L is accepted by some -NFA if and only if L is accepted by some DFA. Proof: (If) -NFA can easily simulate DFA(DFA -NFA). (Only if) Eliminating -transitions( -NFA DFA) 9/14/17 Kwang-Moo Choe 27

Let E = (Q E, T, E, q 0E, F E ) be a -NFA and DFA D = (Q D,, D, q 0D, F D ) is the one in 2.5.5. We show E * (q 0E, w) = D * (q 0D, w) by induction on w. basis: * E (q 0E, ) = * (q 0E ) by basis definition of * E. = q 0D by construction of D. = D * (q 0D, ) by basis definition of D *. Induction: Let w = xa T +, a T, and x T *. E * (q 0, xa) = E ( * ( E * (q 0, x), a) by recursive definition of E *. = E ( * ( D * (q 0D, x), a)) by induction hypothesis. = D ( D * (q 0D, x), a) by construction of D. = D * (q 0D, xa) by recursive definition of D *. 9/14/17 Kwang-Moo Choe 28

-NFA Transition Table for Fig. 2.18 in p. 73. 1 +,. d * q 0 {q 1 } q 0 {q 1 } {q 0, q 1 } q 1 {q 2 } {q 1, q 4 } q 1 {q 1 } q 2 {q 3 } q 2 {q 2 } * q 3 {q 3 } q 3 {q 5 } {q 3, q 5 } q 4 {q 3 } q 4 {q 4 } q 5 q 5 {q 5 } DFA Transition Table for Fig. 2.22 in p. 79. * 1 * +,. d {q 0, q 1 } {q 1 } {q 2 } {q 1, q 4 } {q 1 } {q 2 } {q 1, q 4 } {q 2 } {q 3, q 5 } {q 1, q 4 } {q 2, q 3, q 5 } {q 1, q 4 } * {q 3, q 5 } {q 3, q 5 } * {q 2, q 3, q 5 } {q 3, q 5 } 9/14/17 Kwang-Moo Choe 29

2.A Extended Finite Automata(XFA) X = (Q, T, q 0,, F) is an extended Finite state Automata(XFA), if : Q T * 2 Q. Given an XFA X = (Q X, T, q 0, X, F), construct an equivalent -NFA E = (Q E, T, q 0, E, F) such that L(X) = L(E). Construction algorithm Q E := Q X ; E := ; for ( X (q, x) = P) X where x = a 1 a 2 a n do if 0 n 1 E := E { E (q, x) = P} where x { } n 2 Q E := Q E {p 1 }; E := E { E (q, a 1 ) = {p 1 }}; od for 2 i n do Q E :=Q E {p i }; E := E { E (p i-1, a i )= {p i }} od; E := E { E (p n-1, a n ) = P} where Q X {p 1, p 2,, p n-1 } fi 9/14/17 Kwang-Moo Choe 30

XFA s = -NFA s = NFA s = DFA s = Class of regular languages = FA s Automata XFA=FA X -NFA E NFA N DFA D L(X) L(N) L(E) L(D) Languages 2 T* regular L 9/14/17 Kwang-Moo Choe 31

The following six statements are equivalent, 1. A language L is regular. 2. L = L(D) for some DFA D where : Q T Q. 3. L = L(P) for some DFA P where : Q T Q { }. with partial function. 4. L = L(N) for some NFA N where : Q T 2 Q. 5. L = L(E) for some -NFA E where : Q ({ } T) 2 Q. 6. L = L(X) for some XFA X where : Q T * 2 Q. The following two statements are equivalent, 1. A language L is regular. 2. L = L(A) for some FA A where : Q T * 2 Q. We ve changed the definition of FA from DFA to XFA. 9/14/17 Kwang-Moo Choe 32

2.B Configuration rewriting system for FA Let A = (Q, T,, q 0, F) be a Finite automata where : Q T * 2 Q.Then A configuration rewritng system R A = (Q T *, ) on Q T * is = {(q, x) (p, ) p (q, x)}. (q, x), (p, ) Q T * : configurations Assume x = x 1 x 2...x n T * and 1 i n: q i (q i-1, x i ). Then x q 1 x 2 x 3 x 0 q 1 q 2 n-1 x q n n-1 q n (... ( (q 0, x 1 ), x 2 ),..., x n-1 ), x n ) = q 1 (q 0, x 1 ) ( (... (q 1, x 2 ),...,x n-1 ) x n ) =... = (q n-2, x n-1 ), x n ) = q n-1 (q n-2, x n-1 ) (q n-1, x n ) = q n (q n-1, x n ) q n. (q 0, x 1 x 2...x n-1 x n ) (q 0, x 1 ) (q 1, ) (q 1, x 2...x n-1 x n )... (q n-2, x n-1 x n ) (q n-2, x n-1 ) (q n-1, ) (q n-1, x n ) (q n-1, x n ) (q n, ) (q n, ). L(R A ) = {x T * (q 0, x) * (f, ), f F}. 9/14/17 Kwang-Moo Choe 33

Read this page for the minimal state DFA TBD in Chap. 4. Consider a language L T * and a binary relation R L on T * where x, y * : x R L y, if z T * : xz, yz L or xz, yz L. Then R L is an equivalent(proof? ) binary relation on T *. Consider a DFA M = (Q, T,, q 0, F) and a binary relation R M on T * x, y * : x R M y, if * (q 0, x) = * (q 0, y). Then Par RM ( * ) Q. Compare two quivalent relation on T *, R L and R M where L = L(M). Par RL (T * ) Par RM (T * ) in general. If Par RL (T * ) = Par RM (T * ) for some M = (Q, T,, q 0, F ). M is a minimal state DFA that accepting L. 9/14/17 Kwang-Moo Choe 34