CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Finite Automata CPSC 388 Ellen Walker Hiram College.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata 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
1 Introduction to Computability Theory Discussion1: Non-Deterministic Finite Automatons Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
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.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
Finite Automata Finite-state machine with no output. FA consists of States, Transitions between states FA is a 5-tuple Example! A string x is recognized.
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.
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.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Non-Deterministic Automata Regular Expressions.
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.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Cs3102: Theory of Computation Class 4: Nondeterminism Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
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.
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.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CHAPTER 1 Regular Languages
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
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.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Lecture Notes 
Nondeterministic Finite Automata (NFAs). Reminder: Deterministic Finite Automata (DFA) q For every state q in Q and every character  in , one and only.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
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.
Nondeterminism The Chinese University of Hong Kong Fall 2011
CIS Automata and Formal Languages – Pei Wang
Non Deterministic Automata
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Non-Deterministic Finite Automata
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
CSE322 Definition and description of finite Automata
Non Deterministic Automata
Chapter 1 Regular Language
Nondeterminism The Chinese University of Hong Kong Fall 2010
Part Two : Nondeterministic Finite Automata
Presentation transcript:

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Based on a work at Permissions beyond the scope of this license may be available at

CLOSURE PROOFS REVIEWING OUR EXAMPLE Guaranteed to be on exams

From last time Are regular languages closed under union? a) True b) False

Union of two regular languages L1 = {w | b’s never appear after a’s} L2 = {w | length(w) is odd} L1 U L2 = {w | b’s never appear after a’s OR length(w) is odd} Regular because there’s a DFA

Union of two regular languages L1 U L2 = {w | b’s never appear after a’s OR length(w) is odd} Does this prove that regular languages are closed under union? – (a) True or (b) False It’s just one example

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L 1, L 2. Want to show: L 1 U L 2 is regular. Because L 1 and L 2 are regular, we know there exist DFAs M 1 = (Q 1,Σ,δ 1,q 01,F 1 ) and M 2 = (Q 2,Σ,δ 2,q 02,F 2 ) that recognize L 1 and L 2. We construct a DFA M = (Q,Σ,δ,q 0,F), s.t.: – Q = Q 1 x Q 2 – δ((x,y),c) = (δ 1 (x,c), δ 2 (y,c)), for c in Σ and (x,y) in Q – q 0 = (q 01, q 02 ) – F = {(x,y) in Q | x in F 1 or y in F 2 } M recognizes L 1 U L 2. Correctness: ___________________________________ A DFA recognizes L 1 U L 2, so L 1 U L 2 is regular, and the class of regular languages is closed under union. Q.E.D. Final form for your homework/test: Could you come up with this, and write it correctly, in a short amount of time on an exam??

NONDETERMINISTIC FINITE AUTOMATA NFA They’re really good guessers! What is deterministic?

DFA or NFA? a)DFA b)NFA c)Both DFA and NFA

DFA or NFA? a)DFA b)NFA c)Both DFA and NFA

Tracing in an NFA What are the two sequences of states on the input “100”? a)(q0,q0,q1,q2[accept]), (q0,q1,q2[accept]) Final: Accept b)(q0,q0,q1,q2[accept]), (q0,q1,q2[reject]) Final: Accept c)(q0,q0,q1,q2[accept]), (q0,q1,q2[reject]) Final: Reject d)(q0,q0,q1,q2[reject]), (q0,q1,q2[reject]) Final: Reject “100” b

DFAs vs. NFAs DFAs For each character in the alphabet, exactly one transition leaving every state Computation is “deterministic,” i.e. determined by the input, i.e., the same every time for a given input NFAs There may be 0, 1, or many transitions leaving a single state for the same input character Transition function defined on “epsilon” in addition to alphabet characters There may be several different ways to reach an accept state for a single string—the computation may not determined by the input (“nondeterministic”)

Formal Definition of an NFA An NFA M 1 is defined as a 5-tuple as follows: M 1 = (Q, Σ, δ, q0, F), where: – Q is a finite set of states – Σ is a finite set of characters, the alphabet – δ: Q x Σ -> P (Q), the transition function – q0, a member of Q, the start state – F, a subset of Q, the accept state(s) 12 NEED TO USE THIS FOR PROOFS---CANNOT MAKE GENERAL STATEMENTS BY DRAWING SPECIFIC EXAMPLES! WHAT IS the POWER SET?

Nondeterminism Because NFAs are non-deterministic, the outcome (accept/reject) of the computation may be different from run to run (i.e., isn’t determined by the input) a)TRUE b)FALSE 13

