Finite Automata A simple model of computation. www.ishuchita.comChapter 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.

Slides:



Advertisements
Similar presentations
Finite Automata A simple model of computation. Jaruloj Chongstitvatana Chapter 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How.
Advertisements

CSC 361NFA vs. DFA1. CSC 361NFA vs. DFA2 NFAs vs. DFAs NFAs can be constructed from DFAs using transitions: Called NFA- Suppose M 1 accepts L 1, M 2 accepts.
Lecture 6 Nondeterministic Finite Automata (NFA)
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
YES-NO machines Finite State Automata as language recognizers.
January 7, 2015CS21 Lecture 21 CS21 Decidability and Tractability Lecture 2 January 7, 2015.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
CS21 Decidability and Tractability
Introduction to Computability Theory
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
1 Languages and Finite Automata or how to talk to machines...
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
Lecture 3 Goals: Formal definition of NFA, acceptance of a string by an NFA, computation tree associated with a string. Algorithm to convert an NFA to.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
1.Defs. a)Finite Automaton: A Finite Automaton ( FA ) has finite set of ‘states’ ( Q={q 0, q 1, q 2, ….. ) and its ‘control’ moves from state to state.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 Non-Deterministic Finite Automata. 2 Alphabet = Nondeterministic Finite Automaton (NFA)
Nondeterminism (Deterministic) FA required for every state q and every symbol  of the alphabet to have exactly one arrow out of q labeled . What happens.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { ‘{‘, ‘}’ } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite language,
Theory of Languages and Automata
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
4b 4b Lexical analysis Finite Automata. Finite Automata (FA) FA also called Finite State Machine (FSM) –Abstract model of a computing entity. –Decides.
CMSC 330: Organization of Programming Languages Finite Automata NFAs  DFAs.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Regular Languages ภาษาปกติ. Jaruloj Chongstitvatana Outline Regular expressions Regular languages Equivalence between languages accepted by.
Lecture 5: Finite Automata 虞台文 大同大學資工所 智慧型多媒體研究室.
Modeling Computation: Finite State Machines without Output
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Lecture Notes 
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
P Symbol Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
Lecture #4 Thinking of designing an abstract machine acts as finite automata. Advanced Computation Theory.
Lecture #5 Advanced Computation Theory Finite Automata.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
Languages.
Non Deterministic Automata
Chapter 2 Finite Automata
Finite Automata & Regular Languages
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
Nondeterministic Finite Automata
Chapter 1 Regular Language
Finite-State Machines with No Output
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

Finite Automata A simple model of computation

2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works –How to construct a DFA Non-deterministic finite automata (NFA) –How an NFA works –How to construct an NFA Equivalence of DFA and NFA Closure properties of the class of languages accepted by FA

2 Finite Automata3 Finite Automata (FA) CONTROL UNIT INPUT TAPE TAPE HEAD Finite set of states Move to the right one cell at a time Store input of the DFA Can be of any length Start state Final state(s) is in exactly one state at a time

2 Finite Automata4 What does an FA do? Read an input string from tape Determine if the input string is in a language Determine if the answer for the problem is “YES” or “NO” for the given input on the tape

2 Finite Automata5 How does an FA work? At the beginning, –an FA is in the start state (initial state) –its tape head points at the first cell For each move, FA –reads the symbol under its tape head –changes its state (according to the transition function) to the next state determined by the symbol read from the tape and its current state –move its tape head to the right one cell

2 Finite Automata6 When does an FA stop working? When it reads all symbols on the tape Then, it gives an answer if the input is in the specific language: –Answer “YES” if its last state is a final state –Answer “NO” if its last state is not a final state

2 Finite Automata7 Example of a DFA qa (q,a)(q,a) s0s s1f f0f f1s s f Transition diagram Transition function

2 Finite Automata8 How to define a DFA a 5-tuple (Q, , , s, F), where –a set of states Q is a finite set –an alphabet  is a finite, non-empty set –a start state s in Q –a set of final states F contained in Q –a transition function  is a function Q    Q See formal definition That’s why it’s called a finite automaton.

2 Finite Automata9 How an FA works sf Input: Input: ACCEPT REJECT

2 Finite Automata10 Configurations Definition Let M =( Q, , , s, F ) be a deterministic finite automaton. A configuration of M is an element of Q    configurations of M (s,  ), (s, 00), (s, 01101), (f,  ), (f, ), (f, 1111), (f, ) s f Transition diagram of M Unread input string Current state

2 Finite Automata11 Yielding next configuration Definition Let M = ( Q, , , s, F ) be a deterministic finite automaton, and ( q 0,  0 ) and ( q 1,  1 ) be two configurations of M. We say ( q 0,  0 ) yields ( q 1,  1 ) in one step, denoted by ( q 0,  0 )  M ( q 1,  1 ), if  ( q 0, a ) = q 1, and  0 =a  1, for some a . When a configuration yields another configuration, the first symbol of the string is read and discarded from the configuration. Once a symbol in an input string is read, it does not effect how the DFA works in the future.

2 Finite Automata12 Example : yielding next configuration (s, )  M (s, 01101)  M (s, 1101)  M (f, 101)  M (s, 01)  M (s, 1)  M (f,  ) sf

2 Finite Automata13 Yield in zero step or more Definition Let M = (Q, , , s, F) be a DFA, and (q 0,  0 ) and (q 1,  1 ) be two configurations of M. (q 0,  0 ) yields (q 1,  1 ) in zero step or more, denoted by (q 0,  0 )  * M (q 1,  1 ), if –q 0 = q 1 and  0 =  1, or –(q 0,  0 )  M (q 2,  2 ) and (q 2,  2 )  * M (q 1,  1 ) for some q 2 and  2. This definition is an inductive definition, and it is often used to prove properties of DFA’s.

2 Finite Automata14 Example: Yield in zero step or more (s, )  * M (f, 101)  * M (s, 01)  * M (f,  ) s f (s, 01001)  * M (f, 001)  * M (f, 1)  * M (s,  )

2 Finite Automata15 Accepting a string Definition Let M = (Q, , , s, F) be a DFA, and    *. We say M accepts  if (s,  )  * M (f,  ), when f  F. Otherwise, we say M rejects . (s, )  * M (f,  )  M accepts (s, 01001)  * M (s,  )  M rejects 01001

2 Finite Automata16 Language accepted by a DFA Let M = (Q, , , s, F ) be a DFA. The language accepted by M, denoted by L(M ) is the set of strings accepted by M. That is, L(M) = {  *|(s,  )  * M (f,  ) for some f  F } Example: L(M) = {x  {0,1}* | the number of 1’s in x is odd}. s f

2 Finite Automata17 Example s , 1 0

2 Finite Automata18 How to construct a DFA Determine what a DFA need to memorize in order to recognize strings in the language. –Hint: the property of the strings in the language Determine how many states are required to memorize what we want. –final state(s) memorizes the property of the strings in the language. Find out how the thing we memorize is changed once the next input symbol is read. –From this change, we get the transition function.

2 Finite Automata19 Constructing a DFA: Example Consider L= {  {0,1}*|  has both 00 and 11 as substrings}. Step 1: decide what a DFA need to memorize Step 2: how many states do we need? Step 3: construct the transition diagram

2 Finite Automata20 Example s , 1 0 Got nothing Got 0 as substring Got 00 as substring Got 11 and got 0 Got 00 and 11 as substrings Got 1 as substring Got 11 as substring Got 00 and got 1 Got 11 and 00 as substrings

2 Finite Automata21 Constructing a DFA: Example Consider L= {  {0,1}*|  represents a binary number divisible by 3}. –L = {0, 00, 11, 000, 011, 110, 0000, 0011, 0110, 1001, 00000,...}. Step 1: decide what a DFA need to memorize –remembering that the portion of the string that has been read so far is divisible by 3 Step 2: how many states do we need? –2 states remembering that the string that has been read is divisible by 3 the string that has been read is indivisible by 3. –3 states remembering that the string that has been read is divisible by 3 the string that has been read - 1 is divisible by 3. the string that has been read - 2 is divisible by 3. Choose this!! Why?

2 Finite Automata22 Using 2 states Reading a string w representing a number divisible by 3. –Next symbol is 0. w 0, which is 2* w, is also divisible by 3. If w =9 is divisible by 3, so is 2* w =18. –Next symbol is 1. w 1, which is 2* w +1, may or may not be divisible by 3. If 8 is indivisible by 3, so is 17. If 4 is indivisible by 3, but 9 is divisible. Using these two states is not sufficient.

2 Finite Automata23 Using 3 states Each state remembers the remainder of the number divided by 3. If the portion of the string that has been read so far, say w, represents the number whose remainder is 0 (or, 1, or 2), –If the next symbol is 0, what is the remainder of w 0? –If the next symbol is 1, what is the remainder of w 1?

2 Finite Automata24 How remainder changes Current number Current remainder Next symbol New number New remainder 3n006n0 3n016n+11 3n+1106n+22 3n+1116n+30 3n+2206n+41 3n+2216n+52

2 Finite Automata25 Transition table Current number Current remainder Next symbol New number New remainder 3n006n0 3n016n+11 3n+1106n+22 3n+1116n+30 3n+2206n+41 3n+2216n+52 Current state Next state

2 Finite Automata26 Example DFA Current state Next symbol Next state q0q0 0q0q0 q0q0 1q1q1 q1q1 0q2q2 q1q1 1q0q0 q2q2 0q1q1 q2q2 1q2q2 M = ({q 0, q 1, q 2 }, {0, 1}, , q 0, {q 0 }) q0q0 q1q1 q2q

2 Finite Automata27 Nondeterministic Finite Automata Similar to DFA Nondeterministic move –On reading an input symbol, the automaton can choose to make a transition to one of selected states. –Without reading any symbol, the automaton can choose to make a transition to one of selected states or not. 0 0 

2 Finite Automata28 How to define an NFA a 5-tuple (Q, , , s, F), where –a set of states Q is a finite set –an alphabet  is a finite, non-empty set –a start state s in Q –a set of final states F contained in Q –a transition function  is a function Q  (  {  })  2 Q See formal definition

2 Finite Automata29 Example of NFA An NFA accepting { w  {0,1}  |w ends with 11 } 0, DFA

2 Finite Automata30 Yielding next configuration Definition Let M = (Q, , , s, F) be a non-deterministic finite automaton, and (q 0,  0 ) and (q 1,  1 ) be two configurations of M. We say (q 0,  0 ) yields (q 1,  1 ) in one step, denoted by (q 0,  0 )  M (q 1,  1 ), if q 1   (q 0, a,), and  0 =a  1, for some a    {  }.

2 Finite Automata31 Yield in zero step or more Definition Let M = (Q, , , s, F) be an NFA, and (q 0,  0 ) and (q 1,  1 ) be two configurations of M. (q 0,  0 ) yields (q 1,  1 ) in zero step or more, denoted by (q 0,  0 )  * M (q 1,  1 ), if –q 0 = q 1 and  0 =  1, or –(q 0,  0 )  M (q 2,  2 ) and (q 2,  2 )  * M (q 1,  1 ) for some q 2 and  2. Same as that for DFA

2 Finite Automata32 Accepting a string Definition Let M = (Q, , , s, F) be an NFA, and    *. We say M accepts  if (s,  )  * M (f,  ), when f  F. Otherwise, we say M rejects . Same as the definition for a DFA

2 Finite Automata33 Language accepted by an NFA Let M = (Q, , , s, F) be an NFA. The language accepted by M, denoted by L(M) is the set of strings accepted by M. That is, L(M) = {  *| (s,  )  * M (f,  ) for some f  F } Same as the definition for a DFA

2 Finite Automata34 How NFA’s work (s,01111)  - (s,1111)  - (s,111)  - (s,11)  - (s,1)  - (s,  ) (s,01111)  - (s,1111)  - (s, 111)  - (s,11)  - (s,1)  - (q,  ) (s,01111)  - (s, 1111)  - (s, 111)  - (s,11)  - (q,1)  - (f,  ) (s,01111)  - (s, 1111)  - (s, 111)  - (q,11)  - (f,1) (s,01111)  - (s, 1111)  - (q, 111)  - (f,11) 0,1 11 s, sqf s, 1111 s, 111q, 111 s, 11 f,  q, 1 q, 11 s,  s, 1 q,  f, 1 f, 11

2 Finite Automata35 Other examples of NFA { w  {0,1}* | w has either 00 or 11 as substring} {w  {0,1}* | w has 00 and 11 as substrings and 00 comes before 11 } 0,   

2 Finite Automata36 DFA and NFA are equivalent M d and M n are equivalent  L(M d ) = L(M n ). DFA and NFA are equivalent  For any DFA M d, there exists an NFA M n such that M d and M n are equivalent. (part 1) For any NFA M n, there exists a DFA M d such that M d and M n are equivalent. (part 2)

2 Finite Automata37 Part 1 of the equivalence proof For any DFA M d, there exists an NFA M n such that M d and M n are equivalent. Proof: Let M d be any DFA. We want to construct an NFA M n such that L(M n ) = L(M d ). From the definitions of DFA and NFA, if M is a DFA then it is also an NFA. Then, we let M n = M d. Thus, L(M d ) = L(M n ).

2 Finite Automata38 Part 2 of the equivalence proof For any NFA M n, there exists a DFA M d such that M d and M n are equivalent. Proof: Let M n = (Q, , , s, F) be any NFA. We want to construct a DFA M d such that L(M d ) = L(M n ). First define the closure of q, denoted by E(q). Second, construct a DFA M d =(2 Q, ,  ', E(s), F') Finally, prove     f  F (s,  ) |- * Mn (f,  )   f '  F ' (E(s),  ) |- * Md (f ',  ).

2 Finite Automata39 Eliminating transitions to multiple states sq f 0,1 11 s s,q 1 s,q,f

2 Finite Automata40 Eliminating empty-string transitions spq r f ε, ε ε sp,q, r rp,q,r,f 0 0,1 1 1

2 Finite Automata41 Closure of state q Let M = (Q, , , s, F) be an NFA, and q  Q. The closure of q, denoted by E(q), is –the set of states which can be reached from q without reading any symbol. –{p  Q| (q,  ) |- M * (p,  )} If an NFA is in a state q, it can also be in any state in the closure of q without reading any input symbol.

2 Finite Automata42 Example of closure sqf abc   M=({s, q, f}, {a, b, c}, , s, {f}) where  is defined below. L(M)={a i b j c k | i, j, k  0} stateclosure sqfs, q, f qfq, f ff

2 Finite Automata43 Another example of closure q0q0 q1q1 q2q2 q3q3 q4q4 1q1q1 q 2, q 3 q3q3 2 3 q(q,a,r)(q,b,r) (q, ,r) q0q0 q2q2 q1q1 q1q1 q 0,q 4 q2, q3q2, q3 q2q2 q4q4 q3q3 q4q4 q4q4 q3q3 q0q0 q1q1 q2q2 q3q3 q4q4 b    a b  a a

2 Finite Automata44 Constructing the equivalent DFA Let M n = (Q, , , s, F) be any NFA. We construct a DFA M d =(2 Q, ,  ', E(s), F'), where : –  '(q',a) =  {r  E(p)| p   (q,a) } and –F' = {f  Q | f  F   }) q  q' q pr a a ε ε ε DFA

2 Finite Automata45 Example of DFA construction E(q 0 ) E(q 1 ) E(q 2 )E(q 3 ) E(q 4 ) q 0, q 1, q 2, q 3 q 1, q 2, q 3 q2q2 q3q3 q 3,q 4 q0q0 q1q1 q2q2 q3q3 q4q4 b    a b  a a

2 Finite Automata46 Example of DFA construction q 0,q 1,q 2,q 3 q 0,q 1,q 2,q 3,q 4 q 2,q 3,q 4 q 3,q 4  a b b a a b b a a,b E(q 0 ) E(q 1 ) E(q 2 )E(q 3 ) E(q 4 ) q 0, q 1, q 2, q 3 q 1, q 2, q 3 q2q2 q3q3 q 3,q 4  (q,a,r)(q,b,r) (q, ,r) q0q0 q2q2 q1q1 q1q1 q 0 q 4 q 2 q 3 q2q2 q4q4 q3q3 q4q4 q4q4 q3q3

2 Finite Automata47 Prove property of  and  ' Let M n = (Q, , , s, F) be any NFA, and M d = (2 Q, ,  ', E(s), F') be a DFA, where –  '(q', a) =  {r  E(p)| p  (q,a)} and –F' = {f  Q | f  F   } Prove   ,  f  F (s,  ) |- * Mn (f,  )   f '  F ' (E(s),  ) |- * Md (f',  ) and f  f' by induction. Prove a more general statement   ,  p, q  Q (p,  ) |- * Mn (q,  )  (E(p),  ) |- * Md (q',  ) and q  q'. q  q'

2 Finite Automata48 Proof Part I: For any string  in Σ *, and states q and r in Q, there exists R  Q such that (q,  )  * Mn (r, ε)  (E(q),  )  * Md (R, ε) and r  R.

2 Finite Automata49 Proof Basis: Let  be a string in Σ*, q and r be states in Q, and (q,  )  * Mn (r, ε) in 0 step. Because (q,  )  * Mn (r, ε) in 0 step, we know (1) q=r, and (2)  = ε. Then, (E(q),  ) = (E(r), ε). Thus, (E(q),  )  * Md (E(r), ε). That is, there exists R=E(r) such that r  R and (E(q),  )  * Md (R, ε).

2 Finite Automata50 Proof Induction hypothesis: For any non-negative integer k, string  in Σ *, and states q and r in Q, there exists R  Q : ( q,  )  * Mn (r, ε) in k steps -> (E(q),  )  * Md (R, ε) and r  R. Induction step: Prove, for any non-negative integer k, string  in Σ *, and states q and r in Q, there exists R  Q : (q,  )  * Mn (r, ε) in k +1 steps -> (E(q),  )  * Md (R, ε) and r  R.

2 Finite Automata51 Proof Let  be a string in Σ *, q and r be states in Q, and (q,  )  * Mn (r, ε) in k +1 steps. Because (q,  )  * Mn (r, ε) in k +1 steps and k  0, there exists a state p in Q and a string  Σ * such that (q,  )  * Mn (p, a) in k steps and (p, a)  Mn (r, ε) for some a  Σ  {ε}.

2 Finite Automata52 Proof From the induction hypothesis and (q,  )  * Mn (p, a) in k steps, we know that there exists P  Q such that (E(q),  )  * Md (P, a) and p  P. Since (p, a)  Mn (r, ε), r  (p, a). From the definition of  of M d, E(  (p, a))   (P, a) because p  P. Because r  (p, a) and E(  (p, a))   (P, a), r  (P, a). Then, for R=  (P, a), (P, a)  * Md (R, ε) and r  R. Thus, (E(q),  )  * Md (P, a)  * Md (R, ε) and r  R.

2 Finite Automata53 Proof Part II: For any string  in Σ*, and states q and r in Q, there exists R  Q such that r  R and (E(q),  )  * Md (R, ε) -> (q,  )  * Mn (r, ε). E(q) R q r rRrR

2 Finite Automata54 Proof Basis: Let  be a string in Σ *, q and r be states in Q, R be a subset of Q such that r  R and (E(q),  )  * Md (R, ε) in 0 step. Because (E(q),  )  * Md (R, ε) in 0 step, E(q)=R and  =ε. From the definition of E,  (q, ε)=R because E(q)=R. Then, for any r  R, (q,  )  * Mn (r, ε). That is, there exists R=E(q) such that r  R and (q,  )  * Mn (r, ε).

2 Finite Automata55 Proof Induction hypothesis: For any non-negative integer k, string  in Σ *, and states q and r in Q, there exists R  Q such that r  R and: (E(q),  )  * Md (R, ε) in k steps ->(q,  )  * Mn (r, ε). Induction step: Prove, for any non-negative integer k, string  in Σ *, and states q and r in Q, there exists R  Q such that r  R : ( E(q),  )  * Md (R, ε) in k +1 steps ->(q,  )  * Mn (r, ε).

2 Finite Automata56 Proof Let  be a string in Σ *, q and r be states in Q, and (E(q),  )  * Md (R, ε) in k +1 steps. Because (E(q),  )  * Md (R, ε) in k +1 steps and k  0, there exists P  2 Q (i.e. P  Q ) and a string  Σ * such that  =  a, (E(q),  )  * Md (P,ε) in k steps and (P, a)  Md (R, ε) for some a  Σ. E(q) R q r rRrR P k+1 steps a

2 Finite Automata57 Proof From the induction hypothesis and (E(q),  )  * Md (P, ε) in k steps, we know that there exists p  P such that (q,  )  * Mn (p,ε) (i.e. (q,  a)  * Mn (p, a) ). Since (P, a)  Md (R, ε), there exists r  R such that r=  (p, a). Then, for some r  R, (p, a)  * Mn (r, ε). Thus, (q,  )  * Mn (p, a)  * Mn (r, ε) for some r  R. E(q)E(q) R q r rRrR P p pPpP k +1 steps a a

2 Finite Automata58 Closure Properties The class of languages accepted by FA’s is closed under the operations –Union –Concatenation –Complementation –Kleene’s star –Intersection

2 Finite Automata59 Closure Property under Union The class of languages accepted by FA is closed under union. Proof: Let M A = (Q A, Σ,  A, s A, F A ) and M B = (Q B, Σ,  B, s B, F B ) be any FA. We construct an NFA M = (Q, Σ, , s, F) such that –Q = Q A  Q B  {s} –  =  A   A  {(s, ε, {s A, s B })} –F = F A  F B sAsA sBsB We prove that L(M) = L(M A )  L(M B ). s ε ε

2 Finite Automata60 Proof To prove L(M) = L(M A )  L(M B ), we prove: I.For any string  Σ *  L(M A ) or  L(M B )   L(M) & II.For any string  Σ *  L(M A ) and  L(M B ).   L(M) For I, consider (a)  L(M A ) or (b)  L(M B ). For (a), let  L(M A ). From the definition of strings accepted by an FA, there is a state f A in F A such that ( s A,  ) |-* MA ( f A, ε). Because  A , (s A,  ) |-* M (f A, ε) also. Because s A  (s,ε), (s,  ) |- M (s A,  ). Thus, (s,  ) |- M (s A,  ) |-* M (f A, ε). Because f A  F,  L(M). Similarly for (b). s sAsA sBsB ε ε

2 Finite Automata61 Proof For (II), let  L(M A )  L(M B ). Because (s, ε, {s A, s B }) , either (s,  ) |- M (s A,  ) or (s,  ) |- M (s B,  ) only. Because  L(M A ), there exists no f A in F A such that (s A,  ) |-* MA (f A,ε). Because  L(M B ), there exists no f B in F B such that (s B,  ) |-* MB (f B, ε). Since there is no transition between states in Q A and Q B in M, there exists no state f in F=F A  F B such that (s,  ) |- M (s A,  ) |-* M (f A, ε) or (s,  ) |- M (s B,  ) |-* M (f B, ε). That is,  L(M). Thus, L(M) = L(M A )  L(M B ). s sAsA sBsB ε ε

2 Finite Automata62 Closure under concatenation ε ε ε sAsA MAMA sBsB MBMB

2 Finite Automata63 Closure under complementation sAsA MAMA DFA only

2 Finite Automata64 Closure under Kleene’s star sAsA fAfA s f   

2 Finite Automata65 Closure under intersection The class of languages accepted by FA is closed under intersection. Proof: Let L 1 and L 2 be languages accepted by FA. L 1  L 2 = (  L 1  L 2 ) By the closure property under complementation, there are FA accepting  L 1 and  L 2. By the closure property under union, there is an FA accepting  L 1  L 2. By the closure property under complementation, there is an FA accepting(  L 1  L 2 ). Thus, the class of languages accepted by FA is closed under intersection.

2 Finite Automata66 DFA accepting the intersection of two languages Let M A = (Q A, Σ,  A, s A, F A ) and M B = (Q B, Σ,  B, s B, F B ) be any FA. We construct an NFA M = (Q, Σ, , s, F) such that –Q = Q A  Q B –  =  A   A (i.e.  ((q A,q B ),a) =  A (q A,a)  B (q B,a)) –s = (s A, s B ) –F = F A  F B

2 Finite Automata67 Example q0q0 q1q1 q2q ,1 11 p0p0 p1p1 p2p2 p 0,q 1 p 0,q 0 p 0,q p 1,q 1 1 p 1,q 0 1 p 1,q 2 1 p 2,q 0 1 p 2,q 1 1 p 2,q 2 1

2 Finite Automata68 Check list Basic  Explain how DFA/NFA work (configuration, yield next configuration)  Find the language accepted by DFA/NFA  Construct DFA/NFA accepting a given language  Find closure of a state  Convert an NFA into a DFA  Prove a language accepted by FA  Construct FA from other FA’s Advanced  Prove DFA/NFA accepting a language  Prove properties of DFA/NFA  Configuration change  Under some modification  etc.  Prove some properties of languages accepted by DFA/NFA  Under some modification  Surprise!