input tape head moves current state

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

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

Homework 3 Solutions

Worked out examples Finite Automata

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

Non-Deterministic Finite Automata

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

Let's start with an example:

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

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15-453) - Spring L. Blum

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

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

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

Chapter 2 Finite Automata

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 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.

Formal Language and Automata Theory (CS21004)

Formal Languages and Automata

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

Finite-State Automata: Recap

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

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

Deterministic Finite Automata

Fundamentals of Computer Science

Lecture 08: Feb. 08, 2019

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

Lexical Analysis Finite Automate

Harvard University Computer Science 121 Midterm October 23, 2012

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

Finite Automata-cont d

CMSC 330: Organization of Programming Languages

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

Nondeterminism and Nodeterministic Automata

CS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power

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.

Non-deterministic Finite Automata

Designing finite automata II

Some Theory of Computation Exercises Week 1

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

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

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

Today s Topics Automata and Languages

Automata and Languages

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

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

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

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

1 Nondeterministic Finite Automata

State Minimization for DFAs

First Midterm Examination

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

First Midterm Examination

CHAPTER 1 Regular Languages. Contents

CS375: Logic and Theory of Computing

FABER Formal Languages, Automata and Models of Computation

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Languages & Automata

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

Non-deterministic Finite Automata

SWEN 224 Formal Foundations of Programming WITH ANSWERS

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

Theory of Computation Regular Languages

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

Minimal DFA. minimal DFA for L starting from any other

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

3 Regular expressions

Section: Other Models of Turing Machines. Definition: Two automata are equivalent if they accept the same language.

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

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

Revision Sheet. (a) Give a regular expression for each of the following languages:

Thoery of Automata CS402

CS 330 Formal Methods and Models

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

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

Context-Free Grammars and Languages

Convert the NFA into DFA

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CSC 311 Theory of Computation

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

CSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes

TM M ... TM M. right half left half # # ...

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

Name Ima Sample ASU ID

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

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

CS375: Logic and Theory of Computing

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

1 From NFA to regular expression

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

NFAs continued, Closure Properties of Regular Languages

DFA Minimization and Applications

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

Coalgebra, Lecture 15: Equations for Deterministic Automata

CISC 4090 Theory of Computation

Transcription:

CPS 140 - Mthemticl Foundtions of CS Dr. Susn Rodger Section: Finite Automt (Ch. 2) (lecture notes) Things to do in clss tody (Jn. 13, 2004): ffl questions on homework 1 ffl finish chpter 1 ffl Red Chpter 1-2 1

Section: Finite Automt Deterministic Finite Accepter (or Automt) - DFA ADFA=(Q,±,ffi,q 0,F) input tpe tpe hed hed moves current stte 0 1 where Q is finite set of sttes ± is tpe (input) lphet (finite set) q 0 is initil stte q 0 2 Q F Q is set of finl sttes. ffi:q ±!Q ADFAisvery simple mchine with not lot of power. It cn nswer yes or no (for exmple, if 6789 is vlid integer, or SUM is vlid vrile nme in C++). It cnnot tell whether ((9+5)+) is vlid rithmetic expression. Exmple: Crete DFA tht ccepts even inry numers. BUILD IT USING JFLAP Assign mening to the sttes: - odd numers, - even numers, SHOW Lels in JFLAP Trnsition Digrm: 1 0 0 1 M=(Q,±,ffi,q 0,F) = (f;g, f0;1g, ffi,, fg) Tulr Formt 2

0 1 Exmple of move: ffi(,1)= Algorithm for DFA: Strt in strt stte with input on tpe q = current stte s = current symol on tpe while (s!= lnk) do q=ffi(q,s) s = next symol to the right on tpe if q2f then ccept Exmple of trce: 11010-26 Pictoril Exmple of trce for 100: 1) 1 0 0 2) 1 0 0 3) 1 0 0 4) 1 0 0 Definition: ffi Λ (q; ) =q You didn't go nywhere, you re still in stte q ffi Λ (q; w) =ffi(ffi Λ (q; w);) Apply Delt to ll of w first ( string) nd then to Definition The lnguge ccepted y DFA M=(Q,±,ffi,q 0,F) is set of ll strings on ± ccepted y M. Formlly, L(M)=fw 2 ± Λ j ffi Λ (q 0 ;w)2fg Drw picture: rc... some finl stte, ny pth to finl stte is string tht is ccepted. -Sy this: This is the lnguge ccepted y DFA M. ll strings formed of the lphet such tht if you strt in nd process ll the symols in w, then you end up in finl (or ccepting) stte 3

Set of strings not ccepted L(M)=fw 2 ± Λ j ffi Λ (q 0 ;w)62 F g 4

