MA/CSSE 474 DFSM to RE Theory of Computation

Slides:



Advertisements
Similar presentations
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Advertisements

1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Regular Expressions Highlights: –A regular expression is used to specify a language, and it does so precisely. –Regular expressions are very intuitive.
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.
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
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,
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
MA/CSSE 474 Theory of Computation DFSM Canonical Form Proof of NDFSM  DFSM ALGORITHM (as much as we have time for) This version includes the "answers"
Automata, Computability, & Complexity by Elaine Rich ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Slides provided by author Slides edited for.
Regular Expressions Hopcroft, Motawi, Ullman, Chap 3.
MA/CSSE 474 Theory of Computation Kleene's Theorem Practical Regular Expressions.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
CSCI 2670 Introduction to Theory of Computing September 1, 2005.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts.
CSCI 2670 Introduction to Theory of Computing September 13.
Chapter 3 Regular Expressions, Nondeterminism, and Kleene’s Theorem Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction.
Regular Languages ภาษาปกติ. Jaruloj Chongstitvatana Outline Regular expressions Regular languages Equivalence between languages accepted by.
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Regular Expressions CS 130: Theory of Computation HMU textbook, Chapter 3.
1 Introduction to the Theory of Computation Regular Expressions.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
P Symbol Q E(Q) a b a b a b Convert to a DFA: Start state: Final States:
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
1/29/02CSE460 - MSU1 Nondeterminism-NFA Section 4.1 of Martin Textbook CSE460 – Computability & Formal Language Theory Comp. Science & Engineering Michigan.
3. Regular Expressions and Languages
Practical Regular Expressions
Regular Expressions.
CSE 105 theory of computation
CSE 105 theory of computation
Formal Language & Automata Theory
MA/CSSE 474 Decision Problems about Regular Languages
Single Final State for NFA
Hierarchy of languages
Chapter Seven: Regular Expressions
Properties of Regular Languages
Regular Expressions • Equivalence Of Reg. Exps. And Finite Automata
Definitions Equivalence to Finite Automata
Definitions Equivalence to Finite Automata
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
MA/CSSE 474 Theory of Computation
Regular Languages ภาษาปกติ.
Subject Name: FORMAL LANGUAGES AND AUTOMATA THEORY
CS21 Decidability and Tractability
MA/CSSE 474 Theory of Computation Nondeterminism NFSMs.
More on showing L non-regular
Instructor: Aaron Roth
Definitions Equivalence to Finite Automata
CSCI 2670 Introduction to Theory of Computing
MA/CSSE 474 Theory of Computation
Convert to a DFA: Start state: Final States: P Symbol Q E(Q) a b.
CSE 105 theory of computation
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
Kleene’s Theorem (Part-3)
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
CSE 105 theory of computation
Presentation transcript:

MA/CSSE 474 DFSM to RE Theory of Computation Slide 16 was hidden for 201220. I unhid it for 201240. May want to hide it again for 202420 Take to class: A transparency of the "An Example" slide (32 on 1/3/2010), constructing a reg. exp. from a DFA. DFSM to RE

Exam 1 discussion

Your Questions? Previous class days' material Reading Assignments HW6 problems Anything else

Recap: Kleene’s Theorem Finite state machines and regular expressions define the same class of languages. To prove this, we must show: Theorem: Any language that can be defined by a regular expression can be accepted by some FSM and so is regular. Done last time. Theorem: Every regular language (i.e., every language that can be accepted by some DFSM) can be defined with a regular expression.

For Every Regular Expression There is a Corresponding FSM We’ll show this by construction. An FSM for: : A single element c of :  :

Union If  is the regular expression    and if both L() and L() are regular:

Concatenation If  is the regular expression  and if both L() and L() are regular:

Kleene Star If  is the regular expression * and if L() is regular:

An Example (b  ab)* An FSM for b An FSM for a An FSM for b An FSM for ab:

An Example (b  ab)* An FSM for (b  ab):

An Example (b  ab)* An FSM for (b  ab)*:

For Every FSM There is a Corresponding Regular Expression We’ll show this by construction. The construction is different than the textbook's. Let M = ({q1, …, qn}, , , q1, A) be a DFSM. Define Rijk to be the set of all strings x  * such that (qi,x) |-M (qj, ), and if (qi,y) |-M (q𝓁, ), for any prefix y of x (except y=  and y=x), then 𝓁  k That is, Rijk is the set of all strings that take us from qi to qj without passing through any intermediate states numbered higher than k. In this case, "passing through" means both entering and leaving. Note that either i or j (or both) may be greater than k. * * I do this construction because I think every math or CS major should see this kind of dynamic programming algorithm, and there is no required course that does it. Another algorithm that uses a similar approach is the Floyd-Warshall "all-pairs shortest paths algorithm", which solves a problem ) in n3 time that at first seems like it must be O(n4). Write "Floyd-Warshall" on the board.

