@#? Text Search ] { "!" Nondeterministic Finite Automata. Transformation NFA to DFA and Simulation of NFA. Text Search Using Automata
|
|
- Todd Edwards
- 5 years ago
- Views:
Transcription
1 g Text ~ Mrko Berezovský Rdek Mřík PAL 0 Nondeterministi Finite Automt n Trnsformtion NFA to DFA nd Simultion of NFA f Text Serh Using Automt A B R Power of Nondeterministi Approh u j Regulr Expression Serh u Deling with trnsitions ] { k e! "!" 4 N q u
2 NFA, DFA & Text serh Referenes 0 Lnguges, grmmrs, utomt Czeh instnt soures: [] M. Demlová: A4B0JAG Pges -7, in PAL, you my wish to skip: Proofs, hpters.4,.,.. [] I. Černá, M. Křetínský, A. Kučer: Automty formální jzyky I utomty_i.pdf Chpters nd, skip sme prts s in []. English soures: [] B. Melihr, J. Holu, T. Polr: Text Serh Algorithms Chpters.4 nd., it is proly too short, there is nothing to skip. [4] J. E. Hoproft, R. Motwni, J. D. Ullmn: Introdution to Automt Theory folow the link t Chpters.,.,., there is lot to skip, onsult the teher preferly. For more referenes see PAL links pges (CZ) (EN)
3 Finite Automt Overview Deterministi Finite Automton (DFA) Nondeterministi Finite Automton (NFA) A 0 0 Both DFA nd NFA onsist of: Finite input lphet. Finite set of internl sttes Q. One strting stte q 0 Q. Nonempty set of ept sttes F Q. Trnsition funtion. A , 0 0 DFA trnsition funtion is :Q Q. DFA is lwys in one of its sttes q Q. DFA trnsits from urrent stte to nother stte depending on the urrent input symol. NFA trnsition funtion is : Q P(Q) (P(Q) is the powerset of Q) NFA is lwys (simultneously) in set of some numer of its sttes. NFA trnsits from set of sttes to nother set of sttes depending on the urrent input symol.
4 Indeterminism Bsis NFA A, its trnsition digrm nd its trnsition tle A 0 4 7,, sttes lphet 0,4 F 4, 0 4,7, F ept sttes mrked
5 Indeterminism NFA A proessing input word NFA t work 0 4 A 0 4 7,, 4 Ative sttes 7,, ,,,, ontinue...
6 Indeterminism NFA t work 4...ontinued ,, 0 4 7,, 0 4 7,, Aepted! NFA A hs proessed the word nd went through the input hrters nd respetive sets(!) of sttes {0} {} {, 4} {0,, 7, } {,, 7} {0, 4,, }.
7 Indeterminism Simultion NFA simultion without trnsform to DFA Eh of the urrent sttes is oupied y one token. Red n input symol nd move the tokens ordingly. If token hs more movement possiilities it will split into two or more tokens, if it hs no movement possiility it will leve the ord, uhm, the trnsition digrm. Red from input
8 Indeterminism Simultion Input: NFA, text in rry t NFA simultion without trnsform to DFA Ide: Register ll sttes to whih you hve just rrived. In the next step, red the input symol x nd move SIMULTANEOUSLY to ALL sttes to whih you n get from ALL tive sttes long trnsitions mrked y x. SetOfSttes S = {q0}, S_tmp; i = ; while( (i <= t.length) && (!S.isEmpty()) ) { S_tmp = Set.emptySet(); for( q in S ) // for eh stte in S S_tmp.union( delt(q, t[i]) ); S = S_tmp; i++; } return S.ontinsFinlStte(); // true or flse
9 NFA to DFA Algorithm 7 Generting DFA A equivlent to NFA A using trnsition tles Dt Eh stte of DFA is suset of sttes of NFA. Strt stte of DFA is n one-element set ontining the strt stte of NFA. A stte of DFA is n ept stte iff it ontins t lest one ept stte of NFA. Constrution Crete the strt stte of DFA nd the orresponding first line of its trnsition tle (TT). For eh stte Q of DFA not yet proessed do { Deompose Q into its onstituent sttes Q,..., Qk of NFA For eh symol x of lphet do { S = union of ll referenes in NFA tle t positions [Q] [x],..., [Qk][x] if (S is not mong sttes of DFA yet) dd S to the sttes of DFA nd dd orresponding line to TT of DFA } Mrk Q s proessed } // Rememer, empty set is lso set ot sttes, it n e stte of DFA
10 NFA to DFA Exmple Generting DFA A equivlent to NFA A A 0,4 F 4, 0 4,7, F ,, A Copy strt stte 0... Add new stte(s) 0... ontinue...
11 NFA to DFA Exmple 9 Generting DFA A equivlent to NFA A 0,4 F 4, 0 4,7, F Add new stte(s) A 0 4 F 4... A 0 4 7,, ontinue...
12 NFA to DFA Exmple 0 Generting DFA A equivlent to NFA A 0,4 F 4, 0 4,7, F Add new stte(s) A 0 4 F A 0 4 7,, ontinue...
13 NFA to DFA Exmple Generting DFA A equivlent to NFA A 0,4 F 4, 0 4,7, F Add new stte(s) A 0 4 F A 0 4 7,, ontinue...
14 NFA to DFA Exmple Generting DFA A equivlent to NFA A A 0,4 F 4, 0 4,7, F ,, Add new stte(s) A 0 4 F F ontinue...
15 NFA to DFA Exmple Generting DFA A equivlent to NFA A A 0,4 F 4, 0 4,7, F No new stte 7,, Add new stte(s) A 0 4 F F ontinue...
16 NFA to DFA Exmple 4 Generting DFA A equivlent to NFA A A 0,4 F 4, 0 4,7, F ,, Add new stte(s) A 0 4 F F ontinue...
17 NFA to DFA Exmple Generting DFA A equivlent to NFA A A 0,4 F 4, 0 4,7, F ,, Add new stte(s) A 0 4 F F ontinue...
18 NFA to DFA Exmple Generting DFA A equivlent to NFA A A 0,4 F 4, 0 4,7, F ,, A Add new stte(s) 0 4 F F F ontinue... ontinue... ontinue...
19 NFA to DFA Exmple 7 0 n DFA A equivlent to NFA A A A...FINISHED! 0,4 F 4, 0 4,7, F ,, n 4 n F 4 n n 4 n 07 4 n 7 F 0 n n n 7 7 n n n F 7 04 n 7 n n 7 0 n n F 4 04 n F 0 0 n 0 4 n F 4 4 n n F 47 7 F 07 7 n 07 n 0 4 n 04 n n 4 7 F n n n n
20 Text Serh Repetition To e used with gret ution! Nïve pproh. Align the pttern with the eginning of the text.. While orresponding symols of the pttern nd the text mth eh other move forwrd y one symol in the pttern.. When symol mismth ours shift the pttern forwrd y one symol, reset position in the pttern to the eginning of the pttern nd go to. 4. When the end of the pttern is pssed report suess, shift the pttern forwrd y one symol, reset position in the pttern to its eginning nd go to.. When the end of the text is rehed stop. Might e effiient in fvourle text Strt text. Pttern shift... text... pttern x pttern x fter while: et... text pttern... x mth mismth
21 Text Serh Bsis 9 Alphet: Finite set of symols. Text: Sequene of symols of the lphet. Pttern: Sequene of symols of the sme lphet. Gol: Pttern ourene is to e deteted in the text. Text is often fixed or seldom hnged, pttern typilly vries (looking for different words in the sme doument), pttern is often signifintly shorter thn the text. Nottion Alphet: Symols in the text: t, t,, t n. Symols in the pttern: p, p,, p m. It holds m n, usully m << n Exmple Text:...tsk is very simple ut it is used very freq... Pttern: simple
22 Power of Indeterminism Exmples 0 NFA A whih epts just single word p p p p 4. A 0 p p p p 4 4 NFA A 4 whih epts eh word with suffix p p p p 4 nd its trnsition tle. A 4 p 0 p p p 4 4 p p p p 4 z 0 0, F z {p, p, p, p4}
23 Power of Indeterminism Esy desription A 4 repeted 0 NFA A 4 whih epts eh word with suffix p p p p 4 nd its trnsition tle. p p p p 4 4 p p p p 4 z 0 0, F z {p, p, p, p4} equivlently DFA A is deterministi equivlent of NFA A 4. A x = {x} p p p p p p p p p,p 4,z p,p 4,z p,p,z p p p p p p 4 z F Supposing p p p p 4 re mutully different!
24 Power of Indeterminism Esy onstrution A exmple 0 NFA A whih epts eh word with suffix nd its trnsition tle 4 z 0 0, F z {, } DFA A 7 is deterministi equivlent of NFA A. It lso epts eh word with suffix. A 7,z z z,z z z F Note the struturl differene etween A nd A 7.
25 Power of Indeterminism Simple exmples NFA epting extly one word p p p p 4. 0 p p p p 4 4 NFA epting ny word with suffix p p p p 4. 0 p p p p 4 4 NFA epting ny word with sustring (ftor) p p p p 4 nywhere in it. A 0 p p p p 4 4
26 Power of Indeterminism Esy modifitions 4 NFA epting ny word with sustring (ftor) p p p p 4 nywhere in it. 0 p p p p 4 4 Cn e used for serhing, ut the following redution is more frequent. Text serh NFA for finding pttern P = p p p p 4 in the text. 0 p p p p 4 4 NFA stops when pttern is found. Wnt to know the position of the pttern in the text? Equip the trnsitions with ounter. [pos=0] 0, [pos++] p p p p 4 4
27 Power of Indeterminism Exmples Exmple NFA epting ny word with susequene p p p p 4 nywhere in it. 0 p p p p 4 4 Exmple NFA epting ny word with susequene p p p p 4 nywhere in it, one symol in the sequene my e ltered. p p p p p p p 4 7 Alterntively: NFA epting ny word ontining susequene Q whose Hmming distne from p p p p 4 is t most.
28 Lnguges Hierrhy Wider piture Serh NFA n serh for more thn one pttern simultneously. The numer of ptterns n e finite -- this leds lso to ditionry utomton (we will meet it lter) or infinite -- this leds to regulr lnguge. Chomsky lnguge hierrhy reminder Grmmr Lnguge Automton Type-0 Type- Type- Type- Reursively enumerle Turing mhine Context-sensitive Liner-ounded non-deterministi Turing mhine Context-free Non-deterministi pushdown utomton Regulr Finite stte utomton (NFA or DFA) Only regulr lnguges n e proessed y NFA/DFA. More omplex lnguges nnot. For exmple, ny lnguge ontining well-formed prentheses is ontext-free nd not regulr nd nnot e reognized y NFA/DFA.
29 Regulr Lnguges A reminder 7 Opertions on regulr lnguges Let L nd L e ny lnguges. Then L L is union of L nd L. It is set of ll words whih re in L or in L. L.L is ontention of L nd L. It is set of ll words w for whih holds w = w w (ontention of words w nd w ), where w L nd w L. L * is Kleene str or Kleene losure of lnguge L. It is set of ll words whih re ontentions of ny numer (inl. zero) of ny words of L in ny order. Closure property Whenever L nd L re regulr lnguges then L L, L.L, L * re regulr lnguges too. Exmple L = {00, 000, 0000,...}, L = {0, 0, 0,...}. L L = {00, 0, 000, 0, 000, 0,...} L.L = {000, 000, 000,..., 0000, 0000, 0000,... } L * = {, 00, 0000, , , ,......, , ,... } // this one is not esy to list niely... or is it?
30 Regulr Expressions Another reminder Regulr expressions defined reursively Symol is regulr expression. Eh symol of lphet is regulr expression. Whenever e nd e re regulr expressions then lso strings (e ), e +e, e e, (e ) * re regulr expressions. Lnguges represented y regulr expressions (RE) defined reursively RE represents lnguge ontining only empty string. RE x, where x, represents lnguge {x}. Let RE's e nd e represent lnguges L nd L. Then RE (e ) represents L, RE e +e represents L L, REs e e, e.e represent L.L, RE (e ) * represents L *. Exmples 0+(0+) * ll integers in inry without leding 0's 0.(0+) * ll finite inry frtions (0, ) without triling 0's ((0+)( ) + (0+++)):( )( ) ll 440 dy's times in formt hh:mm from 00:00 to :9 (mon+(wedne+t(ue+hur))s+fri+s(tur+un))dy English nmes of dys in the week ( )( ) * ((+7)+(+0)0) ll deiml integers 00 divisile y
31 Regulr Expressions Conversion to NFA 9 Convert regulr expression to NFA Input: Regulr expression R ontining n hrters of the given lphet. Output: NFA reognizing lnguge L(R) desried y R. Crete strt stte S for eh k ( k n) { ssign index k to the k-th hrter in R // this mkes ll hrters in R unique: [], [],..., [n]. rete stte S[k] // S[k] orresponds diretly to [k] } for eh k ( k n) { if [k] n e the first hrter in some string desried y R then rete trnsition S S[k] leled y [k] with index stripped off if [k] n e the lst hrter in some string desried y R then mrk S[k] s finl stte for eh p ( p n) if ([k] n follow immeditely fter [p] in some string desried y R) then rete trnsition S[p] S[k] leled y [k] with index stripped off }
32 Regulr Expression to NFA Exmple 0 Regulr expression R = *( + *)* + Add indies: R = * ( + 4 * )* + 7 NFA epts L(R) S S7 4 S
33 Regulr Expressions Serh NFA NFA serhes the text for ny ourene of ny word of L(R) R = * ( + *)* + S S7 The only differene from the NFA epting R 4 S
34 Regulr Expressions More pplitions Bonus To find susequene representing word L(R), where R is regulr expression, do the following: Crete NFA epting L(R) Add self loops to the sttes of NFA:. Self loop leled y (whole lphet) t the strt stte.. Self loop leled {x} t eh stte whose outgoing trnsition(s) re leled y single x. // serves s n "optimized" wit loop. Self loop leled y t eh stte whose outgoing trnsition(s) re leled y more thn single symol from. // serves s n "usul" wit loop 4. No self loop to ll other sttes. // whih hve no outgoing loop = finl ones
35 Regulr Expressions Susequene serh Bonus NFA serhes the text for ny ourene of ny susequene representing word of L(R) R = + ( + )*, S S,,,, 4 7 S9
36 Regulr Expressions Effetivity of NFA 4 Trnsforming NFA whih serhes text for n ourene of word of given regulr lnguge into the equivlent DFA might tke exponentil spe nd thus lso exponentil time. Not lwys, ut sometimes yes: Consider regulr expression R = (+)(+)...(+) over lphet {, }. Text serh NFA for R NFA, 0,,,, n Mystery Text serh NFA for R, why not this one? NFA, 0 4 7
37 Regulr Expressions Effetivity of NFA R = (+)(+) Text serh NFA for R, 0,, NFA tle 0 0, Text serh DFA for R DFA tle
38 Epsilon Trnsitions Definition/exmple Serh the text for more thn just ext mth NFA with trnsitions The trnsition from one stte to nother n e performed without reding ny input symol. Suh trnsition is leled y symol. losure Symol CLOSURE(p) denotes the set of ll sttes q, whih n e rehed from stte p using only trnsitions. By definition, let CLOSURE(p) = {p} when there is no trnsition out from p. CLOSURE(0) = {,, 4} CLOSURE() = {} CLOSURE() = {, 4} CLOSURE() = {}... A 9 0, 4
39 Epsilon Trnsitions Removl 7 Constrution of equivlent NFA without trnsitions Input: NFA A with some trnsitions. Output: NFA A' without trnsitions.. A' = ext opy of A.. Remove ll trnsitions from A'.. In A' for eh (q, ) do: dd to the set (p,) ll suh sttes r for whih it holds q CLOSURE(p) nd (q,) =r. 4. Add to the set of finl sttes F in A' ll sttes p for whih it holds CLOSURE(p) F. esy onstrution p q, r t p, q, r t
40 Epsilon Trnsitions Removed, 4 0 NFA with s trnsitions, 4 0, Equivlent NFA without trnsitions New trnsitions nd ept sttes re highlighted
41 Epsilon Trnsitions Applition 9 NFA for serh for ny unempty sustring of pttern p p p p 4 over lphet. Note the trnsitions. 0 A p p p p 4 4 p p p p p 4 0 p 4 Powerful trik! Union of two or more NFA: Crete dditionl strt stte S nd dd trnsitions from S to strt sttes of ll involved NFA's. Drw n exmple yourself!
42 Epsilon Trnsitions Applition ont. 40 Equivlent NFA for serh for ny unempty sustring of pttern p p p p 4 with trnsitions removed. A 0 p p p p 4 4 p p p p 4 7 p p p 4 9 p 0 p 4 p 4 Sttes, 9, re unrehle. Trnsformtion lgorithm NFA -> DFA if pplied, will neglet them. p 4 p 4
43 Epsilon Trnsitions Removed / DFA 4 p p p p 4 z 0 0, 0, 0,0 0, 0 0 F 0 F 4 0 F 4 0 F F 7 0 F 0 F F 0 F 0 0 F p p p p 4 z F F F F F F F F F F Trnsition tle of NFA ove without trnsitions. Trnsition tle of DFA whih is equivlent to previous NFA. DFA in this se hs less sttes thn the equivlent NFA. Q: Does it hold for ny utomton of this type? Proof?
44 Text Serh with epsilon trnsitions 4 Text serh using NFA simultion without trnsform to DFA Input: NFA, text in rry t, SetOfSttes S = eps_closure(q0), S_tmp; int i = ; while ((i <= t.length) && (!S.empty())) { for (q in S) // for eh stte in S if (q.isfinl) print(q.finl_stte_info); // pttern found } S_tmp = Set.empty(); // trnsiton to next for (q in S) // set of sttes S_tmp.union(eps_CLOSURE(delt(q, t[i]))); S = S_tmp; i++; // next hr in text return S.ontinsFinlStte(); // true or flse
Regular languages refresher
Regulr lnguges refresher 1 Regulr lnguges refresher Forml lnguges Alphet = finite set of letters Word = sequene of letter Lnguge = set of words Regulr lnguges defined equivlently y Regulr expressions Finite-stte
More informationCS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6
CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized
More informationFinite State Automata and Determinisation
Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016 Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions
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 informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS
The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their
More informationCS 573 Automata Theory and Formal Languages
Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple
More informationNON-DETERMINISTIC FSA
Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is
More informationNondeterministic Finite Automata
Nondeterministi Finite utomt The Power of Guessing Tuesdy, Otoer 4, 2 Reding: Sipser.2 (first prt); Stoughton 3.3 3.5 S235 Lnguges nd utomt eprtment of omputer Siene Wellesley ollege Finite utomton (F)
More informationCSE 401 Compilers. Today s Agenda
CSE 401 Compilers Leture 3: Regulr Expressions & Snning, on?nued Mihel Ringenurg Tody s Agend Lst?me we reviewed lnguges nd grmmrs, nd riefly strted disussing regulr expressions. Tody I ll restrt the regulr
More information= state, a = reading and q j
4 Finite Automt CHAPTER 2 Finite Automt (FA) (i) Derterministi Finite Automt (DFA) A DFA, M Q, q,, F, Where, Q = set of sttes (finite) q Q = the strt/initil stte = input lphet (finite) (use only those
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 CSI3104-W11 1
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 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 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 informationFinite Automata-cont d
Automt Theory nd Forml Lnguges Professor Leslie Lnder Lecture # 6 Finite Automt-cont d The Pumping Lemm WEB SITE: http://ingwe.inghmton.edu/ ~lnder/cs573.html Septemer 18, 2000 Exmple 1 Consider L = {ww
More informationConverting 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 informationNondeterministic Automata vs Deterministic Automata
Nondeterministi Automt vs Deterministi Automt We lerned tht NFA is onvenient model for showing the reltionships mong regulr grmmrs, FA, nd regulr expressions, nd designing them. However, we know tht n
More information2.4 Theoretical Foundations
2 Progrmming Lnguge Syntx 2.4 Theoretil Fountions As note in the min text, snners n prsers re se on the finite utomt n pushown utomt tht form the ottom two levels of the Chomsky lnguge hierrhy. At eh level
More informationTypes of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.
CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt
More informationTypes of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2
CMSC 330: Orgniztion of Progrmming Lnguges Finite Automt 2 Types of Finite Automt Deterministic Finite Automt () Exctly one sequence of steps for ech string All exmples so fr Nondeterministic Finite Automt
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 informationTechnische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution
Tehnishe Universität Münhen Winter term 29/ I7 Prof. J. Esprz / J. Křetínský / M. Luttenerger. Ferur 2 Solution Automt nd Forml Lnguges Homework 2 Due 5..29. Exerise 2. Let A e the following finite utomton:
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 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 informationData Structures and Algorithm. Xiaoqing Zheng
Dt Strutures nd Algorithm Xioqing Zheng zhengxq@fudn.edu.n String mthing prolem Pttern P ours with shift s in text T (or, equivlently, tht pttern P ours eginning t position s + in text T) if T[s +... s
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 informationPrefix-Free Regular-Expression Matching
Prefix-Free Regulr-Expression Mthing Yo-Su Hn, Yjun Wng nd Derik Wood Deprtment of Computer Siene HKUST Prefix-Free Regulr-Expression Mthing p.1/15 Pttern Mthing Given pttern P nd text T, find ll sustrings
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 informationLecture 08: Feb. 08, 2019
4CS4-6: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 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 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn
More informationRunning an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/
Running n NFA & the suset lgorithm (NFA->DFA) CS 350 Fll 2018 gilry.org/lsses/fll2018/s350/ 1 NFAs operte y simultneously exploring ll pths nd epting if ny pth termintes t n ept stte.!2 Try n exmple: L
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 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 informationJava II Finite Automata I
Jv II Finite Automt I Bernd Kiefer Bernd.Kiefer@dfki.de Deutsches Forschungszentrum für künstliche Intelligenz Finite Automt I p.1/13 Processing Regulr Expressions We lredy lerned out Jv s regulr expression
More informationDeterministic Finite Automata
Finite Automt Deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion Sciences Version: fll 2016 J. Rot Version: fll 2016 Tlen en Automten 1 / 21 Outline Finite Automt Finite
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 informationFirst Midterm Examination
24-25 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 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 informationFirst Midterm Examination
Çnky University Deprtment of Computer Engineering 203-204 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 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 Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,
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 1-4) Weeks
More informationFormal Language and Automata Theory (CS21004)
Forml Lnguge nd Automt Forml Lnguge nd Automt Theory (CS21004) Khrgpur Khrgpur Khrgpur Forml Lnguge nd Automt Tle of Contents Forml Lnguge nd Automt Khrgpur 1 2 3 Khrgpur Forml Lnguge nd Automt Forml Lnguge
More informationCHAPTER 1 Regular Languages. Contents
Finite Automt (FA or DFA) CHAPTE 1 egulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, euivlence of NFAs nd DFAs, closure under regulr
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 informationNFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.
NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD
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 informationCompiler Design. Spring Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
University of Southern Cliforni Computer Siene Deprtment Compiler Design Spring 7 Lexil Anlysis Smple Exerises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sienes Institute 47 Admirlty Wy, Suite
More informationCS241 Week 6 Tutorial Solutions
241 Week 6 Tutoril olutions Lnguges: nning & ontext-free Grmmrs Winter 2018 1 nning Exerises 1. 0x0x0xd HEXINT 0x0 I x0xd 2. 0xend--- HEXINT 0xe I nd ER -- MINU - 3. 1234-120x INT 1234 INT -120 I x 4.
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 informationSpeech Recognition Lecture 2: Finite Automata and Finite-State Transducers
Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Eugene Weinstein Google, NYU Cournt Institute eugenew@cs.nyu.edu Slide Credit: Mehryr Mohri Preliminries Finite lphet, empty string.
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 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 informationLanguages & Automata
Lnguges & Automt Dr. Lim Nughton Lnguges A lnguge is sed on n lphet which is finite set of smols such s {, } or {, } or {,..., z}. If Σ is n lphet, string over Σ is finite sequence of letters from Σ, (strings
More informationNon-deterministic Finite Automata
Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent
More informationGrammar. Languages. Content 5/10/16. Automata and Languages. Regular Languages. Regular Languages
5//6 Grmmr Automt nd Lnguges Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Prof. Mohmed Hmd Softwre Engineering L. The University of Aizu Jpn Regulr Lnguges Context Free Lnguges Context Sensitive
More informationCMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014
CMPSCI 250: Introduction to Computtion Lecture #31: Wht DFA s Cn nd Cn t Do Dvid Mix Brrington 9 April 2014 Wht DFA s Cn nd Cn t Do Deterministic Finite Automt Forml Definition of DFA s Exmples of DFA
More informationCS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata
CS103B ndout 18 Winter 2007 Ferury 28, 2007 Finite Automt Initil text y Mggie Johnson. Introduction Severl childrens gmes fit the following description: Pieces re set up on plying ord; dice re thrown or
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 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 informationFinite-State Automata: Recap
Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under
More informationCHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)
Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr
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 informationThoery of Automata CS402
Thoery of Automt C402 Theory of Automt Tle of contents: Lecture N0. 1... 4 ummry... 4 Wht does utomt men?... 4 Introduction to lnguges... 4 Alphets... 4 trings... 4 Defining Lnguges... 5 Lecture N0. 2...
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 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 informationTable of contents: Lecture N Summary... 3 What does automata mean?... 3 Introduction to languages... 3 Alphabets... 3 Strings...
Tle of contents: Lecture N0.... 3 ummry... 3 Wht does utomt men?... 3 Introduction to lnguges... 3 Alphets... 3 trings... 3 Defining Lnguges... 4 Lecture N0. 2... 7 ummry... 7 Kleene tr Closure... 7 Recursive
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 informationLexical Analysis Part III
Lexicl Anlysis Prt III Chpter 3: Finite Automt Slides dpted from : Roert vn Engelen, Florid Stte University Alex Aiken, Stnford University Design of Lexicl Anlyzer Genertor Trnslte regulr expressions to
More informationNon-deterministic Finite Automata
Non-deterministic Finite Automt From Regulr Expressions to NFA- Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd J. Rot Institute for Computing nd Informtion
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 in-egree, n unique finl stte with
More informationNFAs continued, Closure Properties of Regular Languages
lgorithms & Models of omputtion S/EE 374, Spring 209 NFs continued, losure Properties of Regulr Lnguges Lecture 5 Tuesdy, Jnury 29, 209 Regulr Lnguges, DFs, NFs Lnguges ccepted y DFs, NFs, nd regulr expressions
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 informationChapter 4 State-Space Planning
Leture slides for Automted Plnning: Theory nd Prtie Chpter 4 Stte-Spe Plnning Dn S. Nu CMSC 722, AI Plnning University of Mrylnd, Spring 2008 1 Motivtion Nerly ll plnning proedures re serh proedures Different
More informationCS415 Compilers. Lexical Analysis and. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University
CS415 Compilers Lexicl Anlysis nd These slides re sed on slides copyrighted y Keith Cooper, Ken Kennedy & Lind Torczon t Rice University First Progrmming Project Instruction Scheduling Project hs een posted
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 information1.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
Theory of Computtion Regulr Lnguges Bow-Yw Wng Acdemi Sinic Spring 2012 Bow-Yw 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 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 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 informationinput tape head moves current state
CPS 140 - Mthemticl Foundtions of CS Dr. Susn Rodger Section: Finite Automt (Ch. 2) (lecture notes) Things to do in clss tody (Jn. 13, 2004): ffl questions on homework 1 ffl finish chpter 1 ffl Red Chpter
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 informationContext-Free Grammars and Languages
Context-Free 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 informationState Complexity of Union and Intersection of Binary Suffix-Free Languages
Stte Complexity of Union nd Intersetion of Binry Suffix-Free Lnguges Glin Jirásková nd Pvol Olejár Slovk Ademy of Sienes nd Šfárik University, Košie 0000 1111 0000 1111 Glin Jirásková nd Pvol Olejár Binry
More informationHarvard University Computer Science 121 Midterm October 23, 2012
Hrvrd University Computer Science 121 Midterm Octoer 23, 2012 This is closed-ook exmintion. You my use ny result from lecture, Sipser, prolem sets, or section, s long s you quote it clerly. The lphet is
More informationSpeech Recognition Lecture 2: Finite Automata and Finite-State Transducers. Mehryar Mohri Courant Institute and Google Research
Speech Recognition Lecture 2: Finite Automt nd Finite-Stte Trnsducers Mehryr Mohri Cournt Institute nd Google Reserch mohri@cims.nyu.com Preliminries Finite lphet Σ, empty string. Set of ll strings over
More informationName Ima Sample ASU ID
Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to
More informationCompression of Palindromes and Regularity.
Compression of Plinromes n Regulrity. Kyoko Shikishim-Tsuji Center for Lierl Arts Eution n Reserh Tenri University 1 Introution In [1], property of likstrem t t view of tse is isusse n it is shown tht
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:10-18:30 Techer: Dniel Hedin, phone 021-107052 The exm
More informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER LANGUAGES AND COMPUTATION ANSWERS
The University of Nottinghm SCHOOL OF COMPUTER SCIENCE LEVEL 2 MODULE, SPRING SEMESTER 2016 2017 LNGUGES ND COMPUTTION NSWERS Time llowed TWO hours Cndidtes my complete the front cover of their nswer ook
More informationDescriptional Complexity of Non-Unary Self-Verifying Symmetric Difference Automata
Desriptionl Complexity of Non-Unry Self-Verifying Symmetri Differene Automt Lurette Mris 1,2 nd Lynette vn Zijl 1 1 Deprtment of Computer Siene, Stellenosh University, South Afri 2 Merk Institute, CSIR,
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 informationPetri Nets. Rebecca Albrecht. Seminar: Automata Theory Chair of Software Engeneering
Petri Nets Ree Alreht Seminr: Automt Theory Chir of Softwre Engeneering Overview 1. Motivtion: Why not just using finite utomt for everything? Wht re Petri Nets nd when do we use them? 2. Introdution:
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 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 informationTest Generation from Timed Input Output Automata
Chpter 8 Test Genertion from Timed Input Output Automt The purpose of this hpter is to introdue tehniques for the genertion of test dt from models of softwre sed on vrints of timed utomt. The tests generted
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 informationLecture 9: LTL and Büchi Automata
Lecture 9: LTL nd Büchi Automt 1 LTL Property Ptterns Quite often the requirements of system follow some simple ptterns. Sometimes we wnt to specify tht property should only hold in certin context, clled
More informationNon-Deterministic Finite Automata. Fall 2018 Costas Busch - RPI 1
Non-Deterministic 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 informationAutomata and Regular Languages
Chpter 9 Automt n Regulr Lnguges 9. Introution This hpter looks t mthemtil moels of omputtion n lnguges tht esrie them. The moel-lnguge reltionship hs multiple levels. We shll explore the simplest level,
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 information