Finite Automata. d: Q S Q. Finite automaton is M=(Q, S, d, q 0, F) Ex: an FA that accepts all odd-length strings of zeros: q 0 q 1. q i. q k.

Similar documents
FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, *

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata

Last time: introduced our first computational model the DFA.

DFA (Deterministic Finite Automata) q a

Winter 2016 COMP-250: Introduction to Computer Science. Lecture 23, April 5, 2016

Notes on Finite Automata Department of Computer Science Professor Goldberg Textbooks: Introduction to the Theory of Computation by Michael Sipser

INTEGRALS. Chapter 7. d dx. 7.1 Overview Let d dx F (x) = f (x). Then, we write f ( x)

Formal Languages: Review

The Course covers: Lexical Analysis Syntax Analysis Semantic Analysis Runtime environments Code Generation Code Optimization. CS 540 Spring 2013 GMU 2

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

COMP108 Algorithmic Foundations

Section 3: Antiderivatives of Formulas

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

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

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

Lecture 08: Feb. 08, 2019

Minimum Spanning Trees

CS 6353 Compiler Construction, Homework #1. 1. Write regular expressions for the following informally described languages:

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

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

Minimal DFA. minimal DFA for L starting from any other

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

1 Nondeterministic Finite Automata

Nondeterminism and Nodeterministic Automata

Convert the NFA into DFA

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

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

Instructions for Section 1

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals

Formal Languages. S ={a,b} ababbaab L={a,aa,aaa, } aba =3 "w w e = e w = w ab ba=abba {1,2} {a,b, } ={1a,2a,1b,2b, } a 3 =aaa {0,1} 32

CHAPTER 1 Regular Languages. Contents

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

Lecture 4: Lexical and Syntax Analysis

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

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

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

Propositional Logic. Combinatorial Problem Solving (CPS) Albert Oliveras Enric Rodríguez-Carbonell. May 17, 2018

CS 361 Meeting 12 10/3/18

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

Theory of Computation Regular Languages

1 Introduction to Modulo 7 Arithmetic

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph

CISC 4090 Theory of Computation

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

Formal Languages and Automata

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

Designing finite automata II

Garnir Polynomial and their Properties

First Midterm Examination

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V

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

Outline. Circuits. Euler paths/circuits 4/25/12. Part 10. Graphs. Euler s bridge problem (Bridges of Konigsberg Problem)

TOPIC 5: INTEGRATION

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

Finite Automata-cont d

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

Non-Deterministic Finite Automata

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

Multi-Section Coupled Line Couplers

Ch 1.2: Solutions of Some Differential Equations

Non-deterministic Finite Automata

Why the Junction Tree Algorithm? The Junction Tree Algorithm. Clique Potential Representation. Overview. Chris Williams 1.

Java II Finite Automata I

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2

Non-deterministic Finite Automata

COMPLEXITY OF COUNTING PLANAR TILINGS BY TWO BARS

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

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

Finite-State Automata: Recap

CMSC 330: Organization of Programming Languages

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

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

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

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths.

Lecture 11 Waves in Periodic Potentials Today: Questions you should be able to address after today s lecture:

1 Finite Automata and Regular Expressions

Nondeterministic Automata vs Deterministic Automata

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

Lexical Analysis Finite Automate

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

CS375: Logic and Theory of Computing

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

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013

Walk Like a Mathematician Learning Task:

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

Lecture 9: LTL and Büchi Automata

Fundamentals of Computer Science

Homework 3 Solutions

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued...

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Deterministic Finite Automata

State Minimization for DFAs

Some Theory of Computation Exercises Week 1

Myhill-Nerode Theorem

Transcription:

Finit Automt Bsic id: FA is mchin tht chngs stts whil procssing symols, on t tim. Finit st of stts: Q = {q 0, q 1, q 3,..., q k } Trnsition function: Initil stt: Finl stts: d: Q S Q q 0 Q F Q Finit utomton is M=(Q, S, d, q 0, F) q 1 q i q 0 q k q j Ex: n FA tht ccpts ll odd-lngth strings of zros: 0 q 0 q 1 M=({q 0,q 1 }, {0}, {((q 0,0),q 1 ), ((q 1,0),q 0 )}, q 0, {q 1 }) 0

