FABER Formal Languages, Automata and Models of Computation
|
|
- Lee Walsh
- 5 years ago
- Views:
Transcription
1 DVA337 FABER Forml Lnguges, Automt nd Models of Computtion Lecture 5 chool of Innovtion, Design nd Engineering Mälrdlen University
2 Recp of lecture 4 y definition suset construction DFA NFA stte elimintion RE Thompson s construction (suset construction) nf-to-df (stte elimintion) nf-to-re (Thompson) re-to-nf implied: df-to-re(x) = nf-to-re(df) re-to-df(x) = nf-to-df(re-to-nf(x)) 2
3 Grmmrs Liner grmmrs right liner => NFA NFA => right liner Tody left liner => right liner Regulr grmmr left liner or right liner defines regulr lnguges DFA minimiztion stte reduction vi set prtitioning If time lexicl nlysis revisit 3
4 Grmmrs 4
5 Grmmrs Grmmrs express lnguges Exmple: the English lnguge sentence noun _ phrse predicte noun _ phrse rticle noun predicte ver 5
6 rticle rticle the noun noun ird dog ver ver sings rks 6
7 A derivtion of the ird sings : sentence noun _ phrse predicte rticle noun predicte rticle noun ver the noun ver the ird ver the ird sings 7
8 A derivtion of dog rks : sentence noun _ phrse predicte noun _ phrse ver rticle noun ver noun ver dog ver dog rks 8
9 The lnguge of the grmmr: L = {" " " " " " " " ird rks ", ird sings", the ird rks ", the ird sings", dog rks ", dog sings", the dog rks ", the dog sings" } } 9
10 Nottion noun noun ird dog Non-terminl (Vrile) Production rule Terminl 10
11 Exmple Grmmr: λ Derivtion of sentence: λ 11
12 Grmmr: λ Derivtion of sentence λ 12
13 Other derivtions 13
14 The lnguge of the grmmr λ L n n = { : n 0} 14
15 Forml Definition Grmmr G = ( V, T,, P) V T P : : : : et of vriles/non-terminls et of terminl symols trt symol et of production rules 15
16 Exmple Grmmr G λ G = ( V, T,, P) V = {} T = {, } P = {, λ} 16
17 ententil Form A sentence tht contins vriles nd terminls Exmple sententil forms entence 17
18 We write: * Insted of: 18
19 In generl we write w * 1 w n w 1 if w2 w3! w n By defult w * w ( ) 19
20 Exmple Grmmr Derivtions * λ λ * * * 20
21 Grmmr Exmple λ Derivtions * * 21
22 Another Grmmr Exmple Grmmr G Derivtions A A A A λ A A A A A 22
23 More Derivtions A A A A A n n 23
24 The Lnguge of Grmmr For grmmr G with strt vrile L( G) = { w: w} tring of terminls 24
25 For grmmr G Exmple A A A A λ n L( G) = { : n n 0} ince n n 25
26 Nottion A A λ A A A λ rticle rticle the rticle the 26
27 Liner Grmmrs 27
28 Liner Grmmrs Grmmrs with t most one vrile (non-terminl) t the right side of production Exmples: A λ A A A λ 28
29 A Non-Liner Grmmr Grmmr G λ L( G) = { w: n ( w) n ( w)} = 29
30 A Liner Grmmr Grmmr G A A B λ B A n n L( G) = { : n 0} 30
31 Right-Liner Grmmrs All productions hve form: A or xb A x Exmple 31
32 Left-Liner Grmmrs All productions hve form A or Bx A x Exmple A A A B B 32
33 Regulr Grmmrs A grmmr is regulr grmmr if nd only if it is right-liner or left-liner. 33
34 Regulr Grmmrs Generte Regulr Lnguges 34
35 Theorem Lnguges Generted y Regulr Grmmrs = Regulr Lnguges 35
36 Theorem - Prt 1 Lnguges Generted y Regulr Grmmrs Regulr Lnguges Any regulr grmmr genertes regulr lnguge 36
37 Theorem - Prt 2 Lnguges Generted y Regulr Grmmrs Regulr Lnguges Any regulr lnguge is generted y regulr grmmr 37
38 Proof Prt 1 Lnguges Generted y Regulr Grmmrs Regulr Lnguges The lnguge L(G) ny regulr grmmr generted y G is regulr 38
39 The cse of Right-Liner Grmmrs Let G e right-liner grmmr We will prove: L(G) is regulr Proof ide We will construct NFA with M ) L ( M ) = L( G 39
40 Grmmr G is right-liner Exmple A B A B B B 40
41 M Construct NFA such tht every stte is grmmr vrile: A B V F specil finl stte A B A B B B 41
42 Add edges for ech production: A V F B A B A B B B 42
43 A λ V F B A B A B B B 43
44 A λ V F A B B A B B B 44
45 A λ V F A B B A B B B 45
46 A λ V F A B B A B B B 46
47 A λ V F B A B B 47
48 NFA M A Grmmr G A B A B B B λ V F B L( M ) = L( G) = * + * 48
49 In Generl A right-liner grmmr G hs vriles: V0, V1, V2, nd productions: V! i or 1 2 m V j V i 1 2! m 49
50 We construct the NFA M such tht: ech vrile V i corresponds to node: V0 V1 V2. VF specil finl stte 50
51 For ech production: V! i 1 2 m V j we dd trnsitions nd intermedite nodes Vi 1 2 m V j Exmple: Convert Right-Liner Grmmr to FA y JFLAP 51
52 Exmple V V V V V V V V V 3 3 V V 8 4 V V 2 V V V 4 0 M 5 V F L ( G) = L( M ) 52
53 The cse of Left-Liner Grmmrs Let G e left-liner grmmr We will prove: L(G) is regulr Proof ide We will construct right-liner grmmr Gʹ with L ( G) = L( Gʹ ) R 53
54 ince G is left-liner grmmr the productions look like: A B! 1 2 k A 1 2! k 54
55 Construct right-liner grmmr Gʹ In G : A B! 1 2 k A vb In Gʹ : A k! 21B A v R B 55
56 Construct right-liner grmmr Gʹ In : G A 1 2! k A v Gʹ A k! 2 1 In : A v R 56
57 It is esy to see tht: L ( G) = L( Gʹ ) R ince Gʹ is right-liner, we hve: L(G ʹ R ) L ( Gʹ ) L(G) Regulr Lnguge Regulr Lnguge Regulr Lnguge 57
58 Proof - Prt 2 Lnguges Generted y Regulr Grmmrs Regulr Lnguges Any regulr lnguge L is generted y some regulr grmmr G 58
59 Any regulr lnguge L is generted y some regulr grmmr Proof ide ince L is regulr there is n NFA G M L = L(M ) such tht Construct from such tht M L ( M ) = L( G) regulr grmmr G 59
60 Exmple M q 0 q1 q2 λ L = * ( * )* q 3 L = L(M ) 60
61 Convert G M to right-liner grmmr q q 0 1 q q 1 1 M q0 q1 q2 q 1 q 2 λ q 2 q 3 q 3 q 3 q 1 L ( G) = L( M ) = L q 3 λ 61
62 In Generl For ny trnsition: q p Add production: q p vrile terminl vrile 62
63 For ny finl stte: q f Add production: q f λ 63
64 ince G is right-liner grmmr G is lso regulr grmmr with L ( G) = L( M ) = L 64
65 Regulr Grmmrs A regulr grmmr is ny right-liner or left-liner grmmr Exmples G1 G2 A A A B B 65
66 Oservtion Regulr grmmrs generte regulr lnguges Exmples G1 G2 A A A B B L ( G 1 ) = ( ) * L ( G2) = ( )* 66
67 The Chomsky Hierrchy 67
68 Chomsky s Lnguge Hierrchy Non-regulr lnguges Regulr Lnguges 68
69 Minimizing DFA y et Prtitioning 69
70 Minimiztion of DFA The deterministic finite utomt re not lwys the smllest possile ccepting the source lnguge. There my e sttes with the sme "cceptnce ehvior". This pplies to sttes p nd q, if for ll input words, the utomton lwys or never moves to finl stte from p nd q. 70
71 tte Reduction y et Prtitioning The set prtitioning technique is similr to one used for prtitioning people into groups sed on their responses to questionnire. The following slides show the detiled steps for computing equivlent stte sets of the strting DFA nd constructing the corresponding reduced DFA. 71
72 1 3 trting DFA Reduced DFA 0, 1,2, 4,5 72
73 tte Reduction y et Prtitioning tep 0: Prtition the sttes into two groups ccepting nd non-ccepting. P1 P2 { 3, 4, 5 } { 0, 1, 2 }
74 tte Reduction y et Prtitioning tep 1: Get the response of ech stte for ech input symol. Notice tht ttes 3 nd 0 show different responses from the ones of the other sttes in the sme set. P 1 P 2 P2 P1 p 1 p 1 p 1 p 2 p 1 p 1 {3, 4, 5 } {0, 1, 2 } p 2 p 1 p 1 p 2 p 1 p
75 tte Reduction y et Prtitioning P22: 0, -> P21 0, -> P21 P21: 1, -> P12 1, -> P11 2, -> P12 2, -> P11 P12: 3, -> P12 3, -> P21 P11: 4, -> P11 4, -> P11 5, -> P11 5, -> P11 No more sudivision. Remining prtitions re the new sttes. {0},{1,2},{3},{4,5} P22 0 P P P11 75
76 Minimized DFA consists of four sttes of the finl prtition, nd the trnsitions re the one corresponding to the strting DFA. {4, 5} {3} {1, 2} {0} 0, 1,2 3 4,5, Minimized DFA trting DFA 76
77 DFA Minimiztion Algorithm The lgorithm P { F, {Q-F}} while ( P is still chnging) T { } for ech set s P for ech α Σ prtition s y α into s 1, s 2,, s k T T s 1, s 2,, s k if T P then P T This is fixed-point lgorithm! Why does this work? Prtition P 2 Q (power set) trt off with 2 susets of Q {F} nd {Q-F} While loop tkes P i P i+1 y splitting one or more sets P i+1 is t lest one step closer to the prtition with Q sets Mximum of Q splits Prtitions re never comined Initil prtition ensures tht finl sttes re intct 77
78 et Prtition Algorithm (lling ook) Exmple 2.39 We pply step y step set prtition lgorithm on the following DFA: Two strings x,y re distinguished y lnguge (DFA) if there is (distinguishing) string z such s tht only one of strings xz, yz ends in ccepting stte (elongs to lnguge) Σ = {, } 78
79 We serch for strings tht re distinguished y DFA! Non-ccepting: Wht hppens when we red? From 5 we end in 6 y, leving its group. 4 6 {1,2,3,4,5,6} Accepting: { 1,2,4,5,6} {3} Distinguishing string: Wht hppens when we red? From 1 nd 6 y we rech 3 which is ccepting. They form specil group. { 2,4,5} {1,6 } {2,4} {5} {1,6} or 79 {3} {3}
80 The miniml utomton hs four sttes: {2,4} { 5} {1,6 } {3} {2,4} { 1,6} {5} {3}
81 Regulr grmmrs ummry left liner right liner left liner => right liner (crete reverse regulr lnguges closed under reverse) right liner => NFA NFA => right liner Regulr grmmr ó regulr lnguge DFA minimiztion stte reduction vi set prtitioning 81
82 RE NFA DFA Miniml DFA Thompson s Contruction uset Contruction Hopcroft Minimiztion 82
83 Appliction: Compiler Lexicl Anlysis 83
84 Wht is compiler? A compiler is progrm tht trnsltes source lnguge into n equivlent trget lnguge while (i > 3) { [i] = [i]; i ++ } C progrm compiler does this mov ex, ex dd ex, 1 cmp ex, 3 jcc ex, edx ssemly progrm 84
85 Wht is compiler? compiler does this clss foo { int r;... } struct foo { int r;... } Jv progrm C progrm 85
86 Wht is compiler? compiler does this clss foo { int r;... } Jv progrm Jv virtul mchine progrm 86
87 Phses of compiler ource Progrm cnner Prser Lexicl Anlyzer yntx Anlyzer emntic Anlyzer Tokens Prse Tree Astrct yntx Tree with ttriutes 87
88 Compiltion in Nutshell ource code (chrcter strem) if ( == 0) = ; Lexicl nlysis Token strem if ( == 0 ) = ; Astrct syntx tree (AT) Decorted AT == 0 oolen == if int int 0 if = int = int lvlue int ; ; Prsing emntic Anlysis 88
89 tges of Anlysis Lexicl Anlysis reking the input up into individul words/tokens yntx Anlysis prsing the phrse structure of the progrm emntic Anlysis clculting the progrm s mening 89
90 Lexicl Anlyzer Input is strem of chrcters Produces strem of nmes, keywords & punctution mrks Discrds white spce nd comments 90
91 Lexicl Anlyzer Recognize tokens in progrm source code. The tokens cn e vrile nmes, reserved words, opertors, numers, etc. Ech kind of token cn e specified s n RE, e.g., vrile nme is of the form [A-Z-z] [A-Z-z0-9]*. We cn then construct n λ -NFA to recognize it utomticlly. 91
92 Lexicl Anlyzer By putting ll these λ-nfa s together, we otin one which cn recognize ll different kinds of tokens in the input string. We cn then convert this λ -NFA to NFA nd then to DFA, nd implement this DFA s deterministic progrm - the lexicl nlyzer. 92
CS415 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 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 informationNormal Forms for Context-free Grammars
Norml Forms for Context-free Grmmrs 1 Linz 6th, Section 6.2 wo Importnt Norml Forms, pges 171--178 2 Chomsky Norml Form All productions hve form: A BC nd A vrile vrile terminl 3 Exmples: S AS S AS S S
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 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 informationFormal Languages Simplifications of CFGs
Forml Lnguges implifictions of CFGs ubstitution Rule Equivlent grmmr b bc ubstitute b bc bbc b 2 ubstitution Rule b bc bbc ubstitute b bc bbc bc Equivlent grmmr 3 In generl: xz y 1 ubstitute y 1 xz xy1z
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 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 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 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 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 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 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 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 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 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 informationCompiler Design. Fall Lexical Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz
University of Southern Cliforni Computer Science Deprtment Compiler Design Fll Lexicl Anlysis Smple Exercises nd Solutions Prof. Pedro C. Diniz USC / Informtion Sciences Institute 4676 Admirlty Wy, Suite
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationCS 314 Principles of Programming Languages
C 314 Principles of Progrmming Lnguges Lecture 6: LL(1) Prsing Zheng (Eddy) Zhng Rutgers University Ferury 5, 2018 Clss Informtion Homework 2 due tomorrow. Homework 3 will e posted erly next week. 2 Top
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 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 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 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 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 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 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 informationOverview HC9. Parsing: Top-Down & LL(1) Context-Free Grammars (1) Introduction. CFGs (3) Context-Free Grammars (2) Vertalerbouw HC 9: Ch.
Overview H9 Vertlerouw H 9: Prsing: op-down & LL(1) do 3 mei 2001 56 heo Ruys h. 8 - Prsing 8.1 ontext-free Grmmrs 8.2 op-down Prsing 8.3 LL(1) Grmmrs See lso [ho, Sethi & Ullmn 1986] for more thorough
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 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 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 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 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 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 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 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 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 informationReview for the Midterm
Review for the Midterm Stephen A. Edwrds Columi University Fll 2018 The Midterm Structure of Compiler Scnning Lnguges nd Regulr Expressions NFAs Trnslting REs into NFAs: Thompson s Construction Building
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 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 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 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 information2. Lexical Analysis. Oscar Nierstrasz
2. Lexicl Anlysis Oscr Nierstrsz Thnks to Jens Plserg nd Tony Hosking for their kind permission to reuse nd dpt the CS132 nd CS502 lecture notes. http://www.cs.ucl.edu/~plserg/ http://www.cs.purdue.edu/homes/hosking/
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 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 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 informationFormal Languages and Automata
Moile Computing nd Softwre Engineering p. 1/5 Forml Lnguges nd Automt Chpter 2 Finite Automt Chun-Ming Liu cmliu@csie.ntut.edu.tw Deprtment of Computer Science nd Informtion Engineering Ntionl Tipei University
More informationChapter 4 Regular Grammar and Regular Sets. (Solutions / Hints)
C K Ngpl Forml Lnguges nd utomt Theory Chpter 4 Regulr Grmmr nd Regulr ets (olutions / Hints) ol. (),,,,,,,,,,,,,,,,,,,,,,,,,, (),, (c) c c, c c, c, c, c c, c, c, c, c, c, c, c c,c, c, c, c, c, c, c, c,
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 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 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 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 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 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 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 informationCSC 311 Theory of Computation
CSC 11 Theory of Computtion Tutoril on DFAs, NFAs, regulr expressions, regulr grmmr, closure of regulr lnguges, context-free grmmrs, non-deterministic push-down utomt, Turing mchines,etc. Tutoril 2 Second
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 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.3 Regular Expressions
56 1.3 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,
More informationDFA Minimization and Applications
DFA Minimiztion nd Applictions Mondy, Octoer 15, 2007 Reding: toughton 3.12 C235 Lnguges nd Automt Deprtment of Computer cience Wellesley College Gols for ody o Answer ny P3 questions you might hve. o
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 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 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 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 informationLecture 09: Myhill-Nerode Theorem
CS 373: Theory of Computtion Mdhusudn Prthsrthy Lecture 09: Myhill-Nerode Theorem 16 Ferury 2010 In this lecture, we will see tht every lnguge hs unique miniml DFA We will see this fct from two perspectives
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 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 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 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 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 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 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 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 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 CI3104-W11
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 informationAgenda. Agenda. Regular Expressions. Examples of Regular Expressions. Regular Expressions (crash course) Computational Linguistics 1
Agend CMSC/LING 723, LBSC 744 Kristy Hollingshed Seitz Institute for Advnced Computer Studies University of Mrylnd HW0 questions? Due Thursdy before clss! When in doubt, keep it simple... Lecture 2: 6
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 informationCSE : Exam 3-ANSWERS, Spring 2011 Time: 50 minutes
CSE 260-002: Exm 3-ANSWERS, Spring 20 ime: 50 minutes Nme: his exm hs 4 pges nd 0 prolems totling 00 points. his exm is closed ook nd closed notes.. Wrshll s lgorithm for trnsitive closure computtion is
More informationRevision Sheet. (a) Give a regular expression for each of the following languages:
Theoreticl Computer Science (Bridging Course) Dr. G. D. Tipldi F. Bonirdi Winter Semester 2014/2015 Revision Sheet University of Freiurg Deprtment of Computer Science Question 1 (Finite Automt, 8 + 6 points)
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 informationClosure Properties of Regular Languages
of Regulr Lnguges Dr. Neil T. Dntm CSCI-561, Colordo School of Mines Fll 2018 Dntm (Mines CSCI-561) Closure Properties of Regulr Lnguges Fll 2018 1 / 50 Outline Introduction Closure Properties Stte Minimiztion
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 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 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 informationCSC 473 Automata, Grammars & Languages 11/9/10
CSC 473 utomt, Grmmrs & Lnguges 11/9/10 utomt, Grmmrs nd Lnguges Discourse 06 Decidbility nd Undecidbility Decidble Problems for Regulr Lnguges Theorem 4.1: (embership/cceptnce Prob. for DFs) = {, w is
More information