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

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

Non-Deterministic Finite Automata

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

Recursively Enumerable and Recursive. Languages

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

Theory of Computation Regular Languages

Chapter 2 Finite Automata

Non-deterministic Finite Automata

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

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

Fundamentals of Computer Science

CS375: Logic and Theory of Computing

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

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

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

Deterministic Finite Automata

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

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

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

Lecture 6 Regular Grammars

input tape head moves current state

Lecture 08: Feb. 08, 2019

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

Non-deterministic Finite Automata

Some Theory of Computation Exercises Week 1

Worked out examples Finite Automata

Designing finite automata II

Automata and Languages

CS 275 Automata and Formal Language Theory

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

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

CHAPTER 1 Regular Languages. Contents

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

CSCI FOUNDATIONS OF COMPUTER SCIENCE

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

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

More on automata. Michael George. March 24 April 7, 2014

Deterministic Finite-State Automata

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

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

Let's start with an example:

Formal Languages and Automata

Formal Language and Automata Theory (CS21004)

Nondeterminism and Nodeterministic Automata

CISC 4090 Theory of Computation

Today s Topics Automata and Languages

Automata and Languages

Minimal DFA. minimal DFA for L starting from any other

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Convert the NFA into DFA

1.4 Nonregular Languages

1 Nondeterministic Finite Automata

Normal Forms for Context-free Grammars

Java II Finite Automata I

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.

Finite-State Automata: Recap

Lexical Analysis Finite Automate

1 From NFA to regular expression

State Minimization for DFAs

This lecture covers Chapter 8 of HMU: Properties of CFLs

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

1.3 Regular Expressions

Chapter 1, Part 1. Regular Languages. CSC527, Chapter 1, Part 1 c 2012 Mitsunori Ogihara 1

Turing Machines Part One

CMSC 330: Organization of Programming Languages

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

For convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir

Formal languages, automata, and theory of computation

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

Probabilistic Model Checking Michaelmas Term Dr. Dave Parker. Department of Computer Science University of Oxford

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

5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.

Regular languages refresher

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

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

Lecture 09: Myhill-Nerode Theorem

Finite Automata-cont d

Languages & Automata

Introduction to ω-autamata

CS 573 Automata Theory and Formal Languages

Finite Automata Part Three

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

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

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

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

Harvard University Computer Science 121 Midterm October 23, 2012

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

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

Myhill-Nerode Theorem

FABER Formal Languages, Automata and Models of Computation

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

Name Ima Sample ASU ID

Talen en Automaten Test 1, Mon 7 th Dec, h45 17h30

Turing Machines Part One

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

Chapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)

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.

Transcription:

Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1

Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2

Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices q 1 q2 q 0 q 3 3

Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices q 1 q2 No trnsition q 0 q 3 No trnsition 4

First Choice q 1 q2 q 0 q 3 5

First Choice q 1 q2 q 0 q 3 6

First Choice q 1 q2 q 0 q 3 7

First Choice All input is consumed q 1 q2 ccept q 0 q 3 8

Second Choice q 1 q2 q 0 q 3 9

Second Choice q 1 q2 q 0 q 3 10

Second Choice q 1 q2 q 0 q 3 No trnsition: the utomton hngs 11

Second Choice Input cnnot be consumed q 1 q2 q 0 q 3 reject 12

An NFA ccepts string: when there is computtion of the NFA tht ccepts the string All the input is consumed nd the utomton is in finl stte 13

Exmple is ccepted by the NFA: ccept q 1 q2 q 1 q2 q 0 q 3 q 0 q 3 reject becuse this computtion ccepts 14

Rejection exmple q 1 q2 q 0 q 3 15

First Choice q 1 q2 q 0 q 3 16

First Choice reject q 1 q2 q 0 q 3 17

Second Choice q 1 q2 q 0 q 3 18

Second Choice q 1 q2 q 0 q 3 19

Second Choice q 1 q2 q 0 q 3 reject 20

An NFA rejects string: when there is no computtion of the NFA tht ccepts the string All the input is consumed nd the utomton is in non finl stte The input cnnot be consumed 21

Exmple is rejected by the NFA: q 1 q2 reject q 1 q2 q 0 q 3 reject q 0 q 3 All possible computtions led to rejection 22

Rejection exmple q 1 q2 q 0 q 3 23

First Choice q 1 q2 q 0 q 3 24

First Choice q 1 q2 q 0 q 3 No trnsition: the utomton hngs 25

