CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)

Slides:



Advertisements
Similar presentations
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Advertisements

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Introduction to Computability Theory
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
NFAs and DFAs Sipser 1.2 (pages 47-63). Last time…
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
NFAs Sipser 1.2 (pages 47–54). CS 311 Mount Holyoke College 2 Recall… Last time we showed that the class of regular languages is closed under: –Complement.
Introduction to Computability Theory
Intro to DFAs Readings: Sipser 1.1 (pages 31-44) With basic background from Sipser 0.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Finite Automata and Non Determinism
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
CS 310 – Fall 2006 Pacific University CS310 Converting NFA to DFA Sections:1.2 Page 54 September 15, 2006.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
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.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Nondeterminism.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
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.
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.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
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.
Great Theoretical Ideas in Computer Science.
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,
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Computation 1 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee, UCSD are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Lecture 05: Theory of Automata:08 Kleene’s Theorem and NFA.
CHAPTER 1 Regular Languages
Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
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.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Finite Automata A simple model of computation. 2 Finite Automata2 Outline Deterministic finite automata (DFA) –How a DFA works.
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.
Deterministic Finite-State Machine (or Deterministic Finite Automaton) A DFA is a 5-tuple, (S, Σ, T, s, A), consisting of: S: a finite set of states Σ:
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
CSE 2001: Introduction to Theory of Computation Fall 2009
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
Presentation transcript:

CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)

Give a formal definition of the non- deterministic finite automaton (NFA) and its computation Show that DFA = NFA in terms of string decision power Properties of language recognized by DFA (or NFA) Objectives

