Lecture3 DFA vs. NFA, properties of RL

Slides:



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

8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
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
Regular operations Sipser 1.2 (pages 47-63). First… a sample proof
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
CS 310 – Fall 2006 Pacific University CS310 Finite Automata Sections:1.1 page 44 September 8, 2006.
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.
Automata & Formal Languages, Feodor F. Dragan, Kent State University 1 CHAPTER 1 Regular Languages Contents Finite Automata (FA or DFA) definitions, examples,
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.
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.
Theory of Computing Lecture 22 MAS 714 Hartmut Klauck.
Lecture 4UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 4.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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 Expressions (RE) Empty set Φ A RE denotes the empty set Empty string λ A RE denotes the set {λ} Symbol a A RE denotes the set {a} Alternation M.
REGULAR LANGUAGES.
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.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
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.
Finite Automata & Regular Languages Sipser, Chapter 1.
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.
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.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
1 Chapter 2 Finite Automata (part a) Hokkaido, Japan.
Theory of Computation Automata Theory Dr. Ayman Srour.
Dr. Gary Weiss, January Computer Language Theory Chapter 1: Regular Languages.
CIS Automata and Formal Languages – Pei Wang
Foundations of Computing Science
Lecture2 Regular Language
Non Deterministic Automata
Properties of Regular Languages
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Nondeterministic Finite Automata
NFA vs DFA DFA: For every state q in S and every character  in , one and only one transition of the following form occurs:  q q’ NFA: For every state.
CSE 2001: Introduction to Theory of Computation Fall 2009
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Regular Languages Finite Automata eg. Supermarket automatic door:
CS21 Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CHAPTER 1 Regular Languages
NFAs accept the Regular Languages
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

Lecture3 DFA vs. NFA, properties of RL  2004 SDU

Regular operations They are used to study the properties of regular languages. Let A and B be languages, define the regular operations union, concatenation, and star as follows: Example: A = {good, bad}, B = {boy, girl} Then AB = {good, bad, boy, girl}; A  B ={goodboy, goodgirl, badboy, badgirl}, and A*={, good, bad, goodgood, goodbad, badgood, badbad, goodgoodgood, goodgoodbad, goodbadgood, goodbadbad,…} Union: AB = {x| x  A or x  B} Concatenation: A  B = {xy | x  A and y  B} Star: A* = {x1x2…xk | k  0 and each xi  A }  2004 SDU 2

Closure properties of Regular Languages Regular languages are closed under: Union   if A and B are regular languages, so is A  B Concatenation  if A and B are regular languages, so is A  B Star * if A is a regular language, so is A*.  2004 SDU 3

General Construction for  and  Let A1 and A2 be two regular languages, and M1 and M2 be the DFAs that recognize them, we want to construct a DFA M to recognize A1  A2. Can M first simulate M1 and then simulate M2 on an given input? Idea: Simulate two DFA's simultaneously. Let M1 = (Q1, , 1, s1, F1) and M2 = (Q2, , 2, s2, F2) Define:M = (Q, , , s, F) where: Q = Q1  Q2 s = (s1, s2) ((q1, q2), ) = (1(q1, ), 2(q2, )), for each (q1, q2)Q, and each    For Union, F = ? The proof? Ans: (Q1  F2)  (F1  Q2) For Intersection, F = ? The proof? Ans: F1  F2  2004 SDU 4

Example of union L1={w{0,1}*| w contains 01 as substring} 0,1 1 1 2 3 -redundant states You can construct M in an inductive way and avoid redundancy! 1. (s1, s2)  Q 2. If (q1, q2)  Q, then ((q1,0), (q2,0))  Q ((q1,1), (q2,1))  Q 1 0,1 4 1 6 5 14 15 16 24 25 26 34 35 36 1 0,1  2004 SDU 5

How about the other regular operations The concatenation  ? The star * ? Can we use similar way? To solve this problem, we introduce a new technique  non-determinism. In deterministic computation, the next state is determined In non-deterministic computation, several choices may exist Page 48 for example, and 49 for clarity  2004 SDU 6