First Choice Input cnnot be consumed q 1 q2 reject q 0 q 3 26

Second Choice q 1 q2 q 0 q 3 27

Second Choice q 1 q2 q 0 q 3 28

Second Choice q 1 q2 q 0 q 3 No trnsition: the utomton hngs 29

Second Choice Input cnnot be consumed q 1 q2 q 0 q 3 reject 30

is rejected by the NFA: reject q 1 q2 q 1 q2 q 0 q 3 q 0 q 3 reject All possible computtions led to rejection 31

Lnguge ccepted: L {} q 1 q2 q 0 q 3 32

Lmbd Trnsitions q0 q q3 1 q2 33

q0 q q3 1 q2 34

q0 q q3 1 q2 35

(red hed doesn t move) q0 q q3 1 q2 36

q0 q q3 1 q2 37

ll input is consumed q0 q q3 1 q2 ccept String is ccepted 38

Rejection Exmple q0 q q3 1 q2 39

q0 q q3 1 q2 40

(red hed doesn t move) q0 q q3 1 q2 41

q0 q q3 1 q2 No trnsition: the utomton hngs 42

Input cnnot be consumed q0 q q3 1 q2 reject String is rejected 43

Lnguge ccepted: L {} q0 q q3 1 q2 44

Another NFA Exmple q b q 2 q0 1 q 3 45

b q b q 2 q0 1 q 3 46

b q b q 2 0 q 1 q 3 47

b q q b 1 0 q 2 q 3 48

b q q b 1 0 ccept q 2 q 3 49

Another String b b q b q q3 0 q1 2 50

b b q b q q3 0 q1 2 51

b b q b q q3 0 q1 2 52

b b q b q q3 0 q1 2 53

b b q b q q3 0 q1 2 54

b b q b q q3 0 q1 2 55

b b q b q q3 0 q1 2 56

b b q b q q3 0 ccept q1 2 57

Lnguge ccepted L b, bb, bbb,... b q b q 2 q0 1 q 3 58

Another NFA Exmple 0 q0 1 1 q 0,1 q2 59

Lnguge ccepted L(M ) = = { } λ, 10, { 10}* 0 1010, 101010,... q0 1 1 q 0,1 q2 60

Remrks: The symbol never ppers on the input tpe Extreme utomt: M 1 q 0 M 2 q 0 L(M 1 ) = {} (M ) = {λ} L 2 61

NFAs re interesting becuse we cn express lnguges esier thn DFAs NFA M 1 DFA M 2 q 0 q1 q 2 q 0 q 1 L( M1) = { } L( M 2) = { } 62

Forml Definition of NFAs M Q,,, q0, F Q : Set of sttes, i.e. q, q q 0 1, 2 : Input plhbet, i.e., b : Trnsition function q 0 : Initil stte F : Finl sttes 63

Trnsition Function q, q 0 1 1 0 q0 1 1 q 0,1 q2 64

( q1,0) { q0, q2} 0 q 0 1 q 0,1 1 q2 65

( q0, ) { q0, q2} 0 q 0 1 q 0,1 1 q2 66

( q 2,1) q 0 0 1 q 0,1 1 q2 67

Extended Trnsition Function * * q q 0, 1 q 4 q 5 q 0 q 1 b q 2 q 3 68

q * q q 0, 4, 5 q 4 q 5 q 0 q 1 b q 2 q 3 69

q b * q q q 0, 2, 3, 0 q 4 q 5 q 0 q 1 b q 2 q 3 70

It holds q Formlly j * qi, w if nd only if there is wlk from with lbel w qi to q j 71

The Lnguge of n NFA M F q 0,q 5 q 4 q 5 q 0 q 1 b q 2 q 3 q * q q 0, 4, 5 L(M ) 72

F q 0,q 5 q 4 q 5 q 0 q 1 b q 2 q 3 q b * q q q b LM 0, 2, 3, 0 73

F q 0,q 5 q 4 q 5 q 0 q 1 b q 2 q 3 q b * q q 0, 4, 5 b L(M ) 74

F q 0,q 5 q 4 q 5 q 0 q 1 b q 2 q 3 * q b q b LM 0, 1 75

q 4 q 5 q 0 q 1 b q 2 q 3 L M b* b 76

Formlly The lnguge ccepted by NFA M is: L M,,... w1 w w, 2 3 where *( q 0, w m ) { q i, q j,...} nd there is some q k F (finl stte) 77