Finit Automt FA oprtion: consum string w S * on symol t tim whil chnging stts Accptnc: nd up in finl stt Rjction: nything ls (including hng-up / crsh) Ex: FA tht ccpts ll strings of form = () * M M=({q 0,q 1 }, {,}, {((q 0,),q 1 ), ((q 1,),q 0 )}, q 0, {q 0 }) q 0 q 2 q 1 But M crshs on input string! Solution: dd dd-nd stt to fully spcify M M, M =({q 0,q 1,q 2 }, {,}, {((q 0,),q 1 ), ((q 1,),q 0 ), ((q 0,),q 2 ), ((q 1,),q 2 ). ((q 2,),q 2 ), ((q 2,),q 2 ) }, q 0, {q 0 })

Finit Automt Trnsition function d xtnds from symols to strings: d:q S* Q d(q 0,wx) = d(d(q 0,w),x) whr d(q i,) = q i Lngug of M is L(M)={w S* d(q 0,w) F} Dfinition: A lngug is rgulr iff it is ccptd y som FA. L is rgulr iff thr is FA M whr L(M)=L Equivlntly: A lngug is rgulr iff it cn dscrid y rgulr xprssion (proof nxt tim)

Giv Rgulr Exprssion for th following lngugs ovr Σ={,} 1. L={w w dos not contin th lttr } 2. L={w w is odd} + + + 3. L={w w hs n odd numr of s followd y n vn numr of s}

Giv FA for th following lngugs ovr Σ={,} 1. L={w w dos not contin th lttr } 2. L={w w is odd} vn s,, s odd, ( s, s, Σ, { s,, s, s,, s, ( s,, s), ( s,, s)}, s, { s}) ( vn, odd, Σ, { vn,, odd, vn,, odd, ( odd,, vn), ( odd,, vn)}, vn, {odd}) 3. L={w w hs n odd numr of s thn n vn numr of s}, E s fil O s O s E s

Closur proprtis of Rgulr Lngugs An oprtion prsrvs rgulrity if: Givn ll input lngugs r rgulr Th output lngug must rgulr Th rgulr lngugs r closd undr: Union:L 1 + L 2 or L 1 L 2 Conctntion: L 1 L 2 or L 1 L 2 Kln closur: L Rvrsl: L R = w w R L} Complmnt: L or L c Intrsction: L 1 L 2 Sutrction: L 1 L 2 Among mny othr things (s prolm sts)

Prolm: dsign DFA tht ccpts ll strings ovr {,} whr ny s prcd ny s. Id: skip ovr ny contiguous s, thn skip ovr ny s, nd thn ccpt iff th nd is rchd., q 0 q 1 q 2 L = ** Q: Wht is th complmnt of L?

Prolm: wht is th complmnt of L = **? Id: writ rgulr xprssion nd thn simplify. L = (+)* + (+)* + (+)* = (+)*(+)*(+)* = (+)* + (+)* = (+)*(+)* = * + (+)*, q 0 q 1 q 2

Thorm: Complmnt Prsrvrs Rgulrity. Proof: Givn FSA for lngug L (cll it M), construct FSA for th lngug L (cll it M ). From th mchin M to uild M convrt vry finl stt to non-finl stt, vry non-finl stt to finl stt. L={w w is odd} L ={w w is vn} vn,, odd vn,, odd M = ( vn, odd, Σ, { vn,, odd, vn,, odd, ( odd,, vn), ( odd,, vn)}, vn, {odd}) M = ( vn, odd, Σ, { vn,, odd, vn,, odd, ( odd,, vn), ( odd,, vn)}, vn, {vn}) M = Q, Σ, δ, q 0, F M = (Q, Σ, δ, q 0, F)