Example: Rijk Rijk is the set of all strings that take us from qi to qj without passing through any intermediate states numbered higher than k. In this case, "passing through" means both entering and leaving. Note that either i or j (or both) may be greater than k. R110 R111 R112 R131 R132 R330 R333 R142 R143

DFSMReg. Exp. construction Rijk is the set of all strings that take M from qi to qj without passing through any intermediate states numbered higher than k. Examples: Rij0 Rijn We will show that for all i,j{1, …, n} and all k {0, …, n}, Rijk there is a regular expression rijk that defines Rijk. Also note that L(M) is the union of R1jn over all qj in A. We know that the union of languages defined by reg. exps. is defined by a reg. exp. Rij0 is {a in Sigma : delta(qi, a) = qj. This set has one or zero elements. Rij0 is set of all strings that take M from qi to qj, because all states are numbered  n.

DFSMReg. Exp. continued Rijk is the set of all strings that take M from qi to qj without passing through any intermediate states numbered higher than k. It can be computed recursively: Base cases (k = 0): If i  j, Rij0 = {a : (qi, a) = qj} If i = j, Rii0 = {a : (qi, a) = qi}  {} Recursive case (k > 0): Rijk is Rij(k-1)  Rik(k-1)(Rkk(k-1))*Rkj(k-1) We show by induction that each Rijk is defined by some regular expression rijk. Recursive case: if a string is in Rijjk, it either takes us form state i to state j without passing through state k, or it does pass through k. It takes us to k for the first time, possibly does some loops that pass through k, then goes to j.

DFSMReg. Exp. Proof pt. 1 Base case definition (k = 0): If i  j, Rij0 = {a : (qi, a) = qj} If i = j, Rii0 = {a : (qi, a) = qi}  {} Base case proof: Rij0 is a finite set of symbols, each of which is either  or a single symbol from . So Rij0 can be defined by the reg. exp. rij0 = a1a2…ap (or a1a2…ap if i=j), where {a1, a2, …,ap} is {a  : (qi, a) = qj. Note that if M has no direct transitions from qi to qj, then rij0 is  (it is  if i=j and no "loop" on that state).

DFSMReg. Exp. Proof pt. 2 Recursive definition (k > 0): Rijk is Rij(k-1)  Rik(k-1)(Rkk(k-1))*Rkj(k-1) Induction hypothesis: For each 𝓁 and 𝓂, there is a regular expression r𝓁𝓂k-1 such that L(r𝓁𝓂(k-1) )= R𝓁𝓂(k-1). Induction step. By the recursive parts of the definition of regular expressions and the languages they define, and by the above recursive definition of Rijk : Rijk = L(rij(k-1)  rik(k-1)(rkk(k-1))*rkj(k-1))

DFAReg. Exp. Proof pt. 3 We showed by induction that each Rijk is defined by some regular expression rijk. In particular, for all qjA, there is a regular expression r1jn that defines R1jn. Then L(M) = L(r1j1n  … r1jpn ), where A = {qj1, …, qjp}

An Example Start q1 q2 q3 k=0 k=1 k=2 r11k   (00)* r12k 0 0 0(00)* 1 0,1 Start q1 q2 q3 k=0 k=1 k=2 r11k   (00)* r12k 0 0 0(00)* r13k 1 1 0*1 r21k 0 0 0(00)* r22k    00 (00)* r23k 1 1  01 0*1 r31k   (0  1)(00)*0 r32k 0  1 0  1 (0  1)(00)* r33k    (0  1)0*1 Look quickly at the k=0 cases. Tell students that for practice they should look at some of the others that we do not do together. Look together at these examples: r221 = r220 r210(r110)*r120 =   0()*0 = =   00 r132 = r131 r121(r221)*r231 = 1 0(  00)*(1  01) = 1 0(00)*(  0) 1 . Note that 0(00)*(  0) is equivalent to 0*, so we get 1 0*1 which is equivalent to 0*1. Have students (on the quiz) do r123 and r133 and simplify them. Compare notes with another student. r123 = r122  r132(r332)*r322 = 0(00)*  0*1( (0  1)0*1)*(0  1)(00)* = 0(00)*  0*1((0  1)0*1)*(0  1)(00)* r133 = r132  r132(r332)*r332 = 0*1 0*1( (0  1)0*1)*( (0  1)0*1= 0*1((0  1)0*1)* For the entire machine we get r123  r133 = 0(00)*  0*1((0  1)0*1)*(  (0  1)(00)*)

Another "machine construction" example Given a DFSM M that accepts a language L, how do we construct a FSM M' such that L(M') = LR? Write a careful mathematical description of that machine Optional exercise for later: Prove that L(M') = LR