Trp Stte NOTE: Assign mening to sttes! You could drw this in JFLAP with trp stte nd note you don't hve to do this. Exmple: L(M) = f n j n>0g q2 trp, You don't need to show trp sttes! Any rc not shown will y defult go to trp stte. Exmple: Crete DFA tht ccepts even inry numers tht hve neven numer of 1's. ssign lels: - strt, -even inry numer, even no. 1's, q2 - odd numer, odd numer of 1's, q3 - odd numer, even numerof1's 0 0 0 q3 1 0 1 1 q2 1 Tlk out determinism! - only 1 choice 5

Exmple: L=fw2± Λ jw hs n even numer of 's nd n even numer of 'sg NOTE: Other exmples to mention: Exmple: Cn crete DFA for rel numers, integers, vrile nmes, etc. Definition A lnguge is regulr iff there exists DFA M s.t. L=L(M). Chpter 2.2 Nondeterministic Finite Automt (or Accepter) (NFA) Definition An NFA=(Q,±,ffi,q 0,F) where Q is finite set of sttes ± is tpe (input) lphet (finite set) q 0 is initil stte q 0 2 Q F Q is set of finl sttes. ffi:q (± [f g)!2 Q Note: the result of delt is suset of q Allows choices - from stte on, might e le to go to more thn one stte (drw picture). 6

Exmple q3 q2 Note: In this exmple ffi(q 0 ;)=fq 1 ;q 2 g. Note: ffi is no longer function. L=fg [f n j n 0g Exmple L=f() n j n>0g[f n jn>0g l l q3 q5 l q2 q4 q6 Definition q j 2 ffi Λ (q i ;w) if nd only if there is wlk from q i to q j leled w. Exmple From previous exmple: ffi Λ (q 0 ;)= fq 5 ;q 6 ;q 1 g ffi Λ (q 0 ; )= fq 3 g Definition: For n NFA M, L(M)=fw 2 ± Λ j ffi Λ (q 0 ;w) F 6=;g The lnguge ccepted y nf M is ll strings w such tht there exists wlk leled w from the strt stte to finl stte. Why nondeterminism? It mkes it esier to descrie FA. The only prolem is tht it cn tke LONG time to try out ll possiilities. 2.3 NFA vs. DFA: Which is more powerful? Exmple: 7

q2,q2,q2 NOTE: DO THIS USING JFLAP explining generlly how to do it Theorem Given n NFA M N =(Q N ; ±;ffi N ;q 0 ;F N ), then there exists DFA M D =(Q D ; ±;ffi D ;q 0 ;F D ) such tht L(M N )=L(M D ). 8

Proof: We need to define M D sed on M N. Q D =2 QN F D =fq2q D j9q i 2 Q with q i 2 F N g ffi D : Q D ±! Q D Algorithm to construct M D 1. strt stte is fq 0 g[closure(q 0 ) 2. While cn dd n edge () Choose stte A=fq i ;q j ; :::q k g with missing edge for 2 ± () Compute B = ffi Λ (q i ;)[ffi Λ (q j ;)[:::[ffi Λ (q k ;) (c) Add stte B if it doesn't exist (d) dd edge from A to B with lel 3. Identify finl sttes 4. if 2 L(M N ) then mke the strt stte finl. Exmple:,,q2 q3,q4,q5,q6 q3 q5, q4 q6 λ λ λ q3 q5 q2 q4 q6 DO THIS USING JFLAP. 9

Minimizing Numer of sttes in DFA Why? If you hve nnfa with n sttes, wht is the mximum numer of sttes in the equivlent DFA creted? 2 n Algorithm ffl Identify sttes tht re indistinguishle These sttes form new stte Definition Two sttes p nd q re indistinquishle if for ll w 2 ± Λ ffi Λ (q; w) 2 F ) ffi Λ (p; w) 2 F ffi Λ (p; w) 62 F ) ffi Λ (q; w) 62 F Definition Two sttes p nd q re distinquishle if 9 w 2 ± Λ s.t. ffi Λ (q; w) 2 F ) ffi Λ (p; w) 62 F OR ffi Λ (q; w) 62 F ) ffi Λ (p; w) 2 F p nd q pper to e different. 10

Exmple: Look t A on, Look t F on, Look t D on, This is in file rodger/cl/cps140/jflpex/chp2mindf1.jff A B C D E F G ADF ABDEFG ADEF E BG C AD BG C E F AD F Exmple: This is in file rodger/cl/cps140/jflpex/chp2mindf2.jff 11

A B C D E F G H I ABCDEFGHI ABDFHI CEG ABFHI D AB FHI CE G CE G D FHI AB 12