Formal Definition of NFA An NFA is a 5-tuple (Q, , , q start, F), where –Q is a set consisting finite number of states –  is an alphabet consisting finite number of characters –  : Q x    2 Q is the transition function –q start is the start state –F is the set of accepting states Here, we let   =  [ {  }

Formal Definition of NFA Q = {q 1, q 2, q 3, q 4 },  = { 0, 1 }, q start = q 1, F = { q 4 },  (q 1, 0) = {q 1 },  (q 1, 1) = {q 1,q 2 },  (q 1,  ) = { }, … q1q1 q4q4 0,1 0,  start q2q2 q3q3 0,1 11

Formal Definition of NFA’s Computation Let M = (Q, , , q start, F) be an NFA Let w be a string over the alphabet  Then, M accepts w if we can write w = w 1 w 2 … w n such that each w i 2   and a sequence of states r 0, r 1, …, r n in Q exists with the three conditions: –r 0 = q start –r i+1 2  (r i, w i+1 ) –r n 2 F compare this with DFA

DFA = NFA (in terms of string decision power) Theorem: (1) If a language L can be recognized by a DFA, then there exists an NFA that can recognize L; (2) If a language L’ can be recognized by an NFA, then there exists a DFA that recognizes L’. Proof: For (1), it is easy. (why?) For (2), how to prove?

DFA = NFA (Proof Idea) We prove (2) by showing that: Given a language L’ recognized by an NFA, we can always find a DFA that recognizes L’ (what kind of proof technique?) To help our discussion, we define the following: –For any string w, let R(w) denote “the set of states that NFA can exactly reach” after reading all characters of w.

DFA = NFA (Proof Idea) E.g., R(0) = {q 1 }, R(1) = {q 1,q 2,q 3 }, R(00) = {q 1 } R(11) = {q 1, q 2, q 3, q 4 } q1q1 q4q4 0,1 0,  start q2q2 q3q3 0,1 11

DFA = NFA (Proof Idea) If we are the DFA simulating the NFA At any time when part of the input string is processed, say we have read w’, we MUST need to know exactly what is R(w’)… Otherwise, –if we miss a state of R(w’), what bad things may happen? –if we have an extra state, what bad things may happen?

DFA = NFA (Proof Idea) On the other hand, R(w’) is what we only need to know –Because if we know R(w’), we know exactly the set of states NFA can exactly reach after reading one more character (What are those states??) E.g., R(w’) = {q 1, q 3 }, R(w’0) = ?? R(w’1) = ?? q1q1 q4q4 0,1 0,  start q2q2 q3q3 0,1 1 1

DFA = NFA (Proof Idea) By looking at R(w’), how can we determine if the NFA accepts w’? –Question: If q is an accepting state, and we know that q 2 R(w’), will the NFA accepts w’? –Answer: Yes, since q 2 R(w’) means that by reading w’, there is some way we can reach the accepting state q in NFA. By definition, w’ is accepted In fact, w’ is accepted if and only if some accepting state q is in R(w’)

DFA = NFA (Proof Idea) If we can list out the R(w)’s for all w, we can simulate the computation of NFA However, there are infinite number of strings w 1, w 2, … (what could we do?) How about the number of possible set of states, R(w 1 ), R(w 2 ), …, that are just reachable by an NFA? –Are there infinite of them?

DFA = NFA (Formal Proof) Let N = (Q, , , q start, F) be the NFA recognizing some language A We construct a DFA D = (Q’, ,  ’, q start ’, F’) recognizing A as follows Q’ = 2 Q each state of D corresponds to a particular R(w) where E(X) = {X} [ the set of states that NFA N can reach from X by following only  arrows q start ’ = the state corresponding to R(  ) = E(q start )

DFA = NFA (Formal Proof) F’ = { Y 2 Q’ | Y contains an accept state of N } D accepts if one of the possible states that N can now be in is an accept state The reason why  ’ (Y,a) is defined in this way is because: If N is in one of the states in Y, after reading the character a, N can be in any of the states in  (y,a), so that N can be in any states in E(  (y,a)) For Y 2 Q’ and a 2 ,  ’ (Y, a) = { q | q 2 E(  (y,a)) for some y 2 Y }

DFA = NFA (Formal Proof) At every step in D’s computation, D clearly enters a state that corresponds to the subset of states N can exactly reach at that point. Thus, the DFA D recognizes the same language as the NFA N. Our proof completes.

Constructing DFA from NFA (Example)  start a a,b b 1 32 a

Constructing DFA from NFA (Example)  start a a,b b 1 32 a start a a,b { } 3 b a,b {1} a {1,2} {3} {2} {2,3}{1,3} {1,2,3} b a b b a b a b a

Properties of Language Recognized by DFA or NFA Theorem: If A and B are languages recognized by DFAs, then the language A [ B = { x | x 2 A or x 2 B } can also be recognized by a DFA. Proof: Let N 1 be DFA recognizing A, and N 2 be DFA recognizing B. Construct NFA N that recognizes A [ B.

Proof (Informal)   N N2N2 N1N1

Properties of Language Recognized by DFA or NFA Theorem: If A and B are languages recognized by DFAs, then the language A o B = { xy | x 2 A and y 2 B } can also be recognized by a DFA. Proof: Let N 1 be DFA recognizing A, and N 2 be DFA recognizing B. Construct NFA N that recognizes AB.

Proof (Informal) N N2N2 N1N1  

Properties of Language Recognized by DFA or NFA Theorem: If A is a language that can be recognized by a DFA, then the language A* = { x 1 x 2 …x k | k ¸ 0 and x i 2 A } can also be recognized by a DFA. Proof: Let N 1 be DFA recognizing A. Construct NFA N that recognizes A*.

Proof (Informal) N N1N1   

Regular Language The Union, Concatenation, and Star operations are called regular operations Languages that can be recognized by DFA are called regular language

Practice at Home We have given informal construction of N, showing that the class of regular languages is closed under union operations Can you give formal construction? That is, with N 1 = (Q 1,  1,  1, q 1, F 1 ) and N 2 = (Q 2,  2,  2, q 2, F 2 ), what are the values for the tuples in N? That is, if we take two regular languages and perform union operations on them, the resulting language is also a regular language

Practice at Home Also, how about the formal constructions of N showing that the class of regular languages is closed under concatenation operation and is closed under star operations?