CSE 2001: Introduction to Theory of Computation Fall 2009

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.
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.
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
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.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Finite Automata and Non Determinism
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 Nondeterminism.
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.
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
Great Theoretical Ideas in Computer Science.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
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.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Languages Given an alphabet , we can make a word or string by concatenating the letters of . Concatenation of “x” and “y” is “xy” Typical example: 
CSCI 2670 Introduction to Theory of Computing August 26, 2004.
CSCI 2670 Introduction to Theory of Computing August 25, 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.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Lecture Notes 
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.
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.
CIS Automata and Formal Languages – Pei Wang
Foundations of Computing Science
CSE 105 theory of computation
CSE 105 theory of computation
Nondeterministic Finite Automata
LECTURE NOTES On FINITE AUTOMATA.
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
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
CSE322 CONSTRUCTION OF FINITE AUTOMATA EQUIVALENT TO REGULAR EXPRESSION Lecture #9.
Non-Deterministic Finite Automata
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
CSCI 2670 Introduction to Theory of Computing
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
Finite-State Machines with No Output
CSCI 2670 Introduction to Theory of Computing
Languages Given an alphabet , we can make a word or string by concatenating the letters of . Concatenation of “x” and “y” is “xy” Typical example: ={0,1},
CHAPTER 1 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:

CSE 2001: Introduction to Theory of Computation Fall 2009 12/24/2018 CSE 2001: Introduction to Theory of Computation Fall 2009 Suprakash Datta datta@cs.yorku.ca 12/24/2018 CSE 2001, Fall 2009

Announcements Exercise 1 due now. Solutions will be posted on webpage. Exercise 2 is posted Quiz next Thursday (Oct 1) Room: CLH F Prof. Ruppert will return next week and resume lectures. 12/24/2018 CSE 2001, Fall 2009

Last class Finite automata : Automata accepting strings and recognizing languages. Examples 12/24/2018 CSE 2001, Fall 2009

Finite Automata The most simple machine that is not just a finite list of words. “Read once”, “no write” procedure. Useful for describing algorithms as well. 12/24/2018 CSE 2001, Fall 2009

Examples Determine if a 1-bit number is odd Determine if any unsigned integer (given in binary) is odd 12/24/2018 CSE 2001, Fall 2009

A Simple Automaton transition rules states starting state q1 q2 q3 1 0,1 starting state accepting state 12/24/2018 CSE 2001, Fall 2009

Finite Automaton (DFA) A deterministic finite automaton (DFA) M is defined by a 5-tuple M=(Q,,,q0,F) Q: finite set of states : finite alphabet : transition function :QQ q0Q: start state FQ: set of accepting states 12/24/2018 CSE 2001, Fall 2009

M = (Q,,,q,F) q1 q2 q3 1 0,1 states Q = {q1,q2,q3} 0,1 states Q = {q1,q2,q3} alphabet  = {0,1} start state q1 accept states F={q2} transition function : 12/24/2018 CSE 2001, Fall 2009

Languages recognized by DFA Sets of words accepted by a DFA. Examples: L = {} L = {0,1}* -  L = {w  {0,1}* | w begins with a 1 and ends with a 0} 12/24/2018 CSE 2001, Fall 2009

Recognizing Languages (defn) A finite automaton M = (Q,,,q,F) accepts a string/word w = w1…wn if and only if there is a sequence r0…rn of states in Q such that: 1) r0 = q0 2) (ri,wi+1) = ri+1 for all i = 0,…,n–1 rn  F L(D) = {w| w is accepted by D} 12/24/2018 CSE 2001, Fall 2009

Regular Languages The language recognized by a finite automaton M is denoted by L(M). A regular language is a language for which there exists a recognizing finite automaton. 12/24/2018 CSE 2001, Fall 2009

Two DFA Questions Given the description of a finite automaton M = (Q,,,q,F), what is the language L(M) that it recognizes? In general, what kind of languages can be recognized by finite automata? (What are the regular languages?) 12/24/2018 CSE 2001, Fall 2009

Regular Operations Pages 44-47 (Sipser) The regular operations are: 1. Union 2. Concatenation 3. Star (Kleene Closure): For a language A, A* = {w1w2w3…wk| k  0, and each wi A} 12/24/2018 CSE 2001, Fall 2009

Closure Properties Set of regular languages is closed under Union Concatenation Star (Kleene Closure) 12/24/2018 CSE 2001, Fall 2009

Union of Two Languages Theorem 1.45: If A1 and A2 are regular languages, then so is A1  A2. (The regular languages are ‘closed’ under the union operation.) Proof idea: A1 and A2 are regular, hence there are two DFA M1 and M2, with A1=L(M1) and A2=L(M2). Out of these two DFA, we will make a third automaton M3 such that L(M3) = A1  A2. 12/24/2018 CSE 2001, Fall 2009

Proof Union-Theorem (1) M1=(Q1,,1,q1,F1) and M2=(Q2,,2,q2,F2) Define M3 = (Q3,,3,q3,F3) by: Q3 = Q1Q2 = {(r1,r2) | r1Q1 and r2Q2} 3((r1,r2),a) = (1(r1,a), 2(r2,a)) q3 = (q1,q2) F3 = {(r1,r2) | r1F1 or r2F2} 12/24/2018 CSE 2001, Fall 2009

