Nondeterministic Finite Automata

Similar documents
NON-DETERMINISTIC FSA

CS 573 Automata Theory and Formal Languages

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Regular languages refresher

Finite State Automata and Determinisation

Nondeterministic Automata vs Deterministic Automata

= state, a = reading and q j

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

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

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

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

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

Formal Languages and Automata

Convert the NFA into DFA

Lecture 08: Feb. 08, 2019

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

Prefix-Free Regular-Expression Matching

2.4 Theoretical Foundations

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

Let's start with an example:

Minimal DFA. minimal DFA for L starting from any other

NFAs continued, Closure Properties of Regular Languages

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

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.

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

1 Nondeterministic Finite Automata

Chapter 4 State-Space Planning

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Fundamentals of Computer Science

CHAPTER 1 Regular Languages. Contents

Deterministic Finite Automata

Lecture 6: Coding theory

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

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

Compression of Palindromes and Regularity.

Nondeterminism and Nodeterministic Automata

Thoery of Automata CS402

Designing finite automata II

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

CS375: Logic and Theory of Computing

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

Finite Automata-cont d

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

CMSC 330: Organization of Programming Languages

CS241 Week 6 Tutorial Solutions

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

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

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

Coalgebra, Lecture 15: Equations for Deterministic Automata

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

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

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

Chapter 2 Finite Automata

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

Data Structures and Algorithm. Xiaoqing Zheng

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

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

Automata and Regular Languages

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

Closure Properties of Regular Languages

Homework 3 Solutions

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

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

Theory of Computation Regular Languages

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

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

Hybrid Systems Modeling, Analysis and Control

CSE 401 Compilers. Today s Agenda

System Validation (IN4387) November 2, 2012, 14:00-17:00

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

Lexical Analysis Finite Automate

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Lecture 9: LTL and Büchi Automata

1 From NFA to regular expression

input tape head moves current state

3 Regular expressions

First Midterm Examination

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

NFAs continued, Closure Properties of Regular Languages

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

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.

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

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

Section 1.3 Triangles

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

ɛ-closure, Kleene s Theorem,

GNFA GNFA GNFA GNFA GNFA

Lecture 09: Myhill-Nerode Theorem

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

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

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

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

INTRODUCTION TO AUTOMATA THEORY

CS 275 Automata and Formal Language Theory

Java II Finite Automata I

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

Today s Topics Automata and Languages

Transcription:

Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F) Finite utomt (F) re generlized Fs in whih trnsitions my e leled with ny string (inluding ). n edge with ommseprted strings P, Q Strt is n revition for multiple edges P F Q Nondeterministi Finite utomt 5-2 Leled Pths leled pth in n F is ny pth in whih eh edge is leled y the string Strt on the trnsition tken. The lel of pth is the ontention of ll the edge strings. Some leled pths nd their lels in F : Nondeterministi Finite utomt 5-3 " " " " " ; lel of this pth is " " " ; lel of this pth is ; lel of this pth is F Nondeterminism in Fs In F, there is unique pth with lel s from every stte. This is why they re deterministi. Strt ut in n F, there my e ny numer (inluding ) pths with lel s from stte. This mkes them nondeterministi..g., pths with lel strting t : " " " " " " " " " " " Nondeterministi Finite utomt 5-4 F

epted Strings in n F Prtiing eptne n F epts string s if there is some* leled pth with lel s from its strt stte to finl stte. F Whih of the following strings re epted y F? F * The some is required y the nondeterminism of Fs. Strt Strt F epts vi " " " " F does not ept F epts vi: () " " " " (2) " " " " " " (3) " " " " ut not vi " " " " " " Nondeterministi Finite utomt 5-5 Nondeterministi Finite utomt 5-6 n eptne lgorithm y xmple Is epted y F? Form leled grph in whih. Root node is (, ) 2. For eh node (Q, s pre @ s rest ) nd F trnsition s pre Q Q there s n edge leled s pre to node (Q, s rest ) Strt F More eptne xmples Run the eptne lgorithm on the following exmples: Strt F 3. ept if rete node (Q finl,) for some finl stte Q finl ; (, ) otherwise rejet. This lgorithm is gurnteed to terminte. Why? Nondeterministi Finite utomt 5-7 Nondeterministi Finite utomt 5-8

The Lnguge of n F The lnguge of n F is the set of ll strings it epts. F Relting Fs nd Fs lerly, Fs n speify ny lnguge tht Fs n. ut n Fs speify more lnguge thn Fs? Is there lnguge tht Fs n speify ut Fs nnot? Strt Wht is lnguge(f ) in nglish? Surprisingly, the nswer is no: oth Fs nd Fs desrie extly the sme lnguges = regulr lnguges. We ll prove this in next leture y showing how to trnsform Fs to equivlent Fs. For the rest of this leture, we ll fous on. How to design Fs 2. How to formlize Fs 3. How to use Fs in Forln Nondeterministi Finite utomt 5-9 Nondeterministi Finite utomt 5- The Power of Fs If Fs n t speify more lnguges thn Fs, why do we re out them? euse they re usully more onvenient Whih of the following would you rther speify? eterministi Finite utomton Nondeterministi Finite utomton esigning Finite utomt esign Fs for eh of the following lnguges in {} * :. ll strings ontining. 2. ll strings ontining,, or. 3. ll strings with penultimte. 4. ll strings omposed out of loks of nd (inluding ) 5. ll strings in whih ppers somewhere fter. 6. ll strings denoting integers tht re multiples of 3 or 5. Nondeterministi Finite utomt 5- Nondeterministi Finite utomt 5-2

