Noncanonical LALR(1) Parsing
|
|
- Calvin Harrell
- 6 years ago
- Views:
Transcription
1 Noncnonicl LALR(1) Prsing Sylvin Schmitz Lbortoire I3S, Université de Nice - Sophi Antipolis & CNRS, Frnce schmitz@i3s.unice.fr Abstrct This pper ddresses the longstnding problem of the recognition limittions of clssicl LALR(1) prser genertors by proposing the usge of noncnonicl prsers. To this end, we present definition of noncnonicl LALR(1) prsers, NLALR(1). The clss of grmmrs ccepted by NLALR(1) prsers is proper superclss of the NSLR(1) nd LALR(1) grmmr clsses. Among the recognized lnguges re some nondeterministic lnguges. The proposed prsers retin mny of the qulities of cnonicl LALR(1) prsers: they re deterministic, esy to construct, nd run in liner time. We rgue tht they could provide the bsis for rnge of powerful noncnonicl prsers. Key words: Noncnonicl prser, deterministic prser, LALR, two-stck utomton ACM ctegories: D.3.1 [Progrmming Lnguges]: Forml Definitions nd Theory Syntx ; D.3.4 [Progrmming Lnguges]: Processors Prsing ; F.4.2 [Mthemticl Logic nd Forml Lnguges]: Grmmrs nd Other Rewriting Systems Prsing 1 Introduction Testimonies bound on the shortcomings of clssicl LALR(1) prser genertors like YACC [9]. The problem lies in the lrge expressivity gp between wht cn be specified using the context-free grmmr they re fed with, nd wht cn ctully be prsed by the LALR(1) utomton they produce. Trnsforming grmmr until its LALR(1) prser becomes deterministic is rduous, nd cn obfuscte the ttched semntics; moreover, some lnguges re simply not deterministic. The expressivity gp vnishes when generl prsers [6, 15] re preferred. Such choice is however done t the expense of the detection of mbiguities. While this might seem cceptble for well estblished lnguges, for which the scrutiny of mny implementors hs pinpointed ll mbiguous constructs, there lwys remins risk of runtime problems if n unexpected mbiguity ppers. The voidnce of such problems is clerly desirble gurntee, thus motivting our option of restricting to some subclss of the unmbiguous grmmrs. Also in shorter form in Zhe Dng nd Oscr H. Ibrr, editors, DLT 06, volume 4036 of Lecture Notes in Computer Science, pges c Springer, doi: /
2 2 S. Schmitz This pper dvoctes n lmost forgotten wy of diminishing the expressivity gp: the usge of noncnonicl prsers. We pply it to LALR(1) prsing by mens of generic construction. Therefore, we lso llow immedite ppliction to other LR-bsed prsing methods. Noncnonicl prsers hve been thoroughly investigted on theoreticl level [12]. Surprisingly, there re very few prcticl noncnonicl prsing methods, nd their forml study remins lrgely unexplored. Indeed, the only one of cler prcticl interest is n extension to SLR(1) prsing [13]. Noncnonicl prsers re however powerful mens of reducing the expressivity gp, while still rejecting ny mbiguous syntx. In this they cn be compred to LALR(k) prsers with k > 1 [3], or, to lrger extent, to prsers llowing unbounded regulr lookheds [4, 2, 7]. Like the ltter, noncnonicl prsers cn recognize nondeterministic lnguges. The clsses of grmmrs ccepted by both methods re incomprble in generl, but the clss of lnguges ccepted by noncnonicl prsers is strictly wider thn the one ccepted by regulr lookhed prsers [12]. And there is winning rgument in fvor of noncnonicl prsers: they cn lso increse the size of their lookhed window, possibly to n unbounded length [8]. This point motivtes our study of noncnonicl LALR(1) prsers, since NSLR(1) prsers re unfit for such extensions: their lookhed computtion is not contextul. Also in contrst with NSLR(1), our definitions rely on prefix equivlence reltion: we use the LR(0) equivlence so tht the resulting prsers re LALR(1), but finer equivlences could just s esily be used. Our specific choice of LALR(1) prsers cn be explined by their wide doption, their prcticl relevnce, nd the existence of efficient nd brodly used lgorithms for their genertion [5]. We express our computtions in the sme frmework nd obtin simple nd efficient prcticl construction. The dditionl complexity of generting NLALR(1) prser insted of LALR(1) or NSLR(1) one, s well s the increse of the prser size nd the overhed on prsing performnces re ll quite smll. Therefore, the improved prsing power comes t firly resonble price. The pper is orgnized s follows: Section 2 briefly introduces noncnonicl prsing; Section 3 reclls the forml detils of the cnonicl LALR(1) definition, which will be extended for its noncnonicl counterprt in Section 4. We refer the interested reder to seprte reserch report [10] for complete study, including grmmr clsses comprisons, lterntive definitions for noncnonicl LALR-bsed prsers, concrete exmple of ppliction, nd omitted proofs. Nottion The bsic terminology, definitions, nd nottionl conventions used in this pper re clssicl [1, 11]. Our context-free grmmrs re reduced nd ugmented to G = N,T,P,S = N {S },T {$},P {S S$},S. As usul, A,B,C,... denote nonterminls in N ;,b,c,... denote terminls in T ; u,v,w,... denote strings in T ; X,Y,Z denote symbols in V ; α,β,γ,... denote strings in V ; ε is the empty string or empty sequence; k : α is the prefix of length k of string α. Rightmost derivtions re denoted by rm, wheres leftmost derivtions re denoted by lm.
3 Noncnonicl LALR(1) Prsing 3 q 0: S S$ S BC S AD A B S B A ccept q 1: q A 5: A {b, } B {} $ q 6: S BC {$} C C A A q q 11: 2: A S C C CA S $ q 3: S B C C CA C A A q 4: S A D D D D b A b D q 7: C A q 8: D D D D D b q 10: S AD () LALR(1) utomton b D q 9: D b q 12: D D S$ BC CA CA S$ AD D A D b (b) Derivtion trees Figure 1: The conflict position in stte q 1 for G 1. 2 Noncnonicl Prsing A bottom-up prser reverses the derivtion steps which led to the terminl string it prses. For most bottom-up prsers, including LALR ones, these derivtions re rightmost, nd therefore the reduced phrse is the leftmost one, clled the hndle of the sententil form. Noncnonicl prsers llow the reduction of phrses which my not be hndles [1]. A noncnonicl prser is ble to suspend reduction decision where its cnonicl counterprt would not be deterministic, explore the remining input, perform some reductions, resume to the conflict point nd use nonterminls resulting from the reduction of possibly unbounded mount of input in its lookhed window to infer its prsing decisions. 2.1 Prsing Exmple Consider for instnce grmmr G 1 with rules S BC AD, A, B, C CA A, D D b, generting the lnguge L G1 = + b. The stte q 1 in the utomton of Figure 1 is indequte: the prser is unble to decide between reductions A nd B when the lookhed is. We see on the derivtion trees of Figure 1b tht, in order to choose between the two reductions, the prser hs to know if there is b t the very end of the input. This need for n unbounded lookhed mkes G 1 non-lr. A prser using regulr lookhed would solve the conflict by ssociting the distinct regulr lookheds b nd + $ with the reductions to A nd B respectively. However, we notice tht single lookhed symbol (D or C) is enough: if the prser is ble to explore the context on the right of the conflict, nd to
4 4 S. Schmitz prsing stck input stck ctions q 0 $ shift q 0 q 1 $ shift The indequte stte q 1 is reched with lookhed. The decision of reducing to A or B cn be restted s the decision of reducing the right context to D or C. In order to perform the ltter decision, we shift nd rech stte s 1 where we now expect b nd $. We re pretty much in the sme sitution s before: s 1 is lso indequte. But we know tht in front of b or $ decision cn be mde: q 0 q 1 s 1 $ shift There is new conflict between the reduction A nd the shift of to position D D. We lso shift this. The expected right contexts re still b nd $, so the shift brings us gin to s 1 : q 0 q 1 s 1 s 1 $ reduce using A The decision is mde in front of $. We reduce the represented by s 1 on top of the prsing stck, nd push the reduced symbol A on top of the input stck: q 0 q 1 s 1 A$ reduce using A Using this new lookhed, the prser is ble to decide nother reduction to A: q 0 q 1 AA$ reduce using B We re now bck in stte q 1. Clerly, there is no need to wit until we see completely reduced symbol C in the lookhed window: A is lredy symbol specific to the reduction to B: q 0 BAA$ shift q 0 q 3 AA$ shift q 0 q 3 q 7 A$ reduce using C A q 0 q 3 CA$ shift q 0 q 3 q 6 A$ shift q 0 q 3 q 6 q 11 $ reduce using C CA q 0 q 3 C$ shift q 0 q 3 q 6 $ reduce using S BC q 0 S$ shift, nd then ccept Tble 1: The prse of the string by the NLALR(1) prser for G 1. reduce some other phrses, then, it will reduce this context to D or C. When coming bck to the conflict point, it will see D or C in the lookhed window. Tble 1 presents noncnonicl prse for string in L G1. The noncnonicl mchine is not very different from the cnonicl one, except tht it uses two stcks. The dditionl stck, the input stck, contins the (possibly reduced) right context, wheres the other stck is the clssicl prsing stck. Reductions push the reduced nonterminl on top of the input stck. There is no goto opertion per se: the nonterminl on top of the input stck either llows prsing decision which hd been delyed, or is simply shifted. We will now see how to trnsform nd extend the cnonicl LALR(1) prser of Figure 1 to perform these prsing steps. 2.2 Construction Principles The LALR(1) construction relies hevily on the LR(0) utomton. This utomton provides nice explntion for LALR lookhed sets: the symbols
5 Noncnonicl LALR(1) Prsing 5 q 1: A {D, b} B {C, A} s 1 = {q 5, q 8}: A {A, $} D D D D D b b D q 9 q 12 Figure 2: Stte q 1 extended for noncnonicl prsing. in the lookhed set for some reduction re the symbols expected next by the LR(0) prser, should it relly perform this reduction. Let us compute the lookhed set for the reduction A in stte q 1. Should the LR(0) prser decide to reduce A, it would pop q 1 from the prsing stck (thus be in stte q 0 ), nd then push q 4. We red directly on Figure 1 tht three symbols re cceptble in q 4 : D, nd b. Similrly, the reduction B in q 1 hs {C,A,} for lookhed set, red directly from stte q 3. The intersection of the lookhed sets for the reductions in q 1 is not empty: ppers in both, which mens conflict. Luckily enough, is not totlly reduced symbol: D nd C re reduced symbols, red from kernel items in q 4 nd q 3. The conflicting lookhed symbol could be reduced, nd lter we might see symbol on which we cn mke decision insted. Thus, we shift the lookhed symbol in order to reduce it nd solve the conflict lter. All the other symbols in the computed lookheds llow to mke decision, so we leve them in the lookheds sets, but we remove from both sets. Shifting puts us in the sme sitution we would hve been in if we hd followed the trnsitions on from both q 3 nd q 4, since the noncnonicl genertion simultes both reductions in q 1. We crete noncnonicl trnsition from q 1 on to noncnonicl stte s 1 = {q 5,q 8 }, which will behve s the union of sttes q 5 nd q 8. Stte s 1 will thus llow reduction using A inherited from q 5, nd the shifts of, b nd D inherited from q 8. We therefore need to compute the lookheds for reduction using A in q 5. Using gin the LR(0) simultion technique, we see on Figure 1 tht this reduction would led us to either q 7 or to q 11. In both cses, the LR(0) utomton would perform reduction to C tht would led next to q 6. At this point, the LR(0) utomton expects either the end of file symbol $, should reduction to S occur, or n A or n. The complete lookhed set for the reduction A in q 8 is thus {A,,$}. The new stte s 1 is lso indequte: with n in the lookhed window, we cnnot choose between the shift of nd the reduction A. As before, we crete new trnsition on from s 1 to noncnonicl stte s 1 = {q 5,q 8 }. Stte q 5 is the stte ccessed on from q 6. Stte q 8 is the stte ccessed from q 8 if we simulte shift of symbol. Stte s 1 is the sme s stte s 1, nd we merge them. The noncnonicl computtion is now finished. Figure 2 sums up how stte q 1 hs been trnsformed nd extended. Note tht we just use the set {q 5,q 8 } in noncnonicl LALR(1) utomton; items represented in Figure 2 re only there to ese understnding. 3 LALR(1) Prsers LALR prsers were introduced s prcticl prsers for deterministic lnguges. Rther thn building n exponentil number of LR(k) sttes, LALR(k) prsers dd lookhed sets to the ctions of the smll LR(0) prser. We briefly recll
6 6 S. Schmitz some importnt definitions nd results on LR(0) nd LALR(1) prsers. Vlid Items nd Prefixes A dotted production A α β of G is vlid LR(0) item for string γ in V if S rm δaz rm δαβz = γβz. (1) If such derivtion holds in G, then γ in V is vlid prefix. The set of vlid items for given string γ in V is denoted by Vlid(γ). Two strings δ nd γ re equivlent if nd only if they hve the sme vlid items. The vlid item sets re obtined through the following computtions: Kernel(ε)={S S$}, (2) Kernel(γX)={A αx β A α Xβ Vlid(γ)}, (3) Vlid(γ)=Kernel(γ) {B ω A α Bβ Vlid(γ)}. (4) LR(0) Sttes LR utomt re pushdown utomt tht use equivlence clsses on vlid prefixes s their stck lphbet Q. We therefore denote explicitly sttes of LR prser s q = [δ], where δ is some vlid prefix in q the stte reched upon reding this prefix. For instnce, in the utomton of Figure 1, stte q 2 is the equivlence clss {S}, while stte q 8 is the equivlence clss described by the regulr lnguge A. A pir ([δ],x) in Q V is trnsition if nd only if δx is vlid prefix. If this is the cse, then [δx] is the stte ccessed upon reding δx, thus the nottion [δx] lso implies 1 trnsition from [δ] on X, nd [δα] pth on α. LALR(1) Automt The LALR(1) lookhed set of reduction using A α in stte q is LA(q,A α) = {1:z S rm δaz nd q = [δα]}. (5) 4 NLALR(1) Prsers There is number of differences between the LALR(1) nd NLALR(1) definitions. The most visible one is tht we ccept nonterminls in our lookhed sets. We lso wnt to know which lookhed symbols re totlly reduced. Finlly, we re dding new sttes, which re sets of LR(0) sttes. Therefore, the objects in most of our computtions will be LR(0) sttes. 4.1 Vlid Covers We hve reclled in the previous section tht LR(0) sttes cn be viewed s collections of vlid prefixes. A similr definition for NLALR(1) sttes would be nice. However, due to the suspended prsing ctions, the lnguge of ll prefixes ccepted by noncnonicl prser is no longer regulr lnguge. This mens the prser will only hve regulr pproximtion of the exct prsing stck lnguge. The noncnonicl sttes, being sets of LR(0) sttes (i.e., sets of equivlence clsses on vlid prefixes), provide this pproximtion. We therefore define vlid covers s vlid prefixes covering the prsing stck lnguge. 1 We lwys ssume when writing [δx] tht Vlid(δX) is not the empty set.
7 Noncnonicl LALR(1) Prsing 7 Definition 1 String γ is vlid cover in G for string δ if nd only if γ is vlid prefix nd γ δ. We write ˆδ to denote some cover of δ nd Cover(L) to denote the set of ll vlid covers for the set of strings L. Remember for instnce configurtion q 0 q 1 $ from Tble 1. This configurtion leds to pushing stte s 1 = {q 5,q 8 }, where both vlid prefixes (B BC) nd A of q 5 nd q 8 re vlid covers for the ctul prsing stck prefix. Thus in s 1 we cover the prsing stck prefix by (B BC A ). 4.2 Noncnonicl Lookheds Noncnonicl lookheds re symbols in V. Adpting the computtion of the LALR(1) lookhed sets is simple, but few points deserve some explntions. First of ll, noncnonicl lookhed symbols hve to be non null, i.e. X is non null if X x. Indeed, null symbols do not provide ny dditionl right context informtion worse, they cn hide it. If we consider tht we lwys perform reduction t the erliest prsing stge possible, then they will never pper in lookhed window. Totlly Reduced Lookheds Totlly reduced lookheds form subset of the noncnonicl lookhed set such tht none of its elements cn be further reduced. A conflict with totlly reduced symbol s lookhed of reduction cnnot be solved by noncnonicl explortion of the right context, since there is no hope of ever reducing it ny further. We define here totlly reduced lookheds s non null symbols which cn follow the right prt of the offending rule in leftmost derivtion. Definition 2 The set of totlly reduced lookheds for reduction A α in LR(0) stte q is defined by RLA(q,A α) = {X S zaγxω,γ ε,x x, nd q = [ẑα]}. lm Derived Lookheds The derived lookhed symbols re simply defined by extending (5) to the set of ll non null symbols in V. Definition 3 The set of derived lookheds for reduction A α in LR(0) stte q is defined by DLA(q,A α) = {X S δaxω,x x, nd q = [ˆδα]}. We obviously hve tht LA(q,A α) = DLA(q,A α) T. (6) Conflicting Lookhed Symbols Lst, we need to compute which lookhed symbols would mke the stte indequte. A noncnonicl explortion of the right context is required for these symbols. They pper in the derived lookhed sets of severl reductions nd/or re trnsition lbels. However, the totlly reduced lookheds of reduction re not prt of this lookhed set, for if they re involved in conflict, then there is no hope of being ble to solve it.
8 8 S. Schmitz Definition 4 Conflicts lookhed set for reduction using A α in set s of LR(0) sttes is defined s CLA(s,A α) = {X DLA(q,A α) q s,x RLA(q,A α), (q,x) or ( p s, B β A α P,X DLA(p,B β))}. We then define the noncnonicl lookhed set for reduction using A α in set s of LR(0) sttes s NLA(s,A α) = ( DLA(q,A α) ) CLA(s,A α). q s We illustrte these definitions by computing the lookhed sets for the reduction using A in stte s 1 = {q 5,q 8 } s in Section 2.2: RLA(q 5,A ) = {A,$}, DLA(q 5,A ) = {A,,$}, CLA(s 1,A ) = {} nd NLA(s 1,A ) = {A,$}. 4.3 Noncnonicl Sttes We sid t the beginning of this section tht sttes in the NLALR(1) utomton were in fct sets of LR(0) sttes. We denote by δ the noncnonicl stte ccessed upon reding string δ in V. Definition 5 Noncnonicl stte δ is the set of LR(0) sttes defined by ε ={[ε]} nd δx = {[ ˆγAX] X CLA( δ,a α),[ˆγα] δ } {[ϕx] [ϕ] δ }. Noncnonicl trnsition from δ to δx on symbol X, denoted by ( δ,x), exists if nd only if δx. Reduction ( δ,a α) exists if nd only if there exists reduction (q,a α) nd q is in δ. Note tht these definitions remin vlid for plin LALR(1) sttes since, in bsence of conflict, noncnonicl stte is singleton set contining the corresponding LR(0) stte. A simple induction on the length of δ shows tht the LR(0) sttes considered in the noncnonicl stte δ provide vlid cover for ny ccessing string of the noncnonicl stte. It bsiclly mens tht the ctions decided in given noncnonicl stte mke sense t lest for cover of the rel sententil form prefix tht is red. The pproximtions done when covering the ctul sententil form prefix re mde on top of the previous pproximtions: with ech new conflict, we need to find new set of LR(0) sttes covering the prsing stck contents. This stcking is mde obvious in the bove definition when we write ˆγAX. It mens tht NLALR(1) prsers re not prefix vlid, but prefix cover vlid. Throughout this pper, we use the LR(0) utomton to pproximte the prefix red so fr. We could use more powerful methods but it would not relly be in the spirit of LALR prsing ny longer; see [10] for lterntive methods. 4.4 NLALR(1) Automt Here we formlize noncnonicl LALR(1) prsing mchines. They re specil cse of two-stck pushdown utomt (2PDA). As sid before, the dditionl
9 Noncnonicl LALR(1) Prsing 9 stck serves s n input for the prser, nd reductions push the reduced nonterminl on top of this stck. This behvior of reductions excepted, the definition of NLALR(1) utomton is similr to the LALR(1) one. Definition 6 Let M = (Q V {$, },R) be rewriting system. A configurtion of M is string of the form ε X 1... X 1...X n ω$ where X 1...X n nd ω re strings in V. We sy tht M is NLALR(1) utomton if its initil configurtion is ε w$ with w the input string in T, its finl configurtion is ε S $, nd if ech rewriting rule in R is of the form shift X in stte δ, defined if there is trnsition ( δ,x) δ X shift δ δx, or reduce by rule A X 1...X n of P in stte δx 1...X n with lookhed X, defined if A X 1...X n is reduction in δx 1...X n nd lookhed X is in NLA( δx 1...X n,a X 1...X n ) δx 1... δx 1...X n X A X1... Xn AX. The following rules illustrte Definition 6 on stte s 1 of the NLALR(1) utomton for G 1 : s 1 shift s 1 s 1, s 1 b shift s 1 {q 9 }, s 1 D shift s 1 {q 12 }, s 1 A AA nd s A 1 $ A A$. According to Definition 6, NLALR(1) utomt re ble to bcktrck by limited mount, corresponding to the length of their window, t reduction time only. We know tht noncnonicl prsers using bounded lookhed window operte in liner time [12]; the following theorem precisely shows tht the totl number of rules involved in the prsing of n input string is liner in respect with the number of reductions performed, which itself is liner with the input string length. This theorem uses n output effect τ which outputs the rules used for ech reduction performed by M; we then cll (M,τ) NLALR(1) prser. Theorem 1 Let G be grmmr nd (M,τ) its NLALR(1) prser. If π is prse of w in M, then the number of prsing steps π is relted to the number τ(π) of derivtions producing w in G nd to the length w of w by π = 2 τ(π) + w. Since ll the conflict lookhed symbols re removed from the noncnonicl lookhed sets NLA, the only possibility for the noncnonicl utomton to be nondeterministic would be to hve totlly reduced symbol cusing conflict. A context-free grmmr G is NLALR(1) if its NLALR(1) utomton is deterministic, nd thus if no totlly reduced symbol cn cuse conflict. 4.5 Computing the Lookheds nd Covers The LALR(1) lookhed sets tht re defined in Eqution (5) cn be expressed using the following definitions [5], where lookbck is reltion between reductions nd nonterminl LR(0) trnsitions, includes nd reds re reltions
10 10 S. Schmitz between nonterminl LR(0) trnsitions, nd DR stnding for directly reds is function from nonterminl LR(0) trnsitions to sets of lookhed symbols. ([δα],a α) lookbck ([δ],a), (7) ([δβ],a) includes ([δ],b) iff B βaγ nd γ ε, (8) ([δ],a) reds ([δa],c) iff ([δa],c) nd C ε, (9) DR([δ],A) = { ([δa],)}. (10) Using the bove definitions, we cn rewrite Eqution (5) s LA(q,A α) = (q,a α) lookbck includes reds (r,c) DR(r,C). (11) This computtion for LALR(1) lookhed sets is highly efficient. It cn entirely be performed on the LR(0) utomton, nd the union cn be interleved with fst trnsitive closure lgorithm [14] on the includes nd reds reltions. Since we hve very efficient nd widely dopted computtion for the cnonicl LALR(1) lookhed sets, why not try to use it for the noncnonicl ones? Theorem 2 RLA(q,A α) = {X X x,ψ ε,c ρb ψxσ Kernel(δρB) nd (q,a α) lookbck includes ([δρ],b)}. This theorem is consistent with the description of Section 2.2, where we sid tht C ws totlly reduced lookhed for reduction B in q 1 : item S B C is in the kernel of stte q 3 ccessed by (q 0,B), nd (q 1,B ) lookbck (q 0,B). Theorem 3 Let us extend the directly reds function of (10) to DR([δ],A) = {X ([δa],x) nd X x}; then DLA(q, A α) = DR(r,C). (q,a α) lookbck includes reds (r,c) We re still consistent with the description of Section 2.2 since, using this new definition of the DR function, DR(q 0,B) is {,C,A}. To find the vlid covers tht pproximte sententil form prefix using the LR(0) utomton nd to find the LALR lookhed sets wind up being very similr opertions. This llows us to reuse our reltionl computtions for the utomton construction itself, s illustrted by the following theorem. Theorem 4 Noncnonicl stte δ is the set of LR(0) sttes defined by ε ={[ε]} nd δx = {[γcx] X CLA( δ,a α),q δ nd (q,a α) lookbck includes reds ([γ],c)} {[ϕx] [ϕ] δ }.
11 Noncnonicl LALR(1) Prsing Prcticl Construction Steps We present here more informl construction, with the min steps leding to the construction of NLALR(1) prser, given the LR(0) utomton. 1. Associte noncnonicl stte s={q} with ech LR(0) stte q. 2. Iterte while there exists n indequte 2 stte s: () if it hs not been done before, compute the RLA nd DLA lookhed sets for the reductions involved in the conflict; sve their vlues for the reduction nd LR(0) stte involved; (b) compute the CLA nd NLA lookhed sets for s; (c) set the lookheds to NLA for the reduction ctions in s; (d) if the NLA lookhed sets leve the stte indequte, mening there is conflict on totlly reduced lookhed, then report the conflict, nd use conflict resolution policy or terminte with n error; if CLA is not empty, crete trnsitions on its symbols nd crete new sttes if no fusion occurs. New sttes get new trnsition nd reduction sets computed from the LR(0) sttes they contin. If these new sttes result from shift/reduce conflicts, the trnsitions from s on the conflicting lookhed symbol now led to the new sttes. This process lwys termintes since there is bounded number of LR(0) sttes nd thus bounded number of noncnonicl sttes. Let us conclude this section with few words on the size of the generted prsers. Since NLALR(1) sttes re sets of LR(0) sttes, we find n exponentil function of the size of the LR(0) utomton s n upper bound on the size of the NLALR(1) utomton. This bound seems however pretty irrelevnt in prctice. The NLALR(1) prser genertor needs to crete new stte for ech lookhed cusing conflict, which does not hppen so often. All the grmmrs we studied creted trnsitions to cnonicl sttes very quickly fterwrds. Experimentl results with NSLR(1) prsers show tht the increse in size is negligible in prctice [13]. 5 Conclusion We hve presented construction for noncnonicl LALR(1) prsers. Such prsers re prcticl for some difficult syntx problems. They improve on both noncnonicl SLR(1) prsers nd cnonicl LALR(1) prsers, nd their genertion is only slightly more complex while their size nd their performnces re comprble. For prcticl uses, we feel we would need n unbounded lookhed version of NLALR prsers. Though the cost to py might be qudrtic prsing time in the worst cse, the freedom offered to the grmmr writer would probbly be yet. 2 We men here indequte in the LR(0) sense, thus no lookheds need to be computed
12 12 S. Schmitz worth it. The bility to specify finer equivlence reltions insted of the LR(0) one would prove its usefulness in this setting where precision becomes criticl. In complement to previous theoreticl work on noncnonicl prsing [12], it would be interesting to formlly study prcticl noncnonicl prsers. To this end, we expect the concept of vlid covers modulo n equivlence reltion to be good strting point. Acknowledgements The uthor is highly grteful to Jcques Frré nd An Almeid Mtos for their invluble help in the preprtion of this pper. References [1] Alfred V. Aho nd Jeffrey D. Ullmn. The Theory of Prsing, Trnsltion, nd Compiling. Volume I: Prsing. Series in Automtic Computtion. Prentice Hll, ISBN URL [2] Mnuel E. Bermudez nd Krl M. Schimpf. Prcticl rbitrry lookhed LR prsing. Journl of Computer nd System Sciences, 41(2): , ISSN doi: / (90)90037-L. [3] Philippe Chrles. A Prcticl method for Constructing Efficient LALR(k) Prsers with Automtic Error Recovery. PhD thesis, New York University, My URL [4] Krel Čulik nd Rin Cohen. LR-Regulr grmmrs n extension of LR(k) grmmrs. Journl of Computer nd System Sciences, 7(1):66 96, ISSN doi: /S (73) [5] Frnk DeRemer nd Thoms Pennello. Efficient computtion of LALR(1) look-hed sets. ACM Trnsctions on Progrmming Lnguges nd Systems, 4(4): , ISSN doi: / [6] Jy Erley. An efficient context-free prsing lgorithm. Communictions of the ACM, 13(2):94 102, ISSN doi: / [7] Jcques Frré nd José Fortes Gálvez. A bounded-connect construction for LR-Regulr prsers. In Reinhrd Wilhelm, editor, CC 01, volume 2027 of Lecture Notes in Computer Science, pges Springer, URL [8] Jcques Frré nd José Fortes Gálvez. Bounded-connect noncnonicl discriminting-reverse prsers. Theoreticl Computer Science, 313(1):73 91, ISSN doi: /j.tcs [9] Stephen C. Johnson. YACC yet nother compiler compiler. Computing science technicl report 32, AT&T Bell Lbortories, Murry Hill, New Jersey, July 1975.
13 Noncnonicl LALR(1) Prsing 13 [10] Sylvin Schmitz. Noncnonicl LALR(1) prsing. Technicl Report I3S/RR FR, Lbortoire I3S, November URL mh/rr/2005/rr s.schmitz.pdf. [11] Seppo Sippu nd Eljs Soislon-Soininen. Prsing Theory, Vol. II: LR(k) nd LL(k) Prsing, volume 20 of EATCS Monogrphs on Theoreticl Computer Science. Springer, ISBN [12] Thoms G. Szymnski nd John H. Willims. Noncnonicl extensions of bottom-up prsing techniques. SIAM Journl on Computing, 5(2): , ISSN doi: / [13] Kuo-Chung Ti. Noncnonicl SLR(1) grmmrs. ACM Trnsctions on Progrmming Lnguges nd Systems, 1(2): , ISSN doi: / [14] Robert E. Trjn. Depth first serch nd liner grph lgorithms. SIAM Journl on Computing, 1(2): , ISSN doi: / [15] Msru Tomit. Efficient Prsing for Nturl Lnguge. Kluwer Acdemic Publishers, ISBN
CS 275 Automata and Formal Language Theory
CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.6.: Push Down Automt Remrk: This mteril is no longer tught nd not directly exm relevnt Anton Setzer (Bsed
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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationHow to simulate Turing machines by invertible one-dimensional cellular automata
How to simulte Turing mchines by invertible one-dimensionl cellulr utomt Jen-Christophe Dubcq Déprtement de Mthémtiques et d Informtique, École Normle Supérieure de Lyon, 46, llée d Itlie, 69364 Lyon Cedex
More informationThis lecture covers Chapter 8 of HMU: Properties of CFLs
This lecture covers Chpter 8 of HMU: Properties of CFLs Turing Mchine Extensions of Turing Mchines Restrictions of Turing Mchines Additionl Reding: Chpter 8 of HMU. Turing Mchine: Informl Definition B
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 informationGeneral idea LR(0) SLR LR(1) LALR To best exploit JavaCUP, should understand the theoretical basis (LR parsing);
Bottom up prsing Generl ide LR(0) SLR LR(1) LLR To best exploit JvCUP, should understnd the theoreticl bsis (LR prsing); 1 Top-down vs Bottom-up Bottom-up more powerful thn top-down; Cn process more powerful
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 informationHandout: Natural deduction for first order logic
MATH 457 Introduction to Mthemticl Logic Spring 2016 Dr Json Rute Hndout: Nturl deduction for first order logic We will extend our nturl deduction rules for sententil logic to first order logic These notes
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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationThe Regulated and Riemann Integrals
Chpter 1 The Regulted nd Riemnn Integrls 1.1 Introduction We will consider severl different pproches to defining the definite integrl f(x) dx of function f(x). These definitions will ll ssign the sme vlue
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 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 context-free grmmrs
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 informationCoalgebra, Lecture 15: Equations for Deterministic Automata
Colger, Lecture 15: Equtions for Deterministic Automt Julin Slmnc (nd Jurrin Rot) Decemer 19, 2016 In this lecture, we will study the concept of equtions for deterministic utomt. The notes re self contined
More informationDuality # Second iteration for HW problem. Recall our LP example problem we have been working on, in equality form, is given below.
Dulity #. Second itertion for HW problem Recll our LP emple problem we hve been working on, in equlity form, is given below.,,,, 8 m F which, when written in slightly different form, is 8 F Recll tht 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 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 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 informationThe transformation to right derivation is called the canonical reduction sequence. Bottom-up analysis
Bottom-up nlysis Shift-reduce prsing. Constructs the derivtion tree from ottom to top. Reduces the string to the strt symol. Produces reverse right derivtion. Exmple: G(E): 1. E E + T 2. T 3. T T * F 4.
More informationIntermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4
Intermedite Mth Circles Wednesdy, Novemer 14, 2018 Finite Automt II Nickols Rollick nrollick@uwterloo.c Regulr Lnguges Lst time, we were introduced to the ide of DFA (deterministic finite utomton), one
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 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 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 informationMath 1B, lecture 4: Error bounds for numerical methods
Mth B, lecture 4: Error bounds for numericl methods Nthn Pflueger 4 September 0 Introduction The five numericl methods descried in the previous lecture ll operte by the sme principle: they pproximte the
More informationHere we study square linear systems and properties of their coefficient matrices as they relate to the solution set of the linear system.
Section 24 Nonsingulr Liner Systems Here we study squre liner systems nd properties of their coefficient mtrices s they relte to the solution set of the liner system Let A be n n Then we know from previous
More information12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2016
CS125 Lecture 12 Fll 2016 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple
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 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 informationRecitation 3: More Applications of the Derivative
Mth 1c TA: Pdric Brtlett Recittion 3: More Applictions of the Derivtive Week 3 Cltech 2012 1 Rndom Question Question 1 A grph consists of the following: A set V of vertices. A set E of edges where ech
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 information12.1 Nondeterminism Nondeterministic Finite Automata. a a b ε. CS125 Lecture 12 Fall 2014
CS125 Lecture 12 Fll 2014 12.1 Nondeterminism The ide of nondeterministic computtions is to llow our lgorithms to mke guesses, nd only require tht they ccept when the guesses re correct. For exmple, simple
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 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 informationPart 5 out of 5. Automata & languages. A primer on the Theory of Computation. Last week was all about. a superset of Regular Languages
Automt & lnguges A primer on the Theory of Computtion Lurent Vnbever www.vnbever.eu Prt 5 out of 5 ETH Zürich (D-ITET) October, 19 2017 Lst week ws ll bout Context-Free Lnguges Context-Free Lnguges superset
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 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 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 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 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 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 informationCOMPUTER SCIENCE TRIPOS
CST.2011.2.1 COMPUTER SCIENCE TRIPOS Prt IA Tuesdy 7 June 2011 1.30 to 4.30 COMPUTER SCIENCE Pper 2 Answer one question from ech of Sections A, B nd C, nd two questions from Section D. Submit the nswers
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 informationProperties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives
Block #6: Properties of Integrls, Indefinite Integrls Gols: Definition of the Definite Integrl Integrl Clcultions using Antiderivtives Properties of Integrls The Indefinite Integrl 1 Riemnn Sums - 1 Riemnn
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 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 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 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 informationImproper Integrals, and Differential Equations
Improper Integrls, nd Differentil Equtions October 22, 204 5.3 Improper Integrls Previously, we discussed how integrls correspond to res. More specificlly, we sid tht for function f(x), the region creted
More informationAdvanced Calculus: MATH 410 Notes on Integrals and Integrability Professor David Levermore 17 October 2004
Advnced Clculus: MATH 410 Notes on Integrls nd Integrbility Professor Dvid Levermore 17 October 2004 1. Definite Integrls In this section we revisit the definite integrl tht you were introduced to when
More information1 Online Learning and Regret Minimization
2.997 Decision-Mking in Lrge-Scle Systems My 10 MIT, Spring 2004 Hndout #29 Lecture Note 24 1 Online Lerning nd Regret Minimiztion In this lecture, we consider the problem of sequentil decision mking in
More informationUNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3
UNIFORM CONVERGENCE Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3 Suppose f n : Ω R or f n : Ω C is sequence of rel or complex functions, nd f n f s n in some sense. Furthermore,
More informationStrong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation
Strong Bisimultion Overview Actions Lbeled trnsition system Trnsition semntics Simultion Bisimultion References Robin Milner, Communiction nd Concurrency Robin Milner, Communicting nd Mobil Systems 32
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 1-4) Weeks
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 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 informationp-adic Egyptian Fractions
p-adic Egyptin Frctions Contents 1 Introduction 1 2 Trditionl Egyptin Frctions nd Greedy Algorithm 2 3 Set-up 3 4 p-greedy Algorithm 5 5 p-egyptin Trditionl 10 6 Conclusion 1 Introduction An Egyptin frction
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 information19 Optimal behavior: Game theory
Intro. to Artificil Intelligence: Dle Schuurmns, Relu Ptrscu 1 19 Optiml behvior: Gme theory Adversril stte dynmics hve to ccount for worst cse Compute policy π : S A tht mximizes minimum rewrd Let S (,
More informationThe First Fundamental Theorem of Calculus. If f(x) is continuous on [a, b] and F (x) is any antiderivative. f(x) dx = F (b) F (a).
The Fundmentl Theorems of Clculus Mth 4, Section 0, Spring 009 We now know enough bout definite integrls to give precise formultions of the Fundmentl Theorems of Clculus. We will lso look t some bsic emples
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 informationAutomata and Languages
Automt nd Lnguges Prof. Mohmed Hmd Softwre Engineering Lb. The University of Aizu Jpn Grmmr Regulr Grmmr Context-free Grmmr Context-sensitive Grmmr Regulr Lnguges Context Free Lnguges Context Sensitive
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 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 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 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 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 0. What is the Lebesgue integral about?
Chpter 0. Wht is the Lebesgue integrl bout? The pln is to hve tutoril sheet ech week, most often on Fridy, (to be done during the clss) where you will try to get used to the ides introduced in the previous
More information7.2 The Definite Integral
7.2 The Definite Integrl the definite integrl In the previous section, it ws found tht if function f is continuous nd nonnegtive, then the re under the grph of f on [, b] is given by F (b) F (), where
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 END-OF-YEAR SWEN 224 Forml Foundtions of Progrmming
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 information20 MATHEMATICS POLYNOMIALS
0 MATHEMATICS POLYNOMIALS.1 Introduction In Clss IX, you hve studied polynomils in one vrible nd their degrees. Recll tht if p(x) is polynomil in x, the highest power of x in p(x) is clled the degree of
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 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 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 information