8 Automata and formal languages. 8.1 Formal languages
|
|
- Estella Short
- 6 years ago
- Views:
Transcription
1 8 Automt nd forml lnguges This exposition ws developed y Clemens Gröpl nd Knut Reinert. It is sed on the following references, ll of which re recommended reding: 1. Uwe Schöning: Theoretische Informtik - kurz gefsst. 3. Auflge. Spektrum Akdemischer Verlg, Heidelerg, ISBN PROSITE user mnul 3. Sigrist C.J., Cerutti L., Hulo N., Gttiker A., Flquet L., Pgni M., Biroch A., Bucher P.. PROSITE: documented dtse using ptterns nd profiles s motif descriptors. Brief Bioinform. 3: (2002). We will present sic fcts out: forml lnguges, regulr nd contex-free grmmrs, deterministic finite utomt, nondeterministic finite utomt, pushdown utomt. 8.1 Forml lnguges An lphet Σ is nonempty set of symols (lso clled letters). In the following, Σ will lwys denote finite lphet. A word over n lphet Σ is sequence of elements of Σ. This includes the empty word, which contins no letters nd is denoted y ε. For ny lphet Σ, the set Σ is defined to e the set of ll words over the lphet Σ. The set Σ + := Σ \ {ε} contins ll nonempty words Σ. nd E. g., if Σ = {, }, then Σ = {ε,,,,,,,,,...} Σ + = {,,,,,,,,...}. The length of word x is denoted y x. For words x, y Σ we denote their conctention y xy: If x = x 1,... x m nd y = y 1,..., y n (where x i, y j Σ) then xy = x 1,..., x m, y 1,..., y n. For x Σ let x n := xx... x. (Tht is, n conctented copies of x). } {{ } n
2 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: Thus x n = n x, xy = x + y, nd ε = 0. A (forml) lnguge A over n lphet Σ is simply set of words over Σ, i. e., suset of Σ. The empty lnguge := {} contins no words. (Note: The empty lnguge must not to e confused with the lnguge {ε}, which contins only the empty word.) The complement of lnguge A (over n lphet Σ) is the lnguge Ā := Σ \ A. For lnguges A, B we define their product s using the conctention opertion defined ove. AB := {xy x A, y B}, E. g., if A = {, h}, B = {ε, t, ttu} then AB = {, h, t, ht, ttu, httu}. The powers of lnguge L re defined y L 0 := {ε} L n := L n 1 L, for n 1. The Kleene str (or Kleene hull) of lnguge L is L := L n. i=0 Funnily, n = for n 1, ut = 0 = {ε}, ccording to these definitions. But (defined this wy) lnguge exponentition works s expected: For every lnguge A nd m, n 0, we hve A m A n = A m+n. Most forml lnguges re infinite ojects. In order to del with them lgorithmiclly, we need finite descriptions for them. There re two pproches to this: Grmmrs descrie rules how to produce words from given lnguge. We cn clssify lnguges ccording to the kinds of rules which re llowed. Automt descrie how to test whether word elongs to given lnguge. We cn clssify lnguges ccording to the computtionl power of the utomt which re llowed. Fortuntely, the two pproches cn e shown to e equivlent in mny cses. 8.2 Grmmrs A grmmr is 4-tuple G = (V, Σ, P, S) stisfying the following conditions. V is finite set of vrile symols. For revity, the vrile symols re often simply clled vriles, or nonterminls.
3 8002 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12:48 Σ is finite set of terminl symols, lso clled the terminl lphet. This is the lphet of the lnguge we wnt to descrie. We require tht vrile symols nd terminl symols cn e distinguished, i. e., V Σ =. P is finite set of rules or productions. A rule hs the form where lhs (V Σ) + nd rhs (V Σ). S V is the strt vrile. (left hnd side) (right hnd side), We cn think of the productions of grmmr s wys to trnsform words over the lphet V Σ into other words over V Σ. We cn derive v from u in G in one step if there is production y y in P nd x, z (V Σ) such tht u = xyz nd v = xy z. This is denoted y u G v. If the grmmr is cler from the context, we write just u v. The reflexive nd trnsitive closure G of G is defined s follows. We hve u v if nd only if u = v or v cn G e derived from u in series u w 1 w 2... w n v of steps using the grmmr G. Then L(G) := {w Σ S G w} is the lnguge generted y G. Note: The crucil point is tht we wrote w Σ, not w (V Σ). Vriles re not llowed in generted words which re output. (Note 2: This rises nother question: Productions cn lengthen nd shorten the words. How cn we tell how long it will tke until we hve removed ll vrile symols? Well, tht s nother story.) Exmple 1. The following grmmr genertes ll words over Σ = {, } with eqully mny s nd s. G = ({S}, Σ, P, S), where P := { } S ε, S S, (Cn you prove this?) Exmple 2. The following grmmr genertes well-formed rithmetic expressions over the lphet Σ = {(, ),,, c, +, }.
4 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: G = ({A, M, K}, Σ, P, A), where P := { } A M, A A + M M K, M M K, K, K, K c, K (A), Chomsky descried four sorts of restrictions on grmmr s rewriting rules. The resulting four clsses of grmmrs form hierrchy known s the Chomsky hierchy. In wht follows we use cpitl letters A, B, W, S,... to denote nonterminl symols, smll letters,, c,... to denote terminl symols nd greek letters α, β, γ,... to represent string of terminl nd non-terminl letters. 1. Regulr grmmrs. Only production rules of the form W W or W re llowed. 2. Context-free grmmrs. Any production of the form W α is llowed. 3. Context-sensitive grmmrs. Productions of the form α 1 Wα 2 α 1 βα 2 re llowed. 4. Unrestricted grmmrs. Any production rule of the form α 1 Wα 2 γ is llowed. 8.3 Regulr grmmrs For Bioinformtics we will e interested in the regulr nd context-free grmmrs. definition: Hence more detiled A grmmr is clled regulr if ll productions hve the form l r, where l V nd r Σ ΣV. Tht is, we cn only replce vrile with: terminl (r Σ), or terminl followed y vrile (r ΣV). Exmple. The following regulr grmmr genertes vlid identifier nmes in mny progrmming lnguges. G = ({[lph], [lnum]}, {A,... Z,,..., z,, 0, 1,..., 9}, P, [lph]}, where P := { [lph] A,...,, [lph] A[lnum],..., [lnum], [lnum] A,...,, 0,..., 9, [lnum] A[lnum],..., [lnum], 0[lnum],..., 9[lnum] } Here we used comms to write severl productions shring the sme left hnd side in one line.
5 8004 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: Context-free grmmrs Here the definition of context-free grmmr: Definition 1. A context free grmmr G is 4-tuple G = (V, Σ, P, S) with V nd Σ eing lphets with V Σ =. V is the nonterminl lphet. Σ is the terminl lphet. S N is the strt symol. P V (V Σ) is the finite set of ll productions. Consider the context-free grmmr G = ( {S}, {, }, {S S S }, S ). This CFG produces the lnguge of ll plindromes of the form αα R. For exmple the string cn e generted using the following derivtion: S S S S. The plindrome grmmr cn e redily extended to hndle RNA hirpin loops. For exmple, we could model hirpin loops with three se pirs nd gc or g loop using the following productions. S W 1 u cw 1 g gw 1 c uw 1, W 1 W 2 u cw 2 g gw 2 c uw 2, W 2 W 3 u cw 3 g gw 3 c uw 3, W 3 g gc. (We don t mention the lphets V nd Σ explicitly if they re cler from the context.) Grmmrs generte lnguges. They re mens to quickly specify ll (possily n infinite numer) words in lnguge. Now we will turn the ttention to the utomt tht cn decide whether word is in the lnguge or not. If the word is in the lnguge the utomton ccepts the word. We strt with finite utomt nd proove tht they re le to ccept exctly the words generted y regulr grmmr. 8.5 Deterministic finite utomt A deterministic finite utomton (DFA) is 5-tuple M = (Z, Σ, δ, z 0, E) stisfying the following conditions. Z is finite set of sttes the utomton cn e in. Σ is the lphet. The utomton moves long the input from left to right. In ech step, it reds single chrcter from the input. δ : Z Σ Z is the trnsition function. When the chrcter hs een red, M chnges its stte depending on the chrcter nd its current stte. Then it proceeds to the next input position.
6 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: z 0 is the initil stte of M efore the first chrcter is red. E is the set of end sttes or ccepting sttes. If M is in stte contined in E fter the lst letter hs een red, the input is ccepted. DFAs cn e drwn s digrphs very intuitively. Sttes correspond to vertices. They re drwn s single circles; ccepting sttes re indicted y doule circles. Edges correspond to trnsitions nd re leled with letters from Σ. There is n rc from u to v leled if nd only if there is trnsition δ(u, ) = v. The initil stte is mrked y n ingoing rrow. Exmple. The following utomton ccepts the lnguge (where % denotes modulus, i. e. reminder of division) L = {x {, } (# (x) # (x)) % 3 = 1}. z 0 z 1 z 2 Using the definition of DFA, we hve M = ({z 0, z 1, z 2 }, {, }, δ, z 0, {z 1 }), where δ(z 0, ) = z 1 δ(z 1, ) = z 2 δ(z 2, ) = z 0 δ(z 0, ) = z 2 δ(z 1, ) = z 0 δ(z 2, ) = z 1 A lnguge L is clled regulr if there is regulr grmmr tht produces L \ {ε}. Lengthy remrk: The issue with ε is relly just technicl compliction. We cn lwys modify grmmr G tht genertes lnguge L into grmmr G tht genertes the lnguge L {ε} y the following trick: Let S e the strt vrile of G. Let S e new vrile symol not used y G. Then G is otined y replcing the strt vrile y S nd dding the following productions: S S ε. Whether the resulting grmmr G is lso clled regulr (if G ws regulr) depends on the literture. Schöning uses the following ε-sonderregelung : If ε L(G) is desired, then the production S ε is dmitted, where S is the strt vrile. However, in this cse S must not pper on the right hnd side of production. 8.6 From DFAs to regulr grmmrs Agin, let M = (Z, Σ, δ, z 0, E) e deterministic finite utomton. It is useful to extend the trnsition function δ : Z Σ Z to mpping δ : Z Σ Z, clled the extended trnsition function. We define δ (z, ε) := z for every stte z Z nd inductively, δ (z, x) := δ(δ (z, x), ) for x Σ, Σ.
7 8006 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12:48 Oserve tht if x = x[1.. n] is n input string, then δ (z 0, x[1.. 0]), δ (z 0, x[1.. 1]),..., δ (z 0, x[1.. n]) is the pth of sttes followed y the DFA. Hence, the lnguge ccepted y M is L(M) := {x Σ δ (z 0, x) E}. We re now redy to prove: Theorem 2. Every lnguge which is ccepted y deterministic finite utomton is regulr. Proof: Let M = (Z, Σ, δ, z 0, E) e DFA nd A := L(M). We will construct regulr grmmr G = (V, Σ, P, S) tht genertes A. We let V := Z nd S := z 0. Every rc δ(u, ) = v ecomes production u v P, nd if v E we lso include production u. Tht is, P := {u v δ(u, ) = v} {u δ(u, ) = v E}. Now we hve x[1.. n] L(M) there re sttes z 1,..., z n Z such tht δ(z i 1, x[i]) = z i for i = 1,..., n, where z 0 is the strt stte nd z n E is n ccepting stte there re vriles z 1,..., z n V such tht z i 1 x[i]z i is production in P, where z 0 is the strt vrile, nd z n 1 x[n] is lso production in P we cn derive S = z 0 x[1]z 1 x[1]x[2]z 2... x[1.. n 1]z n 1 x[1.. n] in G, i. e., S G x x[1.. n] L(G). If ε A, i. e., z 0 E, then we need to pply the ε-sonderregelung nd modify G ccordingly. 8.7 Nondeterministic finite utomt In DFAs, the pth followed upon given input ws completely determined. Next we will introduce nondeterministic finite utomt (NFAs). These re defined similr to DFAs, ut ech stte cn hve more thn one successor stte for ny given letter, or none t ll. A nondeterministic finite utomton (NFA) is 5-tuple M = (Z, Σ, δ, U 0, E) stisfying the following conditions. Z is finite set of sttes. Σ is the lphet. δ : Z Σ P(Z) is the trnsition function. Here P(Z) is the power set of Z, i. e. the set of ll susets of Z.
8 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: U 0 is the set of initil sttes. E is the set of ccepting sttes. When the utomton reds Σ nd is in stte z, it is free to choose one of severl sucessor sttes in δ(z, ), or its gets stuck if δ(z, ) =. A nondeterministic finite utomton ccepts nd input if there is t lest one ccepting pth. Agin, we cn define n extended trnsition function δ : P(Z) Σ P(Z). We let δ (U, ε) := U for ll susets of sttes U Z nd inductively, δ (U, x) := δ(v, ) for x Σ, Σ. v δ (U,x) Then the lnguge ccepted y M is L(M) := {x Σ δ (U 0, x) E }. The following illustrtes the definition of δ. The lrge ule on the left side is δ (U, x), the lrge ule on the right side is δ (U, x), where is some letter. The stte spce (ft dots) is shown twice for clrity. Time goes from left to right. The smller cones indicte δ(v, ) for ech v δ (U, x). NFAs cn e drwn s digrphs, similr to DFAs. The resulting digrphs re more generl: We cn hve severl rrows pointing to strt sttes. The numer of rcs with given lel leving vertex is no longer required to e exctly 1, it cn e ny numer (including 0). Exmple. The following NFA ccepts ll words over the lphet Σ = {, } which do not strt or end with the letter.
9 8008 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12:48 z 0 z 1 z 2 z DFAs nd NFAs re equivlent Although NFAs re generliztion of DFAs, they ccept the sme lnguges: Theorem 3 (Rin, Scott). For every nondeterministic finite utomton M there is deterministic finite utomton M such tht L(M) = L(M ). Proof. Let M = (Z, Σ, δ, U 0, E) e n NFA. The sic ide of the proof is to view the susets of sttes of Z s single sttes of n DFA M whose stte spce is P(Z). Then the rest of the definition of M is strightforwrd. The power set utomton is defined s M := (P(Z), Σ, δ, U 0, E ), where P(Z) is the stte spce The trnsition function δ : P(Z) Σ P(Z) is defined y δ (U, ) := δ(v, ) = δ (U, ) for U P(Z). U 0 P(Z) is the new strt stte (note tht in M it ws the set of strt sttes). E := {U Z U E } is the new set of end sttes. v U Using the definitions of M nd M, we hve: x[1.. n] L(M) there re ccepting pths in M, δ (U 0, x[1.. n]) E there re susets U 1, U 2,..., U n Z such tht δ (U i 1, x[i]) = U i nd U n E there is n ccepting pth in M, δ (U 0, x[1.. n]) = U n E x[1.. n] L(M ). Remrks:
10 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: In the power set construction, we cn sfely leve out sttes which cnnot e reched from the strt stte U 0. Tht is, we cn generte the reched stte sets on the fly. 2. The exponentil low up of the numer of sttes (from Z to 2 Z ) cnnot e voided in generl. For exmple, the lnguge L := {x {, } x k nd the k-lst letter of x is n } hs n NFA with k + 1 sttes, ut it is not hrd to show tht no DFA for L cn hve less tht 2 k sttes. 8.9 From regulr grmmrs to NFAs We hve just seen how to trnsform nondeterministic finite utomton into deterministic finite utomton. We hve seen efore how to trnsform deterministic finite utomton into regulr grmmr. Next we will see how to trnsform regulr grmmr into nondeterministic finite utomton. This concludes the proof tht the regulr lnguges re precisely those which re ccepted y finite utomt (of oth kinds). Theorem 4. Every regulr lnguge is ccepted y nondeterministic finite utomton. Proof. Let G = (V, Σ, P, S) e regulr grmmr nd A := L(G). We will construct n NFA M = (Z, Σ, δ, {z 0 }, E) such tht L(M) = A. Note tht in every derivtion in regulr grmmr, the intermedite words contin exctly one vrile, nd the vrile must e t the end. This vrile will ecome stte of the NFA. We need one more extr stte, which M enters when the vrile is eliminted in the lst step. Thus we let the stte set e Z := V {X}. The only possile initil stte is z 0 := S, the strt vrile of G. The set of end sttes is E := {X} if ε A. If ε A, then we let E := {X, S}. Next we trnslte productions into trnsitions. We define δ : Z Σ P(Z) y Tht is, δ(u, ) v δ(u, ) X iff u v P iff u P δ(u, ) = {v u v P} {X u P}. Note tht the end stte X hs no successor sttes. And if S is n end stte, then y the ε-sonderregelung there is no wy to get ck to S, s it does not pper on the right side of production. Now we hve for n 1: x[1.. n] L(G) there re vriles z 1,..., z n V such tht we cn derive z 0 = S G x[1]z 1 G x[1]x[2]z 2 G... G x[1.. n 1]z n 1 G x[1.. n] in G, tht is, z i 1 x[i]z i is production in P, where z 0 = S is the strt vrile, nd z n 1 x[n] is lso production in P there re sttes z 1,..., z n Z {X} such tht δ(z i 1, x[i]) z i for i = 1,..., n, where z 0 is the strt stte, nd z n = X is only end stte which is fesile for word of length 1 x[1.. n] L(M) Moreover, y construction we hve ε L(M) ε A.
11 8010 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: Regulr expressions Regulr expressions re perhps the most populr wy to descrie regulr lnguges in forml terms. Introductory Exmples. At UNIX shell, you might type: > ls s*[re]?t*x script.ux script.tex slides.tex Here we hve used the wildcrd chrcters * nd?. The PROSITE dtse contins common motifs of protein fmilies, some of which re descried y ( restricted form of) regulr expressions. The following two lines re from the PROSITE entry with ccession numer PS00518, which contins pttern for zinc finger C3HC4 domin: ID PA ZINC_FINGER_C3HC4; PATTERN. C-x-H-x-[LIVMFY]-C-x(2)-C-[LIVMYA]. The precise syntx used for regulr expressions vries. Here is one. following rules. A regulr expression γ nd the lnguge L(γ) it represents re defined inductively y the 1. is regulr expression. It denotes the empty lnguge. L( ) =. 2. ε is regulr expression. Its lnguge consists of the empty word. L(ε) = {ε}. 3. For ech single letter, Σ, is regulr expression. L() = {}. 4. Let α nd β e regulr expressions. Then the following re lso regulr expressions: (Closure properties) (i) αβ with L(αβ) := L(α)L(β) product (ii) (α β) with L((α β)) := L(α) L(β) union (iii) (α) with L((α) ) := (L(α)) str hull Some oservtions. 1. For every regulr expression α, it holds αε = εα = α nd α = α =. 2. Let x = x[1.. n] Σ. Then x is regulr expression nd L(x) = {x}, y rules 2., 3., nd 4.(i). 3. Let A = {x 1, x 2,..., x k } Σ e finite lnguge. Then (... ((x 1 x 2 ) x 3 )... x k ) is regulr expression nd L((... ((x 1 x 2 ) x 3 )... x k )) = A, y rule 4.(ii) nd the previous oservtion. We shll rther write this expression s (x 1 x 2 x 3... x k ). Exmple 1. The lnguge L = {x {, } x contins s sustring } cn e represented y the following regulr expression: ( ) ( ).
12 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: Exmple 2. The lnguge L = {x {, } x does not contin s sustring } cn e represented y the following regulr expression: This cn e seen s follows. A DFA for L is ( ) ( ε) z 1 z 2 z 3 We hve δ(z 1, x) = z 1 iff x L(( ) ). After tht we cn mke one more trnsition from z 1 to z 2 reding n Finite utomt nd regulr expressions re equivlent Theorem 5 (Kleene). A lnguge is regulr if nd only if it is descried y regulr expression. (the following proof is not needed for the exmintion. You cn red it t your convenience). Proof. We show oth inclusions in turn. ( ) Let γ e regulr expression. We show tht L(γ) is ccepted y nondeterministic finite utomton. We follow the cses in the inductive definition of regulr expressions. Cses 1., 2., nd 3. re trivil: Clerly there re NFAs for L( ) =, for L(ε) = {ε}, nd for L() = {} (where Σ). Cse 4.(ii): γ hs the form γ = (α β). We cn ssume y induction tht we lredy hve two NFAs M 1 = (Z 1, Σ, δ 1, U 1, E 1 ) nd M 2 = (Z 2, Σ, δ 2, U 2, E 2 ) stisfying L(α) = L(M 1 ), L(β) = L(M 2 ), nd Z 1 Z 2 =. Then we cn simply tke the union of M 1 nd M 2. Tht is, we uild the NFA M := (Z 1 Z 2, Σ, δ 1 δ 2, U 1 U 2, E 1 E 2 ). Here δ 1 δ 2 susumes ll the trnsitions present in M 1 nd M 2. There re no trnsitions etween the M 1 nd M 2 prts in M. Formlly, (δ 1 δ 2 )(U) = δ 1 (U Z 1 ) δ 2 (U Z 2 ). Then L(M) = L(α) L(β) = L(γ). Cse 4.(i): γ hs the form γ = αβ. Here we plug two NFAs M 1 nd M 2 for L(α) nd L(β) in series to otin M. (We cn ssume tht the stte sets re disjoint, Z 1 Z 2 =.) M hs the strt stte set U 1, if ε L(α). If ε L(α), then M hs the strt stte set U 1 U 2. In oth cses, the end stte set of M is E 2.
13 8012 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12:48 Moreover we dd rcs from M 1 to M 2 s follows: For every rc δ 1 (u, ) v in M 1 tht enters stte in E 1, we dd couple of rcs δ(u, ) s 2, for ll s 2 U 2, in M. Hence in M we cn rech stte in U 2 if nd only if the chrcters which re red long the wy form word in L(M 1 ). After tht the rest of the input is processed using M 2. This implies L(M) = L(M 1 )L(M 2 ) = L(α)L(β) = L(αβ) = L(γ). Cse 4.(iii): γ hs the form γ = (α). Agin let M 1 s ove e n NFA for L(α). Then we construct n NFA M which ccepts L((α) ) s follows. M hs the sme sttes, initil sttes, nd end sttes s M 1. The difference is tht we dd trnsitions similr to Cse 4.(ii). Nmely, for ech trnsition δ 1 (u, ) v, where v E 1, we dd couple of rcs δ(u, ) s 1 for ll s 1 U 1. This mens tht whenever we would rech n end stte of M 1, we cn s well strt reding nother word of L(M 1 ) from one of its initil sttes. Using the union construction, we cn dd ε to the ccepted lnguge using Cse 4.(i), if necessry. Note tht L((M) ) = L(ε L(M 1 ) + ), s needed. ( ) Now let M = (Z, Σ, δ, z 1, E) e deterministic finite utomton. We show tht L(M) is descried y regulr expression. We cn ssume w.l.o.g. tht the vertex set of M is numered Z = {z 1, z 2,..., z n } nd z 1 is the initil stte. The key to the proof is the next definition. R k i,j := {x Σ δ (z i, x) = z j nd δ (z i, x[1.. l]) {z 1,..., z k } for ll 1 l < x }. A word x is in R k i,j iff when we strt reding x eginning in stte z i, then we end up in stte x j, nd moreover, ll intermedite sttes (i. e. those sttes where we hve een fter reding proper, non-empty prefix x[1.. l] of x), hve indices t most k. R k is so importnt ecuse it llows use to solve the prolem using 3-prmeter recursion nd dynmic i,j progrmming. The initil cses k = 0 re esy: No intermedite sttes re llowed t ll, thus we hve R 0 i,j = { Σ δ(z i, ) = z j } for i j { Σ δ(z i, ) = z i } {ɛ} for i = j. In oth cses, R 0 is finite lnguge nd we cn write down regulr expression for it. i,j Now for the recursive cse k 1. The difference etween R k+1 nd R k i,j i,j is tht z k+1 ecomes llowed s n intermedite stte. Thus we cn prtition ny word x R k+1 \ R k i,j i,j etween its visits of the stte z k+1. We strt t z i. Either we go to z j without visiting z k+1. Or we visit z k+1 t lest once. The sustring etween two consecutive visits of z k+i is word from the lnguge R k k+1,k+1. Then we go from z k+1 to z j without nother visit t z k+1. Thus it holds: R k+1 i,j = R k i,j Rk i,k+1 (Rk k+1,k+1 ) R k k+1,j. This trnsltes lmost literlly into regulr expression. expressions γ k i,j such tht Rk i,j = L(γk ). Then i,j Assume y induction tht we hve regulr is regulr expression such tht L(γ k+1 i,j ) = R k+1 i,j. γ k+1 i,j := (γ k i,j γk i,k+1 (γk k+1,k+1 ) γ k k+1,j )
14 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: where To summrize, R k i,j := {x Σ δ (z i, x) = z j nd δ (z i, x[1.. l]) {z 1,..., z k } for ll 1 l < x }, R 0 i,j = { Σ δ(z i, ) = z j } for i j { Σ δ(z i, ) = z i } {ɛ} for i = j. R k+1 i,j = R k i,j Rk i,k+1 (Rk k+1,k+1 ) R k k+1,j. When we hve reched k = n, then the restriction which is imposed y the upper index in R k i,j ecomes void. Note tht L(M) = {R n 1,j z j E}. Therefore we let γ := (γ n 1,i 1... γ n 1,i l ), where E = {i 1,..., i l } is n enumertion of the end sttes. Then L(γ) = L(M) Exmple for Kleene s trnsformtion We hve seen DFA for the lnguge efore. L = {x {, } (# (x) # (x)) 1 mod 3} The recurrences from the theorem yield γ 0 i,j γ 1 i,j ε 0 ε 1 ε 1 (ε ) ( ) 2 ε 2 ( ) (ε ) z 0 z 1 z 2 γ 2 i,j (ε () ) () ( () ( )) 1 () () () ( ) 2 ( ( )() ) ( )() ((ε ) ( )() ( )) Since z 2 is the only end stte, regulr expression for L is γ 3 0,1 = γ2 0,2 (γ2 2,2 ) γ 2 2,1 = ( () ( ))(((ε ) ( )() ( ))) ( )().
15 8014 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12:48 Finlly we return to context-free grmmrs nd introduce the utomton tht ccepts context-free lnguge, the pushdown utomton (PDA). We will first define it nd then show t n exmple how we cn decide whether string is in the lnguge generted y given CFG. Recll our smll hirpin generting CFG: S W 1 u cw 1 g gw 1 c uw 1, W 1 W 2 u cw 2 g gw 2 c uw 2, W 2 W 3 u cw 3 g gw 3 c uw 3, W 3 g gc. There is n elegnt representtion for derivtions of sequence in CFG clled the prse tree. The root of the tree is the nonterminl S. The leves re the terminl symols, nd the inner nodes re nonterminls. For exmple if we extend the ove productions with S SS we cn get the following: S S W 1 S W 1 W 2 W 2 W 3 W 3 c g g c u g g g u g c c c Using pushdown utomton we cn prse sequence left to right ccording. A (nondeterministic) PDA is formlly defined s 6-tuple: M = (Z, Σ, Γ, δ, z 0, S) where Z is finite set of sttes, Σ is finite input lphet, Γ is finite stck lphet δ : Z Σ {ɛ} Γ P(Z Γ ) is the trnsition function, where P(S) denotes the power set of S. z 0 is the strt stte, S is the initil stck symol S Γ is the lowest stck symol. There is of course lso deterministic version, however the nondeterministic PDA llows for simple construction when CFG is given. If M is in stte z nd reds the input nd if A is the top stck symol, then M cn go to stte z nd replce A y other stck symols. This implies, tht A cn e deleted, replced, or ugmented.
16 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: After reding the input, the utomton ccepts the word if the stck is empty. Given CFG G = (V, Σ, P, S) we define the corresponding PDA s M = ({z}, Σ, V Σ, δ, z, S). Using the production set P we cn define δ. For ech rule A α P we define δ such tht (z, α) δ(z, ɛ, A) nd (z, ɛ) δ(z,, ). Lets look t our exmple: S W 1 u cw 1 g gw 1 c uw 1, W 1 W 2 u cw 2 g gw 2 c uw 2, W 2 W 3 u cw 3 g gw 3 c uw 3, W 3 g gc. Hence M = ({z}, {, c, g, u}, {, c, g, u, W 1, W 2, W 3, S}, δ, z, S) with δ s explined (lckord). Lets see how the utomton prses word in our hirpin lnguge. Given our CFG, the utomton s stck is initilized with the strt symol S. Then the following steps re iterted until no symols remin. If the stck is empty when no input symols remin, then the sequence hs een successfully prsed. 1. Pop symol off the stck. 2. If the popped symol is non-terminl: Peek hed in the input nd choose vlid production for the symol. (For deterministic PDAs, there is t most one choice. For non-deterministic PDAs, ll possile choices need to e evluted individully.) If there is no vlid trnsision, terminte nd reject. Push the right side of the production on the stck, rightmost symols first. 3. If the popped symol is terminl: Compre it to the current symol of the input. If it mtches, move the utomton to the right on the input. If not, reject nd terminte. Lets try this with the string gccgcggc. Exmple. (The current symol is written using cpitl letter): Input string Stck Opertion Gccgcggc S Pop S. Produce S->gW1c Gccgcggc gw1c Pop g. Accept g. Move right on input. gccgcggc W1c Pop W1. Produce W1->cW2g gccgcggc cw2gc Pop c. Accept c. Move right on input. gccgcggc W2gc Pop W2. Produce W2->cW3g gccgcggc cw3ggc Pop c. Accept c. Move right on input. gccgcggc W3ggc Pop W3. Produce W3->gc gccgcggc gcggc Pop g. Accept g. Move right on input (severl cceptnces) gccgcggc c Pop c. Accept c. Move right on input. gccgcggc$ - Stck empty, input string empty. Accept!
17 8016 Finite utomt nd regulr grmmrs, y Clemens Gröpl, Jnury 9, 2014, 12: Summry Forml lnguges re sic mens in computer science to formlly descrie ojects tht follow certin rules, tht is tht cn e generted using grmmr. Two fundmentl views on forml lnguges re i) to view them s generted y grmmr, or ii) to view them s ccepted y n utomton. The Chomsky hierrchy plces different restrictions on the grmmrs. This limits the possiilities you hve, ut mkes the decision whether word is in such lnguge esier. The nondeterministic utomt (DFA nd PDA) re s powerful s te deterministic counterprts in deciding whether word is in lnguge or not. However, it is esier to define nondeterministic utomton. The importnce for ioinfomtics lies in the stochstic versions of the grmmrs which re used to trin cceptors for iologicl sequence ojects (i.e. Genes using Hidden Mrkov models, or RNA using stochstic CFGs).
7 Automata and formal languages. 7.1 Formal languages
7 Automt nd forml lnguges This exposition ws developed by Clemens Gröpl nd Knut Reinert. It is bsed on the following references, ll of which re recommended reding: 1. Uwe Schöning: Theoretische Informtik
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationAUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton
25. Finite Automt AUTOMATA AND LANGUAGES A system of computtion tht only hs finite numer of possile sttes cn e modeled using finite utomton A finite utomton is often illustrted s stte digrm d d d. d q
More informationFormal languages, 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 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 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 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 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 informationRegular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Regular Expressions (RE) Kleene-*
Regulr Expressions (RE) Regulr Expressions (RE) Empty set F A RE denotes the empty set Opertion Nottion Lnguge UNIX Empty string A RE denotes the set {} Alterntion R +r L(r ) L(r ) r r Symol Alterntion
More 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 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 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 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 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 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 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 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 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 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 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 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 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 informationFundamentals of Computer Science
Fundmentls of Computer Science Chpter 3: NFA nd DFA equivlence Regulr expressions Henrik Björklund Umeå University Jnury 23, 2014 NFA nd DFA equivlence As we shll see, it turns out tht NFA nd DFA re equivlent,
More 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 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 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 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 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 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 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 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 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 informationCSCI 340: Computational Models. Transition Graphs. Department of Computer Science
CSCI 340: Computtionl Models Trnsition Grphs Chpter 6 Deprtment of Computer Science Relxing Restrints on Inputs We cn uild n FA tht ccepts only the word! 5 sttes ecuse n FA cn only process one letter t
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 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 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 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. 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 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 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 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 informationNFA DFA Example 3 CMSC 330: Organization of Programming Languages. Equivalence of DFAs and NFAs. Equivalence of DFAs and NFAs (cont.
NFA DFA Exmple 3 CMSC 330: Orgniztion of Progrmming Lnguges NFA {B,D,E {A,E {C,D {E Finite Automt, con't. R = { {A,E, {B,D,E, {C,D, {E 2 Equivlence of DFAs nd NFAs Any string from {A to either {D or {CD
More 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 informationScanner. Specifying patterns. Specifying patterns. Operations on languages. A scanner must recognize the units of syntax Some parts are easy:
Scnner Specifying ptterns source code tokens scnner prser IR A scnner must recognize the units of syntx Some prts re esy: errors mps chrcters into tokens the sic unit of syntx x = x + y; ecomes
More 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 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 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 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 informationAutomata Theory 101. Introduction. Outline. Introduction Finite Automata Regular Expressions ω-automata. Ralf Huuck.
Outline Automt Theory 101 Rlf Huuck Introduction Finite Automt Regulr Expressions ω-automt Session 1 2006 Rlf Huuck 1 Session 1 2006 Rlf Huuck 2 Acknowledgement Some slides re sed on Wolfgng Thoms excellent
More 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 informationNon-deterministic Finite Automata
Non-deterministic Finite Automt Eliminting non-determinism Rdoud University Nijmegen Non-deterministic Finite Automt H. Geuvers nd T. vn Lrhoven Institute for Computing nd Informtion Sciences Intelligent
More informationNFAs continued, Closure Properties of Regular Languages
Algorithms & Models of Computtion CS/ECE 374, Fll 2017 NFAs continued, Closure Properties of Regulr Lnguges Lecture 5 Tuesdy, Septemer 12, 2017 Sriel Hr-Peled (UIUC) CS374 1 Fll 2017 1 / 31 Regulr Lnguges,
More 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 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 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 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 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 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 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 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 information80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES. 2.6 Finite State Automata With Output: Transducers
80 CHAPTER 2. DFA S, NFA S, REGULAR LANGUAGES 2.6 Finite Stte Automt With Output: Trnsducers So fr, we hve only considered utomt tht recognize lnguges, i.e., utomt tht do not produce ny output on ny input
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 informationAnatomy of a Deterministic Finite Automaton. Deterministic Finite Automata. A machine so simple that you can understand it in less than one minute
Victor Admchik Dnny Sletor Gret Theoreticl Ides In Computer Science CS 5-25 Spring 2 Lecture 2 Mr 3, 2 Crnegie Mellon University Deterministic Finite Automt Finite Automt A mchine so simple tht you cn
More informationCS 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 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 informationLecture 9: LTL and Büchi Automata
Lecture 9: LTL nd Büchi Automt 1 LTL Property Ptterns Quite often the requirements of system follow some simple ptterns. Sometimes we wnt to specify tht property should only hold in certin context, clled
More 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 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 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 informationCS 330 Formal Methods and Models
CS 0 Forml Methods nd Models Dn Richrds, George Mson University, Fll 2016 Quiz Solutions Quiz 1, Propositionl Logic Dte: Septemer 8 1. Prove q (q p) p q p () (4pts) with truth tle. p q p q p (q p) p q
More informationFinite-State Automata: Recap
Finite-Stte Automt: Recp Deepk D Souz Deprtment of Computer Science nd Automtion Indin Institute of Science, Bnglore. 09 August 2016 Outline 1 Introduction 2 Forml Definitions nd Nottion 3 Closure under
More 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 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 informationCS103 Handout 32 Fall 2016 November 11, 2016 Problem Set 7
CS103 Hndout 32 Fll 2016 Novemer 11, 2016 Prolem Set 7 Wht cn you do with regulr expressions? Wht re the limits of regulr lnguges? On this prolem set, you'll find out! As lwys, plese feel free to drop
More informationHomework Solution - Set 5 Due: Friday 10/03/08
CE 96 Introduction to the Theory of Computtion ll 2008 Homework olution - et 5 Due: ridy 10/0/08 1. Textook, Pge 86, Exercise 1.21. () 1 2 Add new strt stte nd finl stte. Mke originl finl stte non-finl.
More informationFormal Languages and Automata Theory. D. Goswami and K. V. Krishna
Forml Lnguges nd Automt Theory D. Goswmi nd K. V. Krishn Novemer 5, 2010 Contents 1 Mthemticl Preliminries 3 2 Forml Lnguges 4 2.1 Strings............................... 5 2.2 Lnguges.............................
More informationHomework 4. 0 ε 0. (00) ε 0 ε 0 (00) (11) CS 341: Foundations of Computer Science II Prof. Marvin Nakayama
CS 341: Foundtions of Computer Science II Prof. Mrvin Nkym Homework 4 1. UsetheproceduredescriedinLemm1.55toconverttheregulrexpression(((00) (11)) 01) into n NFA. Answer: 0 0 1 1 00 0 0 11 1 1 01 0 1 (00)
More 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 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 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 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 information