Parsing and Pattern Recognition
|
|
- Gervais Hoover
- 5 years ago
- Views:
Transcription
1 Topics in IT Prsing nd Pttern Recognition Week Context-Free Prsing College of Informtion Science nd Engineering Ritsumeikn University
2 this week miguity in nturl lnguge in mchine lnguges top-down, redth-first prser: Erley s lgorithm otining derivtion from the prser chrt
3 miguity ungyun Seo nd Roert F. Simmom Syntctic Grphs: A Representtion for the Union of All Amiguous prse Trees \f I vpp rood npp [,rrow,nl I I Sentence: Time flies like n rrow. Figure 6 Grph Representtion nd Prse Trees of Highly Amiguous Sentence. OED: most-used 00 words verge menings ech reding, ecuse ech node cn e modifier node only once in one reding. Therefore, we cn focus on the rcs pointing to the sme node s miguous points. In terms of triples, ny two triples with identicl modifier terms revel point of miguity, where modifier term is dominted y more thn one node. In the exmple in Figure, the syntctic miguities ech position must prticipte in every syntctic reding of syntctic grph, every node which is not root node nd hs only one in-rc, must lwys e included in every syntctic reding. Such unmiguous nodes re common to the intersections of ll possile redings. When we know the exct loctions of severl pieces in jigsw puzzle, it is much esier to plce the other
4 Jungyun Seo nd Roert F. Simmons miguity Syntctic Grphs: A Representtion for the Union of All Amiguous Prse Trees., Jl [I'se''vl I vtp. _... _ ~ /.I"....,,, i i,.,.,...o..o, I I dot Sentence: I sw mn on the hill with telescope. I[8,,rtl [ trees in shred, pcked-prse forest) We clim tht syntctic grph represented y the triples nd n exclusion mtrix contins ll importnt syntctic informtion in the prse forest. In the next section, we motivte this work with n exmple. Then we riefly introduce X (X-r) theory Figure : Syntctic Grph of the Exmple Sentence. OED: most-used 00 words verge menings ech I sw mn on the hill with telescope. I clened the lens to get etter view. When we red the first sentence, we cnnot determine whether the mn hs telescope or the telescope is used to see the mn. This is known s the PP-ttchment prolem, nd mny reserchers hve proposed vrious wys to solve it (Frzier nd Fodor 979; Shuert 98,
5 miguity ny grmmr cn e mde miguous y dding duplictes: two derivtions for the empty string: A ɛ B ɛ infinite numer of derivtions for the empty string: A A ɛ left- nd right-recursive derivtions (nd ny comintion of them): nd... A A A ɛ A A + A A - A clssic exmple, dngling else : if (x) if (y) P; else Q;
6 miguity not prolem in trditionl lnguges designed/implemented y one person who is experienced in grmmrs who would never llow the ove exmples in their grmmr ut: there re lnguges with extensile grmmrs end user cn dd rules to existing grmmr without complete knowledge of the se grmmr without experience in lnguge design nd while we cnnot stop them reking the lnguge... we cn ttempt to produce correct results even when miguity is introduced 6
7 miguity recursive descent cnnot hndle these constructions something more powerful required: emrcing multiple derivtions (for miguity) immune to infinite left-recursion immune to infinite right-recursion etc. in other words technique to prse ny CFG we lredy sw NFAs deling esily with miguity prllel mtching lgorithm let s review how... 7
8 Let s try to mtch: "c" prllel recognition with NFAs egin y dding just the strt stte to the first set (input position 0) ( )*?c 0 c input string nd set of permitted sttes c 9 8
9 prllel recognition with NFAs ( )*?c 6 0 c 7 8 input string nd set of permitted sttes c 9 9
10 prllel recognition with NFAs ( )*?c 6 0 c 7 8 input string nd set of permitted sttes c 9 0
11 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
12 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
13 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
14 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
15 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
16 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 6
17 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 7
18 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 8
19 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 9
20 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 0
21 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
22 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
23 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
24 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
25 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
26 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 6
27 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 7
28 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 8
29 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 9
30 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9 0
31 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
32 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
33 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
34 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
35 prllel recognition with NFAs ( )*?c 6 0 c input string nd set of permitted sttes c 9
36 prllel recognition with NFAs ( )*?c 0 c input string nd set of permitted sttes c 9 6
37 prllel recognition with NFAs ( )*?c 0 c input string nd set of permitted sttes c 9 7
38 prllel recognition with NFAs ( )*?c 0 c input string nd set of permitted sttes c 9 8
39 prllel recognition with NFAs ( )*?c 0 c input string nd set of permitted sttes c 9 9
40 prllel recognition with NFAs ( )*?c 0 c input string nd set of permitted sttes c 9 0
41 prllel recognition with NFAs ( )*?c 0 c input string nd set of permitted sttes c 9
42 prllel recognition with NFAs Success! ( )*?c 0 c input string nd set of permitted sttes c 9
43 tht technique ws useful to turn top-down prsing ck-trcking NFA implementtion into prllel (non-ck-trcking) NFA implementtion we sw (lst week) how top-down ck-trcking prser cn prse input ccording to (restricted) CFG grmmr y expnding sententil forms rememering positions s prser items cking up when the derivtion cnnot continue we will remove ck-trcking from top-down prsing using similr technique to the one we used to remove ck-trcking from NFA mtching first review of the ck-trcking top-down prsing...
44 top-down prsing: ck-trcking production sententil input L,, grmmr for list of two or more digits: L N, L N, L,, N, L,, L N, L, L,, L N, N, L,, L N, L, N, L,, N [0 9] 6 N,, L,, 7,, L,, 8,, L,, 9 L N, L,, N, L,, 0 N,,, L,,,,, L,,,,, L,, input, ck-trck to 8,, L,, nd try different prodution for L L N, N,, N, N,, N,,, N,, 6,,, N,, input, ck-trck to 7, L,, nd try different production for L 8 L N, N, N, N,, 9 N,, N,, 0,, N,,,, N,, N,,,,,,,, derivtion:,, 8, 9,
45 exmple: prllel prsing of CFGs using the grmmr P S S S + M M M M * T T T [0-9] # the strt rule let s consider prsing the sentence: + * the initil input position will e: +* the initil stte (item) set will e: S 0 = {(P S)}
46 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S) initil stte inspecting the first item in the set... the item s position ( ) is immeditely efore non-terminl S we predict n S might pper t this input position we dd items corresponding to ech production of S to the set (there re two of them) 6
47 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from inspecting the next item in the set... the items corresponding to ech production of S re lredy in the set, so there is nothing to do 7
48 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from inspecting the next item in the set... we predict n M might pper t this input position we dd items for ech production of M to the set (there re two of them) 8
49 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from (M M * T ) predict from (M T ) predict from inspecting the next item in the set... we predict n M might pper t this input position the items corresponding to ech production of M re lredy in the set, so there is nothing to do 9
50 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from (M M * T ) predict from (M T ) predict from inspecting the next item in the set... we predict T might pper t this input position dd n item corresponding to its production... 0
51 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from (M M * T ) predict from (M T ) predict from 6 (T ) predict from the current item is positioned efore terminl we check the input for the sme terminl, nd if present... dd n item to the next set representing the prser stte fter scnning pst the terminl
52 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from (M M * T ) predict from (M T ) predict from 6 (T ) predict from S = (T ) scn from S 0.6 there re no more sttes left in set S 0, so... dvnce the input position to the next terminl symol repet the process with the next set, S
53 exmple: prllel prsing of CFGs P S S S + M M M M * T T T [0-9] # the strt rule + * S 0 = (P S ) initil stte (S S + M) predict from (S M ) predict from (M M * T ) predict from (M T ) predict from 6 (T ) predict from S = (T ) scn from S 0.6 the current item (now in S ) is positioned t the end of its production we hve completely recognised T we cn dvnce pst it in the set where it ws originlly predicted: T T ut, how do we know tht the item we re looking for is numer in set S 0?
54 exmple: prllel prsing of CFGs let s dd the originl input position to our stte set items insted of storing sets of (X α β) we will store sets of (j : X α β) where j is the input position where this X ws originlly predicted then, when we rech the end of n item, such s (j : X αβ ) we look in set S j for ny items tht originlly predicted X those items will contin α X β which cn now e dvnced to α X β
55 reooted exmple using the grmmr P S S S + M M M M * T T T [0-9] # the strt rule let s consider prsing the sentence: + * the initil input position will e: +* the initil stte set will e: S 0 = { (0 : P S) }
56 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) ( 0 : T [0-9] ) we completed T t position 0, so... copy the corresponding item from S 0 to S with the T chnged to T 6
57 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) ( 0 : M T ) we completed n M t position 0, so... copy the corresponding items to S with the M chnged to M 7
58 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) ( 0 : M M * T) (0 : S M ) the next item requires * on the input, which is not there move onto the next item 8
59 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T) ( 0 : S M ) we hve completed n S t position 0 copy the corresponding items with S chnged to S 9
60 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) ( 0 : S S + M) (0 : P S ) we need to scn +, which is the next input symol, so... copy the current item to the next set, with + chnged to + 60
61 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) ( 0 : P S ) (0 : S S + M) we hve lso completed the strt rule P in position 0 this input ( ) would e vlid prse, ut... we re not t the end of the input, so we cn continue 6
62 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) (0 : S S + M) there re no more items left in S, so... dvnce the input to the next terminl symol egin considering the next stte set, S 6
63 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) ( 0 : S S + M) predict n M dd two items corresponding to the two productions for M 6
64 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) (0 : S S + M) ( : M M * T ) ( : M T ) predict n M gin ll corresponding items re lredy present in S, so do nothing 6
65 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) (0 : S S + M) ( : M M * T ) ( : M T ) predict T dd the corresponding item 6
66 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) we need to scn digit which we hve ( ), so dd the scnned item to the next stte set, S 66
67 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) ( : T [0-9] ) no more items left in S dvnce the input to the next terminl, nd consider the next stte set, S 67
68 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) * S S we hve completed T in S dd the corresponding item to the set, chnging T to T 68
69 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) * S S we hve completed n M in S dd the corresponding items to the set, chnging M to M 69
70 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 S + S S * S S (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) we need to scn *, which is present on the input dd the corresponding item to the next set, chnging * to * 70
71 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) ( 0 : S S + M ) * S ( : M M * T) S we hve completed n S in S 0 dd the corresponding items to the set, chnging S to S 7
72 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) ( 0 : P S ) (0 : S S + M) * S ( : M M * T) S we hve completed P in S 0 this input ( + ) would e vlid prse, ut there is more input continue with the next item 7
73 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) ( 0 : S S + M) * S ( : M M * T) S we need to scn +, which is not present move on to the next item 7
74 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) S no more items in S dvnce input, consider the next stte set S 7
75 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) S predict T dd the corresponding item 7
76 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S need to scn digit, which is present on the input ( ) copy the item to the next set, with [0-9] chnged to [0-9] 76
77 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) no more items in S dvnce input, consider S 77
78 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) completed T in S copy the corresponding item to the current set, with T chnged to T 78
79 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) completed n M in S copy the corresponding item to the current set, with M chnged to M 79
80 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) ( : M M * T ) (0 : S S + M ) need to scn *, which is not present ignore the item, move on to the next item 80
81 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) ( : M M * T ) ( 0 : S S + M ) completed n M in S copy the items, with M chnged to M 8
82 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) ( : M M * T ) (0 : S S + M ) ( 0 : S S + M) (0 : P S ) need to scn +, which is not present on the input move on to the next item 8
83 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) ( : M M * T ) (0 : S S + M ) (0 : S S + M) ( 0 : P S ) completed P (the strt symol) in S 0 (strt of input) this ( +* ) is vlid prse of the input there is no more input: ccept this s one possile derivtion 8
84 P S S S + M M M M * T T T [0-9] complete exmple # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : P S ) (0 : S S + M) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) ( : M M * T ) (0 : S S + M ) (0 : S S + M) (0 : P S ) there re no more items in this set, nd no more sets there re no more possile prses of the input ll derivtions ccepted so fr re possile prses of the input 8
85 complete exmple P S S S + M M M M * T T T [0-9] # the strt rule S 0 (0 : P S ) (0 : S S + M) (0 : S M ) (0 : M M * T ) (0 : M T ) (0 : T [0-9] ) S (0 : T [0-9] ) (0 : M T ) (0 : M M * T ) (0 : S M ) (0 : S S + M) (0 : P S ) + S (0 : S S + M) ( : M M * T ) ( : M T ) ( : T [0-9] ) S ( : T [0-9] ) ( : M T ) ( : M M * T ) (0 : S S + M ) (0 : S S + M) (0 : P S ) * S ( : M M * T) ( : T [0-9] ) S ( : T [0-9] ) ( : M M * T ) ( : M M * T ) (0 : S S + M ) (0 : S S + M) (0 : P S ) we cn formulte this process s few simple rules... 8
86 prsing CFGs: items let upper-cse letters (e.g., X or Y) e non-terminl symols lower-cse letters (e.g., p or q) e terminl symols greek letters (e.g., α or β) e ny sequence of symols n item is production with dot indicting the current position X α β nd so... X α β γ = n item tht my soon mtch X X α β γ = n item tht hs egun mtching X X α β γ = n item tht hs lmost mtched X X α β γ = n item tht hs finished mtching X 86
87 prsing CFGs: stte sets stte is tuple contining n item nd n input position (i : X α β) the item s production sys wht we re trying to mtch the dot sys how much of the production we hve mtched the position i indictes where the production egn the origin position of X for every input position, the prser genertes stte set position 0 is efore the first token of the input sentence position n is the position fter ccepting the n th token the stte set t input position k is clled S k if the strt symol is S nd the strt rule is S α then, initilly, S 0 = { (0 : S α) } 87
88 prsing CFGs there re three possile forms tht ech stte might tke: stte in S k interprettion (j : X α p β) we expect to see terminl p next on the input (j : X α Y β) we expect to mtch the entire non-terminl Y next (j : X γ ) we hve completely mtched n X t input position j ech cse suggests n pproprite response: stte in S k interprettion (j : X α p β) try to scn p t the current position (j : X α Y β) predict we might see Y t the current position (j : X γ ) complete the mtching of X in stte S j 88
89 prsing CFGs ech response stte in S k interprettion (j : X α p β) try to scn p t the current position (j : X α Y β) predict we might see Y t the current position (j : X γ ) complete the mtching of X in set S j trnsltes into mnipultions of (dditions to) the stte sets: stte in S k new stte(s) (j : X α p β) if the next input token is p, then scn p dd (j : X α, p β) to stte set S k+ (j : X α Y β) for every production in the grmmr for Y, Y γ predict Y dd (k : Y γ) to S k (j : X γ ) for ll sttes in S j of the form (i : Y α X β) complete X dd (i : Y α X β) to S k 89
90 prsing CFGs the result is chrt of the pths tken during prsing oth successful, nd unsuccessful ll successful derivtions will hve completion of the strt rule steps tken within derivtions cn e found esily identify completion of the initil (strt) rule follow completions nd scns ckwrds to the initil rule in S 0 mrk ech step encountered prse tree cn then e reconstructed from the mrked steps either following scns nd predictions forwrds (top-down) or following scns nd completions ckwrds (ottom-up) 90
91 prsing CFGs first vlid prse: S 0. (P S, 0) initil stte S 0. (S M, 0) predict from S 0. (M T, 0) predict from S 0.6 (T [0-9], 0) predict from S. (T [0-9], 0) scn from S 0.6 = (T [0-9], 0) S. (M T, 0) complete from, S 0. = (M T, 0) S. (S M, 0) complete from, S 0. = (S M, 0) S.6 (P S, 0) complete from, S 0. = (P S, 0) 9
92 nother vlid prse: + prsing CFGs S 0. (P S, 0) initil stte S 0. (S M, 0) predict from S 0. (M T, 0) predict from S 0.6 (T [0-9], 0) predict from S. (T [0-9], 0) scn from S 0.6 = (T [0-9], 0) S. (M T, 0) complete from, S 0. = (M T, 0) S. (S M, 0) complete from, S 0. = (S M, 0) S. (S S + M, 0) complete from, S 0. = (S S + M, 0) S. (S S + M, 0) scn from S. = (S M + M, 0) S. (M T, ) predict from S. (T [0-9], ) predict from S. (T [0-9], ) scn from S. S. (M T, ) complete from, S. = (M T, ) S. (S S + M, 0) complete from, S. = (S S + M, 0) S.6 (P S, 0) complete from, S 0. = (P S, 0) 9
93 prsing CFGs finl vlid prse: + * S 0. (P S, 0) initil stte S 0. (S M, 0) predict from S 0. (M T, 0) predict from S 0.6 (T [0-9], 0) predict from S. (T [0-9], 0) scn from S 0.6 S. (M T, 0) complete from, S 0. S. (S M, 0) complete from, S 0. S. (S S + M, 0) complete from, S 0. S. (S S + M, 0) scn from S. S. (M T, ) predict from S. (T [0-9], ) predict from S. (T [0-9], ) scn from S. S. (M T, ) complete from, S. S. (M M * T, ) complete from, S. S. (M M * T, ) scn from S. S. (T [0-9], ) predict from S. (T [0-9], ) scn from S. S. (M M * T, ) complete from, S. S. (S S + M, 0) complete from, S. S.6 (P S, 0) complete from, S 0. 9
94 Erley prsing this form of chrt prser ws invented y Jy Erley in 968 hence we cll it n Erley Prser it cn prse ny context-free grmmr LL nd LR comptile grmmrs in liner time: O(n) ny non-miguous grmmrs in t most qudrtic time: O(n ) ny miguous CF grmmr in (t most) cuic time: O(n ) where n is the size of the input sentence it performs prticulrly well with left-recursive rules very good for left-ssocitive opertors (e.g., most rithmetic opertors) it will deliver ll vlid prses of the input nd useful informtion even if there re no vlid prses Erley prsers re populr for nturl lnguge processing 9
95 Erley prsing function erley-prse(input, grmmr) = dd (0 : S γ) to S 0 for ech stte set S 0, S,..., S k for ech stte s S k if s = (j : X α p β) /* scn */ if input[k] = p dd (j : X α p β) to S k+ else if s = (j : X α Yβ) /* predict */ for ech (Y γ) grmmr dd (k : Y γ) to S k else /* s = (j : X γ ) */ /* complete */ for ech (i : A α X β) S j dd (i : A α X β) to S k 9
96 homework prctice Erley prsing using the input: 9*+ P S S S + M M M M * T T T [0-9] # the strt rule S 0 9 S * S S + S S 96
97 glossry complete step in n Erley prser tht finishes recognising production. All sttes tht were predicting the corresponding non-terminl t the position where the rule egn cn e dvnced nd dded to the current stte. extensile lnguge whose syntx (or semntics) cn e extended y the user, who is often not n expert in the domin of syntx (or semntics). item prser stte, used s n element of stte set or prser stte mchine, contining production rule nd dot representing the progress tht hs een mde in recognising the right-hnd side of tht rule. origin position the input position t which the recognising of production s right-hnd side ws egun. position numericl offset from the strt of the sentence, mesured in tokens. 97
98 predict step in n Erley prser tht predicts seeing non-terminl next in the input. All productions corresponding to the non-terminl re dded to the current stte set. scn step in n Erley prser tht mkes progress y dvncing dot over terminl symol when the next input symol mtches it. Progress is noted y dding new item to the next stte set with the dot moved to fter the terminl symol in the production s right hnd side. stte tuple in n Erley prser comining prsing item with n origin position recording where in the sentence the prsing of the rule ws egun. stte set in n Erley prser, set of sttes ssocited with specific position in the input. tuple pir of vlues tht re ssocited with ech other. In n Erley prser, ech stte is tuple tht comines prser item with n input position. 98
Convert 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationCS 275 Automata and Formal Language Theory
CS 275 Automt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Problem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) Anton Setzer (Bsed on book drft by J. V. Tucker nd K. Stephenson)
More information5. (±±) Λ = fw j w is string of even lengthg [ 00 = f11,00g 7. (11 [ 00)± Λ = fw j w egins with either 11 or 00g 8. (0 [ ffl)1 Λ = 01 Λ [ 1 Λ 9.
Regulr Expressions, Pumping Lemm, Right Liner Grmmrs Ling 106 Mrch 25, 2002 1 Regulr Expressions A regulr expression descries or genertes lnguge: it is kind of shorthnd for listing the memers of lnguge.
More 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 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 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 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 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 informationI1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3
2 The Prllel Circuit Electric Circuits: Figure 2- elow show ttery nd multiple resistors rrnged in prllel. Ech resistor receives portion of the current from the ttery sed on its resistnce. The split is
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 informationCHAPTER 1 Regular Languages. Contents. definitions, examples, designing, regular operations. Non-deterministic Finite Automata (NFA)
Finite Automt (FA or DFA) CHAPTER Regulr Lnguges Contents definitions, exmples, designing, regulr opertions Non-deterministic Finite Automt (NFA) definitions, equivlence of NFAs DFAs, closure under regulr
More 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 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 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 informationCS S-12 Turing Machine Modifications 1. When we added a stack to NFA to get a PDA, we increased computational power
CS411-2015S-12 Turing Mchine Modifictions 1 12-0: Extending Turing Mchines When we dded stck to NFA to get PDA, we incresed computtionl power Cn we do the sme thing for Turing Mchines? Tht is, cn we dd
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 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 informationLecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.
Lecture 3 3 Solving liner equtions In this lecture we will discuss lgorithms for solving systems of liner equtions Multiplictive identity Let us restrict ourselves to considering squre mtrices since one
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 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 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 informationCS 311 Homework 3 due 16:30, Thursday, 14 th October 2010
CS 311 Homework 3 due 16:30, Thursdy, 14 th Octoer 2010 Homework must e sumitted on pper, in clss. Question 1. [15 pts.; 5 pts. ech] Drw stte digrms for NFAs recognizing the following lnguges:. L = {w
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 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 informationSection 4: Integration ECO4112F 2011
Reding: Ching Chpter Section : Integrtion ECOF Note: These notes do not fully cover the mteril in Ching, ut re ment to supplement your reding in Ching. Thus fr the optimistion you hve covered hs een sttic
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 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 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 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 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 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 informationCS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS
CS 310 (sec 20) - Winter 2003 - Finl Exm (solutions) SOLUTIONS 1. (Logic) Use truth tles to prove the following logicl equivlences: () p q (p p) (q q) () p q (p q) (p q) () p q p q p p q q (q q) (p p)
More 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 information2.4 Linear Inequalities and Interval Notation
.4 Liner Inequlities nd Intervl Nottion We wnt to solve equtions tht hve n inequlity symol insted of n equl sign. There re four inequlity symols tht we will look t: Less thn , Less thn or
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 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 informationConverting Regular Expressions to Discrete Finite Automata: A Tutorial
Converting Regulr Expressions to Discrete Finite Automt: A Tutoril Dvid Christinsen 2013-01-03 This is tutoril on how to convert regulr expressions to nondeterministic finite utomt (NFA) nd how to convert
More informationɛ-closure, Kleene s Theorem,
DEGefW5wiGH2XgYMEzUKjEmtCDUsRQ4d 1 A nice pper relevnt to this course is titled The Glory of the Pst 2 NICTA Resercher, Adjunct t the Austrlin Ntionl University nd Griffith University ɛ-closure, Kleene
More informationHow do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?
XII. LINEAR ALGEBRA: SOLVING SYSTEMS OF EQUATIONS Tody we re going to tlk out solving systems of liner equtions. These re prolems tht give couple of equtions with couple of unknowns, like: 6= x + x 7=
More informationKleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem. Kleene s Theorem 2/16/15
Models of Comput:on Lecture #8 Chpter 7 con:nued Any lnguge tht e defined y regulr expression, finite utomton, or trnsi:on grph cn e defined y ll three methods We prove this y showing tht ny lnguge defined
More informationCS 330 Formal Methods and Models Dana Richards, George Mason University, Spring 2016 Quiz Solutions
CS 330 Forml Methods nd Models Dn Richrds, George Mson University, Spring 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Ferury 9 1. (4pts) ((p q) (q r)) (p r), prove tutology using truth tles. p
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 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 information1 From NFA to regular expression
Note 1: How to convert DFA/NFA to regulr expression Version: 1.0 S/EE 374, Fll 2017 Septemer 11, 2017 In this note, we show tht ny DFA cn e converted into regulr expression. Our construction would work
More informationLecture 3: Equivalence Relations
Mthcmp Crsh Course Instructor: Pdric Brtlett Lecture 3: Equivlence Reltions Week 1 Mthcmp 2014 In our lst three tlks of this clss, we shift the focus of our tlks from proof techniques to proof concepts
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 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 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 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 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 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 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 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 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 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 informationName Ima Sample ASU ID
Nme Im Smple ASU ID 2468024680 CSE 355 Test 1, Fll 2016 30 Septemer 2016, 8:35-9:25.m., LSA 191 Regrding of Midterms If you elieve tht your grde hs not een dded up correctly, return the entire pper to
More informationCS375: Logic and Theory of Computing
CS375: Logic nd Theory of Computing Fuhu (Frnk) Cheng Deprtment of Computer Science University of Kentucky 1 Tle of Contents: Week 1: Preliminries (set lger, reltions, functions) (red Chpters 1-4) Weeks
More informationRegular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15
Regulr Lnguge Nonregulr Lnguges The Pumping Lemm Models of Comput=on Chpter 10 Recll, tht ny lnguge tht cn e descried y regulr expression is clled regulr lnguge In this lecture we will prove tht not ll
More 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 informationExercises Chapter 1. Exercise 1.1. Let Σ be an alphabet. Prove wv = w + v for all strings w and v.
1 Exercises Chpter 1 Exercise 1.1. Let Σ e n lphet. Prove wv = w + v for ll strings w nd v. Prove # (wv) = # (w)+# (v) for every symol Σ nd every string w,v Σ. Exercise 1.2. Let w 1,w 2,...,w k e k strings,
More informationCS241 Week 6 Tutorial Solutions
241 Week 6 Tutoril olutions Lnguges: nning & ontext-free Grmmrs Winter 2018 1 nning Exerises 1. 0x0x0xd HEXINT 0x0 I x0xd 2. 0xend--- HEXINT 0xe I nd ER -- MINU - 3. 1234-120x INT 1234 INT -120 I x 4.
More 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 informationBases for Vector Spaces
Bses for Vector Spces 2-26-25 A set is independent if, roughly speking, there is no redundncy in the set: You cn t uild ny vector in the set s liner comintion of the others A set spns if you cn uild everything
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 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 informationSUMMER KNOWHOW STUDY AND LEARNING CENTRE
SUMMER KNOWHOW STUDY AND LEARNING CENTRE Indices & Logrithms 2 Contents Indices.2 Frctionl Indices.4 Logrithms 6 Exponentil equtions. Simplifying Surds 13 Opertions on Surds..16 Scientific Nottion..18
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 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 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 informationInterpreting Integrals and the Fundamental Theorem
Interpreting Integrls nd the Fundmentl Theorem Tody, we go further in interpreting the mening of the definite integrl. Using Units to Aid Interprettion We lredy know tht if f(t) is the rte of chnge of
More informationCS 301. Lecture 04 Regular Expressions. Stephen Checkoway. January 29, 2018
CS 301 Lecture 04 Regulr Expressions Stephen Checkowy Jnury 29, 2018 1 / 35 Review from lst time NFA N = (Q, Σ, δ, q 0, F ) where δ Q Σ P (Q) mps stte nd n lphet symol (or ) to set of sttes We run n NFA
More informationCS 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 informationCHAPTER 1 PROGRAM OF MATRICES
CHPTER PROGRM OF MTRICES -- INTRODUCTION definition of engineering is the science y which the properties of mtter nd sources of energy in nture re mde useful to mn. Thus n engineer will hve to study the
More informationBridging the gap: GCSE AS Level
Bridging the gp: GCSE AS Level CONTENTS Chpter Removing rckets pge Chpter Liner equtions Chpter Simultneous equtions 8 Chpter Fctors 0 Chpter Chnge the suject of the formul Chpter 6 Solving qudrtic equtions
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 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 information