Non-deterministic Finite Automata

Similar documents
Non-deterministic Finite Automata

Deterministic Finite Automata

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

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

NFAs continued, Closure Properties of Regular Languages

Theory of Computation Regular Languages

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

Lecture 08: Feb. 08, 2019

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.

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

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

Minimal DFA. minimal DFA for L starting from any other

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

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

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

Finite Automata-cont d

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

Fundamentals of Computer Science

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

Java II Finite Automata I

CMSC 330: Organization of Programming Languages

NFAs continued, Closure Properties of Regular Languages

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

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

Finite-State Automata: Recap

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.

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

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

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

CHAPTER 1 Regular Languages. Contents

Formal Languages and Automata

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

Worked out examples Finite Automata

State Minimization for DFAs

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

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

Chapter 2 Finite Automata

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

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

Nondeterminism and Nodeterministic Automata

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

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

Languages & Automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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

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

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

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.

Homework 3 Solutions

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

Regular languages refresher

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

Convert the NFA into DFA

Some Theory of Computation Exercises Week 1

3 Regular expressions

Formal Language and Automata Theory (CS21004)

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

Myhill-Nerode Theorem

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

Lexical Analysis Finite Automate

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

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

Coalgebra, Lecture 15: Equations for Deterministic Automata

Non-Deterministic Finite Automata

Closure Properties of Regular Languages

Lecture 6 Regular Grammars

ɛ-closure, Kleene s Theorem,

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

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

1 From NFA to regular expression

CS375: Logic and Theory of Computing

Lecture 09: Myhill-Nerode Theorem

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.

Midterm 1 Practice. CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

CS 275 Automata and Formal Language Theory

Harvard University Computer Science 121 Midterm October 23, 2012

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

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

Let's start with an example:

First Midterm Examination

1 Nondeterministic Finite Automata

Designing finite automata II

Today s Topics Automata and Languages

Automata and Languages

CISC 4090 Theory of Computation

Speech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research

Formal languages, automata, and theory of computation

Lecture 9: LTL and Büchi Automata

1.3 Regular Expressions

FABER Formal Languages, Automata and Models of Computation

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

1.4 Nonregular Languages

Introduction to ω-autamata

Deterministic Finite-State Automata

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

Transcription:

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Rdoud University Nijmegen Version: fll 2016 Jurrin Rot Version: fll 2016 Tlen en Automten 1 / 19

Outline Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Jurrin Rot Version: fll 2016 Tlen en Automten 2 / 19

