Let's start with an example:

Similar documents
Worked out examples Finite Automata

Deterministic Finite Automata

CHAPTER 1 Regular Languages. Contents

Languages & Automata

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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

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

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

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

Homework 3 Solutions

Finite-State Automata: Recap

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

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

CISC 4090 Theory of Computation

Lecture 08: Feb. 08, 2019

Theory of Computation Regular Languages

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Designing finite automata II

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

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

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

Fundamentals of Computer Science

1 Nondeterministic Finite Automata

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

CMSC 330: Organization of Programming Languages

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

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.

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

Chapter 2 Finite Automata

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

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

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

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

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

First Midterm Examination

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

CS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions

Minimal DFA. minimal DFA for L starting from any other

Deterministic Finite-State Automata

Today s Topics Automata and Languages

Automata and Languages

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.

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

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

CS 330 Formal Methods and Models

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

Finite Automata-cont d

Non-Deterministic Finite Automata

Lecture 6 Regular Grammars

Nondeterminism and Nodeterministic Automata

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

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

Some Theory of Computation Exercises Week 1

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

Harvard University Computer Science 121 Midterm October 23, 2012

CSC 311 Theory of Computation

Formal Languages and Automata

Java II Finite Automata I

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

Name Ima Sample ASU ID

3 Regular expressions

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

Lexical Analysis Part III

input tape head moves current state

1 From NFA to regular expression

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

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

CS 330 Formal Methods and Models

CS375: Logic and Theory of Computing

First Midterm Examination

State Minimization for DFAs

Thoery of Automata CS402

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

Normal Forms for Context-free Grammars

CS 330 Formal Methods and Models

Non-deterministic Finite Automata

Automata and Languages

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

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

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

SWEN 224 Formal Foundations of Programming WITH ANSWERS

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...

NFAs continued, Closure Properties of Regular Languages

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

Formal languages, automata, and theory of computation

CS 573 Automata Theory and Formal Languages

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

a b b a pop push read unread

GNFA GNFA GNFA GNFA GNFA

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.

Lexical Analysis Finite Automate

ɛ-closure, Kleene s Theorem,

Non-deterministic Finite Automata

Myhill-Nerode 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?

This lecture covers Chapter 8 of HMU: Properties of CFLs

Transcription:

Finite Automt

Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte or ccept stte (Kozen prefers "ccept"). To process string with this utomton, egin in the strt stte t the strt of the string. Wlk through the letters of the string, tking the trnsitions leled with the letters. If you re in n ccept stte t the end of the string, ccept it; otherwise reject it. S strt T U

For exmple, on string "" we go through the sttes SSTUT nd end in n ccept stte, so we ccept "". On the other hnd, with string "" we go through sttes STU nd we do not ccept. S strt T U On the other hnd, with string "" we strt in stte S, sty in S on input '', go to stte T on input '' nd then hve nowhere to go on input ''. Agin, we do not ccept the string. The only strings ccepted re those for which the utomton consumes ll of the letters in getting to n ccept stte.

The usul question for finite utomton is "Wht is the lnguge ccepted y the utomton?" S strt The lnguge ccepted y this utomton is the set of strings with ny numer of 's followed y n odd numer of 's. T U

In generl, "Deterministic Finite Automton" or DFA is quintuple (Q, S, d, s, F) where Q is finite set of sttes S is n lphet of symols d is trnsition function whose inputs re stte nd n element of S nd whose output is stte. This is represented y the rrows in our digrms. s is one of the sttes in Q. This is our strt stte. Note tht there is only one strt stte in n utomton. F is the set of ccept, or finl sttes.

This utomton processes strings in S * s follows: Let w= 0 1... n-1 e string in S *. Let q 0 e s (the strt stte), nd for i > 0 let q i = d(q i-1, i-1 ) The lst stte is q n. If q n is n element of F ccept the string w. This definition ssumes there is trnsition from every stte on every element of S. We cn mke ny utomton fit this y dding for ny missing trnsition trnsition to "ded" stte from which there is no exit. S str t T ded U,

It is useful to use the Lnguge of Regulr Expressions to descrie the strings ccepted y n utomton: 1. Any prticulr string w represents the lnguge {w} 2. If expressions E nd F represent lnguges L 1 nd L 2 then expression E+F represents L 1 L 2. 3. If expressions E nd F represent lnguges L 1 nd L 2 then expression EF represents the lnguge of strings formed y conctenting string from L 2 onto the end of string from L 1. 4. If expression E represents lnguge L then expression E * represents the lnguge of strings formed y conctenting 0 or more strings from L together. 5. If expression E represents lnguge L then expression E + represents the lnguge of strings formed y conctenting 1 or more strings from L together. E + =EE *

Exmple 1. S strt T U We sid efore tht this ccepts the lnguge of ny numer of 's followed y n odd numer of 's. This lnguge is represented y the regulr expression * () *

Exmple 2 S T U strt 1 0 1 This ccepts 10(10) * = (10) +

Exmple 3 S strt T This ccepts strings with n even numer of 's: ( * * ) *

Exmple 4: Find DFA tht ccepts 101, 11010, nd nothing else. 1 S T U V strt 1 0 0 1 0 W X Y 1 Z Note tht y imitting this exmple you could mke DFA tht ccepts ny prticulr finite lnguge.

Note tht it is esy to write progrm tht simultes DFA's ctions on string. You might hve one vrile tht represents the current stte nd for loop tht itertes through the letters of the string. For simple DFA with only few sttes you might hve ig conditionl sttement tht checks the vrious cses: if you re in stte foo with input letter r chnge the stte to z. For more generl utomton represent the trnsition function y 2D tle whose rows re indexed y the sttes nd whose columns re indexed y the lphet letters. Tle[foo][r] is the stte to trnsition to if you re in stte foo nd see input letter r.

Definition: We sy tht lnguge is regulr if it is the lnguge ccepted y some DFA. For exmples: S * is regulr for ny finite lphet S. Every finite lnguge is regulr. 10 * 1 is regulr. Strings of 0's nd 1's with n even numer of 1's is regulr.

Which of the following re regulr? For ech let the lphet e {0,1} Note tht we cn show set is regulr y producing the DFA tht ccepts it. We don't hve wy to show set isn't regulr. We will. ) Strings of length 2? yep ) Strings of even length? yep c) Strings of prime length? d) Strings with the sme numer of 0's s 1's? e) Strings with more 0's thn 1's? f) Strings tht contin 010 s sustrings? yep g) Strings with no more thn 2 0's? yep h) Strings tht re plindromes? i) Strings tht re plindromes of length 6 or less?