Finite Automata Part Three

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

Turing Machines Part One

Theory of Computation Regular Languages

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

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

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

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

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

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

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

Designing finite automata II

CS375: Logic and Theory of Computing

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

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

Harvard University Computer Science 121 Midterm October 23, 2012

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

Let's start with an example:

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.

CMSC 330: Organization of Programming Languages

Finite-State Automata: Recap

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Finite Automata-cont d

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

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

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

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

Lecture 6 Regular Grammars

Name Ima Sample ASU ID

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

1 Nondeterministic Finite Automata

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

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

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

CISC 4090 Theory of Computation

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

Some Theory of Computation Exercises Week 1

NFAs continued, Closure Properties of Regular Languages

Lecture 08: Feb. 08, 2019

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

CS 275 Automata and Formal Language Theory

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation

Convert the NFA into DFA

Non-deterministic Finite Automata

Non-deterministic Finite Automata

1.3 Regular Expressions

State Minimization for DFAs

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

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

1.4 Nonregular Languages

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

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.

Nondeterminism and Nodeterministic Automata

Deterministic Finite Automata

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

Fundamentals of Computer Science

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

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

Minimal DFA. minimal DFA for L starting from any other

Worked out examples Finite Automata

This lecture covers Chapter 8 of HMU: Properties of CFLs

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

3 Regular expressions

Non-Deterministic Finite Automata

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

Turing Machines Part One

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

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

Deterministic Finite-State Automata

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

Formal Language and Automata Theory (CS21004)

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

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

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

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

NFAs continued, Closure Properties of Regular Languages

Automata and Languages

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

Lecture 09: Myhill-Nerode Theorem

Java II Finite Automata I

Lexical Analysis Part III

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

E 1 (n) = E 0 (n-1) E 0 (n) = E 0 (n-1)+e 0 (n-2) T(n -1)=2E 0 (n-2) + E 0 (n-3)

Homework 3 Solutions

Formal Methods in Software Engineering

CSCI FOUNDATIONS OF COMPUTER SCIENCE

1 Structural induction, finite automata, regular expressions

Chapter 0. What is the Lebesgue integral about?

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

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

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Formal Languages and Automata

Formal languages, automata, and theory of computation

Introduction to ω-autamata

Today s Topics Automata and Languages

Automata and Languages

CS375: Logic and Theory of Computing

First Midterm Examination

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

practice How would you find: e x + e x e 2x e x 1 dx 1 e today: improper integrals

Transcription:

Finite Automt Prt Three

Hello Hello Wonderful Wonderful Condensed Condensed Slide Slide Reders! Reders! The The first first hlf hlf of of this this lecture lecture consists consists lmost lmost exclusively exclusively of of nimtions nimtions of of the the subset subset construction, construction, which which ren t ren t present present in in these these condensed condensed slides. slides. You You might might wnt wnt to to red red over over the the full full version version of of these these slides slides to to get get better better sense sense for for how how tht tht construction construction works. works. Hope Hope this this helps! helps! -Keith -Keith

Recp from Lst Time

Tbulr DFAs strt 1 q 0 0 1 0 q 1 q 2 q 3 0 q 3 1 Σ 0 1 *q 0 q 1 q 0 These These strs strs indicte indicte ccepting ccepting sttes. sttes. q 1 q 2 *q 3 q 3 q 3 q 3 q 3 q2 q 0

Tbulr DFAs strt 1 q 0 0 1 0 q 1 q 2 q 3 0 q 3 1 Σ 0 1 *q 0 q 1 q 0 Since Since this this is is the the first first row, row, it's it's the the strt strt stte. stte. q 1 q 2 *q 3 q 3 q 3 q 3 q 3 q2 q 0

A lnguge L is clled regulr lnguge if there exists DFA D such tht L( D) = L.

NFAs An NFA is Nondeterministic Finite Automton Cn hve missing trnsitions or multiple trnsitions defined on the sme input symbol. Accepts if ny possible series of choices leds to n ccepting stte.

ε-trnsitions NFAs hve specil type of trnsition clled the ε-trnsition. An NFA my follow ny number of ε-trnsitions t ny time without consuming ny input. strt q 0 q 1 q 2 ε q 03 ε b, ε q 4 b q 5 b b b b

Perfect Guessing We cn view nondeterministic mchines s hving Mgic Superpowers tht enble them to guess the correct choice of moves to mke. If there is t lest one choice tht leds to n ccepting stte, the mchine will guess it. If there re no choices, the mchine guesses ny one of the wrong guesses. No known physicl nlog for this style of computtion this is totlly new!

Mssive Prllelism An NFA cn be thought of s DFA tht cn be in mny sttes t once. At ech point in time, when the NFA needs to follow trnsition, it tries ll the options t the sme time. The NFA ccepts if ny of the sttes tht re ctive t the end re ccepting sttes. It rejects otherwise.

Just how powerful re NFAs?

New Stuff!

NFAs nd DFAs Any lnguge tht cn be ccepted by DFA cn be ccepted by n NFA. Why? Every DFA essentilly lredy is n NFA! Question: Cn ny lnguge ccepted by n NFA lso be ccepted by DFA? Surprisingly, the nswer is yes!

