Automata and Languages

Similar documents
Today s Topics Automata and Languages

GNFA GNFA GNFA GNFA GNFA

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

CS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Grammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages

Theory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38

Theory of Computation Regular Languages

CHAPTER 1 Regular Languages. Contents

Fundamentals of Computer Science

Non Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51

Non-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1

Let's start with an example:

Lecture 08: Feb. 08, 2019

Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*

Regular expressions, Finite Automata, transition graphs are all the same!!

Homework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama

CS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

Chapter 2 Finite Automata

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

Languages & Automata

Finite Automata-cont d

Lexical Analysis Finite Automate

CS375: Logic and Theory of Computing

Finite-State Automata: Recap

Non-deterministic Finite Automata

CHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)

1 Nondeterministic Finite Automata

1 From NFA to regular expression

CMSC 330: Organization of Programming Languages

Automata and Languages

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

Non-deterministic Finite Automata

Worked out examples Finite Automata

Deterministic Finite Automata

Harvard University Computer Science 121 Midterm October 23, 2012

CSCI 340: Computational Models. Transition Graphs. Department of Computer Science

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Assignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages

CISC 4090 Theory of Computation

Lecture 6 Regular Grammars

input tape head moves current state

Designing finite automata II

12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016

NFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

First Midterm Examination

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

NFAs continued, Closure Properties of Regular Languages

NFAs and Regular Expressions. NFA-ε, continued. Recall. Last class: Today: Fun:

Name Ima Sample ASU ID

ɛ-closure, Kleene s Theorem,

Homework 3 Solutions

Formal Languages and Automata

Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15

CMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)

Minimal DFA. minimal DFA for L starting from any other

Nondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute

CS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

In-depth introduction to main models, concepts of theory of computation:

a,b a 1 a 2 a 3 a,b 1 a,b a,b 2 3 a,b a,b a 2 a,b CS Determinisitic Finite Automata 1

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

First Midterm Examination

Some Theory of Computation Exercises Week 1

Thoery of Automata CS402

Lexical Analysis Part III

CS375: Logic and Theory of Computing

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Non Deterministic Automata. Formal Languages and Automata - Yonsei CS 1

Java II Finite Automata I

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

Deterministic Finite-State Automata

Table of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...

FABER Formal Languages, Automata and Models of Computation

Formal languages, automata, and theory of computation

Coalgebra, Lecture 15: Equations for Deterministic Automata

Convert the NFA into DFA

Nondeterministic Automata vs Deterministic Automata

CS 311 Homework 3 due 16:30, Thursday, 14 th October 2010

Myhill-Nerode Theorem

Nondeterminism and Nodeterministic Automata

Automata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.

1.3 Regular Expressions

3 Regular expressions

NFAs continued, Closure Properties of Regular Languages

Non-Deterministic Finite Automata

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers

CS 573 Automata Theory and Formal Languages

Formal Language and Automata Theory (CS21004)

80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CS 330 Formal Methods and Models

Lecture 09: Myhill-Nerode Theorem

Section: Other Models of Turing Machines. Definition: Two automata are equivalent if they accept the same language.

Compiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Transcription:

Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn

Tody s Topics DFA to Regulr Expression GFNA DFAèGNFA GNFA è RE DFA è RE Exmples 2

DFA è RE NFA DFA -NFA REX GNFA 3

Definition GNFA A generlized nondeterministic finite utomton (GNFA) is grph whose edges re leled y regulr expressions, with unique strt stte with in-degree 0, nd unique finl stte with out-degree 0. A string u is sid to lel pth in GNFA, if it is n element of the lnguge generted y the regulr expression which is gotten y conctenting ll lels of edges trversed in the pth. The lnguge ccepted y GNFA consists of ll the ccepted strings of the GNFA. 4

GNFA Exmple 1 0110 0 q S q f 01* 0* 11 5

GNFA Exmple 2 000 0 (0110 1001)* c This is GNFA ecuse edges re leled y REX s, strt stte hs no in-edges, nd the unique finl stte hs no out-edges. Q: Is 000000100101100110 ccepted? 6

GNFA Exmple 2 000 0 (0110 1001)* c A: 000000100101100110 is ccepted. The pth given y c 000 000 100101100110 proves this fct. (The lst lel results from 100101100110 (0110 1001)* ) 7

GNFA Definition A Generlized nondeterministic finite utomton (GNFA) is defined y M=(Q, Σ, δ, q strt, q finl ) with Q finite set of sttes Σ the input lphet q strt the strt stte with 0 in-degree q finl the ccept stte with 0 out-degree δ:(q\{q finl }) (Q\{q strt }) R the trnsition function (R is the set of regulr expressions over Σ) 8

DFAèGNFA Theorem For every DFA M, there exist n equivlent GNFA M 9

DFAèGNFA Remove Internl stte of GNFA If the GNFA M hs more thn 2 sttes, rip internl q rip to get equivlent GNFA M y: - Removing stte q rip : Q =Q\{q rip } - Chnging the trnsition function δ y δ (q i,q j ) = δ(q i,q j ) (δ(q i,q rip )(δ(q rip,q rip ))*δ(q rip,q j )) for every q i Q \{q finlt } nd q j Q \{q strt } R 1 q rip R 2 q i R 3 = q i R 4 (R 1 R 2 *R 3 ) q j R 4 q j 10

