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

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

Last time: introduced our first computational model the DFA.

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

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.

DFA (Deterministic Finite Automata) q a

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

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

Minimum Spanning Trees

Non-Deterministic Finite Automata

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

1 Nondeterministic Finite Automata

Lecture 08: Feb. 08, 2019

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

Formal Languages and Automata

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

1 Finite Automata and Regular Expressions

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

Non-deterministic Finite Automata

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

Lecture 09: Myhill-Nerode Theorem

1 Introduction to Modulo 7 Arithmetic

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

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

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

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

Present state Next state Q + M N

Instructions for Section 1

The Equitable Dominating Graph

TOPIC 5: INTEGRATION

Lecture 4: Lexical and Syntax Analysis

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Ch 1.2: Solutions of Some Differential Equations

Theory of Computation Regular Languages

Worked out examples Finite Automata

Minimal DFA. minimal DFA for L starting from any other

Basic Polyhedral theory

CHAPTER 1 Regular Languages. Contents

Lecture 6 Regular Grammars

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

Harvard University Computer Science 121 Midterm October 23, 2012

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

Most Complex Regular Ideal Languages

Non-deterministic Finite Automata

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

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

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

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

Convert the NFA into DFA

Let's start with an example:

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

Chapter 2 Finite Automata

Finite Automata-cont d

cycle that does not cross any edges (including its own), then it has at least

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

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

Deterministic Finite Automata

State Minimization for DFAs

Multi-Section Coupled Line Couplers

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

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

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

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

Walk Like a Mathematician Learning Task:

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

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

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

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

CIVL 8/ D Boundary Value Problems - Rectangular Elements 1/7

Nondeterminism and Nodeterministic Automata

Chapter 16. 1) is a particular point on the graph of the function. 1. y, where x y 1

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

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

Section 3: Antiderivatives of Formulas

Week 3: Connected Subgraphs

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.

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

0.1. Exercise 1: the distances between four points in a graph

CS 314 Principles of Programming Languages

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

Enforcement of Opacity Security Properties Using Insertion Functions

11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?

NON-DETERMINISTIC FSA

Finite-State Automata: Recap

CSI35 Chapter 11 Review

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

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

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

CISC 4090 Theory of Computation

Closure Properties of Regular Languages

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA.

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Formal languages, automata, and theory of computation

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

5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata

Fundamentals of Computer Science

Regular languages refresher

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

COMP108 Algorithmic Foundations

Transcription:

CmSc 365 Thory of Computtion Finit Stt Automt nd Rgulr Exprssions (Chptr 2, Sction 2.3) ALPHABET oprtions: U, conctntion, * otin otin Strings Form Rgulr xprssions dscri Closd undr U, conctntion nd * (if nd r rg. xpr., thn U, nd * r rg. xpr.) Sts of strings Sts of strings (sust of ) By dfinition By dfinition Lngugs Rgulr lngugs (sust of) Closd undr, conctntion nd * (if L1 nd L2 r rg. lngugs., thn L1 U L2, L1L2 nd L1* r rg. lng.) THEOREM: Rgulr lngug IFF ccptd y som FSA lngugs Closd undr, conctntion nd * FSA rcogniz (ccpt) Strings ovr n lpht If L1 nd L2 r ccptd y som FSA, thn L1 L2, L1L2 nd L1* r ccptd y som FSA 1

Thorm : Th clss of lngugs ccptd y finit utomt is closd undr. union. conctntion c. Kln str d. complmnttion. intrsction Proof. union Lt M1 = (K1,, 1, s1, F1), M2 = (K2,, 2, s2, F2), W construct non-dtrministic utomton M = (K,,, s, F), whr K = K1 K2 {s} F = F1 F2 = 1 2 { (s,, s1), (s,, s2)} W introduc nw strt stt s, nd M gusss whthr th input is for M1 or M2. Formlly, if w є * thn (s,w) * M (q, ) for som q є F iff ithr (s1, w) * M1 (q, ) for som q є F1 or (s2, w) * M2 (q, ) for som q є F2 Hnc M ccpts w iff M1 ccpts w or M2 ccpts w, thus L(M) = L(M1) L(M2). conctntion W will construct n utomton M tht ccpts L(M) = L(M1) L(M2) Lt M1 = (K1,, 1, s1, F1), M2 = (K2,, 2, s2, F2), W construct non-dtrministic utomton M = (K,,, s, F), whr K = K1 K2 s = s1 F = F2 = 1 2 { (q,, s2) q є F 1} Hr th id is th connct ll finl stts of M1 with mpty links to th strt stt of M2. 2

Formlly, if w є * thn (s,w) * M (q, ) for som q є F iff w = uv, nd (s1, u) * M1 (q, ) for som q є F1, i.. u є L(M1) (s2, v) * M2 (q, ) for som q є F2, i.. v є L(M2) Hnc M ccpts w iff M1 ccpts prt of w nd thn M2 ccpts th rmining prt thus L(M) = L(M1) L(M2) c. Kln str Lt M1 = (K1,, 1, s1, F1), ccpting L(M1) W construct M tht ccpts L(M) = L(M1)* in th following wy: M = (K,,, s, F), whr K = K1 {s} F = F1 {s} = 1 {(s,, s1)} { (q,, s1) q є F 1} Th id hr is to hv nw strt stt connctd to s1 with n mpty link, so tht M ccpts th mpty string, nd to hv -trnsitions from ll finl stts of M1 to s1, so tht onc string hs n rd, th computtion cn rsum from th initil stt. d. complmnttion Lt M = (K,, δ, s, F), ccpting L(M). Th complmnt of L(M) is * - L(M). It is ccptd y dtrministic FSA constructd in th following wy: M = (K,, δ, s, K F) M is idnticl to M xcpt tht th finl nd non-finl stts r intrchngd. Thus string tht is ccptd y M will not ccptd y M nd vic vrs.. intrsction Hr w pply th qulity L1 L2 = * - (( * - L1) ( * - L2)) 3

