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

Similar documents
1 Nondeterministic Finite Automata

Nondeterminism and Nodeterministic Automata

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Chapter 2 Finite Automata

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

Theory of Computation Regular Languages

Convert the NFA into DFA

Minimal DFA. minimal DFA for L starting from any other

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

Designing finite automata II

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

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

Non-deterministic Finite Automata

Let's start with an example:

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

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

Formal Languages and Automata

CMSC 330: Organization of Programming Languages

Deterministic Finite Automata

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

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

Chapter Five: Nondeterministic Finite Automata

Lecture 08: Feb. 08, 2019

Harvard University Computer Science 121 Midterm October 23, 2012

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

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 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018

State Minimization for DFAs

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

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

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

Non-Deterministic Finite Automata

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

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

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

Homework 3 Solutions

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.

Finite-State Automata: Recap

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Formal languages, automata, and theory of computation

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

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

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

Non-deterministic Finite Automata

CHAPTER 1 Regular Languages. Contents

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

Nondeterministic Finite Automata

NFAs continued, Closure Properties of Regular Languages

Some Theory of Computation Exercises Week 1

CISC 4090 Theory of Computation

Finite Automata-cont d

Fundamentals of Computer Science

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

Worked out examples Finite Automata

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

CS375: Logic and Theory of Computing

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

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

Lecture 09: Myhill-Nerode Theorem

Java II Finite Automata I

First Midterm Examination

Formal Language and Automata Theory (CS21004)

Name Ima Sample ASU ID

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

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

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

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

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

NFAs continued, Closure Properties of Regular Languages

3 Regular expressions

Context-Free Grammars and Languages

1 From NFA to regular expression

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

This lecture covers Chapter 8 of HMU: Properties of CFLs

Finite Automata Part Three

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

Lecture 9: LTL and Büchi Automata

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

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.

Languages & Automata

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

First Midterm Examination

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

Thoery of Automata CS402

CS375: Logic and Theory of Computing

GNFA GNFA GNFA GNFA GNFA

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

Tutorial Automata and formal Languages

CS 275 Automata and Formal Language Theory

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

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

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

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

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

1.4 Nonregular Languages

Lexical Analysis Part III

Coalgebra, Lecture 15: Equations for Deterministic Automata

Transcription:

Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1

A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more flexile kind of utomton: the nondeterministic finite utomton or NFA. NFAs re it hrder to think out thn DFAs, ecuse they do not pper to define simple computtionl processes. They my seem t first to e unnturl, like puzzles invented y professors for the torment of students. But hve ptience! NFAs nd other kinds of nondeterministic utomt rise nturlly in mny wys, s you will see lter in this ook, nd they too hve vriety of prcticl pplictions. Forml Lnguge, chpter 5, slide 2 2

Outline 5.1 Relxing Requirement 5.2 Spontneous Trnsitions 5.3 Nondeterminism 5.4 The 5-Tuple for n NFA 5.5 The Lnguge Accepted y n NFA Forml Lnguge, chpter 5, slide 3 3

Not A DFA q 0 q 1, Does not hve exctly one trnsition from every stte on every symol: Two trnsitions from q 0 on No trnsition from q 0 (on either or ) Though not DFA, this cn e tken s defining lnguge, in slightly different wy Forml Lnguge, chpter 5, slide 4 4

Possile Sequences of Moves q 0 q 1, We'll consider ll possile sequences of moves the mchine might mke for given string For exmple, on the string there re three: From q 0 to q 0 to q 0, rejecting From q 0 to q 0 to q 1, ccepting From q 0 to q 1, getting stuck on the lst Our convention for this new kind of mchine: string is in L(M) if there is t lest one ccepting sequence Forml Lnguge, chpter 5, slide 5 5