Thought Experiment: How would you simulte n NFA in softwre?

Σ strt b q₀ q₁ q₂ q₃ strt {q₀} {q₀, q₁} b {q₀} {q₀, q₁} {q₀, q₁} {q₀, q₂} {q₀, q₂} {q₀, q₁, q₃} {q₀} *{q₀, q₁, q₃} {q₀, q₁} {q₀, q₂} b {q₀} {q₀, q₁} b b {q₀, q₂} b {q₀, q₁, q₃}

Once More, With Epsilons! strt Σ q₀ ε q₃ q₂ Σ b b q₁ q₄ b *{q₀, q₃} {q₁, q₄} {q₄} *{q₁, q₄} Ø {q₂, q₃} {q₄} Ø {q₃} *{q₂, q₃} {q₀, q₃, q₄} {q₀, q₃, q₄} *{q₃} {q₄} {q₄} *{q₀, q₃, q₄} {q₁, q₄} {q₃, q₄} *{q₃, q₄} {q₄} {q₃, q₄} Ø Ø Ø

The Subset Construction This construction for trnsforming n NFA into DFA is clled the subset construction (or sometimes the powerset construction). Ech stte in the DFA is ssocited with set of sttes in the NFA. The strt stte in the DFA corresponds to the strt stte of the NFA, plus ll sttes rechble vi ε-trnsitions. If stte q in the DFA corresponds to set of sttes S in the NFA, then the trnsition from stte q on chrcter is found s follows: Let S' be the set of sttes in the NFA tht cn be reched by following trnsition lbeled from ny of the sttes in S. (This set my be empty.) Let S'' be the set of sttes in the NFA rechble from some stte in S' by following zero or more epsilon trnsitions. The stte q in the DFA trnsitions on to DFA stte corresponding to the set of sttes S''. Red Sipser for forml ccount.

The Subset Construction In converting n NFA to DFA, the DFA's sttes correspond to sets of NFA sttes. Useful fct: (S) = 2 S for ny finite set S. In the worst-cse, the construction cn result in DFA tht is exponentilly lrger thn the originl NFA. Interesting chllenge: Find lnguge for which this worst-cse behvior occurs (there re infinitely mny of them!)

A lnguge L is clled regulr lnguge if there exists DFA D such tht L( D) = L.

An Importnt Result Theorem: A lnguge L is regulr iff there is some NFA N such tht L( N) = L. Proof Sketch: If L is regulr, there exists some DFA for it, which we cn esily convert into n NFA. If L is ccepted by some NFA, we cn use the subset construction to convert it into DFA tht ccepts the sme lnguge, so L is regulr.

Why This Mtters We now hve two perspectives on regulr lnguges: Regulr lnguges re lnguges ccepted by DFAs. Regulr lnguges re lnguges ccepted by NFAs. We cn now reson bout the regulr lnguges in two different wys.

Time-Out for Announcements!

Problem Set Five PS5 is due this Fridy t the strt of clss. Need help? Stop by office hours! Ask question on Pizz! We ve relesed new Inductive Proofwriting Checklist contining some common mistkes on PS5. Tke minute or two to red through it before submitting.

Extr Prctice Problems We ve relesed four more sets of extr prctice problems (EPP4 EPP7) in cse you d like to get some extr prctice with the topics from PS3 PS5. We ll relese solutions next week.

SLAE Monthly Event SLAE (Stnford LtinA Engineers) is holding their Very First Monthly Event this Fridy from 8PM 10PM in the Centro Lounge. They re providing sncks nd Netflix.

Your Questions

Wht do you think is the idel role of technology in eduction? I I hve hve to to prefce prefce this this by by sying sying I m I m not not n n expert, expert, becuse becuse I m I m definitely definitely not. not. From From experience, experience, technology technology works works well well in in eduction eduction when when it it (1) (1) cts cts s s force force multiplier multiplier or or (2) (2) mkes mkes the the bstrct bstrct tngible. tngible. We ll We ll be be relesing relesing tools tools for for designing designing nd nd testing testing DFAs, DFAs, which which is is (1) (1) on on the the bckend bckend nd nd (2) (2) on on the the frontend. frontend. Chris Chris Piech Piech is is doing doing some some truly truly groundbreking groundbreking work work on on option option (1). (1). Khn Khn Acdemy Acdemy is is both both (1) (1) nd nd (2), (2), nd nd MooCs MooCs re re (very (very wek) wek) (1). (1). You You should should be be skepticl skepticl when when someone someone sys sys tht tht they they hve hve new new technology technology tht tht will will revolutionize revolutionize eduction. eduction. All All technology technology does does is is chnge chnge the the cost cost of of things. things. It s It s not not going going to to fix fix highly highly troubled troubled nd nd complicted complicted system system overnight. overnight.