Th closdnss undr intrsction follows from th closdnss undr union nd complmnttion. How to construct M (w considr dtrministic complt utomt): Lt M1 = (K1,, 1, s1, F1), M2 = (K2,, 2, s2, F2), W construct dtrministic utomton M = (K,,, s, F), whr K = K1 x K2 s = (s1,s2) F = {(q, p) q є F 1, p є F 2 } = { (q1, p1),, (q2,p2)) (q1,, q2) є 1,(p1,,p2) є 2 } Lt M1 nd M2 r ccpting L(M1) nd L(M2) rspctivly. Th nw utomton M hs to ccpt strings { w w L(M1) L(M2)}, i.. oth M1 nd M2 on w hv to stop in finl stts. How to construct FSA Rul 1: An FSA tht ccpts string of on lttr: Whn pplying Rul 2, Rul 3, nd Rul 4 low, ssum tht n FSA hs on finl stt only. If thr r mor finl stts, w cn rplc thm y intrnl stts nd link thm to nw finl stt y th mpty string. Rul 2: Squntil linking of two FSAs W link th finl stt of th first FSA with th strting stt of th scond FSA y n mpty link. Th finl stt of th first FSA is not finl stt in th nw FSA. Th strting stt of th scond FSA is not nymor strting stt in th nw FSA. Thus w otin nw FSA. If th first FSA ccpts L1 nd th scond FSA ccpts L2, thn th nw FSA will ccpt L1L2 Rul 3: Prlll linking of two FSAs. Introduc nw strting stt. 4

. Link th nw strting stt with th strting stts of ch FSA y n mpty link (th strting stts of th two FSAs r no mor strting stts) c. Introduc nw finl stt d. Link th finl stts of ch FSA to th nw finl stt y n mpty link. Th finl stts of th two FSAs r no mor finl stts. If th first FSA ccpts L1 nd th scond FSA ccpts L2, th nw FSA will ccpt L1 L2 Rul 4: Kln str on FSA. Givn n FSA tht ccpts th lngug L, how do w uild n FSA ht ccpts L*? W link its strting stt to its finl stt y n mpty link, nd its finl stt to its strting stt y n mpty link. Rul 5: Complmnttion Hr w simpl intrchng th finl nd th non-finl stts Rul 6: Intrsction S prt ) in th thorm ov. Exmpl 1: Build n FSA tht ccpts ( U *)* 1. W uild n FSA tht ccpts '' - FSA1 (Rul 1) 2. W uild n FSA tht ccpts '' - FSA2 (Rul 1) 3. W link ths two FSA squntilly - FSA3 (Rul 2) 5

Hr w cn simplify th FSA: 4. Nxt w uild n FSA tht ccpts (sm s in 2.) - FSA4 (Rul 1) 5. Th FSA tht ccpts * will FSA5 (Rul 4) 6. Now w link in prlll FSA3 nd FSA5. Th nw FSA is FSA6 (Rul 3) 6

7 7. Lst w uild FSA7 = FSA6* (Rul 4) Exmpl 2: Construct utomton tht ccpts L1 L2, whr L1 = {w * w contins vn numr of s} L2 = {w * w contins odd numr of s}

Lt M1 ccpt L1, nd M2 ccpt L2. W will dscri M1 nd M2 y trnsition tls: M1: K1 = {q1, q2} S1 = q1 F1 = {q1} q1 q2 q1 q2 q1 q2 M2: K2 = {p1, p2} S2= p1 F2 = {p2} p1 p1 p2 p2 p2 p1 Th nw utomton M will hv th following stts: K = {(q1, p1), (q1, p2), (q2, p1), (q2, p2)} S = (q1, p1) F = {(q1, p2)} Th trnsition tl is: (q1, p1) ( q2, p1) (q1, p2) (q1, p2) ( q2, p2) (q1, p1) (q2, p1) ( q1, p1) (q2, p2) (q2, p2) ( q1, p2) (q2, p1) W will show now tht th string is ccptd, whil th strings nd will not ccptd 8

((q1, p1), ) ((q2, p1), ) ((q1, p1), ) ((q1, p2), ) ((q2, p2), ) ((q1, p2), ) ((q1, p1), ) ((q1, p2), ) (q1, p2) is finl stt in M, so th string is ccptd ((q1, p1), ) ((q2, p1), ) ((q1, p1), ) ((q1, p2), ) ((q1, p1), ) (q1,p1) is not finl stt, so is not ccptd ((q1, p1), ) ((q2, p1), ) ((q2, p2), ) ((q2, p1), ) ((q2, p2), ) (q2, p2) is not finl stt, so is not ccptd 9