CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)

Slides:



Advertisements
Similar presentations
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Advertisements

CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
Regular Expressions and DFAs COP 3402 (Summer 2014)
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
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)
CS5371 Theory of Computation
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
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 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.
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.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA to regular.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
REGULAR LANGUAGES.
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.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
CHAPTER 1 Regular Languages
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Recap: Transformation NFA  DFA  s s1s1... snsn p1p1 p2p2... pmpm >...  p1p1  p2p2  pipi s e s1s1 e s2s2 e sisi >
Regular Expressions Section 1.3 (also 1.1, 1.2) CSC 4170 Theory of Computation.
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.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
Theory of Computation Automata Theory Dr. Ayman Srour.
1 Section 11.2 Finite Automata Can a machine(i.e., algorithm) recognize a regular language? Yes! Deterministic Finite Automata A deterministic finite automaton.
Theory of Languages and Automata By: Mojtaba Khezrian.
CSE 105 theory of computation
Non Deterministic Automata
Regular Expressions Sections:1.3 page 63 September 17, 2008
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Non-Deterministic Finite Automata
CS 154, Lecture 3: DFANFA, Regular Expressions.
Non-Deterministic Finite Automata
Non Deterministic Automata
CS 350 — Fall 2018 gilray.org/classes/fall2018/cs350/
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CSC 4170 Theory of Computation Nondeterminism Section 1.2.
Chapter 1 Regular Language
CHAPTER 1 Regular Languages
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
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)

Give formal definition of Regular Expression Show that the power of Regular Expression = the power of NFA = the power of DFA –in terms of describing a language Objectives

Regular Expression (Formal Definition) We say R is a regular expression if R is – a for some a in the alphabet , or – , or – ;, or – (R 1 [ R 2 ), where R 1 and R 2 are regular expressions, or – (R 1 o R 2 ), where R 1 and R 2 are regular expressions, or – (R 1 *), where R 1 is a regular expression Don’t confuse  with ;

True or False? R [ ; = R R o  = R R [  = R R o ; = R True False

Equivalence with NFA (Part I) Lemma: If a language is described by a regular expression, then it is regular. Proof: Let R be the regular expression and L be the language described by R. We show how to convert R into an NFA recognizing L(R). Note: L is sometimes written as L(R)

Six Cases to Consider (1)R = a for some a in the alphabet . Then L(R) = { a }, and the following NFA recognizes L(R) a

(2) R = . Then L(R) = {  }, and the following NFA recognizes L(R) (3) R = ;. Then L(R) = { }, and the following NFA recognizes L(R)

For the last three cases: (4) R = R 1 [ R 2 (5) R = R 1 o R 2 (6) R = R 1 * we use the constructions given in the proofs that the class of regular language is closed under the regular operations. –In other words, we construct NFA for R from NFA for R 1 and NFA for R 2

Converting R to NFA (Example) R = ( ab [ a )* a a b b a ab b 

ab [ a a ab    (ab [ a)* a ab      

Equivalence with NFA (Part II) Lemma: If a language is regular, it can be described by a regular expression. Proof: Let L be the regular language. We will convert DFA for L to a regular expression. Before that, we introduce a new type of automaton: the generalized non- deterministic finite automaton (GNFA) Later, we show DFA  GNFA  Reg Ex

GNFA (Example) q start q accept b ab [ ba ; a* aa ab* (aa)* b* ab

GNFA Similar to NFA, except that the labels on the transition arrows are regular expressions (instead of a character or  ) To move along a transition arrow, we read blocks of characters such that it matches the description of the regular expression on that arrow An input string is accepted if there is a way to read the input string such that the GNFA exactly reaches an accepting state after processing the whole input string

GNFA (further assumptions) Only one start state q start, with no incoming arrows Only one accepting state q accept, with no outgoing arrows Each state (except q start and q accept ) has exactly one arrow going to every other state and also itself

Back to the Proof: Converting DFA to GNFA Add a new start state, with  arrow to the original start state Add a new accept state, with  arrow from each of the original accept state If original arrow has multiple labels, we replace this with a new arrow whose label is a regular expression formed by the union of the labels If originally no arrow between two states, we add a new arrow whose label is ;

Converting DFA to GNFA (Example) a a b b b a DFA a a b b b a GNFA   

Converting GNFA to Regular Expression We iteratively remove one state in GNFA, such that after each state removal, the new GNFA obtained will recognize the same language as the previous one When the number of states of GNFA is 2, we have the regular expression (why??)

How to remove a state? Select any state q except q start and q accept Remove q –To compensate the absence of q, the new label on the arrow from q i to q j becomes a regular expression that describes all strings that would take the GNFA to go from q i to q j, either directly or via q

How to remove a state? R1R1 R2R2 R4R4 R3R3 qiqi qjqj Before Removal q R 4 [ (R 1 ) (R 2 )*(R 3 ) qiqi qjqj After Removal

a a b b b a Before Removal    Previous Example aa [ b ?   After Removal a b ? ?

Before Removal Previous Example aa [ b   After Removal a b ab ba [ a bb ? ?? ?

Before Removal: Previous Example After Removal: a(aa [ b)* (ba [ a) (aa [ b)* [  (ba [ a) (aa [ b)* ab [ bb a(aa [ b)*ab [ b ?

Final Step (a(aa [ b)*ab [ b)((ba [ a) (aa [ b)* ab [ bb)* ((ba [ a) (aa [ b)* [  ) [ a(aa [ b)*

What we have learnt so far DFA = NFA –proof by construction Regular Expression = DFA –proof by construction Pumping Lemma –proof by contradiction Existence of Non-regular Languages –pumping lemma