Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

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

Regular languages refresher

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS 573 Automata Theory and Formal Languages

NON-DETERMINISTIC FSA

NFA and regex. the Boolean algebra of languages. non-deterministic machines. regular expressions

Nondeterministic Automata vs Deterministic Automata

Prefix-Free Regular-Expression Matching

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

NFAs continued, Closure Properties of Regular Languages

Finite-State Automata: Recap

Finite State Automata and Determinisation

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

First Midterm Examination

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

Nondeterminism and Nodeterministic Automata

Theory of Computation Regular Languages

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

Nondeterministic Finite Automata

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

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

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.

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

CSE 401 Compilers. Today s Agenda

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

NFAs continued, Closure Properties of Regular Languages

Fundamentals of Computer Science

Non-deterministic Finite Automata

Formal Language and Automata Theory (CS21004)

Finite Automata-cont d

Lecture 6 Regular Grammars

CHAPTER 1 Regular Languages. Contents

Prefix-Free Subsets of Regular Languages and Descriptional Complexity

1 From NFA to regular expression

Non-deterministic Finite Automata

CS375: Logic and Theory of Computing

State Complexity of Union and Intersection of Binary Suffix-Free Languages

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

First Midterm Examination

Lecture 08: Feb. 08, 2019

Minimal DFA. minimal DFA for L starting from any other

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

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

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

CISC 4090 Theory of Computation

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

CMSC 330: Organization of Programming Languages

Homework 3 Solutions

Deterministic Finite-State Automata

Today s Topics Automata and Languages

Automata and Languages

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

CS241 Week 6 Tutorial Solutions

Java II Finite Automata I

Deterministic Finite Automata

Closure Properties of Regular Languages

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

input tape head moves current state

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

2.4 Theoretical Foundations

Myhill-Nerode Theorem

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

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

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

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

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

Data Structures and Algorithm. Xiaoqing Zheng

= state, a = reading and q j

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

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

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

CS375: Logic and Theory of Computing

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

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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

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

Languages & Automata

Let's start with an example:

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Name Ima Sample ASU ID

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

Descriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata

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

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

State Minimization for DFAs

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

Solutions Problem Set 2. Problem (a) Let M denote the DFA constructed by swapping the accept and non-accepting state in M.

Convert the NFA into DFA

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

GNFA GNFA GNFA GNFA GNFA

Lexical Analysis Finite Automate

Non-Deterministic Finite Automata

Worked out examples Finite Automata

Harvard University Computer Science 121 Midterm October 23, 2012

Lecture 09: Myhill-Nerode Theorem

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

Some Theory of Computation Exercises Week 1

CSCI565 - Compiler Design

Transcription:

Running n NFA & the suset lgorithm (NFA->DFA) CS 350 Fll 2018 gilry.org/lsses/fll2018/s350/ 1

NFAs operte y simultneously exploring ll pths nd epting if ny pth termintes t n ept stte.!2

Try n exmple: L is the lnguge L(( )*). q0 q1,!3

Let s run this nondeterministilly on the string nd trk wht pths we n tke: q0 q1,!4

Let s run this nondeterministilly on the string nd trk wht pths we n tke: q0 q1,!5

Let s run this nondeterministilly on the string / nd trk wht pths we n tke: q0 q1,!6

Let s run this nondeterministilly on the string // nd trk wht pths we n tke: q0 q1,!7

Let s run this nondeterministilly on the string /// nd trk wht pths we n tke: q0 q1,!8

Let s run this nondeterministilly on the string //// nd trk wht pths we n tke: q0 q1,!9

Let s run this nondeterministilly on the string ///// nd trk wht pths we n tke: If ny possile pth would ept, then the NFA epts. q0 q1,!10

Consider tht wht n e deterministilly known out n NFA, fter onsuming string, is not single stte the mhine must oupy, ut the set of NFA sttes the mhine ould oupy.!11

Try n exmple: L(( )( )*) L is the lnguge.!12

Try n exmple: L(( )( )*) L is the lnguge. q0 q1 q4 q5!13

Try n exmple: L(( )( )*) L is the lnguge. q0 q1 q6 q4 q5!14

Try n exmple: L(( )( )*) L is the lnguge. q0 q1 q7 q8 q6 q9 q4 q5 q10!15

Try n exmple: L(( )( )*) L is the lnguge. q0 q1 q11 q7 q8 q6 q9 q4 q5 q10!16

