CSCI 2670 Introduction to Theory of Computing September 13.

Slides:



Advertisements
Similar presentations
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Advertisements

CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CSCI 2670 Introduction to Theory of Computing September 15, 2004.
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2006Costas Busch - RPI1 Regular Expressions.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
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.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
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.
CS 310 – Fall 2006 Pacific University CS310 Homework 2 & JFLAP September 22, 2006.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
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.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
CSCI 2670 Introduction to Theory of Computing September 1, 2005.
Lecture 5 Sept 06, 2012 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
CHAPTER 1 Regular Languages
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CS 203: Introduction to Formal Languages and Automata
Regular Expressions Costas Busch - LSU.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Computability Regular expressions. Languages defined by regular expresses = Regular languages (languages recognized by FSM). Applications. Pumping lemma.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Regular Expressions Section 1.3 (also 1.1, 1.2) CSC 4170 Theory of Computation.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
 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.
1 Introduction to the Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Computation Automata Theory Dr. Ayman Srour.
Foundations of Computing Science
PROPERTIES OF REGULAR LANGUAGES
Regular Expressions Sections:1.3 page 63 September 17, 2008
Single Final State for NFA
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
Chapter 1 Regular Language - 02
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

CSCI 2670 Introduction to Theory of Computing September 13

Agenda Last class –Example DFA construction (on board) –Equivalence of RE’s and regular languages –GNFA’s Today –More on equivalence of RE’s and regular languages –Non-regular languages? Tomorrow –Dr. Canfield returns

RE’s and regular languages Theorem: A language is regular if and only if some regular expression describes it. –i.e., every regular expression has a corresponding DFA and vice versa

GNFA’s To prove every DFA can be described using an RE, we introduce GNFA’s A GNFA is an NFA with the following properties: 1.The start state has transition arrows going to every other state, but no arrows coming in from any other state 2.There is exactly one accept state and there is an arrow from every other state to this state, but no arrows to any other state from the accept state 3.The start state is not the accept state

GNFA’s (continued) 4.Except for the start and accept states, one arrow goes from every state to every other state and also from each state to itself 5.Instead of being labeled with symbols from the alphabet, transitions are labeled with regular expressions

Equivalence of DFA’s and RE’s First show every DFA can be converted into a GNFA that accepts the same language Then show that any GNFA has a corresponding RE that accepts the same language

Converting a DFA to a GNFA Add two new states ε ε qsqs qtqt q1q1 q2q2 q3q3 q4q4 0,1

Converting a DFA to a GNFA ε ε qsqs qtqt q1q1 q2q2 q3q3 q4q4 0,1 All transition labels with multiple labels are relabeled with the union of the previous labels 0101 0101

Converting a DFA to a GNFA ε ε qsqs qtqt q1q1 q2q2 q3q3 q4q4 All pairs of states without transitions get a transition labeled  0101 0101

Converting a DFA to a GNFA ε ε qsqs qtqt q1q1 q2q2 q3q3 q4q4 The resulting state diagram is a GNFA –All GNFA properties are satisfied 0101 0101

Converting a DFA to a GNFA ε ε qsqs qtqt q1q1 q2q2 q3q3 q4q4 No step changed the strings accepted by the machine 0101 0101

Converting a GNFA to a RE If the GNFA has two states, then the label connecting the states is the RE Otherwise, remove one state at a time without changing the language accepted by the machine until the GNFA has two states

Removing one state from a GNFA q1’q1’ q2’q2’ a 13 a 32 a 12 a 33 q2q2 q1q1 q3q3 a 12  a 13 a 33 * a 32

Accounting for loops a 11  a 13 a 33 * a 31 q1’q1’ q2’q2’ a 31 a 13 a 32 a 23 a 21 a 12 a 33 a 22 q2q2 q1q1 q3q3 a 11 a 22  a 23 a 33 * a 32 a 21  a 23 a 33 * a 31 a 12  a 13 a 33 * a 32

Every DFA has a corresponding RE Proof: Let M be any DFA and let w be any string in Σ *. Convert M to G, a GNFA, then convert G to R, a regular expression, using methods shown in class.  Want to show w  L(M) iff w  L(R).  First show w  L(M) iff w  L(G).  Then show w  L(G) iff w  L(R).

w  L(M) iff w  L(G) Let w = w 1 w 2 …w n, where each w i  Σ. w  L(M) iff there is a sequence of states q 1, q 2, …, q n+1 such that q 1 = q 0 q n+1  F q i+1 =  (q i,w i ) for each i = 1, 2, …, n iff when w is read by G, the sequence of states q s, q 1, q 2, …, q n+1, q t would accept w iff w  L(G)

w  L(G) iff w  L(R) Prove by induction on number of states in G Base case: If G has 2 states then clearly w  L(G) iff w  L(R). Induction step: Assume w  L(G) iff w  L(R) for every G with k-1 states. Prove w  L(G) iff w  L(R) for every G with k states.

w  L(R) if w  L(G) Assume w  L(G) and an accepting branch of the computation G enters on w is q s, q 1, q 2, …, q t.Let G’ be the GNFA that results from removing one of G’s states, q rip. There are two possibilities: Case 1: q rip is never entered in the computation of w. Then the same branch of computation exists in G’.

w  L(R) if w  L(G) Assume w  L(G) and an accepting branch of the computation G enters on w is q s, q 1, q 2, …, q t. Let G’ be the GNFA that results from removing one of G’s states, q rip. There are two possibilities: Case 2: q rip is entered in the computation of w (bracketed byq i and q j ). Then the new transition between q i and q j in G’ describes the computation that could be done on the computation of w through the branch q i, q rip, q j. So G’ accepts w. By induction w  L(R).

w  L(G) if w  L(R) Assume w  L(R). By induction hypothesis, w  L(G’), the k-1 state GNFA resulting from removing one state from G. By construction, any computation in G’ can also be done in G – possibly going through an extra state q rip. Therefore, w  L(G).

Example 1 q1q1 q2q

1 q1q1 q2q qsqs qtqt Step 1: Add two new states ε ε

Example 1 q1q1 q2q qsqs qtqt Step 2: Remove q 1 ε 1*01*0 101*0101*0 ε

Example q2q2 qsqs qtqt Step 3: Remove q 2 1*01*0 101*0101*0 ε 1 * 0(1  01*0) *

Example 1 q1q1 q2q So this DFA Is equivalent to the regular expression 1 * 0(1  01 * 0) *

Nonregular languages So far, we have explored several ways to identify regular languages –DFA’s, NFA’s, GNFA’s, RE’s There are many nonregular languages –{0 n 1 n | n  0} –{101,101001, ,…} –{w | w has the same number of 0s and 1s} How can we tell if a language is not regular?

Property of regular languages All regular languages can be generated by finite automata States must be reused if the length of a string is greater than the number of states If states are reused, there will be repetition

The pumping lemma Theorem: If A is a regular language, then there is a number p where, if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions 1.for each i  0, xy i z is in A 2.|y| > 0, and 3.|xy|  p p is called the pumping length

Proof idea Pumping length is equal to the number of states in the DFA whose language is A –p = |Q| If A accepts a word w with |w| > p, then some state must be entered twice while processing w –Pigeonhole principle

Proof idea 1.for each i  0, xy i z is in A 2.|y| > 0, and 3.|xy|  p x y z