Nondeterministic Finite Automton (NFA) q 0 q 1, L(M) = the set of strings tht hve t lest one ccepting sequence In the exmple ove, L(M) = {x x {,}*} A DFA is specil cse of n NFA: An NFA tht hppens to e deterministic: there is exctly one trnsition from every stte on every symol So there is exctly one possile sequence for every string NFA is not necessrily deterministic Forml Lnguge, chpter 5, slide 6 6

NFA Advntge An NFA for lnguge cn e smller nd esier to construct thn DFA Strings whose next-to-lst symol is 1: 0 DFA: 1 NFA: 0 0 0 1 1 0,1 1 0,1 1 Forml Lnguge, chpter 5, slide 7 7

Outline 5.1 Relxing Requirement 5.2 Spontneous Trnsitions 5.3 Nondeterminism 5.4 The 5-Tuple for n NFA 5.5 The Lnguge Accepted y n NFA Forml Lnguge, chpter 5, slide 8 8

Spontneous Trnsitions An NFA cn mke stte trnsition spontneously, without consuming n input symol Shown s n rrow leled with ε For exmple, {}* {}*: q 1 q 0 q 2 Forml Lnguge, chpter 5, slide 9 9

ε-trnsitions To Accepting Sttes q 1 q 0 q 2 An ε-trnsition cn e mde t ny time For exmple, there re three sequences on the empty string No moves, ending in q 0, rejecting From q 0 to q 1, ccepting From q 0 to q 2, ccepting Any stte with n ε-trnsition to n ccepting stte ends up working like n ccepting stte too Forml Lnguge, chpter 5, slide 10 10

ε-trnsitions For NFA Comining q 1 q 0 ε-trnsitions re useful for comining smller utomt into lrger ones This mchine is comines mchine for {}* nd mchine for {}* It uses n ε-trnsition t the strt to chieve the union of the two lnguges q 2 Forml Lnguge, chpter 5, slide 11 11

Incorrect Union A = { n n is odd} B = { n n is odd} A B? No: this NFA ccepts Forml Lnguge, chpter 5, slide 12 12

Correct Union A = { n n is odd} B = { n n is odd} A B Forml Lnguge, chpter 5, slide 13 13

Incorrect Conctention A = { n n is odd} B = { n n is odd} {xy x A nd y B}? No: this NFA ccepts Forml Lnguge, chpter 5, slide 14 14

Correct Conctention A = { n n is odd} B = { n n is odd} {xy x A nd y B} Forml Lnguge, chpter 5, slide 15 15

Outline 5.1 Relxing Requirement 5.2 Spontneous Trnsitions 5.3 Nondeterminism 5.4 The 5-Tuple for n NFA 5.5 The Lnguge Accepted y n NFA Forml Lnguge, chpter 5, slide 16 16

DFAs nd NFAs DFAs nd NFAs oth define lnguges DFAs do it y giving simple computtionl procedure for deciding lnguge memership: Strt in the strt stte Mke one trnsition on ech symol in the string See if the finl stte is ccepting NFAs do it without such cler-cut procedure: Serch ll legl sequences of trnsitions on the input string? How? In wht order? Forml Lnguge, chpter 5, slide 17 17

Nondeterminism The essence of nondeterminism: For given input there cn e more thn one legl sequence of steps The input is in the lnguge if t lest one of the legl sequences sys so We cn chieve the sme result y deterministiclly serching the legl sequences, ut...this nondeterminism does not directly correspond to nything in physicl computer systems In spite of tht, NFAs hve mny prcticl pplictions Forml Lnguge, chpter 5, slide 18 18

Outline 5.1 Relxing Requirement 5.2 Spontneous Trnsitions 5.3 Nondeterminism 5.4 The 5-Tuple for n NFA 5.5 The Lnguge Accepted y n NFA Forml Lnguge, chpter 5, slide 19 19

Powerset If S is set, the powerset of S is the set of ll susets of S: P(S) = {R R S} This lwys includes the empty set nd S itself For exmple, P({1,2,3}) = {{}, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}} Forml Lnguge, chpter 5, slide 20 20