Thorm: Union Prsrvrs Rgulrity. Proof: Cross Product Construction Simult oth mchins in prlll Lt ch stt in th nw mchin pir of stts. Trnsitions occur s if ch mchin rn individully. Accpt if ndd in finl stt for ithr mchin. To union rgulr lngugs L 1 nd L 2 : (FSA M 1 = Q 1, Σ, δ 1, q 1, F 1, M 2 = Q 2, Σ, δ 2, q 2, F 2 rspctivly) M 1 2 = Q 1 Q 2, Σ, δ 1 2, q 1, q 2, F 1 2 Whr: s s, {w w dos not contin th lttr } vn,, odd {w w is odd} δ 1 2 q i, q j, σ = δ 1 q i, σ, δ 2 q j, σ, F 1 2 = {(q i, q j ) q i F 1 q j F 2 } E O E, O, {w w is odd or contins no s}

Thorm: Intrsction Prsrvrs Rgulrity. Proof: L 1 L 2 = L 1 L 2 To intrsct rgulr lngugs L 1 nd L 2 : (FSA M 1 = Q 1, Σ, δ 1, q 1, F 1, M 2 = Q 2, Σ, δ 2, q 2, F 2 rspctivly) M 1 2 = Q 1 Q 2, Σ, δ 1 2, q 1, q 2, F 1 2 Whr: Cross Product Construction! δ 1 2 q i, q j, σ = δ 1 q i, σ, δ 2 q j, σ, F 1 2 = {(q i, q j ) q i F 1 q j F 2 }

Thorm: Sutrction Prsrvrs Rgulrity. Proof: L 1 L 2 = L 1 L 2 To sutrct rgulr lngug L 2 from L 1 : (FSA M 1 = Q 1, Σ, δ 1, q 1, F 1, M 2 = Q 2, Σ, δ 2, q 2, F 2 rspctivly) M 1 2 = Q 1 Q 2, Σ, δ 1 2, q 1, q 2, F 1 2 Whr: Cross Product Construction! δ 1 2 q i, q j, σ = δ 1 q i, σ, δ 2 q j, σ, F 1 2 = {(q i, q j ) q i F 1 q j F 2 }

Prolm:?

Finit Automt Non-dtrminism: gnrlizs dtrminism, whr mny nxt movs r llowd t ch stp: Old Nw d:q S Q d:2 Q S 2 Q Computtion coms tr. Accptnc: $ pth from root (strt stt) to som lf ( finl stt) Ex: non-dtrministiclly ccpt ll strings whr th 7 th symol for th nd is :,,,,,, q 0 q 1 q 2 q 3 q 4 q 5 q 6 q 7, Input: Accpt!

Finit Automt Thorm: Non-dtrminism in FAs dosn t incrs powr. Proof: y simultion: Construct ll supr-stts, on pr ch stt sust. Nw supr-trnsition function jumps mong supr-stts, simulting old trnsition function Initil supr stt r thos contining old initil stt. Finl supr stts r thos contining old finl stts. Rsulting DFA ccpts th sm lngug s originl NFA, ut cn hv xponntilly mor stts.

