Deterministic Finite Automata

Similar documents
Non-deterministic Finite Automata

Non-deterministic Finite Automata

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

Let's start with an example:

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

Lecture 08: Feb. 08, 2019

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

Worked out examples Finite Automata

CHAPTER 1 Regular Languages. Contents

Finite Automata-cont d

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

NFAs continued, Closure Properties of Regular Languages

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

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

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

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

Nondeterminism and Nodeterministic Automata

Theory of Computation Regular Languages

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

1 Nondeterministic Finite Automata

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

Homework 3 Solutions

Finite-State Automata: Recap

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Non-Deterministic Finite Automata

Fundamentals of Computer Science

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

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.

Minimal DFA. minimal DFA for L starting from any other

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

Formal Language and Automata Theory (CS21004)

Java II Finite Automata I

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

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

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

Some Theory of Computation Exercises Week 1

CSC 311 Theory of Computation

CS375: Logic and Theory of Computing

Designing finite automata II

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

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

Lexical Analysis Finite Automate

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

Languages & Automata

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

CMSC 330: Organization of Programming Languages

Lecture 09: Myhill-Nerode Theorem

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

CISC 4090 Theory of Computation

Thoery of Automata CS402

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.

Closure Properties of Regular Languages

NFAs continued, Closure Properties of Regular Languages

Lecture 6 Regular Grammars

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

Chapter 2 Finite Automata

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

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

3 Regular expressions

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

Formal Languages and Automata

Lexical Analysis Part III

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

First Midterm Examination

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Regular languages refresher

Convert the NFA into DFA

Harvard University Computer Science 121 Midterm October 23, 2012

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

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

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

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

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

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

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

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

Formal Methods in Software Engineering

1 From NFA to regular expression

CS375: Logic and Theory of Computing

Coalgebra, Lecture 15: Equations for Deterministic Automata

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

Scanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:

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

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

Hybrid Control and Switched Systems. Lecture #2 How to describe a hybrid system? Formal models for hybrid system

CS 275 Automata and Formal Language Theory

Deterministic Finite-State Automata

First Midterm Examination

State Minimization for DFAs

input tape head moves current state

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

CS 330 Formal Methods and Models

FABER Formal Languages, Automata and Models of Computation

Transcription:

Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21

Outline Finite Automt Finite Automt J. Rot Version: fll 2016 Tlen en Automten 2 / 21

Finite Automt Regulr lnguges Definition L A is regulr if L = L(e) for some regulr expression e. Decidility Prolems Q1 Cn we decide (lgorithmiclly) if w L(e)? Q2 If yes, wht is the complexity of this decision procedure? Q3 Cn we decide if L(e 1 ) = L(e 2 )? Some nswers A1 Yes, we cn give deterministic finite utomton for e to decide w L(e). (This lecture) A2 time is liner in w ; memory is constnt (independent of w). A3 Yes: vi utomt constructions or vi eutions, see Exercise 2.3.6 of the course notes. J. Rot Version: fll 2016 Tlen en Automten 4 / 21

Finite Automt Deterministic Finite Automton (DFA) Intuition. Let A = {, }. Consider the DFA M: strt 0 1 2, Letters, re the moves in the grph Words w A give seuences of moves Strt stte is indicted y strt, Accepting/finl sttes y doule circle (there cn e severl ccepting sttes) The word is ccepted, ut is not ccepted (rejected) J. Rot Version: fll 2016 Tlen en Automten 5 / 21

Finite Automt Deterministic Finite Automton (DFA), strt 0 1 2 M = (Q, 0, δ, F ) with Q = { 0, 1, 2 }, F = { 2 } nd δ given y δ 0 0 1 1 0 2 2 2 2 J. Rot Version: fll 2016 Tlen en Automten 6 / 21

Finite Automt Deterministic Finite Automt formlly M is DFA over A if M = (Q, 0, δ, F ) with A is finite lphet Q is finite set of sttes 0 Q is the initil stte F Q is finite set of finl sttes δ : Q A Q is the trnsition function The multi-step trnsition δ : Q A Q is defined inductively y δ (, λ) = δ (, w) = δ (δ(, ), w) The lnguge ccepted y M, nottion L(M), is: L(M) = {w A δ ( 0, w) F } J. Rot Version: fll 2016 Tlen en Automten 7 / 21

Finite Automt Reding words w A Computtion for δ ( 0, w) in the exmple DFA. strt 0 1 2 Tke w = :, δ ( 0, ) = δ (δ( 0, ), ) = δ ( 0, ) = δ (δ( 0, ), ) = δ ( 1, ) = δ (δ( 1, ), ) = δ ( 2, ) = δ (δ( 2, ), λ) = δ ( 2, λ) = 2 So is ccepted. J. Rot Version: fll 2016 Tlen en Automten 8 / 21

