Finite State Automata and Determinisation

Similar documents
CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Regular languages refresher

Nondeterministic Finite Automata

Nondeterministic Automata vs Deterministic Automata

CS 573 Automata Theory and Formal Languages

NON-DETERMINISTIC FSA

CSE 401 Compilers. Today s Agenda

Fundamentals of Computer Science

Prefix-Free Regular-Expression Matching

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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

2.4 Theoretical Foundations

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

Finite-State Automata: Recap

@#? Text Search ] { "!" Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata

= state, a = reading and q j

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

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

CMSC 330: Organization of Programming Languages

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

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

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

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

NFAs continued, Closure Properties of Regular Languages

Lecture 08: Feb. 08, 2019

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.

Chapter 2 Finite Automata

CISC 4090 Theory of Computation

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

Lexical Analysis Finite Automate

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

Petri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering

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

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Worked out examples Finite Automata

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

Convert the NFA into DFA

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

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

input tape head moves current state

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

Homework 3 Solutions

Thoery of Automata CS402

Data Structures and Algorithm. Xiaoqing Zheng

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

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

Formal Language and Automata Theory (CS21004)

CHAPTER 1 Regular Languages. Contents

Formal Languages and Automata

Let's start with an example:

Coalgebra, Lecture 15: Equations for Deterministic Automata

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

NFAs continued, Closure Properties of Regular Languages

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

Designing finite automata II

1 From NFA to regular expression

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

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

1 Nondeterministic Finite Automata

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.

Minimal DFA. minimal DFA for L starting from any other

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

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

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

Formal languages, automata, and theory of computation

ɛ-closure, Kleene s Theorem,

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

Deterministic Finite Automata

Some Theory of Computation Exercises Week 1

Theory of Computation Regular Languages

Non-deterministic Finite Automata

CS375: Logic and Theory of Computing

CSCI565 - Compiler Design

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

Automata and Languages

Java II Finite Automata I

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Harvard University Computer Science 121 Midterm October 23, 2012

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

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

CS241 Week 6 Tutorial Solutions

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

State Minimization for DFAs

Nondeterminism and Nodeterministic Automata

CS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Closure Properties of Regular Languages

Non-deterministic Finite Automata

First Midterm Examination

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

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

1.4 Nonregular Languages

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL:

Automata and Regular Languages