Previous Weeks Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Regulr Expressions nd Regulr Lnguges rexp Σ ::= 0 1 s rexp Σ rexp Σ rexp Σ +rexp Σ rexp Σ with s Σ L Σ is regulr if L = L(e) for some regulr expression e. Deterministic Finite Automt, DFA Proposition Closure under complement, union, intersection If L 1, L 2 re ccepted y some DFA, then so re L 1 = Σ L 1 L 1 L 2 L 1 L 2. Jurrin Rot Version: fll 2016 Tlen en Automten 3 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Kleene s Theorem (nnounced lst lecture) Theorem The lnguges ccepted y DFAs re exctly the regulr lnguges We prove this y 1 If L = L(M) for some DFA M, then there is regulr expression e such tht L = L(e) (Previous lecture) 2 If L = L(e), for some regulr expression e, then there is non-deterministic finite utomton with -steps (NFA-) M such tht L = L(M). (This lecture) 3 For every NFA-, M, there is DFA M such tht L(M) = L(M ) (This lecture) Jurrin Rot Version: fll 2016 Tlen en Automten 4 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic finite utomton (NFA), q strt 0 q 1 q 2 δ(q, ) is not one stte, ut set of sttes. δ q 0 {q 0 } {q 0, q 1 } q 1 {q 2 } q 2 in shorthnd δ q 0 q 0 q 0, q 1 q 1 q 2 q 2 Jurrin Rot Version: fll 2016 Tlen en Automten 6 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt: NFA (definition) M is NFA over Σ if M = (Q, q 0, δ, F ) with Q is finite set of sttes q 0 Q is the initil stte F Q is finite set of finl sttes δ : Q Σ PQ is the trnsition function [PQ denotes the collection of susets of Q] Reding function δ : Q Σ PQ (multi-step trnsition) δ (q, ) = {q} δ (q, w) = {q q δ (p, w) for some p δ(q, )} = δ (p, w) p δ(q,) The lnguge ccepted y M, nottion L(M), is: L(M) = {w Σ q f δ (q 0, w) such tht q f F } Jurrin Rot Version: fll 2016 Tlen en Automten 7 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen For the union of lnguges we cn put NFAs in prllel Exmple Suppose we wnt to hve n NFA for L 1 L 2 = {w w is even or w 1} First ide: put the two mchines non-deterministiclly in prllel strt ev od, strt 0 1 strt, ev0 od 1 But this is wrong: The NFA ccepts. Jurrin Rot Version: fll 2016 Tlen en Automten 8 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism NFAs with silent steps: NFA- We dd -trnsitions or silent steps to NFAs The correct union of M 1 nd M 2 is: ev od Rdoud University Nijmegen strt U, 0 1 In n NFA- we llow for q q. Tht mens δ(q, ) = q δ : Q (Σ {}) PQ Jurrin Rot Version: fll 2016 Tlen en Automten 9 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism NFA- (definition) Rdoud University Nijmegen M is n NFA- over Σ if M = (Q, q 0, δ, F ) with Q is finite set of sttes q 0 Q is the initil stte F Q is finite set of finl sttes δ : Q (Σ {}) PQ is the trnsition function The -closure of stte q, -closure(q), is the set of sttes rechle with only -steps. Reding function δ : Q Σ PQ (multi-step trnsition) δ (q, ) = -closure(q) δ (q, w) = {q p -closure(q) r δ(p, ) (q δ (r, w))} = δ (r, w) p -closure(q) r δ(p,) The lnguge ccepted y M, nottion L(M), is: L(M) = {w Σ q f δ (q 0, w) such tht q f F } Jurrin Rot Version: fll 2016 Tlen en Automten 10 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Toolkit for uilding n NFA- from regulr expression For ech regulr expression, we construct n NFA-. e M such tht L(M) = L(e) 0 strt q 0 1 strt q 0 (for Σ) strt q 0 f M 1 e = e 1 + e 2 with L(M 1 ) = L(e 1 ) L(M 2 ) = L(e 2 ) strt q 0 M 2 f q 1 f 1 q 2 f 2 Jurrin Rot Version: fll 2016 Tlen en Automten 12 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Toolkit (continued) Rdoud University Nijmegen e M such tht L(M) = L(e) e = e 1 e 2 with L(M 1 ) = L(e 1 ) L(M 2 ) = L(e 2 ) M 1 M 2 strt q 1 f 1 q 2 f 2 e = (e 1 ) with L(M 1 ) = L(e 1 ) M 1 strt q 0 q 1 f 1 Jurrin Rot Version: fll 2016 Tlen en Automten 13 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Regulr lnguges ccepted y NFA- Rdoud University Nijmegen Proposition. For every regulr expression e there is n NFA- M e such tht L(M e ) = L(e). Proof. Apply the toolkit. M e cn e found y induction on the structure of e: First do this for the simplest regulr expressions. For composed regulr expression compose the utomt. Corollry. For every regulr lnguge L there is n NFA- M tht ccepts L (so L(M) = L). Jurrin Rot Version: fll 2016 Tlen en Automten 14 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Avoiding non-determinism Rdoud University Nijmegen We cn trnsform ny NFA (nd NFA-) into DFA tht ccepts the sme lnguge. Ide: Keep trck of the set of ll sttes you cn go to! Sttes of the DFA re sets-of-sttes from the originl NFA-. A set of sttes is finl if one of the memers is finl. Exmple L = {w w is even or w 1} strt U ev od, strt U od,0 od,1 ev,0 0 1 ev,1 Jurrin Rot Version: fll 2016 Tlen en Automten 16 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Eliminting non-determinism nd -steps Let M e NFA given y (Q, q 0, δ, F ) Define the DFA M s (Q, q 0, δ, F ) where Q = PQ Rdoud University Nijmegen q 0 = {q 0 } δ(h, ) = δ(q, ), for H Q, q H F = {H Q H F } If M is n NFA-, we define q 0 = -closure(q 0 ) δ(h, ) = -closure(δ(p, )) q H p -closure(q) F = {H Q -closure(h) F } Jurrin Rot Version: fll 2016 Tlen en Automten 17 / 19

Correctness Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Given M, n NFA-, we hve defined the DFA M y q 0 = {q 0 } δ(h, ) = q H p -closure(q) -closure(δ(p, )) F = {H Q -closure(h) F } Theorem M nd M ccept the sme lnguges. Proof: This follows from Lemm δ (q, w) F δ ({q}, w) F (Tke q := q 0 ) Proof of the Lemm: induction on w, considering the cses w = nd w = u. Jurrin Rot Version: fll 2016 Tlen en Automten 18 / 19

Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Equivlence of DFA, NFA nd NFA- Rdoud University Nijmegen Conclusion. Every NFA- (or NFA) M cn e turned into DFA M ccepting the sme lnguge. Corollry. For every regulr lnguge L there is DFA M tht ccepts L (so L(M) = L). Proof. Given regulr expression e, first construct n NFA- M such tht L(M) = L(e). Then chnge it into DFA preserving the lnguge tht is ccepted. Rephrsing of Kleene s Theorem: The clss of regulr lnguges is (equivlently) chrcterized s 1 The lnguges descried y regulr expression 2 The lnguges ccepted y DFA 3 The lnguges ccepted y n NFA 4 The lnguges ccepted y NFA- Jurrin Rot Version: fll 2016 Tlen en Automten 19 / 19