CSCI 2670 Introduction to Theory of Computing September 11, 2007.

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

Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
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.
Fall 2006Costas Busch - RPI1 Regular Expressions.
1 Introduction to Computability Theory Lecture2: Non Deterministic Finite Automata (cont.) Prof. Amos Israeli.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
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 Regular.
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.
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
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.
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 Non-Deterministic Automata Regular Expressions.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
Introduction to Finite Automata Adapted from the slides of Stanford CS154.
Fall 2004COMP 3351 Another NFA Example. Fall 2004COMP 3352 Language accepted (redundant state)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
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
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,
Nondeterministic Finite Automata CS 130: Theory of Computation HMU textbook, Chapter 2 (Sec 2.3 & 2.5)
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.
CSCI 2670 Introduction to Theory of Computing August 26, 2004.
CSCI 2670 Introduction to Theory of Computing August 25, 2005.
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.
Lesson No.6 Naveen Z Quazilbash. Overview Attendance and lesson plan sharing Assignments Quiz (10 mins.). Some basic ideas about this course Regular Expressions.
CHAPTER 1 Regular Languages
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CSCI 2670 Introduction to Theory of Computing September 13.
Regular Expressions Costas Busch - LSU.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Algorithms for hard problems Automata and tree automata Juris Viksna, 2015.
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.
1 Introduction to the Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Theory of Computation Automata Theory Dr. Ayman Srour.
CSE 105 theory of computation
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
CSCI 2670 Introduction to Theory of Computing
Chapter 1 Regular Language
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
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

CSCI 2670 Introduction to Theory of Computing September 11, 2007

Agenda Last class –Discussed non-determinism –Equivalence of DFA’s and NFA’s Today –Further exploration of equivalence of DFA’s and NFA’s Tomorrow –Closure of regular languages under regular operators –Another method for describing regular languages

Example 01 {q1}{q1}{q2,q3}{q2,q3}  {q2}{q2}  {q1,q3}{q1,q3} {q3}{q3}  {q1,q2}{q1,q2}{q2,q3}{q2,q3}{q1,q3}{q1,q3} {q1,q3}{q1,q3}{q2,q3}{q2,q3}  {q2,q3}{q2,q3}  {q1,q3}{q1,q3} {q1,q2,q3}{q1,q2,q3}{q2,q3}{q2,q3}{q1,q3}{q1,q3}  q1q1 q2q2 q3q3 1 0,1 {q1}{q1}  1 {q 2,q 3 }

What about ε jumps? For each R  P (Q), define function E(R) E(R) = {q | q can be reach by 0 or more ε jumps from some r  R} Redefine  ’(R,a) to include E(R)  ’(R,a) = {q | q  E(  (r,a)) for some r  R} Are we done? No! What if there are  jumps from q 0 ? q 0 ’ = E({q 0 })

Closure of NFA’s under regular operations Recall the following are the regular operators –Union –Concatenation –Kleene star

Union is a regular operation Theorem: The class of regular languages is closed under the union operation Proof approach: Assume A 1 and A 2 are both regular languages with A 1 =L(M 1 ) and A 2 =L(M 2 ) and create an NFA M such that L(M) = A 1  A 2 Method: Proof by construction

M Construct M from M 1 and M 2 M1M1 M2M2 ε ε

Concatenation is a regular operation Theorem: The class of regular languages is closed under the concatenation operation Proof approach: Assume A 1 and A 2 are both regular languages with A 1 =L(M 1 ) and A 2 =L(M 2 ) and create an NFA M such that L(M) = A 1  A 2 Method: Proof by construction

M Construct M from M 1 and M 2 M1M1 M2M2 εε

Kleene star is a regular operation Theorem: The class of regular languages is closed under the Kleene operation Proof approach: Assume A 1 is a regular language with A 1 =L(M 1 ) and create an NFA M such that L(M) = A 1 * Method: Proof by construction

M Construct M from M 1 M1M1 ε ε ε

Regular expressions (RE’s) So far we have had to describe languages either with finite automata or with words –Potentially clumsy or imprecise Today we learn precise expression to describe regular languages –Example: All strings with at least one 1 becomes  *  {1}  *, or more simply  * 1  *

Where have you seen RE’s? Grep Awk Perl Search expressions within emacs or vi

RE inductive definition R is a regular expression if R is 1.a for some a   2. ε 3.  4.R 1  R 2 where R 1 and R 2 are both regular expressions 5.R 1  R 2 where R 1 and R 2 are both regular expressions 6.(R 1 * ) where R 1 is a regular expression Abuse of notation. These should be sets!

Examples 0 * 10 * 10 * –{w | w contains exactly two 1’s}  * 11  * –{w | w contains two consecutive 1’s}  * 1(0  ε)1  * –{w | w contains two 1’s separated by at most one 0} (0  ε)(1  ε) –{0,1,01,ε}

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

RE’s and regular languages Lemma: If a language is described by a regular expression, then it is regular. –find an NFA corresponding to any regular expression –use inductive definition of RE’s

1. R=a for some a  N = {{q 1,q 2 }, , ,q 1,{q 2 }} where  (q 1,a)={q 2 } and  (r,x)=  whenever r=q 2 or x≠a a q1q1 q2q2

2. R= ε N = {{q 1 }, , ,q 1,{q 1 }} where  (q 1,x)=  for all x q1q1

3. R=  N = {{q 1 }, , ,q 1,  } where  (q 1,x)=  for all x q1q1

Remaining constructions R = R 1  R 2 R = R 1  R 2 R = R 1 * These were all shown to be regular operators –We know we can construct NFA’s for R provided they exist for R 1 and R 2

Example R =  1 –R = (0  1)1 0 R 1 = 0 R 3 = 0  ε ε 1 R = Σ1 0 1 ε ε ε ε 1 R 2 = 1

Example2 R = 1(0  ε)  * 1 R 1 = 1 R 2 = 0  ε 0 ε ε ε 0,1 R 3 =  * ε R = 1(0  ε )  * 1 0 ε ε ε ε 0,1 ε ε ε

Equivalence of RE’s and DFA’s We have seen that every RE has a corresponding NFA –Therefore, every RE has a corresponding DFA –I.e, every RE describes a regular language We need to show that every regular language can be described by a RE Begin by converting all DFA’s into GNFA’s –Generalized Non-deterministic Finite Automata

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

Example GNFA  0101 0  

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 into a GNFA Add two new states –New start state with an ε jump to the original DFA’s start state –New accept state with an ε jump from each of the original DFA’s accept states This new state will be the only accept state All transition labels with multiple labels are relabeled with the union of the previous labels All pairs of states without transitions get a transition labeled 

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