Try n exmple: L(( )( )*) L is the lnguge. q0 q1 q11 q7 q8 q6 q9 q4 q5 q10!17

Now onsider the sttes visited t eh step, running the string: {q 9 } q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!18 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 9 } {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!19 q5 q10

The ε-losure of set of sttes is the set of sttes whih re rehle without onsuming ny hrters/strings. (Another fixpoint itertion.) losure δ : P(Q) P(Q) losure δ (qs) = ext N δ (qs) where ext N 1 (qs) = ext δ N δ (qs) ext δ (qs) = qs {q q qs (q,, q ) δ}!20

Now onsider the sttes visited t eh step, running the string: {q 9 } {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!21 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } {q 5 } / q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!22 q5 q10

The move of set of sttes nd hrter s, is the set of sttes whih re rehle from ny input stte, vi single trnsition on the hrter s. move δ : P(Q) Σ P(Q) move δ (qs, s) = {q q qs (q, s, q ) δ}!23

Now onsider the sttes visited t eh step, running the string: {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } {q 5 } / q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!24 q5 q10

Now onsider the sttes visited t eh step, running the string: / {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } {q 5, q 10, q 11, q 7, q 2, q 0 } q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!25 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 5, q 10, q 11, q 7, q 2, q 0 } {q 3 } // q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!26 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 5, q 10, q 11, q 7, q 2, q 0 } // {q 3, q 8, q 11, q 7, q 2, q 0 } q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!27 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 3, q 8, q 11, q 7, q 2, q 0 } {q 1 } /// q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!28 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 3, q 8, q 11, q 7, q 2, q 0 } /// {q 1, q 8, q 11, q 7, q 2, q 0 } q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!29 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 1, q 8, q 11, q 7, q 2, q 0 } {q 3 } //// q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!30 q5 q10

Now onsider the sttes visited t eh step, running the string: {q 1, q 8, q 11, q 7, q 2, q 0 } {q 3, q 8, q 11, q 7, q 2, q 0 } //// q0 q1 q11 q7 q8 q6 q9 L(( )( )*) q4!31 q5 q10

Now onsider the sttes visited t eh step, running the string: //// {q 3, q 8, q 11, q 7, q 2, q 0 } {q 11 } Ø q0 q1 q11 q7 q8 q6 q9 q10 L(( )( )*) q4!32 q5

So, if we n deterministilly step through n NFA using sets of NFA sttes insted of single NFA sttes, n we produe DFA from n NFA tht enodes these sets of sttes? {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } YES {q 5, q 10, q 11, q 7, q 2, q 0 } {q 3, q 8, q 11, q 7, q 2, q 0 } {q 1, q 8, q 11, q 7, q 2, q 0 }!33

So, if we n deterministilly step through n NFA using sets of NFA sttes insted of single NFA sttes, n we produe DFA from n NFA tht enodes these sets of sttes? {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } YES {q 5, q 10, q 11, q 7, q 2, q 0 } {q 3, q 8, q 11, q 7, q 2, q 0 } Wht we just worked through is just frgment of the DFA enoding this NFA! {q 1, q 8, q 11, q 7, q 2, q 0 }!34

Models of regulr lnguges Converts to GNFA Converts to RE DFA Minimizes to Converts to NFA Converts to!35

The suset lgorithm!36

The suset lgorithm Input: NFA (Q, Σ, δq, q0, FQ) Output: DFA (D, Σ, δd, d0, FD) Let d0 = ε-losureδ({q0}) mrked = {} D = {d0} δd = {} While d D suh tht d mrked: mrked = mrked {d} For eh s Σ: Let dmv = moveδ(d,s) Let dmv+ε = ε-losureδ(dmv) If dmv+ε D: D = D {dmv+ε} δd = δd {(d,s,dmv+ε)} FD = { d D q d. q FQ}!37

Try n exmple: L(( )( )*) L is the lnguge. q0 q1 q11 q7 q8 q6 q9 q4 q5 q10!38

Try n exmple: L(( )( )*) L is the lnguge. {q 5, q 10, q 11, q 7, q 2, q 0 } {q 1, q 8, q 11, q 7, q 2, q 0 } d1 d0 d2 d3 {q 9, q 4, q 6, q 10, q 11, q 7, q 2, q 0 } {q 3, q 8, q 11, q 7, q 2, q 0 }!39