CSCI 2670 Introduction to Theory of Computing

Slides:



Advertisements
Similar presentations
Non-Deterministic Finite Automata
Advertisements

Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata Prof. Amos Israeli.
Introduction to Computability Theory
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Finite Automata and Non Determinism
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.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
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 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.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
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.
CSCI 2670 Introduction to Theory of Computing August 24, 2005.
Theory of Languages and Automata
CSCI 2670 Introduction to Theory of Computing August 26, 2004.
CSCI 2670 Introduction to Theory of Computing August 25, 2005.
CSCI 2670 Introduction to Theory of Computing September 1, 2005.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Lecture Notes 
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 Language Recognition (11.4) Longin Jan Latecki Temple University Based on slides by Costas Busch from the courseCostas Busch
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
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.
Theory of Languages and Automata By: Mojtaba Khezrian.
Recap: Nondeterministic Finite Automaton (NFA) A deterministic finite automaton (NFA) is a 5-tuple (Q, , ,s,F) where: Q is a finite set of elements called.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
Non Deterministic Automata
Regular Expressions.
CSE 105 theory of computation
Single Final State for NFA
Language Recognition (12.4)
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Hierarchy of languages
Non-Determinism 12CS45 Finite Automata.
Lecture3 DFA vs. NFA, properties of RL
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
Non-Deterministic 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
Chapter Five: Nondeterministic Finite Automata
CSCI 2670 Introduction to Theory of Computing
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Language Recognition (12.4)
CSCI 2670 Introduction to Theory of Computing
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
CSE 105 theory of computation
Chapter 1 Regular Language
Finite-State Machines with No Output
CHAPTER 1 Regular Languages
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
Presentation transcript:

CSCI 2670 Introduction to Theory of Computing September 6, 2007

Announcement Check website for next homework assignment http://www.cs.uga.edu/~shelby/classes/2670-fall-07/

Agenda Last class This class Defined regular languages Discussed creating DFA’s Showed that union is a regular operation This class Show concatenation is a regular operation Introduce NFA’s Non-deterministic finite automata

Combining regular languages We can create a regular language from other regular languages A and B using specific allowable operations called regular operations Union: A  B Concatenation: A  B Kleene star: A*

Union is a regular operation Theorem: The class of regular languages is closed under the union operation Proof approach: Assume A1 and A2 are both regular languages with A1=L(M1) and A2=L(M2) and create a DFA M such that L(M) = A1A2 Method: Proof by construction

Example M1 M2 q1 q2 q3 0,1 1 q1’ q2’ q3’ 1 1 1 q2,q1’ q3,q1’ q1,q1’ 1 0,1 1 M1 Example q1’ q2’ q3’ 1 1 1 M2 q2,q1’ q3,q1’ q1,q1’ 1 1 1 q3,q2’ q1,q2’ q2,q2’ 1 1 1

Still need to prove L(M) = A1A2 How should we do this? Show any string in A1A2 is in L(M) Let x be an element of A1A2 For simplicity, assume x is in A1 Same argument below (with minor changes) applies for A2 The computation path q0, q1, …, qk for x in the DFA that recognizes A1 ends at an accept state The computation path in M will be (q0,r0), (q1,r1), …, (qk,rk) for some states r0, r1, …, rk in the DFA that accepts A2 (qk,rk) is an accept state in M Therefore x is in L(M)

Still need to prove L(M) is A1A2 Show any string in L(M) is in A1A2 Let x be an element of L(M) The computation path of x in M is (q0,r0), (q1,r1), …, (qk,rk) for some states q0, q1, …, qk and r0, r1, …, rk in the DFA’s that accept A1 and A2, respectively (qk,rk) is an accept state in M Either qk or rk must be an accept state in its DFA Therefore x is in A1A2

Concatenation is a regular operation Theorem: The class of regular languages is closed under the concatenation operation Proof approach: Assume A1 and A2 are both regular languages with A1=L(M1) and A2=L(M2) and create a DFA M such that L(M) = A1A2 Method: Proof by construction

Example M1 M2 Can jump to q1’ non-deterministically q1 q2 q3 0,1 1 1 0,1 1 M1 1 q1’ q2’ q3’ M2 Example q1 q2 q3 0,1 1 q1’ q2’ q3’ ε Can jump to q1’ non-deterministically