REG. LANGS. CLOSED UNDER UNION (WHY NFAS ARE SO USEFUL IN PROOFS) A different (easier!) way to prove what we just proved

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L 1, L 2. Want to show: L 1 U L 2 is regular. Because L 1 and L 2 are regular, we know there exist DFAs M 1 = (Q 1,Σ,δ 1,q 01,F 1 ) and M 2 = (Q 2,Σ,δ 2,q 02,F 2 ) that recognize L 1 and L 2. We construct a DFA M = (Q,Σ,δ,q 0,F), s.t.: – Q = Q 1 x Q 2 – δ((x,y),c) = (δ 1 (x,c), δ 2 (y,c)), for c in Σ and (x,y) in Q – q 0 = (q 01, q 02 ) – F = {(x,y) in Q | x in F 1 or y in F 2 } M recognizes L 1 U L 2. Correctness: ___________________________________ A DFA recognizes L 1 U L 2, so L 1 U L 2 is regular, and the class of regular languages is closed under union. Q.E.D. Final form for your homework/test: Could you come up with this, and write it correctly, in a short amount of time on an exam??

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L 1, L 2. Want to show: L 1 U L 2 is regular. Because L 1 and L 2 are regular, we know there exist DFAs M 1 = (Q 1,Σ,δ 1,q 01,F 1 ) and M 2 = (Q 2,Σ,δ 2,q 02,F 2 ) that recognize L 1 and L 2. We construct an NFA M = (Q,Σ,δ,q 0,F), s.t.: – Q = – δ(x,c) = – q 0 = – F = M recognizes L 1 U L 2. Correctness: ___________________________________ An NFA recognizes L 1 U L 2, so L 1 U L 2 is regular, and the class of regular languages is closed under union. Q.E.D. Final form for your homework/test: Could you come up with this, and write it correctly, in a short amount of time on an exam??

Back to our working example

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L 1, L 2. Want to show: L 1 U L 2 is regular. Because L 1 and L 2 are regular, we know there exist DFAs M 1 = (Q 1,Σ,δ 1,q 01,F 1 ) and M 2 = (Q 2,Σ,δ 2,q 02,F 2 ) that recognize L 1 and L 2. We construct an NFA M = (Q,Σ,δ,q 0,F), s.t.: – Q = – δ(x,c) = – q 0 is a new state not in Q 1 or Q 2 – F = M recognizes L 1 U L 2. Correctness: ___________________________________ An NFA recognizes L 1 U L 2, so L 1 U L 2 is regular, and the class of regular languages is closed under union. Q.E.D. Final form for your homework/test: Discrepancy here NFA vs DFA

Thm. The class of regular languages is closed under the union operation. Because L 1 and L 2 are regular, we know there exist DFAs M 1 = (Q 1,Σ,δ 1,q 01,F 1 ) and M 2 = (Q 2,Σ,δ 2,q 02,F 2 ) that recognize L 1 and L 2. We construct an NFA M = (Q,Σ,δ,q 0,F), s.t.: – Q = ? – δ(x,c) = – q 0 is a new state not in Q 1 or Q 2 – F = ? – a) Q = Q 1 X Q 2, F = F 1 X F 2 – b) Q = Q 1 X Q 2, F = {(x,y) in Q | x in F 1 or y in F 2 } – c) Q = Q 1 U Q 2, F = F 1 U F 2 – d) Q = Q 1 U Q 2 U {q 0 }, F = F 1 U F 2 Why q0 in {}?

Thm. The class of regular languages is closed under the union operation. Proof: Given: Two regular languages L 1, L 2. Want to show: L 1 U L 2 is regular. Because L 1 and L 2 are regular, we know there exist DFAs M 1 = (Q 1,Σ,δ 1,q 01,F 1 ) and M 2 = (Q 2,Σ,δ 2,q 02,F 2 ) that recognize L 1 and L 2. We construct an NFA M = (Q,Σ,δ,q 0,F), s.t.: – Q = Q 1 U Q 2 – δ(x,c) = ? – q 0 is a new state not in Q 1 or Q 2 – F = F 1 U F 2 M recognizes L 1 U L 2. Correctness: ___________________________________ An NFA recognizes L 1 U L 2, so L 1 U L 2 is regular, and the class of regular languages is closed under union. Q.E.D. Final form for your homework/test: Discrepancy here NFA vs DFA

Thm. The class of regular languages is closed under the union operation. – Q = Q 1 U Q 2 – δ(x,c) = δ 1 (x,c) if x in Q 1 δ 2 (x,c) if x in Q 2 {q 01,q 02 } if x = q 0 and c = ε { } if x = q 0 and c != ε – q 0 is a new state not in Q 1 or Q 2 – F = F 1 U F 2 Almost done: we have shown there is an NFA accepting L1 U L2. Does this mean it’s regular? Next class! Zoomed in Discrepancy here NFA vs DFA