One Minute To Learn Programming: Finite Automata

Size: px
Start display at page:

Download "One Minute To Learn Programming: Finite Automata"

Transcription

1 Gret Theoreticl Ides In Computer Science Steven Rudich CS Spring 2005 Lecture 9 Fe Crnegie Mellon University One Minute To Lern Progrmming: Finite Automt

2 Let me tech you progrmming lnguge so simple tht you cn lern it in less thn minute.

3 Meet ABA The Automton! Input String ε Result Accept Reject Accept Accept

4 The Simplest Interesting Mchine: Finite Stte Mchine OR Finite Automton

5 Finite Automton Finite set of sttes o 1 2 A strt stte Q = { q, q, q,, q } q o k A set of ccepting sttes A finite lphet Stte trnsition instructions # qi x 1 q j { } i i i F = q, q,, q 1 2 r : Q ( q, ) = i Σ q j Q

6 How Mchine M opertes. M reds one letter t time from the input string (going from left to right) M strts in stte q 0. If M is in stte q i reds the letter then If δ(q i. ) is undefined then CRASH. Otherwise M moves to stte δ(q i,)

7 Let M=(Q,S,F,d) e finite utomton. M ccepts the string x if when M reds x it ends in n ccepting stte. M rejects the string x if when M reds x it ends in nonccepting stte. M crshes on x if M crshes while reding x.

8 The set (or lnguge) ccepted y M is: M { * } L = x M ccepts x k All length k strings over the lphet * Notice tht this is {ε}

9 Wht is the lnguge ccepted y this mchine?, L = {,}* = ll finite strings of s nd s

10 Wht is the lnguge ccepted y this mchine?,, L = ll even length strings of s nd s

11 Wht mchine ccepts this lnguge? L = ll strings in {,}* tht contin t lest one,

12 Wht mchine ccepts this lnguge? L = strings with n odd numer of s nd ny numer of s

13 Wht is the lnguge ccepted y this mchine? L = ny string ending with

14 Wht is the lnguge ccepted y this mchine?, L = ny string with t lest two s

15 Wht mchine ccepts this lnguge? L = ny string with n nd,

16 Wht mchine ccepts this lnguge? L = strings with n even numer of pirs

17 L = ll strings contining s consecutive sustring, ε Invrint: I m stte s exctly when s is the longest suffix of the input (so fr) tht forms prefix of.

18 The grep Prolem Input: text T of length t string S of length n Nïve method: Prolem: Does the string S pper inside the text T? n symols,,,, t Cost: O(nt) comprisons

19 Automt Solution Build mchine M tht ccepts ny string with S s consecutive sustring. Feed the text to M. Cost: t comprisons + time to uild M. As luck would hve it, the Knuth, Morris, Prtt lgorithm uilds M quickly. By the wy, it cn e done with fewer thn t comprisons in the worst cse!

20 Rel-life uses of finite stte mchines grep coke mchines thermostts (fridge) elevtors trin trck switches lexicl nlyzers for prsers

21 Any L Σ is defined to e lnguge. L is just set of strings. It is clled lnguge for historicl resons.

22 Let L Σ e lnguge. L is clled regulr lnguge if there is some finite utomton tht ccepts L. In this lecture we hve seen mny regulr lnguges. Σ even length strings strings contining

23 Theorem: Any finite lngge is regulr. Proof: Mke mchine with pth for ech string in the lnguge. Exmple: L = {, cd, c, } c c d

24 Are ll lnguges regulr?

25 Consider the lnguge n n = { ε,,,, } i.e., unch of s followed y n equl numer of s No finite utomton ccepts this lnguge. Cn you prove this?

26 n n is not regulr. No mchine hs enough sttes to keep trck of the numer of s it might encounter.

27 Tht is firly wek rgument. Consider the following exmple

28 L = strings where the # of occurrences of the pttern is equl to the numer of occurrences of the pttern Cn t e regulr. No mchine hs enough sttes to keep trck of the numer of occurrences of.

29 Rememer ABA? ABA ccepts only the strings with n equl numer of s nd s!

30 Let me show you professionl strength proof tht n n is not regulr.

31 Professionl Strength Proof Theorem: n n is not regulr. Proof: Assume tht it is. Then M with k sttes tht ccepts it. For ech 0 i k, let S i e the stte M is in fter reding i. i,j k s.t. S i = S j, ut i j M will do the sme thing on i i nd j i. But vlid M must reject j i nd ccept i i.

32 MORAL: Finite utomt cn t count.

33 Advertisement You cn lern much more out these cretures in the FLAC course. Forml Lnguges, Automt, nd Computtion There is unique smllest utomton for ny regulr lnguge It cn e found y fst lgorithm.

34 Cellulr Automt Line up unch of identicl finite utomt in stright line. qi q k q j Trnsitions re sed on the sttes of the mchine s two neighors or n indictor tht neighor is missing. (There is no other input.) Q Q Q Q ( q, q, q ) k i j l = q qk q, q i j ql All cells move to their Steven next Rudich: sttes t the sme time: synchronous trnsition

35 The Firing Squd Prolem Five soldiers ll strt in the stte. You chnge the one on the left to the wke stte. All five must get to the fire stte t the sme time (for the first time). wke fire wke fire wke fire wke fire wke fire wke fire wke fire wke fire wke fire wke fire

36 Shorthnd { d} Q,,, Mens use this trnsition when your left neighor is in ny stte t ll nd your right neighor is in stte,, or d.