NFA vs. DFA DFA NFA Exactly one arrow exiting each node for each symbol of the alphabet Number of exiting arrows can be anything from 0 to the number of nodes Each arrow is labeled only with characters of the alphabet Characters may be labeled with an empty string, ε Each string reaches exactly one state at the end of the input A string may reach several different states states at the end of the input

Computing on an NFA For each symbol of the string, keep track of all possible transitions in parallel When input ends, there may be several possible ending states If at least one of the possibilities is an accepting state, then the NFA accepts the string

Example Does this NFA accept the string 001? From state(s) Input 0,1 1 q1 q2 ε q3 1 1 Does this NFA accept the string 001? From state(s) Input To state(s) q1 q2, q3 1 q1, q3 Yes q1, q3

Example Any string containing two 1’s separated by at most one 0 0,1 1 ε Any string containing two 1’s separated by at most one 0

Example Zero or more concatenations of the strings aba and ab   b a

Example ε a, b, c a, b, d a, c, d b, c, d Strings of any length containing at most three of the symbols in  = {a, b, c, d}

The power of non-determinism Strings of any length containing at most two of the symbols in  = {a, b, c} c a b a, b, c a, c b,c a, b DFA a, b a, c b, c ε NFA

Non-deterministic finite automaton A non-deterministic finite automaton is a 5-tuple (Q,,,q0,F), where Q is a finite set of states  is a (finite) alphabet  : Q × ε  P(Q) is the transition function  maps to sets of states q0 is the start state, and F  Q is the set of accept states

Equivalence of DFAs and NFAs Theorem: Every non-deterministic finite automaton has an equivalent deterministic finite automaton Both FAs accept the same language Proof method Construction Similar to method used for calculating strings Follow all paths in parallel where states represent parallel paths

Proof idea Given NFA M1={Q,,,q0,F} construct DFA M2={Q’,,’,q0’,F’} with L(M1)=L(M2) Intuition Recall :Q×εP(Q) Our DFA’s transition function will generate paths within P(Q) ’: P(Q)×P(Q)

Defining M2 (ignoring  jumps) Determine Q’, q0’, and F’ Q’ = P(Q) q0’ = {q0} F’ = {R  Q’ | R  F  } i.e., R contains at least one of M1’s accept states Defining ’ (for now ignore ε jumps) (r,a) is the set of states reached from r when a is processed r is one of the states in R (i.e., a state in the NFA) R is a set of states from the NFA a is a symbol in the alphabet

Example Q’={,{q1}, {q2}, {q3}, {q1,q2}, {q1,q3}, {q2,q3}, {q1,q2,q3}} q1 1 q3 Q’={,{q1}, {q2}, {q3}, {q1,q2}, {q1,q3}, {q2,q3}, {q1,q2,q3}}

Example 1 q2 q1 1 q3 q0’={q1}

Example 1 q2 q1 1 q3 F’={{q3}, {q1,q3}, {q2,q3}, {q1,q2,q3}}

Example 1 {q1} {q2,q3}  {q2} {q1,q3} {q3} {q1,q2} {q1,q2,q3} 1 1 q2 1 {q1} {q2,q3}  {q2} {q1,q3} {q3} {q1,q2} {q1,q2,q3} 0,1 {q1}  1 {q2,q3} {q1,q3} 1 q1 q2 q3

Proof of Correctness Theorem: Let N be an NFA and let M be the DFA constructed by the method described above. Then L(M) = L(N). Proof: Let x be any string in Σ*. Let R be the set of states in N in which computation of x terminates and let R’ be the state in M in which computation of x terminates. Want to prove R = R’

R = R’ Proof by induction Base case Induction hypothesis On what? Base case x = ε Then R = R’ = {q0} Induction hypothesis Assume R = R’ for all strings of length at most k Induction step Prove R = R’ when |x| = k + 1

Induction Step Let x = x1x2…xkxk+1 Let S and S’ be the (set of) states arrived at after computing x1…xk in M and N, respectively By induction hypothesis S = S’ What happens when we read xk+1 In N, we can go to any state q such that q = δ(q’,xi+1) for some q’ in S R = {δ(q’,xk+1) | q’ in S} In M, by definition we go to R’ = δ’(S’,xk+1) = {δ(q’,xk+1) | q’ in S’} Thus R = R’ by induction hypothesis

Have a Fabulous Weekend