Proof Union-Theorem (2) The automaton M3 = (Q3,,3,q3,F3) runs M1 and M2 in ‘parallel’ on a string w. In the end, the final state (r1,r2) ‘knows’ if wL1 (via r1F1?) and if wL2 (via r2F2?) The accepting states F3 of M3 are such that wL(M3) if and only if wL1 or wL2, for: F3 = {(r1,r2) | r1F1 or r2F2}. 12/24/2018 CSE 2001, Fall 2009

Concatenation of L1 and L2 Definition: L1• L2 = { xy | xL1 and yL2 } Example: {a,b} • {0,11} = {a0,a11,b0,b11} Theorem 1.13: If L1 and L2 are regular languages, then so is L1•L2. (The regular languages are ‘closed’ under concatenation.) 12/24/2018 CSE 2001, Fall 2009

Proving Concatenation Thm. Consider the concatenation: {1,01,11,001,011,…} • {0,000,00000,…} (That is: the bit strings that end with a “1”, followed by an odd number of 0’s.) Problem is: given a string w, how does the automaton know where the L1 part stops and the L2 substring starts? We need an M with ‘lucky guesses’. 12/24/2018 CSE 2001, Fall 2009

Non-determinism Non-deterministic machines are capable of being lucky, no matter how small the probability. A non-deterministic finite automaton has transition rules/possibilities like q2 1 q1 q2  q1 q3 1 12/24/2018 CSE 2001, Fall 2009

A Non-deterministic Automaton 0,1 0,1 1 0,  1 q1 q2 q3 q4 This automaton accepts “0110”, because there is a possible path that leads to an accepting state, namely: q1  q1  q2  q3  q4  q4 12/24/2018 CSE 2001, Fall 2009

A Non-deterministic Automaton 0,1 0,1 1 0,  1 q1 q2 q3 q4 The string 1 gets rejected: on “1” the automaton can only reach: {q1,q2,q3}. 12/24/2018 CSE 2001, Fall 2009

Non-determinism ~ Parallelism For any (sub)string w, the non-deterministic automaton can be in a set of possible states. If the final set contains an accepting state, then the automaton accepts the string. “The automaton processes the input in a parallel fashion. Its computational path is no longer a line, but a tree.” (Fig. 1.28) 12/24/2018 CSE 2001, Fall 2009

Non-deterministic FA (def.) A non-deterministic finite automaton (NFA) M is defined by a 5-tuple M=(Q,,,q0,F), with Q: finite set of states : finite alphabet : transition function :QP (Q) q0Q: start state FQ: set of accepting states 12/24/2018 CSE 2001, Fall 2009

Non-deterministic :QP (Q) The function :QP (Q) is the crucial difference. It means: “When reading symbol “a” while in state q, one can go to one of the states in (q,a)Q.” The  in  = {} takes care of the empty string transitions. 12/24/2018 CSE 2001, Fall 2009

Recognizing Languages (defn) A non-deterministic FA M = (Q,,,q,F) accepts a string w = w1…wn if and only if we can rewrite w as y1…ym with yi and there is a sequence r0…rm of states in Q such that: 1) r0=q0 2) ri+1  (ri,yi+1) for all i=0,…,m–1 3) rm  F 12/24/2018 CSE 2001, Fall 2009

Closure under regular operations Union (new proof): 12/24/2018 CSE 2001, Fall 2009

Closure under regular operations Concatenation: 12/24/2018 CSE 2001, Fall 2009

Closure under regular operations Star: For a language A, A* = {w1w2w3…wk| k  0, and each wi A} 12/24/2018 CSE 2001, Fall 2009

Incorrect reasoning about RL Since L1 = {w| w=an, n  N}, L2 = {w| w = bn, n  N} are regular, therefore L1  L2 = {w| w=an bn, n  N} is regular If L1 is a regular language, then L2 = {wR| w  L1} is regular, and Therefore L1  L2 = {w wR | w  L1} is regular 12/24/2018 CSE 2001, Fall 2009

All all languages regular? No! Will see examples (and proofs) later. 12/24/2018 CSE 2001, Fall 2009

Equivalence of NFA, DFA Pages 54-58 (Sipser) We will prove that every NFA is equivalent to a DFA (with upto exponentially more states). Non-determinism does not help FA’s to recognize more languages! 12/24/2018 CSE 2001, Fall 2009

Epsilon Closure Let N=(Q,,,q0,F) be any NFA Consider any set R  Q E(R) = {q|q can be reached from a state in R by following 0 or more -transitions} 12/24/2018 CSE 2001, Fall 2009

Proving equivalence One direction is easy: A DFA M is also a NFA N! So N does not have to be `constructed’ from M 12/24/2018 CSE 2001, Fall 2009

Proving equivalence – contd. The other direction: Construct M from N N = (Q,,,q0,F) Construct M= (Q’,,’,q’0,F’) such that, for any string w  *, w is accepted by N iff w is accepted by M 12/24/2018 CSE 2001, Fall 2009

Special case Assume that  is not used in the NFA N. - Need to keep track of each subset of N - So Q’ = P (Q), q’0 = {q0} - ’(R,a) = ((r,a)) over all r  R, R  Q’ - F’ = {R  Q’| R contains an accept state of N} Now let us assume that  is used. 12/24/2018 CSE 2001, Fall 2009

Construction (general case) Q’ = P(Q) q’0 = E({q0}) for all R  Q’ and a Σ ’(R, a) = {q  Q|q  E((r,a)) for some rR} F’ = { R  Q’| R contains an accept state of N} 12/24/2018 CSE 2001, Fall 2009

Why the construction works for any string w  *, w is accepted by N iff w is accepted by M Can prove using induction on the number of steps of computation… 12/24/2018 CSE 2001, Fall 2009