One Minute To Learn Programming: Finite Automata


 Beatrice Blankenship
 1 years ago
 Views:
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 Rellife 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
525 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 informationAnatomy 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 525 Fll 2 Lecture 2 Oct 28, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn understnd
More informationComputation. 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 informationFormal 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 informationOutline. Learning Goals: InClass. Learning Goals: InClass. 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 informationFinite 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 informationLecture 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 informationInside 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 information0.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 informationString Matching. Pattern Matching. Algorithms on Strings. Deterministic Finite Automaton. BruteForce Algorithm. Plan:
Algorithm Design nd Anlysis Victor Admchik CS 545 Spring 25 Lecture 24 Apr 2, 25 Crnegie Mellon University String Mtching Pln: KnuthMorrisPrtt AhoCorsick RinKrp J.Morris D.Knuth Algorithms on Strings
More informationNondeterministic Finite Automata
Nondeterministic finite utomt (NFAs) Equivlence of DFAs nd NFAs Nondeterministic Finite Automt Informtics 2A: Lecture 4 Alex Simpson School of Informtics University of Edinburgh ls@inf.ed.c.uk 24 September,
More informationHomework 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 informationHarvard CS 121 and CSCI E121 Lecture 4: Nondeterministic Finite Automata and Closure Properties
Hrvrd CS 121 nd CSCI E121 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 informationChapter 5. Pushdown Automata. By Dr Zalmiyah Zakaria
Chpter 5 Pushdown Automt By Dr Zlmiyh Zkri PushDown 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 informationBuilding 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 informationCSC236H: 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 informationFrom 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 informationCS 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 informationHarvard CS 121 and CSCI E121 Lecture 3: Finite Automata
Hrvrd CS 121 nd CSCI E121 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 informationCS2 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 information1. 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 information15 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 informationFinite 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 informationString Matching. String Matching. Naive String Matching RabinKarp Matcher String Matching with Finite Automata KnuthMorrisPratt Algorithm
String Mtching String Mtching Nive String Mtching RinKrp Mtcher String Mtching with Finite Automt KnuthMorrisPrtt Algorithm Input is pttern P[1..m] nd text T[1..n]. Find shift s s.t. P[i] = T[s+i] for
More informationRegular 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 Σ* Lngugeforming opertions L 1 L 2, L 1 L 2 L 1* (Kleene closure) Regulr Expressions Inductive
More informationCA320  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 informationRegular 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 informationCS 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 informationHomework 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 informationR10 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 informationAutomata Theory. CS S07 NonRegular Languages Closure Properties of Regular Languages DFA State Minimization. David Galles
Automt Theory CS4112015S07 NonRegulr Lnguges Closure Properties of Regulr Lnguges DFA Stte Minimiztion Dvid Glles Deprtment of Computer Science University of Sn Frncisco 070: Fun with Finite Automt
More informationCS 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 informationRegular 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 informationConverting Regular Expressions to Discrete Finite Automata: A Tutorial
Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 20130103 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert
More informationDeterministic FiniteState Automata
Deterministic FiniteStte 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 informationCS 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 informationDeterministic 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 informationEquivalence 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 information1 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 informationsource 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 informationNonRegular Languages and The Pumping Lemma
CS240 Lnguge Theory nd Automt Fll 2011 NonRegulr Lnguges nd The Pumping Lemm NonRegulr Lnguges Not every lnguge is regulr lnguge. However, there re some rules tht sy "if these lnguges re regulr, so is
More information15 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 informationUnit4: Regular properties
1/26 Unit4: Regulr properties B. Srivthsn Chenni Mthemticl Institute NPTELcourse 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 information11.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 minimumstte DFA. Chllenge 12. Wht cn you
More informationConstruction of State Diagram of. Regular Expressions Using Derivatives
Applied Mthemticl Sciences, Vol. 6, 2012, no. 24, 11731179 Construction of Stte Digrm of egulr Expressions Using Derivtives N. Murugesn nd O.V. Shnmug Sundrm # Post Grdute & eserch Deprtment of Mthemtics
More informationKleene'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 informationCompiler 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 informationDFA 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. 4546, toughton 3.11 3.12 C235 nguges nd Automt Deprtment of
More informationTuring 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 informationIn 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 informationFABER 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. Nonregulr Lnguges ü ContextFree
More informationFast 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 KMPlgorithm [KMP1977] uses O(n) time (ssume
More informationCS 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 informationStarComplementStar on PrefixFree Languages
History nd motivtion Preliminries Bounds Unry lphet Specil cse Open prolems StrComplementStr on PrefixFree Lnguges Mtúš Plmovský, Jurj Šeej DCFS 2015 1/19 Outline History nd motivtion Preliminries Bounds
More informationCS402 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 informationCS 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
CMSC 330 HOMEWORK EXERCISES #2 1. Give unmiguous grmmrs for the following lnguges: In ll the grmmrs shown, single cpitl letters re used for nonterminls. otherwise stted, S is the strt symol. Unless ()
More information6 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 informationCS 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 informationPrinciples 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 informationLexical 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 informationECE 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 informationUnion, 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 informationLexical analysis, scanners. Construction of a scanner
Lexicl nlysis scnners (NB. Pges 449 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 informationAlgorithms for Media
Algorithms for Medi Dvid Eppstein Univ. of Cliforni, Irvine School of Informtion nd Computer Science Joint work with JenClude Flmgne Univ. of Cliforni, Irvine School of Socil Sciences Wht is medium? Introduced
More informationMathematics 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 informationInf1A: Nondeterministic Finite State Machines
Lecture 3 InfA: Nondeterministic Finite Stte Mchines 3. Introduction In this lecture we del with nondeterministic Finite Stte Mchines, clss of mchines which re generliztion of deterministic Finite Stte
More informationToday. 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 informationLecture 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 informationLexical 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 informationCOMS 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 informationPhases 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 informationSuffix 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 informationflex 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 informationCS 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 informationBack 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 wellformed (semnticlly)?
More informationRegular 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 worstcse efficient regulr expression mtching NFAs nd stteset simultion. NFA
More informationConverting an NFA to a DFA Given: A nondeterministic finite state machine (NFA)
Lexicl nlysis  Prt 3 onverting n NF to F Given: nondeterministic finite stte mchine (NF) Gol: onvert to n equivlent deterministic finite stte mchine (F) Why? Fster recognizer! pproch: onsider simulting
More informationChapter 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 informationKleene Closure and State Complexity
ITAT 2013 Proceedings, CEUR Workshop Proceedings Vol. 1003, pp. 94 100 http://ceurws.org/vol1003, Series ISSN 16130073, c 2013 G. Jirásková, M. Plmovský Kleene Closure nd Stte Complexity Glin Jirásková
More informationq 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 informationFORMAL 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 informationSTRINGS AND PATTERN MATCHING
STRINGS AND PATTERN MATCHING Brute Force,RbinKrp, KnuthMorrisPrtt 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 informationBasics 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 informationCOMP9319 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, TelAviv U. nd the slides from Andrew Dvison. Wht is Pttern
More informationStrings. 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 informationReasoning 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 informationBasics 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 informationOneBit Adder MIPS. Detecting Overflow. Effects of Overflow. An ALU (arithmetic logic unit) Different Implementations
MIPS OneBit 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 informationdata structures and algorithms lecture 13
dt strutures nd lgorithms 0 0 7 leture overview singlesoure shortest pth stringmthing rutefore string mthing lgorithm KnuthMorrisPrtt pttern mthing mteril overview singlesoure shortest pth stringmthing
More informationArithmetic. 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 informationRegular 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 informationGrammars: 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 information1 General LR Parsing. BottomUp Parsing
ection  BottomUp Prsings: 1 Generl LR Prsing 1 Generl LR Prsing BottomUp Prsing Bottomup prsing is more powerful nd preferle LR(1) exists for ny LR(k) (with endmrkers) there re LR(1) tht do not hve
More information1.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 informationSquare 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 informationHuffman 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 informationSolutions 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 informationIntroduction to Languages and Grammars
Introduction to Lnguges nd Grmmrs lphbets nd Lnguges n lphbet is finite nonempty 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