Exmple GNFAèRE 0110 0 R q s q f 01* ε 0* 11 11

Ripping out GNFAèRE Ripping out is done s follows. If you wnt to rip the middle stte v out of: r 2 u r 1 v r 3 w r 4 then you ll need to recrete ll the lost possiilities from u to w. I.e., to the current REX lel r 4 of the edge (u,w) you should dd the conctention of the (u,v ) lel r 1 followed y the (v,v )-loop lel r 2 repeted ritrrily, followed y the (v,w ) lel r 3.. The new (u,w ) sustitute would therefore e: u r 4 r 1 (r 2 )*r 3 w 12

Theorem For every (NFA) DFA M, there exist n equivlent RE R, with L(M)=L(R) Proof ide: 1. Trnsform n NFA into n equivlent GNFA 2. Trnsform the GNFA into regulr expression y removing sttes nd releling the rrows with regulr expressions 13

Proof ide: NFA 1. NFAèGNFA Add unique nd distinct strt stte with 0 in-degree nd finl stte with 0 out-degree, then connect them to the NFA with 2. GNFAèRE While mchine hs more thn 2 sttes: Pick n internl stte, rip it out nd re-lel the rrows with regulr expressions to ccount for the missing stte For Exmple: 0 0 01*0 1 14

Exmple 1, q 0 q 1 q 2 q 3 15

Exmple 1, * q 0 q 2 q 3 16

Exmple 1 (*)( )* q 0 q 3 R(q 0,q 3 ) = (*)( )* 17

Exmple 2 q 1 q 2 q 3 18

Exmple 2 q 1 q 2 q 3 19

Exmple 2 q 1 q 2 q 3 20

Exmple 2 q 1 q 2 21

Exmple 2 q 1 q 2 22

Exmple 2 q 1 + q 2 23

Exmple 2 q 1 + q 2 24

Exmple 2 q 1 + 25

Exmple 2 + ( + )* q 1 + 26

Exmple 2 + ( + )* q 1 + ( + )* 27

Exmple 2 + ( + )* + ( + )* 28

Exmple 2 [ + ( + )*]* [ + ( + )*] 29

Exmple 3 Strt with: This is not GNFA ecuse finl stte, though unique, hs nonzero out-degree. First we need to convert this into GNFA. Strt stte hs zero in-degree, so is oky. 30

Exmple 3 Just dded n ccept stte y connecting vi from the old ccept stte. Since the lels re single letters, they re utomticlly regulr expressions so this is GNFA And we re redy to strt ripping out interior sttes. 31

Exmple 3 Now, let s rip out d. Q1: Wht will e the lel of (,c )? Q2: Wht will e the lel of (c,c )? 32

Exmple 3 A1: (,c ): CD*A A2: (c,c ): CD*A Next, rip out c. Q: Wht will e the lel of (, )? 33

Exmple 3 A: B (CD*A)(CD*A)*B which simplifies to B (CD*A) + B Next, rip out. 34

Exmple 3 Finlly, rip out : 35

Exmple 3 The resulting REX Is the unique lel (A D(B (CD*A) + B)) + 36

Exmple 4 Convert the following NFA into regulr expression? q 1, q 2 q 3 37

Exmple 4 Convert the following NFA into regulr expression? q 1, q 2 q 3 38

Exmple 4 Convert the following NFA into regulr expression? q 1, q 2 q 3 39

Exmple 4 Convert the following NFA into regulr expression? q 1, q 3 40

Exmple 4 Convert the following NFA into regulr expression? q 1 ( + )* q 3 41

Exmple 4 Convert the following NFA into regulr expression? q 1 ( + )* * q 3 42

Exmple 4 Convert the following NFA into regulr expression? q 1 ( + )* * 43

Exmple 4 Convert the following NFA into regulr expression? q 1 ( + )* ( + )*(*)* * 44

Exmple 4 Convert the following NFA into regulr expression? q 1 ( + )*(*)* ( + )*(*)* 45

Exmple 4 Convert the following NFA into regulr expression? ( + )*(*)* ( + )*(*)* 46

Exmple 4 Convert the following NFA into regulr expression? [( + )*(*)*]* ( + )*(*)* 47

Algorithm Next we study the Algorithm 48

Algorithm Add q strt nd q finl to crete G Run CONVERT(G): If #sttes = 2 return the expression on the rrow going from q strt to q finl If #sttes > 2 select q rip Q different from q strt nd q finl define Qʹ = Q {q rip } define Rʹ s: Rʹ(q i,q j ) = R(q i,q rip )R(q rip,q rip )*R(q rip,q j ) R(q i,q j ) return CONVERT(Gʹ) 49

Algorithm CONVERT(G) is equivlent to G Proof y induction on k (numer of sttes in G) Bse Cse: ü k = 2 Inductive Step: Assume clim is true for k-1 sttes We first note tht G nd Gʹ re equivlent But, y the induction hypothesis, Gʹ is equivlent to CONVERT(Gʹ) 50

Exercise q 1 q 2 q 3 51