Finit Automt Not: Powrst construction gnrlizs th cross-product construction. Mor gnrl constructions r possil. EC: Lt HALF(L)={v $ v,w S * ' v = w nd vw L} Show tht HALF prsrvs rgulrity. A two wy FA cn mov its hd ckwrds on th input: d:q S Q {lft,right} EC: Show tht two-wy FA r not mor powrful thn ordinry on-wy FA. -trnsitions: q i q j q i q j On supr-stt! Thorm: -trnsitions don t incrs FA rcognition powr. Proof: Simult -trnsitions FA without using -trnsitions. i.., considr -trnsitions to form of non-dtrminism.

Th movi Nxt (2007) Bsd on th scinc fiction story Th Goldn Mn y Philip Dick Prmis: mn with th supr powr of non-dtrminism! At ny givn momnt his rlity rnchs into multipl dirctions, nd h cn choos th rnch tht h prfrs! Trnsition function!

Top-10 Rsons to Study Non-dtrminism 1. Hlps us undrstnd th uiquitous concpt of prlllism / concurrncy; 2. Illumints th structur of prolms; 3. Cn hlp sv tim & ffort y solving intrctl prolms mor fficintly; 4. Enls vst, dp, nd gnrl studis of compltnss thoris; 5. Hlps xplin why vrifying proofs & solutions sms to sir thn constructing thm;

Why Study Non-dtrminism? 6. Gv ris to nw nd novl mthmticl pprochs, proofs, nd nlyss; 7. Roustly dcoupls / strcts complxity from undrlying computtionl modls; 8. Givs disciplind tchniqus for idntifying hrdst prolms / lngugs; 9. Forgd nw unifictions twn computr scinc, mth & logic; 10. Non-dtrminism is intrsting fun, nd cool!

Rgulr Exprssions Rgulr xprssions r dfind rcursivly s follows: Ø mpty st q 0 {} trivil lngug {x} " x S singlton lngug q 0 q 0 x q 1 Inductivly, if R nd S r rgulr xprssions, thn so r: (R+S) union M 1 RS conctntion M 2 M 2 M 1 Compositions! R * Kln closur Exmpls: (+) * (+) * (+) * (+) * Thorm: Any rgulr xprssion is ccptd y som FA. M

Rgulr Exprssions A FA for rgulr xprssions cn uilt y composition: Ex: ll strings ovr S={,} whr $ prcding n (+) * (+) * (+) * = (+) * (+) * Why? Rmov prvious strt/finl stts

FA Minimiztion Id: Equivlnt stts cn mrgd:,,,,,,

FA Minimiztion Thorm [Hopcroft 1971]: th numr N of stts in FA cn minimizd within tim O(N log N). Bsd on rlir work [Huffmn 1954] & [Moor 1956]. Conjctur: Minimizing th numr of stts in nondtrministic FA cn not don in polynomil tim. Thorm: Minimizing th numr of stts in pushdown utomton (or TM) is undcidl. Projct id: implmnt finit utomton minimiztion tool. Try to dsign it to run rsonly fficintly. Considr lso including: A rgulr-xprssion-to-fa trnsformr, A non-dtrministic-to-dtrministic FA convrtr.

FAs nd Rgulr Exprssions Thorm: Any FA ccpts lngug dnotd y som RE. Proof: Us gnrlizd finit utomt whr trnsition cn rgulr xprssion (not just symol), nd: Only 1 supr strt stt nd 1 (sprt) supr finl stt. Ech stt hs trnsitions to ll othr stts (including itslf), xcpt th supr strt stt, with no incoming trnsitions, nd th supr finl stt, which hs no outgoing trnsitions. M M Ø Ø Ø Ø Ø M Ø Ø Ø Ø Originl FA M Gnrlizd FA (GFA) M

FAs nd Rgulr Exprssions Now rduc th siz of th GFA y on stt t ch stp. A trnsformtion stp is s follows: q i P q j q i P q j q i P + RS * T q j R S q T RS * T Such trnsformtion stp is lwys possil, until th GFA hs only two stts, th supr-strt nd supr-finl stts: M P Ll of lst rmining trnsition is th rgulr xprssion corrsponding to th lngug of th originl FA! Corollry: FAs nd REs dnot th sm clss of lngugs.

R+S = S+R R(ST) = (RS)T Rgulr Exprssions Idntitis R(S+T) = RS+RT (R+S)T = RT+ST Ø * = * = R+Ø = Ø+R = R R = R = R (R * ) * = R * ( + R) * = R * (R * S * ) * = (R+S) * R+ R RØ R

Dcidl Finit Automt Prolms Df: A prolm is dcidl if $ n lgorithm which cn dtrmin (in finit tim) th corrct nswr for ny instnc. Givn finit utomt M 1 nd M 2 : Q 1 : Is L(M 1 ) = Ø? Hint: grph rchility Q 2 : Is L(M 2 ) infinit? Hint: cycl dtction Q 3 : Is L(M 1 ) = L(M 2 )? Hint: considr L 1 -L 2 nd L 2 -L 1 M M $? $? S * -{} Ø Ø

Giv FA nd rgulr xprssion for th following lngug ovr th Ssm Strt Alpht: L = {w w stisfis i for xcpt ftr c } This mns w wnt ny string whr n i dos not immditly succd n, unlss w s c, in which cs n my not succd n i. Accptd words: liv, firc, rcipt Rjctd words: siz, thir, scinc

L = {w w stisfis i for xcpt ftr c } Σ {c, } sf c c c i c ci i c fil ( Σ c, + Σ c, i, + c + Σ c, i + c + i Σ, c + ε ) + + c + + c + i + ε Σ