w L M *( q 0, w) w q i q0 w qk q k F w q j 78

Equivlence of NFAs nd DFAs Linz: 2.3 Equivlence of Deterministic nd Nondeterministic Finite Accepters, pge 58 79

Equivlence of Mchines For DFAs or NFAs: Mchine M1 is equivlent to mchine M 2 if LM 1 L M 2 80

L M 1 {10} * Exmple 0 q0 1 1 NFA q 0,1 q2 M 1 L M 2 {10} * 0 DFA q q 1 0 1 q2 1 0 M 2 0,1 81

Since L 10* M1 L M2 M M 2 mchines 1 nd re equivlent NFA M1 0 q q 0 1 2 1 0,1 q DFA M 2 0 q q 0 1 2 1 0 1 0,1 q 82

Equivlence of NFAs nd DFAs Question: NFAs = DFAs? Sme power? Accept the sme lnguges? 83

Equivlence of NFAs nd DFAs Question: NFAs = DFAs? YES! Sme power? Accept the sme lnguges? 84

We will prove: Lnguges ccepted by NFAs Lnguges ccepted by DFAs NFAs nd DFAs hve the sme computtion power 85

Step 1 Lnguges ccepted by NFAs Lnguges ccepted by DFAs Proof: Every DFA is trivilly n NFA A lnguge ccepted by DFA is lso ccepted by n NFA 86

Step 2 Lnguges ccepted by NFAs Lnguges ccepted by DFAs Proof: Any NFA cn be converted to n equivlent DFA A lnguge ccepted by n NFA is lso ccepted by DFA 87

NFA M NFA to DFA q 0 q1 q2 b DFA M q 0 88

NFA M NFA to DFA q 0 q1 q2 b DFA M q 0 q 1,q 2 89

NFA M NFA to DFA q 0 q1 q2 b DFA M q 0 q 1,q 2 b 90

NFA M NFA to DFA q 0 q1 q2 b DFA M q 0 q 1,q 2 b 91

NFA M NFA to DFA q 0 q1 q2 b DFA M b q 0 q 1,q 2 b 92

NFA M NFA to DFA q 0 q1 q2 b DFA M b q 0 q 1,q 2 b,b 93

NFA M NFA to DFA q 0 q1 q2 b LM L(M) DFA M b q 0 q 1,q 2 b,b 94

NFA to DFA: Remrks We re given n NFA M We wnt to convert it to n equivlent DFA M With LM L(M) 95

If the NFA hs sttes q0, q1, q2,... the DFA hs sttes in the powerset,,,,,,,..., q0 q1 q1 q2 q3 q4 q7 96

Procedure NFA to DFA 1. Initil stte of NFA: q 0 Initil stte of DFA: q 0 97

NFA M Exmple q 0 q1 q2 b DFA M q 0 98

Procedure NFA to DFA 2. For every DFA s stte { q, q,..., q } i j m Compute in the NFA * * q q i j,,,, { qi, qj,..., qm }... Add trnsition to DFA q, q,..., q }, { q, q,..., q } { i j m i j m 99

NFA DFA M M Exmpe q 0 q1 q2 b *( q0, ) { q1, q2} q 0 q 1,q 2 q, q q 0 1, 2 100

Procedure NFA to DFA Repet Step 2 for ll letters in lphbet, until no more trnsitions cn be dded. 101

NFA M Exmple q 0 q1 q2 b DFA M b q 0 q 1,q 2 b,b 102

Procedure NFA to DFA 3. For ny DFA stte { qi, q j,..., qm} If some q j is finl stte in the NFA Then, { qi, q j,..., qm} is finl stte in the DFA 103

NFA M Exmple q 0 q1 q2 b q F 1 DFA M b b q 0 q 1,q 2,b q q F 1, 2 104

Tke NFA M Theorem Apply procedure to obtin DFA M Then M nd M re equivlent : LM LM 105

Finlly We hve proven Lnguges ccepted by NFAs Lnguges ccepted by DFAs 106

We hve proven Lnguges ccepted by NFAs Lnguges ccepted by DFAs Regulr Lnguges 107

We hve proven Lnguges ccepted by NFAs Lnguges ccepted by DFAs Regulr Lnguges Regulr Lnguges 108

We hve proven Lnguges ccepted by NFAs Lnguges ccepted by DFAs Regulr Lnguges Regulr Lnguges Thus, NFAs ccept the regulr lnguges 109