An example of NFA 0,1 q1 1 q3 1 q4 0,1 q2 0, What is the difference between DFA and NFA? How does it compute on input 001100?  2004 SDU 7

Formal definition of DFA A DFA is a 5-tuple: M = (Q, , , s, F) Where, Q is finite set of states  is finite input alphabet s  Q is the initial state F  Q is the set of final states : Q   -> Q // note that this is a function  2004 SDU 8

Nondeterministic Finite Automaton (NFA) Generalization of DFA. Allows: 0 or more next states for the same (q, a). Guessing Transitions labeled by the empty string . Changing state without reading input Motivation: Flexibility, simplicity.  2004 SDU 9

Formal definition of NFA Notation:   =   {}. An NFA is a 5-tuple: M = (Q, , , s, F) where: Q - a finite set of states  - a finite alphabet s – the start state F  Q – the set of final states  : Q     P(Q), the power set of Q.  2004 SDU 10

NFA -definition Let N =(Q, , , q0, F) be an NFA and w a string over the alphabet . We say N accepts w if we can write w as w = y1…ym ,where each yi is a member of  and a sequence of states p0,…, pm exists with three conditions: p0=q0; for every i, 1 i  m, pi(pi-1,yi); pm F Language recognized by an NFA N, denoted as L(N), is the set of the strings accepted by N.  2004 SDU 11

Example of NFA   guess check Pr: How to understand some branch dies? An NFA that accepts all strings of 0’s the number of which is either a multiple of 2 or a multiple of 3.   guess check Pr: How to understand some branch dies? The formal description of this NFA is…? The computing process on input 0000 is…? more examples on pages 48, 51  2004 SDU 12

NFA vs. DFA Is NFA more powerful than DFA? Theorem: Proof Idea: Ans: No. Theorem: For every NFA M there is an equivalent DFA M' Proof Idea: NFA is in a set of states at any point during reading a string. DFA will use a state to keep track of this. Important Assumption: No transition labeled by epsilon. (Will get rid of this assumption later.)  2004 SDU 13

Equivalent DFA construction. NFA N = (Q, , , s, F) DFA M = (Q', , , s', F') where: Q' = p(Q), power set of Q s' = {s} F' = {P  Q' | P  F is nonempty} ({q1,…,qm}, a) = (q1, a)  (q2, a)  ...  (qm, a) i.e. find all the states that can be reached on a from all the NFA states in a DFA state.  2004 SDU 14

How to handle epsilon transitions? Define e-closure of state P, E(P) = {q|q can be reached from some p  P by traveling along 0 or more  arrows}. Let: ({q1,…,qm}, a) = {qQ| q  E((q1, a))  E((q2, a))  ...  E((qm, a)) Let: s’=E(s) Proof: at each step of M on an input, it clearly enters a state that corresponds to the subset of states that N could be in at that point. See page56. See page 57, example1.41  2004 SDU 15

Construct DFA from NFA ………………………….w1 …………………….w2 … ……………………..wn  is an accepting path on w1…wn in NFA is an accepting path on w1…wn in DFA  2004 SDU 16

Construct from NFA to DFA (example) 1  b a 3 a 2 a,b {1,2} a b {2} a,b {1}  a,b a b a b b a a a {2,3} {1,2,3} {3} {1,3} b b  2004 SDU 17

Regular languages Conclusion: A language is regular iff some NFA recognizes it.  2004 SDU 18

Construction for LºL‘ page 60 Let L=(Q1, , 1,s1,F1); L’=(Q2, , 2,s2,F2) Define: L’’ = (Q,,,s,F), where Q = Q1  Q2 s = s1 F = F2  2004 SDU 19

N’ N N’’     2004 SDU 20

L* Let L=(Q1, , 1, s1, F1) Define: L* = (Q, , , s, F) Q = {s}  Q1 F = {s}  F1  2004 SDU 21

N* N     2004 SDU 22