Finite Automt Reding words w A Computtion for δ ( 0, w) in the exmple DFA. strt 0 1 2 Tke w = :, δ ( 0, ) = δ (δ( 0, ), ) = δ ( 0, ) = δ (δ( 0, ), ) = δ ( 1, ) = δ (δ( 1, ), λ) = δ ( 0, λ) = 0 So is not ccepted. The (regulr) lnguge ccepted y M (of the first slide) is: L(( + ) ( + ) ). J. Rot Version: fll 2016 Tlen en Automten 9 / 21

Finite Automt From trnsition tle to stte digrm Consider the utomton M over A = {, } with Q = {0, 1, 2, 3, 4}, 0 = 0, F = {4} δ 0 1 0 1 1 2 2 1 3 3 4 0 4 4 4 1 Which of the following words is ccepted?,, 2 Is it the cse tht {w w is even } L(M)? 3 Is it the cse tht {w w contins } L(M)? J. Rot Version: fll 2016 Tlen en Automten 10 / 21

Finite Automt Mnipulting Finite Automt: products for intersection M strt 0 1 L(M) L 1 = {w w is even} strt p, L 2 = {w w 1} strt 0, p 1, p 0, 1, L 1 L 2 = {w w is even nd w 1} J. Rot Version: fll 2016 Tlen en Automten 12 / 21

Finite Automt Product of two DFAs Given two DFAs over the sme A M 1 = (Q 1, 01, δ 1, F 1 ) M 2 = (Q 2, 02, δ 2, F 2 ) Define with M 1 M 2 = (Q 1 Q 2, 0, δ, F ) 0 := ( 01, 02 ) δ(( 1, 2 ), ) := (δ 1 ( 1, ), δ 2 ( 2, )) Then with F := F 1 F 2 := {( 1, 2 ) 1 F 1 nd 2 F 2 } we hve L(M 1 M 2 ) = L(M 1 ) L(M 2 ) J. Rot Version: fll 2016 Tlen en Automten 13 / 21

Finite Automt Closure Properties Proposition Closure under complement If L is ccepted y some DFA, then so is L = A L. Proof. Suppose tht L is ccepted y M = (Q, 0, δ, F ). Then L is ccepted y M = (Q, 0, δ, F ). Proposition Closure under intersection nd union If L 1, nd L 2 re ccepted y some DFA, then so re L 1 L 2 nd L 1 L 2. Proof. For the intersection, this follows from the product construction on the previous slide. For the union, this cn e seen y the product construction, tking different F (which one?) or y noticing tht L 1 L 2 = L 1 L 2. J. Rot Version: fll 2016 Tlen en Automten 14 / 21

Finite Automt Kleene s Theorem Theorem The lnguges ccepted y DFAs re exctly the regulr lnguges We will prove this in this nd the next lecture y 1 If L = L(M), for some DFA M, then there is regulr expression e such tht L = L(e) (this lecture). 2 If L = L(e), for some regulr expression e, then there is non-deterministic finite utomton (NFA) M such tht L = L(M). (next lecture). 3 For every NFA M, there is DFA M such tht L(M) = L(M ) (next lecture) J. Rot Version: fll 2016 Tlen en Automten 15 / 21

Finite Automt From DFAs to regulr expressions Given the DFA M = (Q, 0, δ, F ), we construct regulr expression e such tht Procedure: L(e) = L(M). We remove sttes, replcing symols from A y regulr expressions over A, until we end up with simple utomton from which we cn red off e. J. Rot Version: fll 2016 Tlen en Automten 17 / 21

Simple utomt Finite Automt M w e such tht L(e) = L(M) w strt 0 w 0 strt 0 u strt 0 1 x v (u + xv y) y u strt 0 1 x v u x(v + yu x) y J. Rot Version: fll 2016 Tlen en Automten 18 / 21

Finite Automt Eliminting sttes Remove stte p, while dding rrows w etween other pirs of sttes. Before: v x y p After: xv y p J. Rot Version: fll 2016 Tlen en Automten 19 / 21

Specil cses Finite Automt Join rrows using + x y x + y First crete new single finl stte 1 p 1 Bewre of loops! v x y p xv y p J. Rot Version: fll 2016 Tlen en Automten 20 / 21

Finite Automt From DFA to RegExp The lgorithm outlined in the previous slides produces for every deterministic finite utomton M, regulr expression e M. Theorem For M DFA we hve L(e M ) = L(M). J. Rot Version: fll 2016 Tlen en Automten 21 / 21