The 5-Tuple An NFA M is 5-tuple M = (Q, Σ, δ, q 0, F), where: Q is the finite set of sttes Σ is the lphet (tht is, finite set of symols) δ (Q (Σ {ε}) P(Q)) is the trnsition function q 0 Q is the strt stte F Q is the set of ccepting sttes The only chnge from DFA is the trnsition function δ δ tkes two inputs: A stte from Q (the current stte) A symol from Σ {ε} (the next input, or ε for n ε-trnsition) δ produces one output: A suset of Q (the set of possile next sttes) Forml Lnguge, chpter 5, slide 21 21

, Exmple: q 0 q 1 q 2 Formlly, M = (Q, Σ, δ, q 0, F), where Q = {q 0,q 1,q 2 } Σ = {,} (we ssume: it must contin t lest nd ) F = {q 2 } δ(q 0,) = {q 0,q 1 }, δ(q 0,) = {q 0 }, δ(q 0,ε) = {q 2 }, δ(q 1,) = {}, δ(q 1,) = {q 2 }, δ(q 1,ε) = {} δ(q 2,) = {}, δ(q 2,) = {}, δ(q 2,ε) = {} The lnguge defined is {,}* Forml Lnguge, chpter 5, slide 22 22

Outline 5.1 Relxing Requirement 5.2 Spontneous Trnsitions 5.3 Nondeterminism 5.4 The 5-Tuple for n NFA 5.5 The Lnguge Accepted y n NFA Forml Lnguge, chpter 5, slide 23 23

The δ* Function The δ function gives 1-symol moves We'll define δ* so it gives whole-string results (y pplying zero or more δ moves) For DFAs, we used this recursive definition δ*(q,ε) = q δ*(q,x) = δ(δ*(q,x),) The intuition is the similr for NFAs, ut the ε-trnsitions dd some technicl hir Forml Lnguge, chpter 5, slide 24 24

NFA IDs An instntneous description (ID) is description of point in n NFA's execution It is pir (q,x) where q Q is the current stte x Σ* is the unred prt of the input Initilly, n NFA processing string x hs the ID (q 0,x) An ccepting sequence of moves ends in n ID (f,ε) for some ccepting stte f F Forml Lnguge, chpter 5, slide 25 25

The One-Move Reltion On IDs We write I! J if I is n ID nd J is n ID tht could follow from I fter one move of the NFA Tht is, for ny string x Σ* nd ny ω Σ or ω = ε, ( q,ωx)! ( r,x) if nd only if r δ( q,w) Forml Lnguge, chpter 5, slide 26 26

The Zero-Or-More-Move Reltion We write I! J if there is sequence of zero or more moves tht strts with I nd ends with J: I! "! J Becuse it llows zero moves, it is reflexive reltion: for ll IDs I, I! I Forml Lnguge, chpter 5, slide 27 27

The δ* Function Now we cn define the δ* function for NFAs: δ q, x { } ( ) = r ( q, x)! ( r,ε) Intuitively, δ*(q,x) is the set of ll sttes the NFA might e in fter strting in stte q nd reding x Our definition llows ε-trnsitions, including those mde efore the first symol of x is red, nd those mde fter the lst Forml Lnguge, chpter 5, slide 28 28

M Accepts x Now δ*(q,x) is the set of sttes M my end in, strting from stte q nd reding ll of string x So δ*(q 0,x) tells us whether M ccepts x: A string x Σ* is ccepted y n NFA M = (Q, Σ, δ, q 0, F) if nd only if δ*(q 0, x) contins t lest one element of F. Forml Lnguge, chpter 5, slide 29 29

The Lnguge An NFA Defines For ny NFA M = (Q, Σ, δ, q 0, F), L(M) denotes the lnguge ccepted y M, which is L(M) = {x Σ* δ*(q 0, x) F {}}. Forml Lnguge, chpter 5, slide 30 30