reful with omplements Unlike with Fs, omplementing n F does not neessrily omplement the epted lnguge Why? xmple: Wht lnguges re epted y these Fs? Formlizing Finite utomt F Strt n F is quintuple (Q, #, T, s, F). Q is finite set of sttes ( {,,,,}, 2. # is n lphet {, }, 3. T is trnsition reltion $ Q x #* x Q see next slide, 4. s in Q is strt stte, 5. F $ Q is set of finl sttes {,,}) Nondeterministi Finite utomt 5-3 Nondeterministi Finite utomt 5-4 Speifying n F Trnsition Reltion T F in Forln Syntx T $ Q x #* x Q egin stte string end stte Strt Trnsition reltion T for F : { (,, ), (,, ), (,, ), (,, ), (,, ), (,, ), (,,), (,, ), (,, ), (,, ) } F ontents of file f.f {sttes},,,, {strt stte} Strt {epting sttes},, {trnsitions}, -> ;, % -> ;, -> ;, -> ;, -> ;, -> ;, -> ; F, -> ;, -> Nondeterministi Finite utomt 5-5 Nondeterministi Finite utomt 5-6

Testing eptne in Forln onfusing Terminology - vl f = F.input("f.f"); vl f = - : f - F.epted; vl it = fn : f -> str -> ool Strt - F.epted f (Str.fromString ""); vl it = true : ool - F.epted f (Str.fromString ""); vl it = flse : ool F We ll use Stoughton s terminology for lssifying utomt, whih differs from Sipser s. (There s no generl greement.) Stoughton F (Finite utomton); Uses % in ple of. F (mpty-string Finite utomton) NF (Nondeterministi Finite utomton) F (eterministi Finite utomton Trnsition funtion or reltion T Stoughton $ Q x #* x Q T Stoughton $ Q x (# U ) x Q % Sipser & Q x (# U ) ' P(Q) T Stoughton $ Q x # x Q Sipser oesn t onsider this. lls this NF; Uses # for (# U ) oesn t onsider this. % Stoughton, Sipser & Q x # ' Q lls this F. Nondeterministi Finite utomt 5-7 Nondeterministi Finite utomt 5-8 Trnsition Reltions vs. Trnsition Funtions lssifition xmples: F, F, NF, or F? Stoughton uses trnsition reltion to speify F trnsitions: T Stoughton $ Q x #* x Q egin stte string end stte Sipser uses trnsition funtion to speify NF trnsitions: % Sipser & Q x (# U {}) ' P(Q) stte symol or empty string set of sttes F G H T Stoughton = { (R,, R), (R,, S), (S,, R), (S,, R),} R, S % Sipser = { ((R, ), {R}), ((R, ), {}) ((R, ), {R,S}), ((S, ), {R,S}), ((S, ), {R}), ((S, ), {}) } euse reltions re esier to mnipulte (e.g, ompose, invert), we ll use Stoughton s reltions rther thn Sipser s funtions for Fs. I J K L, M N O,, P Nondeterministi Finite utomt 5-9 Nondeterministi Finite utomt 5-2

onverting etween utomt in Forln F.injToF: ef -> f NF.injToF: nf -> ef F.injToNF: df -> nf F F NF F ftof: f -> ef eftonf: ef -> nf nftof: nf -> df Forln lso provides: F.injToF: df -> f Next leture we ll study how the red onversions work We n esily define: vl ftof = nftof o eftonf o ftof Other Forln F Opertions - vl renmesttes : f * sym_rel -> f - vl renmesttesnonilly : f -> f - vl isomorphism : f * f * sym_rel -> ool (* s for F *) - vl findisomorphism : f * f -> sym_rel - vl isomorphi : f * f -> ool - vl simplify : f -> f (* remove ded nd unrehle sttes* ) - vl union : f * f -> f (* union of two Fs *) - vl ont : f * f -> f (* ontention of two Fs *) - vl losure : f -> f (* Kleene str of n F *) - vl rev : f -> f (* Reversl of n F (PS6) *) o F does not provide omplement nd intersetion These re defined only for the F module. o ut F does provide the union opertor missing for F. Nondeterministi Finite utomt 5-2 Nondeterministi Finite utomt 5-22 esigning Fs nd Fs in Forln zero.f one.f Given Forln files with the ove two Fs, use Forln to onstrut n F nd F for the following lnguge: ll inry strings tht either () ontin only s or (2) onsist of ny numer of s Nondeterministi Finite utomt 5-23