Keith. According to the midterm, I m terrible t CS 103 but I love thinking bout computers, mchines nd this clss. How do I reconcile the love nd the grde A A single single low low exm exm score score does does not not men men tht tht you you re re terrible terrible t t this. this. It s It s single single dt dt point point sying sying how how you you did did t t specific specific point point in in time. time. Tret Tret it it s s signl signl tlking tlking bout bout where where to to focus focus your your efforts efforts nd nd improve. improve. If If you you like like thinking thinking bout bout this this stuff, stuff, tht s tht s gret! gret! Keep Keep doing doing so. so. Use Use your your curiosity curiosity to to drive drive your your explortion explortion of of these these topics. topics. Hng Hng in in there. there. You You cn cn do do this! this!

Bck to CS103!

Properties of Regulr Lnguges

The Union of Two Lnguges If L1 nd L 2 re lnguges over the lphbet Σ, the lnguge L 1 L 2 is the lnguge of ll strings in t lest one of the two lnguges. If L1 nd L 2 re regulr lnguges, is L 1 L 2?

The Union of Two Lnguges If L1 nd L 2 re lnguges over the lphbet Σ, the lnguge L 1 L 2 is the lnguge of ll strings in t lest one of the two lnguges. If L1 nd L 2 re regulr lnguges, is L 1 L 2? strt Mchine for L 1 strt Mchine for L 2

The Union of Two Lnguges If L1 nd L 2 re lnguges over the lphbet Σ, the lnguge L 1 L 2 is the lnguge of ll strings in t lest one of the two lnguges. If L1 nd L 2 re regulr lnguges, is L 1 L 2? ε Mchine for L 1 strt Mchine for L 1 L 2 ε Mchine for L 2

The Intersection of Two Lnguges If L1 nd L 2 re lnguges over Σ, then L 1 L 2 is the lnguge of strings in both L 1 nd L 2. Question: If L1 nd L 2 re regulr, is L 1 L 2 regulr s well? L 1 L 2 Hey, Hey, it's it's De De Morgn's Morgn's lws! lws!

Conctention

String Conctention If w Σ* nd x Σ*, the conctention of w nd x, denoted wx, is the string formed by tcking ll the chrcters of x onto the end of w. Exmple: if w = quo nd x = kk, the conctention wx = quokk. Anlogous to the + opertor for strings in mny progrmming lnguges. Some fcts bout conctention: The empty string ε is the identity element for conctention: Conctention is ssocitive: wε = εw = w wxy = w(xy) = (wx)y

Conctention The conctention of two lnguges L₁ nd L₂ over the lphbet Σ is the lnguge L₁L₂ = { wx Σ* w L₁ x L₂ } =Two views of L₁L₂: The set of ll strings tht cn be mde by conctenting string in L₁ with string in L₂. The set of strings tht cn be split into two pieces: piece from L₁ nd piece from L₂. Conceptully similr to the Crtesin product of two sets, only with strings.

Conctention Exmple Let Σ = {, b,, z, A, B,, Z } nd consider these lnguges over Σ: Noun = { Puppy, Rinbow, Whle, } Verb = { Hugs, Juggles, Loves, } The = { The } The lnguge TheNounVerbTheNoun is { ThePuppyHugsTheWhle, TheWhleLovesTheRinbow, TheRinbowJugglesTheRinbow, }

Conctention The conctention of two lnguges L₁ nd L₂ over the lphbet Σ is the lnguge L₁L₂ = { wx Σ* w L₁ x L₂ } Two views of L₁L₂: The set of ll strings tht cn be mde by conctenting string in L₁ with string in L₂. The set of strings tht cn be split into two pieces: piece from L₁ nd piece from L₂. Conceptully similr to the Crtesin product of two sets, only with strings.

Conctenting Regulr Lnguges If L1 nd L 2 re regulr lnguges, is L 1 L 2? Intuition cn we split string w into two strings xy such tht x L 1 nd y L 2? Ide: Run the utomton for L1 on w, nd whenever L 1 reches n ccepting stte, strt strt optionlly hnd the rest off w to L 2. If L2 ccepts the reminder, then L 1 ccepted the first prt nd the string is in L 1 L 2. Mchine for L 1 Mchine for L 2 If L2 rejects the reminder, then the split ws incorrect. b o o k k e e p e r

Conctenting Regulr Lnguges If L1 nd L 2 re regulr lnguges, is L 1 L 2? Intuition cn we split string w into two strings xy such tht x L 1 nd y L 2? Ide: Run the utomton for L1 on w, nd whenever L 1 reches n ccepting stte, optionlly hnd the rest off w to L 2. If L2 ccepts the reminder, then L 1 ccepted the first prt nd the string is in L 1 L 2. If L2 rejects the reminder, then the split ws incorrect.

Conctenting Regulr Lnguges ε strt ε ε Mchine for L 1 Mchine for L 2 Mchine for L 1 L 2

Summry NFAs re powerful type of utomton tht llows for nondeterministic choices. NFAs cn lso hve ε-trnsitions tht move from stte to stte without consuming ny input. The subset construction shows tht NFAs re not more powerful thn DFAs, becuse ny NFA cn be converted into DFA tht ccepts the sme lnguge. The union, intersection, complement, nd conctention of regulr lnguges re ll regulr lnguges.