1.3 Regular Expressions


 Ruth Tate
 1 years ago
 Views:
Transcription
1 Regulr xpressions These hve n importnt role in describing ptterns in serching for strings in mny pplictions (e.g. wk, grep, Perl,...) All regulr expressions of lphbet re 1.Ønd re regulr expressions, 2.is regulr expression of for ll, 3. if R 1 nd R 2 re regulr expressions, then lso (R 1 R 2 ), (R 1 R 2 ) nd R 1 * re regulr expressions 57 ch regulr expression R of represents lnguge L(R) 1. L(Ø) = Ø, 2. L) = {}, 3. L() = {}, 4. L((R 1 R 2 )) = L(R 1 ) L(R 2 ), 5. L((R 1 R 2 )) = L(R 1 )L(R 2 ) nd 6. L(R 1 *) = (L(R 1 ))* Proper closure: R + is shorthnd for RR* (Kleene plus) Observe: R + = R* Let R k be shorthnd for the conctention of kr s with ech other. 1
2 58 xmples 0*10* = { w w contins single 1 } *001* = { w w contins the string 001 s substring } 1*(01 + )* = { w every 0 in w is followed by t lest one 1 } )* = { w w is string of even length } = { 01,10 } *0 *1 0 1 = { w w strts nd ends with the sme symbol } (0 )1* = 01* 1* (0 )(1 ) = {, 0, 1, 01 } 1*Ø = Ø Ø* = { } 59 For ny regulr expression R R Ø = R nd R = R However, it my hold tht R Rnd RR For exmple, the unsigned rel numbers tht cn be recognized using the previous utomton cn be expressed with the regulr expression d + (.d + )( (+ )d + ), where d = ( 0 9 ) 2
3 60 d d d. d q 0 q 1 q 2 q 3 d q 4 q 6 d +,  d q 5 61 Theorem 1.54 A lnguge is regulr if nd only if some regulr expression describes it. We stte nd prove both directions of this theorem seprtely. Lemm 1.55 If lnguge is described by regulr expression, then it is regulr. Proof. Any regulr expression cn be converted into finite utomton, which recognizes the sme lnguge s tht described by the regulr expression. There re only six rules by which regulr expressions cn be composed. The following pictures illustrte the NFA for ech of these cses. 3
4 62 r = Ø r = r = 63 r = s t N s N t 4
5 64 r = st N s N t 65 r = s* N s 5
6 66 r = ((b bb))* b b b b b b 67 Lemm 1.60 If lnguge is regulr, then it is described by regulr expression. Proof. By definition regulr lnguge cn be recognized with (nondeterministic) finite utomton, which cn be converted into generlized nondeterministic finite utomton (GNFA). The GNFA finlly yields regulr expression tht is equivlent with the originl utomton. Let R denote the set of regulr expressions over In GNFA the trnsition function is finite mpping : Q R P(Q) (q,w)(q', w') if q (q, r) for some r R s.t. w = zw', z L(r) 6
7 68 A GNFA M cn be reduced into regulr expression which describes the lnguge recognized by M 1. We compress M into GNFA with only 2 sttes (so tht the lnguge recognized remins equivlent) 1. The ccept sttes of M re replced by single one ( rrows) 2. We remove ll other sttes q except the strt stte nd finl stte. Let q i nd q j be the predecessor nd successor of q on some route pssing through q. Now we cn remove q nd renme the rrow between q i nd q j with new expression. 2. ventully the GNFA contins t most two sttes. It is esy to convert the lnguge recognized into regulr expression. 69 7
8 70 q i r q s q j q i rs q j t q i r q s q j q i rt*s q j 71 q i r s q j q i r s q j r r* r s t u r*s(t* ur*s)* 8
9 72 b b bb b b b b bb 73 b b b bb ( b)(b)*(bb ) (b ( b)(b)*(bb ))* 9
10 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll lnguges cnnot be regulr Cn we find n intuitive exmple of nonregulr lnguge? The lnguge of blnced pirs of prentheses L prenth = { ( k ) k k 0 } 75 Theorem 1.70 (Pumping lemm) Let A be regulr lnguge. Then there exists p 1 (the pumping length) s.t. ny string s A, s p, my be divided into three pieces, s = xyz, stisfying the following conditions: xy p, y 1 nd xy i z A i = 0, 1, 2, Proof. Let M= (Q,,q 0,F)be DFA tht recognizes A s.t. Q = p. When the DFA is computing with input s A, s p, it must pss through some stte t lest twice when processing the first p chrcters of s. Let q be the first such stte. 10
11 76 Let us choose so tht: x is the prefix of s tht hs been processed when M enters q for the first time, y is tht prt of the suffix s tht gets processed by M before it reenters stte q, nd z is the rest of the string s. Obviously xy p, y 1 nd xy i z A for ll i = 0, 1, 2, x q y z Observe: The pumping lemm does not give us liberty to choose x nd y s we plese. 77 xmple Let us ssume tht L prenth is regulr lnguge. By the pumping lemm there exists some number p s.t. strings of L prenth of length t lest p cn be pumped. Let us choose s = ( p ) p. Then s = 2p > p. By Lemm 1.70 s cn be divided into three prts s = xyz s.t. xy p nd y 1. Therefore, it must be tht x = ( i i p 1, y = ( j j 1, nd z = ( p(i+j) ) p. By our ssumption xy k z L prenth for ll k = 0, 1, 2,, but for exmple xy 0 z = xz = ( i ( p(i+j) ) p = ( pj ) p L prenth, becuse p j p since j 1. Hence, L prenth cnnot be regulr lnguge 11
12 78 The min limittion tht finite utomt hve is tht they hve no (externl) mens of keeping trck of n unlimited number of possibilities; i.e., to count Consider the following two lnguges C = { w w hs n equl number of 0s nd 1s } D= { w w hs n equl number of occurrences of 01 nd 10 s substrings } At first glnce recognizing mchine needs to count in ech cse The lnguge C contins { 0 k 1 k k 0 } s subset nd, hence, the nonregulrity of L prenth proves tht of C Surprisingly, D is regulr 79 An lterntive proof for nonregulrity of C The complement of regulr lnguge is regulr (xercises 1, question 5) The intersection of two regulr lnguges A nd B cn be expressed s A B A B Therefore, by Theorem 1.25, the intersection is lso regulr Lnguge L prenth cn be expressed s the intersection of C nd 0*1*, the ltter of which is regulr lnguge If C were regulr, then its intersection with the regulr lnguge 0*1* would lso be regulr However, we know tht L prenth is not regulr Therefore, C cnnot either be regulr 12
13 80 DFA for recognizing D xmple 1.75 Let F = { ww w { 0, 1 }* }. We show tht F is not regulr. Assume tht F is regulr. Let p be the pumping length given by the pumping lemm. Let s be the string 0 p 10 p 1. Becuse s is member of F nd it hs length more thn p, the pumping lemm gurntees tht s cn be split into pieces s = xyz, stisfying the three conditions of the lemm. We show tht this outcome is impossible. Becuse xy p, x nd y must consist only of 0s, so xyyz F. More exctly, x = 0 i, y = 0 j, nd z = 0 p (i+j) 10 p 1. Therefore, xy 2 z = xyyz = 0 i+j+j+p (i+j) 10 p 1 = 0 p+j 10 p 1 which does not belong to F since 0 p+j 1 hs more zeros thn 0 p 1 since by pumping lemm j 1. Hence, F is not regulr lnguge. 13
14 82 xmple 1.77 Let = { 0 i 1 j i > j }. We show tht is not regulr. Assume tht is regulr. Let p be the pumping length for given by the pumping lemm. Let s be the string 0 p+1 1 p. Then s cn be split into xyz stisfying the conditions of the pumping lemm. Becuse xy p, x nd y must consist only of 0s: x = 0 i nd y = 0 j Let us exmine the string xyyz to see whether it cn be in. Adding n extr copy of y increses the number of 0s. But contins ll strings in 0*1* tht hve more 0s thn 1s, so incresing the number of 0s will still give string in. We need to pump down: xy 0 z = xz = 0 i+p+1 (i+j) 1 p = 0 p+1 j 1 p since p+1 j p becuse by ssumption j 1. Hence, the clim follows ContextFree Lnguges The lnguge of blnced pirs of prentheses is not regulr one On the other hnd, it cn be described using the following substitution rules 1.Snd 2.S(S) These productions generte the strings of the lnguge L prenth strting from the strt vrible S S ² (S) ² ((S)) ² (((S))) ¹ ((())) = ((( ))) 14
15 84 The string being described is generted by substituting vribles one by one ccording to the given rules The string surrounding vrible does not determine the chosen production contextfree grmmr One often bbrevites A w 1 w k to describe the lterntive productions ssocited with the vrible A A w 1,, A w k S (S) 85 Simple rithmetic expressions ( = expression, T = term nd F = fctor) + T T T T F F F () Genertion the expression ( + ()) T T F F F () F ( + T) F (T + T) F (F + T) F ( + T) F ( + F) F ( + ()) F ( + (T)) F ( + (F)) F ( + ()) F ( + ()) 15
16 86 Definition 2.2 A contextfree grmmr is 4tuple G = (V,, R, S), where V is finite set clled the vribles, is finite set, disjoint from V, clled the terminls V is the lphbet of G, R V (V )* is finite set of rules, nd S V is the strt vrible (A, w) R is usully denoted s A w 87 Let G = (V,, R, S), strings u, v, w (V )*, nd A w production in R uav yields string uwv in grmmr G, written uav G uwv String u derives string v in grmmr G, written u G v, if sequence u 1, u 2,, u k (V )* (k 0) exists s.t. u G u 1 G u 2 G G u k G v k = 0: u G u for ny u (V )* 16
17 88 u (V )* is sententil form of G if S G u A sententil form consisting of only terminls w * is sentence of G The lnguge of the grmmr G consists of sentences L(G) = { w * S G w } A forml lnguge L * is contextfree, if it cn be generted using contextfree grmmr 89 A contextfree grmmr is rightliner if ll its productions re of type A or A B Theorem Any regulr lnguge cn be generted using rightliner contextfree grmmr. Theorem Any rightliner contextfree lnguge is regulr. Hence, rightliner grmmrs generte exctly regulr lnguges However, there re contextfree lnguges which re not regulr; e.g., the lnguge of blnced pirs of prentheses L prenth Therefore, contextfree lnguges re proper superset of regulr lnguges 17
18 90 Ambiguity The sequence of onestep derivtions leding from the strt vrible S to string w S w 1 w k w is clled the derivtion of w In the grmmr for rithmetic expressions the sentence + cn be derived in mny different wys: 1.+TT+TF+T+T+F+ 2.+T+FT+FF+FF++ 3.+T+F+T+F++ The differences cused by vrying substitution order of vribles cn be bstrcted wy by exmining prse trees 91 T F + T F 18
19 92 Contextfree grmmr G is mbiguous if some sentence of G hs two (or more) distinct prse trees Otherwise the grmmr is unmbiguous Lnguge tht hs no unmbiguous contextfree grmmr is inherently mbiguous.g. lnguge { i b j c k i = j j = k } is inherently mbiguous An lterntive grmmr for the simple rithmetic expressions: + ()
1.4 Nonregular Languages
74 1.4 Nonregulr Lnguges The number of forml lnguges over ny lphbet (= decision/recognition problems) is uncountble On the other hnd, the number of regulr expressions (= strings) is countble Hence, ll
More informationTheory of Computation Regular Languages. (NTU EE) Regular Languages Fall / 38
Theory of Computtion Regulr Lnguges (NTU EE) Regulr Lnguges Fll 2017 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of Finite Automt A finite utomton hs finite set of control
More informationTheory of Computation Regular Languages
Theory of Computtion Regulr Lnguges BowYw Wng Acdemi Sinic Spring 2012 BowYw Wng (Acdemi Sinic) Regulr Lnguges Spring 2012 1 / 38 Schemtic of Finite Automt control 0 0 1 0 1 1 1 0 Figure: Schemtic of
More informationFor convenience, we rewrite m2 s m2 = m m m ; where m is repeted m times. Since xyz = m m m nd jxyj»m, we hve tht the string y is substring of the fir
CSCI 2400 Models of Computtion, Section 3 Solutions to Homework 4 Problem 1. ll the solutions below refer to the Pumping Lemm of Theorem 4.8, pge 119. () L = f n b l k : k n + lg Let's ssume for contrdiction
More informationNFAs and Regular Expressions. NFAε, continued. Recall. Last class: Today: Fun:
CMPU 240 Lnguge Theory nd Computtion Spring 2019 NFAs nd Regulr Expressions Lst clss: Introduced nondeterministic finite utomt with trnsitions Tody: Prove n NFA is no more powerful thn n NFA Introduce
More informationAutomata and Languages
Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Contextfree Grmmr Contextsensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive
More informationLecture 6 Regular Grammars
Lecture 6 Regulr Grmmrs COT 4420 Theory of Computtion Section 3.3 Grmmr A grmmr G is defined s qudruple G = (V, T, S, P) V is finite set of vribles T is finite set of terminl symbols S V is specil vrible
More informationAUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton
25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q
More informationHarvard University Computer Science 121 Midterm October 23, 2012
Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closedook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is
More information1.3 Regular Expressions
51 1.3 Regular Expressions These have an important role in descriing patterns in searching for strings in many applications (e.g. awk, grep, Perl,...) All regular expressions of alphaet are 1.Øand are
More informationAnatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute
Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 525 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn
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.5.: Properties of Context Free Grmmrs (14) Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson)
More information5. (±±) Λ = 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.
Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018
Finite Automt Theory nd Forml Lnguges TMV027/DIT321 LP4 2018 Lecture 10 An Bove April 23rd 2018 Recp: Regulr Lnguges We cn convert between FA nd RE; Hence both FA nd RE ccept/generte regulr lnguges; More
More informationGrammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages
5//6 Grmmr Automt nd Lnguges Regulr Grmmr Contextfree Grmmr Contextsensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive
More informationLecture 08: Feb. 08, 2019
4CS46:Theory of Computtion(Closure on Reg. Lngs., regex to NDFA, DFA to regex) Prof. K.R. Chowdhry Lecture 08: Fe. 08, 2019 : Professor of CS Disclimer: These notes hve not een sujected to the usul scrutiny
More informationFinite Automata. Informatics 2A: Lecture 3. John Longley. 22 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 22 September 2017 1 / 30 Lnguges nd Automt 1 Lnguges nd Automt Wht is
More informationCS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018
CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA
More informationCS:4330 Theory of Computation Spring Regular Languages. Equivalences between Finite automata and REs. Haniel Barbosa
CS:4330 Theory of Computtion Spring 208 Regulr Lnguges Equivlences between Finite utomt nd REs Hniel Brbos Redings for this lecture Chpter of [Sipser 996], 3rd edition. Section.3. Finite utomt nd regulr
More informationCHAPTER 1 Regular Languages. Contents
Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Nondeterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr
More informationFormal languages, automata, and theory of computation
Mälrdlen University TEN1 DVA337 2015 School of Innovtion, Design nd Engineering Forml lnguges, utomt, nd theory of computtion Thursdy, Novemer 5, 14:1018:30 Techer: Dniel Hedin, phone 021107052 The exm
More informationFinite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh
Finite Automt Informtics 2A: Lecture 3 Mry Cryn School of Informtics University of Edinburgh mcryn@inf.ed.c.uk 21 September 2018 1 / 30 Lnguges nd Automt Wht is lnguge? Finite utomt: recp Some forml definitions
More informationClosure Properties of Regular Languages
Closure Properties of Regulr Lnguges Regulr lnguges re closed under mny set opertions. Let L 1 nd L 2 e regulr lnguges. (1) L 1 L 2 (the union) is regulr. (2) L 1 L 2 (the conctention) is regulr. (3) L
More informationFinite Automatacont d
Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automtcont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww
More informationCS 275 Automata and Formal Language Theory
CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)
More informationHomework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama
CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)
More informationFirst Midterm Examination
Çnky University Deprtment of Computer Engineering 203204 Fll Semester First Midterm Exmintion ) Design DFA for ll strings over the lphet Σ = {,, c} in which there is no, no nd no cc. 2) Wht lnguge does
More informationAssignment 1 Automata, Languages, and Computability. 1 Finite State Automata and Regular Languages
Deprtment of Computer Science, Austrlin Ntionl University COMP2600 Forml Methods for Softwre Engineering Semester 2, 206 Assignment Automt, Lnguges, nd Computility Smple Solutions Finite Stte Automt nd
More informationNon Deterministic Automata. Linz: Nondeterministic Finite Accepters, page 51
Non Deterministic Automt Linz: Nondeterministic Finite Accepters, pge 51 1 Nondeterministic Finite Accepter (NFA) Alphbet ={} q 1 q2 q 0 q 3 2 Nondeterministic Finite Accepter (NFA) Alphbet ={} Two choices
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY. FLAC (15453)  Spring L. Blum
15453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THE PUMPING LEMMA FOR REGULAR LANGUAGES nd REGULAR EXPRESSIONS TUESDAY Jn 21 WHICH OF THESE ARE REGULAR? B = {0 n 1 n n 0} C = { w w hs equl numer of
More informationRegular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene*
Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion
More informationNonDeterministic Finite Automata. Fall 2018 Costas Busch  RPI 1
NonDeterministic Finite Automt Fll 2018 Costs Busch  RPI 1 Nondeterministic Finite Automton (NFA) Alphbet ={} q q2 1 q 0 q 3 Fll 2018 Costs Busch  RPI 2 Nondeterministic Finite Automton (NFA) Alphbet
More informationNondeterministic Finite Automata
Nondeterministic Finite Automt Eliminting nondeterminism Rdoud University Nijmegen Nondeterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent
More informationFundamentals of Computer Science
Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,
More informationCSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science
CSCI 340: Computtionl Models Kleene s Theorem Chpter 7 Deprtment of Computer Science Unifiction In 1954, Kleene presented (nd proved) theorem which (in our version) sttes tht if lnguge cn e defined y ny
More informationRegular expressions, Finite Automata, transition graphs are all the same!!
CSI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 7: Kleene s Theorem Chpter 7: Kleene s Theorem Regulr expressions, Finite Automt, trnsition grphs re ll the sme!! Dr. Neji Zgui CSI3104W11 1
More informationMinimal DFA. minimal DFA for L starting from any other
Miniml DFA Among the mny DFAs ccepting the sme regulr lnguge L, there is exctly one (up to renming of sttes) which hs the smllest possile numer of sttes. Moreover, it is possile to otin tht miniml DFA
More informationContextFree Grammars and Languages
ContextFree Grmmrs nd Lnguges (Bsed on Hopcroft, Motwni nd Ullmn (2007) & Cohen (1997)) Introduction Consider n exmple sentence: A smll ct ets the fish English grmmr hs rules for constructing sentences;
More informationChapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1
Chpter Five: Nondeterministic Finite Automt Forml Lnguge, chpter 5, slide 1 1 A DFA hs exctly one trnsition from every stte on every symol in the lphet. By relxing this requirement we get relted ut more
More information1 Structural induction, finite automata, regular expressions
Discrete Structures Prelim 2 smple uestions s CS2800 Questions selected for spring 2017 1 Structurl induction, finite utomt, regulr expressions 1. We define set S of functions from Z to Z inductively s
More information1 From NFA to regular expression
Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work
More informationTalen en Automaten Test 1, Mon 7 th Dec, h45 17h30
Tlen en Automten Test 1, Mon 7 th Dec, 2015 15h45 17h30 This test consists of four exercises over 5 pges. Explin your pproch, nd write your nswer to ech exercise on seprte pge. You cn score mximum of 100
More informationRegular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15
Regulr Lnguge Nonregulr Lnguges The Pumping Lemm Models of Comput=on Chpter 10 Recll, tht ny lnguge tht cn e descried y regulr expression is clled regulr lnguge In this lecture we will prove tht not ll
More information11.1 Finite Automata. CS125 Lecture 11 Fall Motivation: TMs without a tape: maybe we can at least fully understand such a simple model?
CS125 Lecture 11 Fll 2016 11.1 Finite Automt Motivtion: TMs without tpe: mybe we cn t lest fully understnd such simple model? Algorithms (e.g. string mtching) Computing with very limited memory Forml verifiction
More information1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.
York University CSE 2 Unit 3. DFA Clsses Converting etween DFA, NFA, Regulr Expressions, nd Extended Regulr Expressions Instructor: Jeff Edmonds Don t chet y looking t these nswers premturely.. For ech
More informationCMSC 330: Organization of Programming Languages. DFAs, and NFAs, and Regexps (Oh my!)
CMSC 330: Orgniztion of Progrmming Lnguges DFAs, nd NFAs, nd Regexps (Oh my!) CMSC330 Spring 2018 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All
More informationCS375: Logic and Theory of Computing
CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tble of Contents: Week 1: Preliminries (set lgebr, reltions, functions) (red Chpters 14) Weeks
More informationDesigning finite automata II
Designing finite utomt II Prolem: Design DFA A such tht L(A) consists of ll strings of nd which re of length 3n, for n = 0, 1, 2, (1) Determine wht to rememer out the input string Assign stte to ech of
More informationNondeterministic Finite Automata
Nondeterministic Finite Automt From Regulr Expressions to NFA Eliminting nondeterminism Rdoud University Nijmegen Nondeterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion
More informationOverview HC9. Parsing: TopDown & LL(1) ContextFree Grammars (1) Introduction. CFGs (3) ContextFree Grammars (2) Vertalerbouw HC 9: Ch.
Overview H9 Vertlerouw H 9: Prsing: opdown & LL(1) do 3 mei 2001 56 heo Ruys h. 8  Prsing 8.1 ontextfree Grmmrs 8.2 opdown Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough
More informationNondeterminism and Nodeterministic Automata
Nondeterminism nd Nodeterministic Automt 61 Nondeterminism nd Nondeterministic Automt The computtionl mchine models tht we lerned in the clss re deterministic in the sense tht the next move is uniquely
More information3 Regular expressions
3 Regulr expressions Given n lphet Σ lnguge is set of words L Σ. So fr we were le to descrie lnguges either y using set theory (i.e. enumertion or comprehension) or y n utomton. In this section we shll
More informationa b b a pop push read unread
A Finite Automton A Pushdown Automton 0000 000 red unred b b pop red unred push 2 An Exmple A Pushdown Automton Recll tht 0 n n not regulr. cn push symbols onto the stck cn pop them (red them bck) lter
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 informationFABER Formal Languages, Automata and Models of Computation
DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University 2015 1 Recp of lecture 4 y definition suset construction DFA NFA stte
More informationSpeech Recognition Lecture 2: Finite Automata and FiniteState Transducers. Mehryar Mohri Courant Institute and Google Research
Speech Recognition Lecture 2: Finite Automt nd FiniteStte Trnsducers Mehryr Mohri Cournt Institute nd Google Reserch mohri@cims.nyu.com Preliminries Finite lphet Σ, empty string. Set of ll strings over
More informationFirst Midterm Examination
2425 Fll Semester First Midterm Exmintion ) Give the stte digrm of DFA tht recognizes the lnguge A over lphet Σ = {, } where A = {w w contins or } 2) The following DFA recognizes the lnguge B over lphet
More informationParse trees, ambiguity, and Chomsky normal form
Prse trees, miguity, nd Chomsky norml form In this lecture we will discuss few importnt notions connected with contextfree grmmrs, including prse trees, miguity, nd specil form for contextfree grmmrs
More informationTHEOTY OF COMPUTATION
Pushdown utomt nd Prsing lgorithms: Pushdown utomt nd contextfree lnguges; Deterministic PDNondeterministic PD Equivlence of PD nd CFGclosure properties of CFL. PUSHDOWN UTOMT ppliction: Regulr lnguges
More informationSome Theory of Computation Exercises Week 1
Some Theory of Computtion Exercises Week 1 Section 1 Deterministic Finite Automt Question 1.3 d d d d u q 1 q 2 q 3 q 4 q 5 d u u u u Question 1.4 Prt c  {w w hs even s nd one or two s} First we sk whether
More informationNondeterminism. Nondeterministic Finite Automata. Example: Moves on a Chessboard. Nondeterminism (2) Example: Chessboard (2) Formal NFA
Nondeterminism Nondeterministic Finite Automt Nondeterminism Subset Construction A nondeterministic finite utomton hs the bility to be in severl sttes t once. Trnsitions from stte on n input symbol cn
More informationState Minimization for DFAs
Stte Minimiztion for DFAs Red K & S 2.7 Do Homework 10. Consider: Stte Minimiztion 4 5 Is this miniml mchine? Step (1): Get rid of unrechle sttes. Stte Minimiztion 6, Stte is unrechle. Step (2): Get rid
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 informationCS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)
CS 373, Spring 29. Solutions to Mock midterm (sed on first midterm in CS 273, Fll 28.) Prolem : Short nswer (8 points) The nswers to these prolems should e short nd not complicted. () If n NF M ccepts
More informationa,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
CS4 45 Determinisitic Finite Automt : Genertors vs. Checkers Regulr expressions re one wy to specify forml lnguge String Genertor Genertes strings in the lnguge Deterministic Finite Automt (DFA) re nother
More informationWorked out examples Finite Automata
Worked out exmples Finite Automt Exmple Design Finite Stte Automton which reds inry string nd ccepts only those tht end with. Since we re in the topic of Non Deterministic Finite Automt (NFA), we will
More informationDeterministic FiniteState Automata
Deterministic FiniteStte Automt Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 12 August 2013 Outline 1 Introduction 2 Exmple DFA 1 DFA for Odd number of
More informationCHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Nondeterministic Finite Automata (NFA)
Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Nondeterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr
More informationSpeech Recognition Lecture 2: Finite Automata and FiniteState Transducers
Speech Recognition Lecture 2: Finite Automt nd FiniteStte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.
More informationGNFA GNFA GNFA GNFA GNFA
DFA RE NFA DFA NFA REX GNFA Definition GNFA A generlize noneterministic finite utomton (GNFA) is grph whose eges re lele y regulr expressions, with unique strt stte with inegree, n unique finl stte with
More informationI. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines
CI 3104 /Winter 2011: Introduction to Forml Lnguges Chpter 16: NonContextFree Lnguges Chpter 16: NonContextFree Lnguges I. Theory of utomt II. Theory of Forml Lnguges III. Theory of Turing Mchines
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 Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed
More informationCSCI FOUNDATIONS OF COMPUTER SCIENCE
1 CSCI 2200 FOUNDATIONS OF COMPUTER SCIENCE Spring 2015 My 7, 2015 2 Announcements Homework 9 is due now. Some finl exm review problems will be posted on the web site tody. These re prcqce problems not
More informationScanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:
Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes
More information1 Nondeterministic Finite Automata
1 Nondeterministic Finite Automt Suppose in life, whenever you hd choice, you could try oth possiilities nd live your life. At the end, you would go ck nd choose the one tht worked out the est. Then you
More informationNFAs continued, Closure Properties of Regular Languages
Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel HrPeled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,
More informationɛclosure, Kleene s Theorem,
DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛclosure, Kleene
More informationCS 330 Formal Methods and Models
CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2017 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 2 1. Prove ((( p q) q) p) is tutology () (3pts) y truth tle. p q p q
More informationAutomata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ωautomata. Ralf Huuck.
Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ωautomt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent
More informationTutorial Automata and formal Languages
Tutoril Automt nd forml Lnguges Notes for to the tutoril in the summer term 2017 Sestin Küpper, Christine Mik 8. August 2017 1 Introduction: Nottions nd sic Definitions At the eginning of the tutoril we
More informationPART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA
PART 2. REGULAR LANGUAGES, GRAMMARS AND AUTOMATA RIGHT LINEAR LANGUAGES. Right Liner Grmmr: Rules of the form: A α B, A α A,B V N, α V T + Left Liner Grmmr: Rules of the form: A Bα, A α A,B V N, α V T
More informationLexical Analysis Finite Automate
Lexicl Anlysis Finite Automte CMPSC 470 Lecture 04 Topics: Deterministic Finite Automt (DFA) Nondeterministic Finite Automt (NFA) Regulr Expression NFA DFA A. Finite Automt (FA) FA re grph, like trnsition
More informationTuring Machines Part One
Turing Mchines Prt One Wht problems cn we solve with computer? Regulr Lnguges CFLs Lnguges recognizble by ny fesible computing mchine All Lnguges Tht sme drwing, to scle. All Lnguges The Problem Finite
More information5.1 Definitions and Examples 5.2 Deterministic Pushdown Automata
CSC4510 AUTOMATA 5.1 Definitions nd Exmples 5.2 Deterministic Pushdown Automt Definitions nd Exmples A lnguge cn be generted by CFG if nd only if it cn be ccepted by pushdown utomton. A pushdown utomton
More informationChapter 2 Finite Automata
Chpter 2 Finite Automt 28 2.1 Introduction Finite utomt: first model of the notion of effective procedure. (They lso hve mny other pplictions). The concept of finite utomton cn e derived y exmining wht
More informationCISC 4090 Theory of Computation
9/6/28 Stereotypicl computer CISC 49 Theory of Computtion Finite stte mchines & Regulr lnguges Professor Dniel Leeds dleeds@fordhm.edu JMH 332 Centrl processing unit (CPU) performs ll the instructions
More informationCS375: Logic and Theory of Computing
CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 14) Weeks
More informationW. We shall do so one by one, starting with I 1, and we shall do it greedily, trying
Vitli covers 1 Definition. A Vitli cover of set E R is set V of closed intervls with positive length so tht, for every δ > 0 nd every x E, there is some I V with λ(i ) < δ nd x I. 2 Lemm (Vitli covering)
More informationHomework Solution  Set 5 Due: Friday 10/03/08
CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution  et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte nonfinl.
More information1 Structural induction
Discrete Structures Prelim 2 smple questions Solutions CS2800 Questions selected for Spring 2018 1 Structurl induction 1. We define set S of functions from Z to Z inductively s follows: Rule 1. For ny
More informationLet's start with an example:
Finite Automt Let's strt with n exmple: Here you see leled circles tht re sttes, nd leled rrows tht re trnsitions. One of the sttes is mrked "strt". One of the sttes hs doule circle; this is terminl stte
More informationCS 310 (sec 20)  Winter Final Exam (solutions) SOLUTIONS
CS 310 (sec 20)  Winter 2003  Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)
More informationSWEN 224 Formal Foundations of Programming WITH ANSWERS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Time Allowed: 3 Hours EXAMINATIONS 2011 ENDOFYEAR SWEN 224 Forml Foundtions of Progrmming
More informationNon Deterministic Automata. Formal Languages and Automata  Yonsei CS 1
Non Deterministic Automt Forml Lnguges nd Automt  Yonsei CS 1 Nondeterministic Finite Accepter (NFA) We llow set of possible moves insted of A unique move. Alphbet = {} Two choices q 1 q2 Forml Lnguges
More informationConvert the NFA into DFA
Convert the NF into F For ech NF we cn find F ccepting the sme lnguge. The numer of sttes of the F could e exponentil in the numer of sttes of the NF, ut in prctice this worst cse occurs rrely. lgorithm:
More informationRelating logic to formal languages
Relting logic to forml lnguges Kml Lody The Institute of Mthemticl Sciences, Chenni October 2018 Reding 1. Howrd Strubing: Forml lnguges, finite utomt nd circuit complexity, birkhäuser. 2. Wolfgng Thoms:
More informationMore on automata. Michael George. March 24 April 7, 2014
More on utomt Michel George Mrch 24 April 7, 2014 1 Automt constructions Now tht we hve forml model of mchine, it is useful to mke some generl constructions. 1.1 DFA Union / Product construction Suppose
More informationI. Theory of Automata II. Theory of Formal Languages III. Theory of Turing Machines
CI 3104 /Winter 2011: Introduction to Forml Lnguges Chter 13: Grmmticl Formt Chter 13: Grmmticl Formt I. Theory of Automt II. Theory of Forml Lnguges III. Theory of Turing Mchines Dr. Neji Zgui CI3104W11
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 CMSC 330 1 Types of Finite Automt Deterministic Finite Automt (DFA) Exctly one sequence of steps for ech string All exmples so fr Nondeterministic
More information