37 {,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire!

38 {,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! wke

39 {,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! wke wke2 wke2

40 {,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! wke wke2 wke2 wke3 wke3 wke3

41 {,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! wke wke2 wke2 wke3 wke3 wke3 wke4 wke4 wke4 wke4

42 {,fire,end},q {w},q {w2},q {w3},q {w4},q wke wke2 wke3 wke4 Q,Q Q,Q Q,Q Q,Q fire! wke wke2 wke2 wke3 wke3 wke3 wke4 wke4 wke4 wke4 fire fire fire fire fire

43 Question Cn you uild the soldier s finite utomton rin efore you know how mny soldiers will e in the line? No. Finite utomt cn t count!

44 Don t jump to conclusions! It is possile to design single cellulr utomton tht works for ny numer of soldiers!

Deterministic Finite Automata. Great Theoretical Ideas in Computer Science

Deterministic Finite Automata. Great Theoretical Ideas in Computer Science 5-25 Gret Theoreticl Ides in Computer Science Let me show you mchine so simple tht you cn understnd it in less thn two minutes Deterministic Finite Automt Lecture 2 (Octoer 3, 28), The mchine ccepts string

More information

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

Anatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute Anupm Gupt Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Fll 2 Lecture 2 Oct 28, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn understnd

More information

Computation. Models of Computation. x 2. Example: memory CPU. temporary memory. temporary memory. input memory CPU.

Computation. Models of Computation. x 2. Example: memory CPU. temporary memory. temporary memory. input memory CPU. Computtion Models of Computtion CPU memory Exmple: f ( x) x temporry memory temporry memory input memory input memory CPU CPU Progrm memory output memory Progrm memory compute x x output memory compute

More information

Formal Languages and Automata Exam

Formal Languages and Automata Exam Forml Lnguges nd Automt Exm Fculty of Computers & Informtion Deprtment: Computer Science Grde: Third Course code: CSC 34 Totl Mrk: 8 Dte: 23//2 Time: 3 hours Answer the following questions: ) Consider

More information

Outline. Learning Goals: In-Class. Learning Goals: In-Class. Reminder: Formal DFA Specification I the (finite) set of letters in the input.

Outline. Learning Goals: In-Class. Learning Goals: In-Class. Reminder: Formal DFA Specification I the (finite) set of letters in the input. CPSC 121: Models of Computtion 2010 Winter Term 2 DFAs in Depth Benjmin Isrel isrel@cs.uc.c Notes hevily orrowed from Steve Wolfmn s, whose slides were sed on notes y Ptrice Belleville nd others snick

More information

Finite Automata (FAs)

Finite Automata (FAs) Finite Automt (FAs) Automt: The Generl Ide Digrms nd Lnguge Recognition Forml Nottion Nondeterministic Finite Automt Removing Nondeterminism Why FAs? Recognition : Is string x in lnguge L? Simplest wy

More information

Lecture 4 - Closure Properties, Nondeterminism

Lecture 4 - Closure Properties, Nondeterminism CSU39 Theory of Computtion Lecture 4 - Closure Properties, Nondeterminism Spring 28 Jnury 24, 28 Lecture 4 - Closure Properties, Nondeterminism Forml Definitions Theorem: The clss of regulr lnguges is

More information

Inside scanner generator

Inside scanner generator Finite Automt (FA) FA lso clled Finite Stte Mchine (FSM) Astrct model of computing entity. Decides whether to ccept or reject string. Every regulr expression cn e represented s FA nd vice vers Two types

More information

0.1 Computational Problems

0.1 Computational Problems 12 0.1 Computtionl Prolems A computtionl prolem cn e modeled so tht it cn e solved using computer; e.g. rithmetic, lexicogrphic ordering, slry ccounting, course mintennce,... A representtion of the prolem

More information

String Matching. Pattern Matching. Algorithms on Strings. Deterministic Finite Automaton. Brute-Force Algorithm. Plan:

String Matching. Pattern Matching. Algorithms on Strings. Deterministic Finite Automaton. Brute-Force Algorithm. Plan: Algorithm Design nd Anlysis Victor Admchik CS 5-45 Spring 25 Lecture 24 Apr 2, 25 Crnegie Mellon University String Mtching Pln: Knuth-Morris-Prtt Aho-Corsick Rin-Krp J.Morris D.Knuth Algorithms on Strings

More information

Non-deterministic Finite Automata

Non-deterministic Finite Automata Non-deterministic finite utomt (NFAs) Equivlence of DFAs nd NFAs Non-deterministic Finite Automt Informtics 2A: Lecture 4 Alex Simpson School of Informtics University of Edinburgh ls@inf.ed.c.uk 24 September,

More information

Homework 3 Solutions

Homework 3 Solutions CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 3 Solutions 1. Give NFAs with the specified numer of sttes recognizing ech of the following lnguges. In ll cses, the lphet is Σ = {,1}.

More information

Harvard CS 121 and CSCI E-121 Lecture 4: Nondeterministic Finite Automata and Closure Properties

Harvard CS 121 and CSCI E-121 Lecture 4: Nondeterministic Finite Automata and Closure Properties Hrvrd CS 121 nd CSCI E-121 Lecture 4: Nondeterministic Finite Automt nd Closure Properties Hrry Lewis September 11, 2014 Reding: Sipser, 1.1 nd 1.2. Exmple of n NFA N : q 0 b q 1 q 2 b q 3 N = ({q 0, q

More information

Chapter 5. Push-down Automata. By Dr Zalmiyah Zakaria

Chapter 5. Push-down Automata. By Dr Zalmiyah Zakaria Chpter 5 Push-down Automt By Dr Zlmiyh Zkri Push-Down Automt Regulr expressions re string genertors they tell us how to generte ll strings in lnguge L. Finite Automt (DFA, NFA) re string cceptors they

More information

Building Finite Automata From Regular Expressions

Building Finite Automata From Regular Expressions Building Automt From Regulr Expressions We mke n FA from regulr expression in two steps: Trnsform the regulr expression into n NFA. Trnsform the NFA into deterministic FA. The first step is esy. Regulr

More information

CSC236H: Introduction to the Theory of Computation. Assignment 3. Due on Friday December 4, 2015 before 5pm (submit PDF on Markus)

CSC236H: Introduction to the Theory of Computation. Assignment 3. Due on Friday December 4, 2015 before 5pm (submit PDF on Markus) CSC236H: Introduction to the Theory of Computtion Assignment 3 Due on Fridy Decemer 4, 25 efore 5pm (sumit PDF on Mrkus) (Solutions written y Azdeh Frzn). DFAs: Design DFA for ech of the following lnguges

More information

From Regular Expression to NFA to DFA

From Regular Expression to NFA to DFA From Regulr Expression to NF to DF It is proven (Kleene s Theorem) tht RE nd F re equivlent lnguge definition methods. Bsed on this theoreticl result prcticl lgorithms hve een developed enling us ctully

More information

CS 381 Introduction to Theory of Computing Summer 2002 Prelim 2 June 21, 2002

CS 381 Introduction to Theory of Computing Summer 2002 Prelim 2 June 21, 2002 CS 381 Introduction to Theory of Computing Summer 2002 Prelim 2 June 21, 2002 10 points per prolem. 1. For ech of the following lnguges R, find set of strings S L tht contins exctly one string from every

More information

Harvard CS 121 and CSCI E-121 Lecture 3: Finite Automata

Harvard CS 121 and CSCI E-121 Lecture 3: Finite Automata Hrvrd CS 121 nd CSCI E-121 Lecture 3: Finite Automt Hrry Lewis September 9, 2014 Reding: Sipser, 1.1 nd 1.2. Lnguges A lnguge L over lphbet Σ is set of strings over Σ (i.e. L Σ ) Computtionl problem: given

More information

CS2 Language Processing note 2 CS2Ah

CS2 Language Processing note 2 CS2Ah % / CS2 Lnguge Processing note 2 Regulr lnguges Lst lecture we reviewed finite utomt (k finite stte mchines) nd formlly defined DFAs (deterministic finite utomt) In this lecture, we will use these to define

More information

1. Give a DFA for Σ = {0, 1} and strings that have an odd number of 1 s and any number of 0 s.

1. Give a DFA for Σ = {0, 1} and strings that have an odd number of 1 s and any number of 0 s. DFAs DFA stnds for deterministic finite utomton. Bsiclly, it is directed grph where ech node hs edges coming out of it leled with the letters from fixed finite lphet Σ. One node is designted s the strt

More information

15 AUGUST 2002 SOLUTIONS

15 AUGUST 2002 SOLUTIONS CD58 AUTOMATE, BEÄKNINGA OCH FOMELLA METODE, 5 p. DFA nd egulr Expressions 5 AUGUST 22 SOLUTIONS () Build the miniml DFA tht ccepts the strings over Σ ={,} whose ll proper prefixes (i.e the prefix is not

More information

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

Finite Automata. Informatics 2A: Lecture 3. John Longley. 25 September School of Informatics University of Edinburgh Lnguges nd Automt Finite Automt Informtics 2A: Lecture 3 John Longley School of Informtics University of Edinburgh jrl@inf.ed.c.uk 25 September 2015 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is

More information

String Matching. String Matching. Naive String Matching Rabin-Karp Matcher String Matching with Finite Automata Knuth-Morris-Pratt Algorithm

String Matching. String Matching. Naive String Matching Rabin-Karp Matcher String Matching with Finite Automata Knuth-Morris-Pratt Algorithm String Mtching String Mtching Nive String Mtching Rin-Krp Mtcher String Mtching with Finite Automt Knuth-Morris-Prtt Algorithm Input is pttern P[1..m] nd text T[1..n]. Find shift s s.t. P[i] = T[s+i] for

More information

Regular Languages and Finite- State Automata. Formal Languages. Regular Expressions. 22c:19

Regular Languages and Finite- State Automata. Formal Languages. Regular Expressions. 22c:19 Regulr Lnguges nd Finite- Stte Automt 22c:19 Forml Lnguges Σ* for the set of ll words over Σ Lnguges = susets of Σ* Lnguge-forming opertions L 1 L 2, L 1 L 2 L 1* (Kleene closure) Regulr Expressions Inductive

More information

CA320 - Computability & Complexity

CA320 - Computability & Complexity Regulr Lnguges CA320 - Computility & Complexity Regulr Lnguges Dvid Sinclir Regulr Lnguges Regulr Lnguges The set of regulr lnguges R over n lphet Σ is defined s: The lnguge is n element of R. Σ, the lnguge

More information

Regular Sets and Expressions

Regular Sets and Expressions Regulr Sets nd Expressions Finite utomt re importnt in science, mthemtics, nd engineering. Engineers like them ecuse they re super models for circuits (And, since the dvent of VLSI systems sometimes finite

More information

CS Lecture 12. Pushdown Automata and Context Free Grammars. Another NPDA example. $ Stack. a, $ 0$ a, 0 00 a,1 λ. b, $ 1$ b, 1 11 b, 0 λ.

CS Lecture 12. Pushdown Automata and Context Free Grammars. Another NPDA example. $ Stack. a, $ 0$ a, 0 00 a,1 λ. b, $ 1$ b, 1 11 b, 0 λ. CS 30 - Lecture 2 Pushdown Automt nd Context Free Grmmrs Fll 2008 Review Lnguges nd Grmmrs Alphets, strings, lnguges Regulr Lnguges Deterministic Finite nd Nondeterministic Automt Euivlence of NFA nd DFA

More information

Homework One Solution CSE 355

Homework One Solution CSE 355 Homework One Solution CSE 355 Due: 3 Jnury 2 Plese note tht there is more thn one wy to nswer most of these questions. The following only represents smple solution. Prolem : Linz 2..7()(c)(g), 2.2.7. nd

More information

R10 SET - 1 0,1 0,1. 3. a) Convert the following finite automata to regular expressions

R10 SET - 1 0,1 0,1. 3. a) Convert the following finite automata to regular expressions www.lljntuworld.in R0 SET - II B. Tech II Semester Supplementry Exmintions Jn/Fe - 205 FORMAL LANGUAGES AND AUTOMATA THEORY (Computer Science nd Engineering) Time: 3 hours Mx. Mrks: 75 Answer ny FIVE Questions

More information

Automata Theory. CS S-07 Non-Regular Languages Closure Properties of Regular Languages DFA State Minimization. David Galles

Automata Theory. CS S-07 Non-Regular Languages Closure Properties of Regular Languages DFA State Minimization. David Galles Automt Theory CS411-2015S-07 Non-Regulr Lnguges Closure Properties of Regulr Lnguges DFA Stte Minimiztion Dvid Glles Deprtment of Computer Science University of Sn Frncisco 07-0: Fun with Finite Automt

More information

CS 341: Chapter Contents. CS 341: Chapter q 1,q 2,q 3 are the states.

CS 341: Chapter Contents. CS 341: Chapter q 1,q 2,q 3 are the states. CS 34: Foundtions of CS II Mrvin K. Nkym Computer Science Deprtment New Jersey Institute of Technology Newrk, NJ 72 CS 34: Chpter -2 Contents Chpter Regulr Lnguges Finite Automt Clss of Regulr Lnguges

More information

Regular Languages, Kleene s Theorem, Union, Concatenation and Kleene Star

Regular Languages, Kleene s Theorem, Union, Concatenation and Kleene Star Regulr Lnguges, Kleene s Theorem, Union, Conctention nd Kleene Str (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Regulr Lnguges re defined y regulr expressions, Finite Automt nd Regulr Grmmrs.

More information

Converting Regular Expressions to Discrete Finite Automata: A Tutorial

Converting Regular Expressions to Discrete Finite Automata: A Tutorial Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert

More information

Deterministic Finite-State Automata

Deterministic Finite-State Automata Deterministic Finite-Stte Automt Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 05 August 2011 Outline 1 Introduction 2 Exmple DFA 1 DFA for Odd number of

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson) Dept. of Computer

More information

Deterministic Finite Automata

Deterministic Finite Automata Deterministic Finite Automt Bkhdyr Khoussinov Computer Science Deprtment, The University of Aucklnd, New Zelnd mk@cs.ucklnd.c.nz In this lecture we introduce deterministic finite utomt, one of the foundtionl

More information

Equivalence of Regular Languages and FSMs

Equivalence of Regular Languages and FSMs Equivlence of Regulr Lnguges nd FSMs Red K & S 2.4 Red Supplementry Mterils: Regulr Lnguges nd Finite Stte Mchines: Generting Regulr Expressions from Finite Stte Mchines. Do Homework 8. Equivlence of Regulr

More information

1 First order logic of words

1 First order logic of words Lecture 2: Lnguges vi Logicl Formule Lnguges cn e defined (nd this is perhps the most nturl wy to define them) s words stisfying prticulr property. For exmple, the set of words stisfying ech of the following

More information

source code tokens scanner parser IR errors

source code tokens scanner parser IR errors Front end Specifying ptterns source code Scnner: tokens scnner prser IR errors ffl mps chrcters into tokens the sic unit of syntx x = x + y; ecomes = + ; ffl chrcter string vlue for

More information

Non-Regular Languages and The Pumping Lemma

Non-Regular Languages and The Pumping Lemma CS240 Lnguge Theory nd Automt Fll 2011 Non-Regulr Lnguges nd The Pumping Lemm Non-Regulr Lnguges Not every lnguge is regulr lnguge. However, there re some rules tht sy "if these lnguges re regulr, so is

More information

15 CYK algorithm and PDA

15 CYK algorithm and PDA Forml Lnguge nd Automt Theory: CS21004 15 CYK lgorithm nd PDA 15.1 Introduction We begin todys lecture with n exmple illustrting how to develop CNF for given CFL, nd lter on lern bout CYK lgorithm nd PDA.

More information

Unit-4: Regular properties

Unit-4: Regular properties 1/26 Unit-4: Regulr properties B. Srivthsn Chenni Mthemticl Institute NPTEL-course July - November 2015 2/26 Module 2: A gentle introduction to utomt 3/26 { p 1 } { p 1,p 2 } request=1 redy request=1 busy

More information

11.4 Regular Language Topics

11.4 Regular Language Topics 54 Regulr Lnguges nd Finite Automt Find simple regulr expression for the regulr lnguge recognized by this NFA. Hint: Trnsform the NFA into DFA, nd then find the minimum-stte DFA. Chllenge 12. Wht cn you

More information

Construction of State Diagram of. Regular Expressions Using Derivatives

Construction of State Diagram of. Regular Expressions Using Derivatives Applied Mthemticl Sciences, Vol. 6, 2012, no. 24, 1173-1179 Construction of Stte Digrm of egulr Expressions Using Derivtives N. Murugesn nd O.V. Shnmug Sundrm # Post Grdute & eserch Deprtment of Mthemtics

More information

Kleene's Theorem. CS 2800: Discrete Structures, Fall Sid Chaudhuri

Kleene's Theorem. CS 2800: Discrete Structures, Fall Sid Chaudhuri Kleene's Theorem CS 2800: Discrete Structures, Fll 2014 Sid Chudhuri Kleene's Theorem A lnguge is regulr, i.e. it cn be defned by regulr epression, if nd only if it is recognized by fnite utomton Kleene's

More information

Compiler Fall 2011 PRACTICE Midterm Exam

Compiler Fall 2011 PRACTICE Midterm Exam Compiler Fll 2011 PRACTICE Midterm Exm This is full length prctice midterm exm. If you wnt to tke it t exm pce, give yourself 7 minutes to tke the entire test. Just like the rel exm, ech question hs point

More information

DFA Operations. Complement, Product, Union, Intersection, Difference, Equivalence and Minimization of DFAs

DFA Operations. Complement, Product, Union, Intersection, Difference, Equivalence and Minimization of DFAs DFA Opertions Complement, Product, nion, Intersection, Difference, Equivlence nd inimiztion of DFAs Wednesdy, Octoer 7, 2009 eding: ipser pp. 45-46, toughton 3.11 3.12 C235 nguges nd Automt Deprtment of

More information

Turing Machine Extensions

Turing Machine Extensions Red K & S 4.3.1, 4.4. Do Homework 19. Turing Mchine Extensions Turing Mchine Definitions An lterntive definition of Turing mchine: (K, Σ, Γ, δ, s, H): Γ is finite set of llowble tpe symbols. One of these

More information

In the following there are presented four different kinds of simulation games for a given Büchi automaton A = :

In the following there are presented four different kinds of simulation games for a given Büchi automaton A = : Simultion Gmes Motivtion There re t lest two distinct purposes for which it is useful to compute simultion reltionships etween the sttes of utomt. Firstly, with the use of simultion reltions it is possile

More information

FABER Formal Languages, Automata and Models of Computation

FABER Formal Languages, Automata and Models of Computation DVA 325 FABR Forml Lnguges, Automt nd Models of Computtion Lecture 7 chool of Innovtion, Design nd ngineering Mälrdlen University 27 November 2014 1 Content ü Regulr vs. Non-regulr Lnguges ü Context-Free

More information

Fast Searching in Packed Strings. Philip Bille

Fast Searching in Packed Strings. Philip Bille Fst Serching in Pcked Strings Philip Bille 1 String Mtching Prolem: Given strings P nd Q of lengths m nd n, resp., report ll occurrences of P in Q. Q = ccc P = c KMP-lgorithm [KMP1977] uses O(n) time (ssume

More information

CS 311 Homework 5 Solutions due 16:40, Thursday, 28 th October 2010

CS 311 Homework 5 Solutions due 16:40, Thursday, 28 th October 2010 CS 311 Homework 5 Solutions due 16:40, Thursdy, 28 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [30 pts.; 15 pts. ech] Prove tht the following lnguges re not regulr using the pumping

More information

Star-Complement-Star on Prefix-Free Languages

Star-Complement-Star on Prefix-Free Languages History nd motivtion Preliminries Bounds Unry lphet Specil cse Open prolems Str-Complement-Str on Prefix-Free Lnguges Mtúš Plmovský, Jurj Šeej DCFS 2015 1/19 Outline History nd motivtion Preliminries Bounds

More information

CS402 Theory of Automata. Theory of Automata. Lecture N0. 38 Reading Material. Introduction to Computer Theory Chapter 14

CS402 Theory of Automata. Theory of Automata. Lecture N0. 38 Reading Material. Introduction to Computer Theory Chapter 14 C02 Theory of Automt Theory of Automt Lecture N0. 38 Reding Mteril Introduction to Computer Theory Chpter 1 ummry Exmple of PA with tle for running string, Equivlent PA, PA for EVEN EVEN Lnguge. Non- eterministic

More information

CS 470/570 Exam 2 Spring 2016 Solution

CS 470/570 Exam 2 Spring 2016 Solution CS 470/570 Exm 2 Spring 2016 Solution CS 470 Answer ny 6 of the 12 individul prts (,,c,d). CS 570 Answer ny 7 of the 12 individul prts (,,c,d). Extr credit will e wrded if you nswer dditionl prts correctly.

More information

(f) All possible sequences of balanced parentheses

(f) All possible sequences of balanced parentheses CMSC 330 HOMEWORK EXERCISES #2 1. Give unmiguous grmmrs for the following lnguges: In ll the grmmrs shown, single cpitl letters re used for non-terminls. otherwise stted, S is the strt symol. Unless ()

More information

6 JUNE 2002 SOLUTIONS

6 JUNE 2002 SOLUTIONS 1. DFA nd Regulr Expressions () Build the miniml DFA tht ccepts the strings over Σ = {, } whose ll prefixes with length lrger or equl to 3 hve either n even numer of s or even numer of s (or n even numer

More information

CS 154. Reductions and Undecidability 2/2/2012. A Concrete Undecidable Problem. (M,w) The Halting Problem. (M,w) Mapping Reductions

CS 154. Reductions and Undecidability 2/2/2012. A Concrete Undecidable Problem. (M,w) The Halting Problem. (M,w) Mapping Reductions 2/2/212 Reductions nd Undecidility A Concrete Undecidle Prolem CS 154 A TM = { (M, w) M is TM tht ccepts string w } Theorem: A TM is recognizle ut NOT decidle Corollry: A TM is not recognizle The Hlting

More information

Principles of Programming Languages

Principles of Programming Languages Principles of Progrmming Lnguges h"p://www.di.unipi.it/~ndre/did2c/plp- 15/ Prof. Andre Corrdini Deprtment of Computer Science, Pis Lesson 6! Towrds Gener=on of Lexicl Anlyzers Finite stte utomt (FSA)

More information

Lexical Analysis. Parser. Tokens Token Type Examples: ID, NUM, IF, EQUALS,... Source Code. Lexical Analyzer. String Table/ Symbol Table Management

Lexical Analysis. Parser. Tokens Token Type Examples: ID, NUM, IF, EQUALS,... Source Code. Lexical Analyzer. String Table/ Symbol Table Management Lexicl Anlysis Source Code Lexicl Anlyzer gettoken() Prser token String Tle/ Symol Tle Mngement!Must e efficient!looks t every input chr!textook, Chpter 2 1 Tokens Token Type Exmples: ID, NUM, IF, EQUALS,...

More information

ECE 468/573 Midterm 1 September 30, 2011

ECE 468/573 Midterm 1 September 30, 2011 ECE 468/573 Midterm 1 September 30, 2011 Nme: Purdue emil: Plese sign the following: I ffirm tht the nswers given on this test re mine nd mine lone. I did not receive help from ny person or mteril other

More information

Union, Intersection and Complement. Formal Foundations Computer Theory

Union, Intersection and Complement. Formal Foundations Computer Theory Union, Intersection nd Complement FAs Union, Intersection nd Complement FAs Forml Foundtions Computer Theory Ferury 21, 2013 This hndout shows (y exmples) how to construct FAs for the union, intersection

More information

Lexical analysis, scanners. Construction of a scanner

Lexical analysis, scanners. Construction of a scanner Lexicl nlysis scnners (NB. Pges 4-49 re for those who need to refresh their knowledge of DFAs nd NFAs. These re not presented during the lectures) Function. Red the input strem (sequence of chrcters) group

More information

Algorithms for Media

Algorithms for Media Algorithms for Medi Dvid Eppstein Univ. of Cliforni, Irvine School of Informtion nd Computer Science Joint work with Jen-Clude Flmgne Univ. of Cliforni, Irvine School of Socil Sciences Wht is medium? Introduced

More information

Mathematics for Chemists 2 Lecture 1: Integral calculus I. Indefinite and definite integrals, basic calculation of integrals

Mathematics for Chemists 2 Lecture 1: Integral calculus I. Indefinite and definite integrals, basic calculation of integrals Mthemtics for Chemists 2 Lecture 1: Integrl clculus I Indefinite nd definite integrls, sic clcultion of integrls Johnnes Kepler University Summer semester 2012 Lecturer: Dvid Sevill Integrl clculus I 1/19

More information

Inf1A: Non-deterministic Finite State Machines

Inf1A: Non-deterministic Finite State Machines Lecture 3 InfA: Non-deterministic Finite Stte Mchines 3. Introduction In this lecture we del with non-deterministic Finite Stte Mchines, clss of mchines which re generliztion of deterministic Finite Stte

More information

Today. Quiz 8. Exam overview. DFA Minimization. Assignments. HW 8 due. HW 9 out (just three questions) Announcement.

Today. Quiz 8. Exam overview. DFA Minimization. Assignments. HW 8 due. HW 9 out (just three questions) Announcement. Tody Quiz 8 Exm overview DFA Minimiztion Assignments HW 8 due HW 9 out (just three questions) Announcement Exm 3 next Tues S. Bowers 1 of 11 Exm 3 Bsics: 4 multiprt questions worth 10% of finl grde closed

More information

Lecture Notes for CIS 341: Introduction to Logic and Automata

Lecture Notes for CIS 341: Introduction to Logic and Automata Lecture Notes for CIS 341: Introduction to Logic nd Automt Mrvin K. Nkym Computer Science Deprtment New Jersey Institute of Technology Newrk, NJ 07102 August, 2003 c 2003 Mrvin K. Nkym ALL RIGHTS RESERVED

More information

Lexical Analysis - An Introduction

Lexical Analysis - An Introduction Lexicl Anlysis - An Introduction Copyright 2003, Keith D. Cooper, Ken Kennedy & Lind Torczon, ll rights reserved. Students enrolled in Comp 412 t Rice University hve explicit permission to mke copies of

More information

COMS W4115 Monday, March 9, 2009 Solutions to Homework #1

COMS W4115 Monday, March 9, 2009 Solutions to Homework #1 1 COMS W4115 Mondy, Mrch 9, 2009 Solutions to Homework #1 1. Regulr expressions. Lex regulr expression for ll lowercse English words with the five vowels in order. Throughout we ssume tht ech input line

More information

Phases of Syntax Analysis. Lexical Analysis. Terminology. Terminology. Patterns. Regular Expressions

Phases of Syntax Analysis. Lexical Analysis. Terminology. Terminology. Patterns. Regular Expressions : stnds for the set {} tht contins single string. Phses of Syntx Anlysis 1. Identify the words: Lexicl Anlysis. Converts strem of chrcters (input progrm) into strem of tokens. Also clled Scnning or Tokenizing.

More information

Suffix Trees CMSC 423

Suffix Trees CMSC 423 Suffix Trees CMSC 423 Preprocessing Strings Over the next few lectures, we ll see severl methods for preprocessing string dt into dt structures tht mke mny questions (like serching) esy to nswer: Suffix

More information

flex Regular Expressions and Lexical Scanning Regular Expressions and flex Examples on Alphabet A = {a,b} (Standard) Regular Expressions on Alphabet A

flex Regular Expressions and Lexical Scanning Regular Expressions and flex Examples on Alphabet A = {a,b} (Standard) Regular Expressions on Alphabet A flex Regulr Expressions nd Lexicl Scnning Using flex to Build Scnner flex genertes lexicl scnners: progrms tht discover tokens. Tokens re the smllest meningful units of progrm (or other string). flex is

More information

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

CS 6353 Compiler Construction, Homework #1 1. Write regular expressions for the following informally described languages: CS 6353 Compiler Construction, Homework #1 1. Write regulr expressions for the following informlly descried lnguges:. All strings of s nd s with the susequence. = {, }; ( )*( )*( )*( )*. All strings of

More information

Back End. The front end is not monolithic. IR Scanner. tokens. Parser

Back End. The front end is not monolithic. IR Scanner. tokens. Parser The Front End Source code Front End IR Bck End Mchine code Errors The purpose of the front end is to del with the input lnguge Perform memership test: code source lnguge? Is the progrm well-formed (semnticlly)?

More information

Regular Expression Matching: History, Status, and Challenges. Philip Bille

Regular Expression Matching: History, Status, and Challenges. Philip Bille Regulr Expression Mtching: History, Sttus, nd Chllenges Philip Bille Outline The problem Applictions Tour of techniques for worst-cse efficient regulr expression mtching NFAs nd stte-set simultion. NFA

More information

Converting an NFA to a DFA Given: A non-deterministic finite state machine (NFA)

Converting an NFA to a DFA Given: A non-deterministic finite state machine (NFA) Lexicl nlysis - Prt 3 onverting n NF to F Given: non-deterministic finite stte mchine (NF) Gol: onvert to n equivlent deterministic finite stte mchine (F) Why? Fster recognizer! pproch: onsider simulting

More information

Chapter 1 Mathematics Preliminary

Chapter 1 Mathematics Preliminary 1 Mthemtics Preliminry Chpter 1 Mthemtics Preliminry Answer for Exercises (Pge 13, Theory of Computer Science: Definitions nd Exmples. 3 rd Ed.) 1. ) {1,10,100} ) { n n Z nd n > 5 } c) { n n N nd n < 5

More information

Kleene Closure and State Complexity

Kleene Closure and State Complexity ITAT 2013 Proceedings, CEUR Workshop Proceedings Vol. 1003, pp. 94 100 http://ceur-ws.org/vol-1003, Series ISSN 1613-0073, c 2013 G. Jirásková, M. Plmovský Kleene Closure nd Stte Complexity Glin Jirásková

More information

q 2 q q1 q δ a b c λ REGULAR LANGUAGES (14 POINTS) Problem 1 (6 points) For the following NFA (Sudkamp) Solution 1 a) The transition function for M

q 2 q q1 q δ a b c λ REGULAR LANGUAGES (14 POINTS) Problem 1 (6 points) For the following NFA (Sudkamp) Solution 1 a) The transition function for M DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 REGULAR LANGUAGES (4 POINTS) Prolem (6 points) For the following NFA

More information

FORMAL LANGUAGES, AUTOMATA AND THEORY OF COMPUTATION EXERCISES ON REGULAR LANGUAGES

FORMAL LANGUAGES, AUTOMATA AND THEORY OF COMPUTATION EXERCISES ON REGULAR LANGUAGES FORMAL LANGUAGES, AUTOMATA AND THEORY OF COMPUTATION EXERCISES ON REGULAR LANGUAGES Introduction This compendium contins exercises out regulr lnguges for the course Forml Lnguges, Automt nd Theory of Computtion

More information

STRINGS AND PATTERN MATCHING

STRINGS AND PATTERN MATCHING STRINGS AND PATTERN MATCHING Brute Force,Rbin-Krp, Knuth-Morris-Prtt Regulr Expressions Wht s up? I m looking for some string. Tht s quite trick considering tht you hve no eyes. Oh yeh? Hve you seen your

More information

Basics of Logic Design: Boolean Algebra, Logic Gates. Administrative

Basics of Logic Design: Boolean Algebra, Logic Gates. Administrative Bsics of Logic Design: Boolen Alger, Logic Gtes Computer Science 104 Administrtive Homework #3 Due Sundy Midterm I Mondy in clss, closed ook, closed notes Ø Will provide IA32 instruction set hndout Ø Lst

More information

COMP9319 Web Data Compression and Search

COMP9319 Web Data Compression and Search COMP9319 We Dt Compression nd Serch Lecture 3: Serch nd sic indexing Including slides modified from the slides from comp3402 t cs.ucf.edu, himk, Tel-Aviv U. nd the slides from Andrew Dvison. Wht is Pttern

More information

Strings. String Processing. Periodicity. Strings. Typical applications:

Strings. String Processing. Periodicity. Strings. Typical applications: String Processing Typicl pplictions: pttern mtching/recognition moleculr biology, comprtive genomics, informtion retrievl dt/text mining dt/text compression, coding, encryption string processing in lrge

More information

Reasoning to Solve Equations and Inequalities

Reasoning to Solve Equations and Inequalities Lesson4 Resoning to Solve Equtions nd Inequlities In erlier work in this unit, you modeled situtions with severl vriles nd equtions. For exmple, suppose you were given usiness plns for concert showing

More information

Basics of Logic Design: Boolean Algebra, Logic Gates. Today s Lecture

Basics of Logic Design: Boolean Algebra, Logic Gates. Today s Lecture Bsics of Logic Design: Boolen Alger, Logic Gtes Computer Science 104 Tody s Lecture Projects (groups of 2 or 3) Outline Building the uilding locks Logic Design Truth tles, Boolen functions, Gtes nd Circuits

More information

One-Bit Adder MIPS. Detecting Overflow. Effects of Overflow. An ALU (arithmetic logic unit) Different Implementations

One-Bit Adder MIPS. Detecting Overflow. Effects of Overflow. An ALU (arithmetic logic unit) Different Implementations MIPS One-Bit Adder it signed numers: two = ten two = + ten two = + ten... two = +,7,8,66 ten two = +,7,8,67 ten two =,7,8,68 ten two =,7,8,67 ten two =,7,8,66 ten... two = ten two = ten two = ten mxint

More information

data structures and algorithms lecture 13

data structures and algorithms lecture 13 dt strutures nd lgorithms 0 0 7 leture overview single-soure shortest pth string-mthing rute-fore string mthing lgorithm Knuth-Morris-Prtt pttern mthing mteril overview single-soure shortest pth string-mthing

More information

Arithmetic. Numbers ALU. operation. result Morgan Kaufmann Publishers Morgan Kaufmann Publishers

Arithmetic. Numbers ALU. operation. result Morgan Kaufmann Publishers Morgan Kaufmann Publishers Arithmetic Where we ve een: Performnce (seconds, cycles, instructions) Astrctions: Instruction Set Architecture Assemly Lnguge nd Mchine Lnguge Wht s up hed: Implementing the Architecture opertion 32 ALU

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata N Lecture Notes on Regulr Lnguges nd Finite Automt for Prt IA of the Computer Science Tripos Mrcelo Fiore Cmbridge University Computer Lbortory First Edition 1998. Revised 1999, 2000, 2001, 2002, 2003,

More information

Grammars: Notation to succinctly represent the structure of a language. Example:

Grammars: Notation to succinctly represent the structure of a language. Example: Introduction Syntx Anlysis Structure of Lnguge Grmmrs: Nottion to succinctly represent the structure of lnguge. Exmple: Stmt if Expr then Stmt else Stmt Stmt while Expr do Stmt Stmt do Stmt until Expr.

More information

1 General LR Parsing. Bottom-Up Parsing

1 General LR Parsing. Bottom-Up Parsing ection - Bottom-Up Prsings: 1 Generl LR Prsing 1 Generl LR Prsing Bottom-Up Prsing Bottom-up prsing is more powerful nd preferle LR(1) exists for ny LR(k) (with end-mrkers) there re LR(1) tht do not hve

More information

1.4.1 LU Decomposition. In section 1.3.6, we have seen that calculating the inverse of a matrix A involves solving N linear problems:

1.4.1 LU Decomposition. In section 1.3.6, we have seen that calculating the inverse of a matrix A involves solving N linear problems: .4. LU Decomposition In section..6, we hve seen tht clculting the inverse of mtrix A involves solving N liner prolems: ~ [k] A = e [k] (.4.-) ~ [] ~ [N] For the N column vectors,, of A -. Ech of these

More information

Square Roots Teacher Notes

Square Roots Teacher Notes Henri Picciotto Squre Roots Techer Notes This unit is intended to help students develop n understnding of squre roots from visul / geometric point of view, nd lso to develop their numer sense round this

More information

Huffman Codes. Spring 2010

Huffman Codes. Spring 2010 Huffmn Coes 18.310C Lecture Notes Spring 2010 Shnnon s noiseless coing theorem tells us how compctly we cn compress messges in which ll letters re rwn inepenently from n lphet A n we re given the proility

More information

Solutions to Problem Set 1 (Revised)

Solutions to Problem Set 1 (Revised) CSE 5: Introduction to the Theory o Computtion, Spring 3 A. Hevi Solution to Prolem Set (Revied) April 6, 3 Solution to Prolem Set (Revied).4 ). L = {w w egin with nd end with }. q q q q 3, d). L = {w

More information

Introduction to Languages and Grammars

Introduction to Languages and Grammars Introduction to Lnguges nd Grmmrs lphbets nd Lnguges n lphbet is finite non-empty set. Let nd T be lphbets. T = { s t s ε, t ε T } (We ll often write T for T.) λ = empty string, string of length one 0

More information