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.

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.
8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
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.
THE PUMPING LEMMA PROVING A LANGUAGE IS NOT REGULAR Dr. Cynthia Lee - UCSD - Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia.
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.
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
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
Lexical Analysis III Recognizing Tokens Lecture 4 CS 4318/5331 Apan Qasem Texas State University Spring 2015.
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.
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.
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 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
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.
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,
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.
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.
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
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.
1 Unit 1: Automata Theory and Formal Languages Readings 1, 2.2, 2.3.
Theory of Languages and Automata
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.
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Lexical Analysis Constructing a Scanner from Regular Expressions.
Tutorial: Reduction from A TM Proofs Dr. Cynthia Lee CSE 105, UCSD Spring 2011 Theory of Computation Peer Instruction Lecture Slides by Dr. Cynthia Lee,
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2010.
CMSC 330: Organization of Programming Languages Theory of Regular Expressions Finite Automata.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
NFA defined. NFA A Non-deterministic Finite-state Automata (NFA) is a language recognizing system similar to a DFA. It supports a level of non-determinism.
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 3 Mälardalen University 2007.
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.
Chapter 5 Finite Automata Finite State Automata n Capable of recognizing numerous symbol patterns, the class of regular languages n Suitable for.
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.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Deterministic Finite Automata Nondeterministic Finite Automata.
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
Non-Deterministic Finite Automata
Non Deterministic Automata
Chapter 1 Regular Language
Presentation transcript:

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 3.0 Unported License. Based on a work at Cynthia Lee, UCSDCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licensewww.peerinstruction4cs.org

Extra Credit Quiz If there is somebody in your group who seems really smart, it is a good idea to just let that person do all the talking like a “mini-teacher,” so that you can learn from them. a)TRUE b)FALSE

NONDETERMINISTIC FINITE AUTOMATA NFA They’re really good guessers!

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”

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 A DFA 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) 8

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 9

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.

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.

Back to our working example

EQUIVALENCE OF FINITE AUTOMATA NFA & DFA Another construction proof

Tracing in NFA Fill in the missing row of states: a)q2, q3, q4, q4, q4 b)q1, q2, q4, q4, q4 c)q1, q2, q3, q4, q4 d)None of the above e)I don’t understand this at all (Fig in your book) Run this NFA on input

Tracing in NFA Each row is a set of states that we are in at the “same time” – {q1} – {q1,q2,q3} – {q1,q3} – {q1,q2,q3,q4} – {q1,q3,q4} Recall that when we did the union closure proof with DFAs, we were always in a pair of states at the “same time”—same concept What are all the possible unique sets of states? (a) QxQ (b) |Q| 2 (c) P (Q) (d) |Q|! (Fig in your book) Run this NFA on input (e) I don’t understand this at all

Thm. 1.39: Every NFA has an equivalent DFA. Given: NFA M = (Q,Σ,δ,q 0,F) Want: DFA M’ = (Q’,Σ,δ’,q 0 ’,F’) s.t. L(M) = L(M’). Construction: //need to make a DFA that simulates nondeterminism within the constraints of determinism (!!) – Q’ = – Σ – δ’ – q 0 ’ = – F’ = A DFA recognizes L(M), then every NFA has an equivalent DFA. Q.E.D.

Thm. 1.39: Every NFA has an equivalent DFA. We also know every DFA is an NFA. Corollary of these two facts: The class of languages recognized by DFAs and the class of languages recognized by NFAs are the same class – The Class of Regular Languages It may be surprising that adding something as powerful and magic-seeming as instantaneous, 100% accurate guessing to the DFA model could turn out to not increase the power of the model! – This course is full of surprises!

REGULAR EXPRESSIONS PATTERN MATCHING Extremely useful

From the Reading Quiz Let L be the language of this regular expression: 1*0 Which of the following is NOT in L? a)10 b)100 c)110 d)They’re all in L

Regular Expressions and UNIX/Linux Shell Wildcard 1*0 = “Any number of 1’s (including no 1’s), followed by a single 0” – “100” not accepted by that RE This may be confusing to those who are used to *’s usage in, say, UNIX/Linux shell—VERY DIFFERENT – In UNIX/Linux * means “replace with anything here” 1*0 matches “100” and “1blahblahblah0” – Typical shell usage: “ls *.jpg” (to list all JPEG files) – This is very useful to know! Just don’t confuse it with REs in this course

Regular Expressions Let L be the language of this regular expression: ((a U Ø) + b*)* Which of the following is NOT true of L? a)Some strings in L have equal numbers of a’s and b’s b)All strings in L have more b’s than a’s c)L contains “aaaaaa” d)a‘s never follow b’s in any string in L e)None or more than one of the above

Regular Expressions Let L be the language of this regular expression: aØb* Which of the following is NOT true of L? a)L is the empty set b)L contains “a” c)aaab is not in L d)None or more than one of the above