Transcription:

Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016

Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions 5 Deterministi Finite Stte Automt (df) 6 Deterministion Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 3 Alphets An lphet Σ is set of tokens used y lnguge Σ = {0, 1} is the lphet for inry Σ = {., 0, 1,..., 9} is the lphet for deiml numer Σ = {mro, polo} is the lphet for the ommunitions protool in the gme Mro Polo 1 Wht lnguge(s) is this the lphet for? Σ = {x, 0, 1,..., 9, A, B,..., F} 1 A gme involving lling out Mro! nd Polo!, with n optionl swimming pool Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 4 Strings A omintion 2 of elements from Σ is lled string 0, 101101, 111 re ll strings of Σ = {0, 1} The set Σ is the infinite set of ll omintions of the elements of Σ For the inry lphet, Σ = {0, 1}, Σ is 3 Σ = {, (0), (1), (00), (01), (10), (11), (000), (001),...} 2 Oviously, ontiguous ordered tuple of elements, not set: 01 is different string from 10 3 Here the empty set will do to represent null or empty string Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 5 Lnguges A lnguge L is set of items from Σ whih re deemed to e vlid (L Σ ) For hexdeiml, only the strings whih egin with 0x nd hve t lest one more non- x token re deemed vlid 0xF9 1234 0x0 0x 1xA (the empty string) A lnguge in this ontext is not set of rules, syntx, grmmr nd ll: it s just set of vlid strings Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 6 Finite Stte Automt Finite Stte Automt re representtions of self-ontined finite set of sttes, with rules tht govern movement mong those sttes. Finite Stte Automt (fss) exist everywhere They re used to illustrte the possile sttes some proess n e in how the proess moves etween these sttes Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 7 Finite Stte Automt E.g. stte mhine for PIN ode entry on your moile 4 : 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! 4 How mny people do you know who sy PIN Numer? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges fs edges (trnsitions) hve lels Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges fs edges (trnsitions) hve lels fss hve strt node (entry point) Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 8 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! fss hve nodes fss hve edges fs edges (trnsitions) hve lels fss hve strt node (entry point) fss hve epting nodes, denoted with the doule outline Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 9 Finite Stte Automt 0-9 nel witing 0-9 witing nel nel witing 0-9 witing 0-9 nel hek pssword! You re lwys on one of the nodes, i.e., in one of the sttes. You n trvel etween the nodes following the direted edges You n only trvel long n edge if you see the lel tht is on the edge Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 0x0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 0x0 q 0 q 1 q 2 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 0x0 q 0 q 1 q 2 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 0x0 q 0 q 1 q 2 q 3 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 0x0 q 0 q 1 q 2 q 3 q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 10 Pttern Reognition using fss 0-9,A-F 0 x 0-9,A-F Wlk the following strings through the fs. Are they epted? String Pth Aepts? 0xF9 q 0 q 1 q 2 q 3 q 3 1234 q 0 0x0 q 0 q 1 q 2 q 3 q 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 11 Non-deterministi Finite Stte Automt There re two min types of fss Deterministi Non-deterministi Wht we hve een looking t so fr re exmples of non-deterministi finite [stte] utomt (nf) E.g. nf for reognising hexdeiml numer: 0-9,A-F 0 x 0-9,A-F Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 12 Properties of nfs Must hve strt node No restritions on the edge lels Allowed speil ε edge lels (we ll ome k to this) Allowed to e on multiple sttes simultneously non-determinism Bsilly n NFA is FSA tht isn t fully defined: in DFA (Deterministi Finite (Stte) Automton of ourse), everything hs to e determined: if there s n error ondition tht hs to e explined, there n t e ny miguity, nd so on. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 1 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 1 } {q 3 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 13 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 1 } {q 3 } Aepted: Yes,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 1, q 3 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 14 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 1, q 3 } Aepted: Yes,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } {q 0, q 1, q 2 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } {q 0, q 1, q 2 } {q 1, q 3 } Aepted:,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 15 Non-determinism exmple Is the string epted y the nf? Pth: {q 0 } {q 0, q 2 } {q 0, q 2 } {q 0, q 1, q 2 } {q 1, q 3 } Aepted: Yes,,, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 16 ε trnsitions nfs n hve speil trnsition lel ε ε llows trnsition without onsuming ny input tokens ϵ q4 In English, wht pttern does this nf therefore llow us to mth? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 16 ε trnsitions nfs n hve speil trnsition lel ε ε llows trnsition without onsuming ny input tokens ϵ q4 In English, wht pttern does this nf therefore llow us to mth? Any string strting with, followed y one or more instnes of, followed y Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s. 1 1 0 0 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s. 1 1 0 0 As ove, exept for one s insted of zero s. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 17 Your turn Woo! Construt nf whih epts only inry numers with n even numer of zero s. 1 1 0 0 As ove, exept for one s insted of zero s. 0 0 1 1 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 18 Your turn Construt nf whih epts only inry numers with n even numer of zero s OR n even numer of one s. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 18 Your turn Construt nf whih epts only inry numers with n even numer of zero s OR n even numer of one s. 1 1 ϵ 0 0 ϵ 0 0 1 1 q4 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 19 Regulr Expressions (re) You rememer the power of regulr expressions? These things n sve the world! regex s rule.... nd it turns out they re muh etter interpreted nd delt with Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 20 Regulr Expressions s nfs Regulr expressions n esily e represented using nfs We n group regulr expressions into 4 different omponents Chrter single hrter: // Contention two djent expressions: // Union two OR d expressions: / / Kleene str zero or more repetitions: /*/ /( d*)*e/ n e viewed s ont ont str union e ont str d Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 21 And it relly does mtter Knowing the right wy to do regulr expressions, using good omputer siene, mens tht you don t hve to mke mjor errors leding to relly relly d performne, in hrdly-used it of softwre, like sy, Perl. This is the time tken to mth the sequene? n n ginst n where the supersript represents string repets, so? 2 2 =?? Soure: Russ Cox / rs@swth.om 5 5 For gret disussion of this, see http://swth.om/~rs/regexp/regexp1.html Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 22 re to nf: Chrter // Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 23 re to nf: Contention // + eomes ϵ Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 24 re to nf: Union / / + eomes q4 ϵ ϵ ϵ ϵ q5 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 25 re to nf: Kleene Str /*/ eomes ϵ ϵ ϵ ϵ Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 26 An exmple onversion /( d*)*e/ eomes ϵ ϵ ϵ ϵ q4 ϵ q5 q6 ϵ ϵ d ϵ q7 q8 ϵ q9 0 ϵ ϵ 1 ϵ 2 ϵ 3 e 4 ϵ Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 27 DFAs vs NFAs How do dfs differ from nfs? Deterministi (not non-deterministi) No ε edges Every edge from node must hve unique lel (n t e in multiple sttes) Every node must hve n outwrd edge for eh token of the lphet (it is ompletely desried) Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 28 dfs vs. nfs E.g. df for reognising hexdeiml numer: 0-9,A-F 0 x 1-9,A-F,x 0-9,A-F 0-9,A-F q4 x x 0-9,A-F,x q5 Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 29 Why do we need dfs? Wht s wrong with nfs? The non-deterministi spet of nfs mkes them d for modern-dy omputtion Computers nnot effiiently perform the e in multiple sttes t one In df, you n only e in one stte t time Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 30 Your turn dfs n e hrder to mnully onstrut thn nfs, due to their restritions. Construt df over Σ = {, } epting strings ending in. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 30 Your turn dfs n e hrder to mnully onstrut thn nfs, due to their restritions. Construt df over Σ = {, } epting strings ending in. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 31 nf? = df At first glne, it would pper tht nfs re more powerful thn dfs. Why? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 31 nf? = df At first glne, it would pper tht nfs re more powerful thn dfs. Why? multiple edges with the sme lel oming off node ε edges ility to e in multiple sttes t one Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 31 nf? = df At first glne, it would pper tht nfs re more powerful thn dfs. Why? multiple edges with the sme lel oming off node ε edges ility to e in multiple sttes t one In 1959, Rin nd Sott proved tht nfs nd dfs hve the sme expressive power The proof is surprisingly simple: we need to show tht for eh NFA there is DFA, nd vie-vers, tht ept preisely the sme lnguges. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 32 Deterministion Algorithm This lgorithm onverts ny nf into n equivlent df ϵ 0 0 ϵ q4 0 1 1 1 into 0,1 {,,} 0,1 {,q4} 0 1 {,} 0 0 {q4} 1 {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 33 Move nd Epsilon-Closure Move M(sttes, token) Given set of sttes nd n input token, wht set of sttes do you end up t Epsilon-Closure EC(sttes) Given set of sttes, wht set of sttes do you get y expnding ll ε trnsitions, ϵ, M({q 0, q 1 }, ) = {q 2, q 3 } EC({q 2, q 3 }) = {q 0, q 2, q 3 } Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 34 Algorithm Ide We need to remove the onept of non-determinism in the df Ahieved y reting stte in the df for every possile set of sttes in the nf Q: If the nf hs n sttes, wht s the mximum numer of sttes its orresponding df ould hve? Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 34 Algorithm Ide We need to remove the onept of non-determinism in the df Ahieved y reting stte in the df for every possile set of sttes in the nf Q: If the nf hs n sttes, wht s the mximum numer of sttes its orresponding df ould hve? A: P(n) = 2 n Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 35 Pseudoode Require: nf df new DFA ojet df.strt EC(nf.strt) todo [df.strt] while todo = do sttes = pop the next item off todo for ll σ Σ NFA \ {ε} do s = EC (M(sttes, σ)) if s = then Add the edge sttes Add s to todo if it s new end if end for end while return df σ s to df Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple, todo {0} ϵ, Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple, todo {0} ϵ, {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {,} {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {,} {,,} {,} {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {} {,} {,,} {,}, {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3} {} {,} {,,} {,,} {,}, {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3} {} {,} {,,} {,,} {,},, {} {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3} {} {,} {,,} {,,} {,},, {} {},,,, {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 36 Exmple ϵ,, todo {0} {0, 2} {1} {0, 1, 2} {1, 3} {3} {0, 2, 3}, {} {,} {,,} {,,} {,},, {} {},,,, {} Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016

Lnguges fs nf re df Deterministion 37 Finish End of presenttion. Tim Dworn Finite Stte Automt nd Deterministion Jnury, 2016