1.[3] Give an unambiguous grammar that generates the set of all regular expressions on Ó = {a,b}. Justify your construction.
|
|
- Emmeline Richard
- 6 years ago
- Views:
Transcription
1 CAS 705. Sample solutions to the assignment 2 (many questions have more than one solutions). Total of this assignment is 135 pts. Each assignment is worth 25%. 1.[3] Give an unambiguous grammar that generates the set of all regular expressions on Ó = {a,b}. Justify your construction. ó (ó ó) (óó) ó* ö å a b The first three productions correspond to three induction steps, while the last four productions are for four base cases. The parenthesis guarantee that the grammar is unambiguous. 2.[6] Which of the following grammars is ambiguous and which is unambiguous. In each case justify your answer in as much formal way as you can. (a) ó AB aab (b) ó aab A å A a Aa A aabb abb B b (c) ó aób aab (d) ó ab aa å A cad B A aó baa B abb å B bó abb (a)[1.5] ó AB aab (b)[1.5] ó aab A å A a Aa A aabb abb B b It is ambiguous. See following two It is unambiguous. In each derivation left derivations for aab. ó occurs only once, at the ning. ó AB AaB aab aab If x å, A aabb is then applied ó aab aab several times and a derivation is completed with A abb. So, no split can happen, i.e. the grammar is unambiguous. (c)[1.5] ó aób aab (d)[1.5] ó ab aa å A cad B A aó baa B abb å B bó abb It is ambiguous. See following two It is ambiguous. See following two 1
2 left derivations for aabb. ó aób aaabb aabbb aabb ó aab abb aabbb aabb left derivations for abaa. ó ab abó abaa abaaó abaa ó aa abaa abaóa abaa abaaó abaa 3.[4] Prove that the language L = { xx R x {a,b}* } is not inherently ambiguous. Here is a grammar generating above language. ó aóa bób a b It is unambiguous, since it generates strings in an unique way, i.e. from both ends toward the centre. 4.[4] Construct a right linear grammar that generates the language over L = (aab*ab)*. Construct a DFA for L first, then, it is easy to get the right linear grammar as following, ó aa å A ab B ac bb C bó b 5.[6] Show that the regular languages cannot be inherently ambiguous. Let L be a regular language and let M=(Q,Ó,ä,s 0,F), be a deterministic finite state automaton such that L(M) = L. Define the following right linear grammar G, G = (Ó,Q,P,s 0 ), where P = { p aq ä(p,a)=q } {p a ä(p,a) F }. Clearly L(G)=L(M), see Lecture Notes or any textbook. Since the automaton is deterministic, there is always exactly one derivation, so there is also exactly one leftmost derivation. 2
3 6.[4] Eliminate all useless productions from the below grammar. Give all the steps. ó AC Bó B A aa af B CF b C cc D D ad BD C E aa BóA F bb b What language does this grammar generate? First eliminate type 1 useless symbol, namely C and D, and we have, ó Bó B A aa af B b E aa BóA F bb b Then, eliminate type 2 useless symbols, namely A, E, and F. We have, ó Bó B B b What language does this grammar generate? L = bb* 7.[4] Eliminate all -productions from ó AaB aab ABB A AB B bba Give all the steps. By observation, we can see that A and B are nullable. By ó ABB, we know ó is nullable. Hence, ó AaB aab ABB ab Aa a aa BB AB A B å A AB A B B bba bb 3
4 8.[4] Eliminate all unit-productions from ó ACA CA AA AC A C A aaa aa B C B bb b C cc c Give all the steps. A B C are unit-productions. Since we have B bb b and C cc c, we can replace them by A bb b cc c. Then we have A aaa aa bb b cc c Again, ó A C are unit-productions. Since we have A aaa aa bb b cc c and C cc c, we can replace them by ó aaa aa bb b cc c. Finally, we have, ó ACA CA AA AC aaa aa bb b cc c A aaa aa bb b cc c B bb b C cc c 9.[5] It is possible to define the term simplification precisely by introducing the concept of complexity of a grammar. This can be done in many ways; one of them is through the length of all the strings giving the production rules. For example, we might use: complexity(g) = A v P (1+ v ). A context-free grammar G min is said to be minimal for a given language L if L(G min )=L and complexity(g min ) complexity(g) for any G such that L(G)=L. Does a removal of useless symbols always produce a minimal grammar? Justify your answer. No. After the removal of useless symbols, there may still exist å-productions and/or unit-productions. The removals of å-productions and/or unit-productions may also reduce the complexity of the grammar. Therefore a removal of useless symbols may not produce a minimal grammar. However, a removal of useless symbols does reduce the complexity of the grammar, and sometimes it produces a minimal grammar. Consider the following case. 4
5 ó aa B C A aa a B b C ac Only C is useless and after its removal we have: ó aa B A aa a B b which is not minimal as for instance (after removing unit- and -productions) ó aa b A aa a has smaller complexity. Note that L(G)= aa* b, so the last grammar is minimal one. 10.[5] Convert the grammar ó abab AB ab A bab aab B BAa A bba into Chomsky normal form. Give all the steps. First we have to get rid of all -productions. The obtained grammar is: ó abab AB ab aba abb ab A B a å A bab aab ba bb b B BAa A bba Aa Ba a bb Next we have to get rid of all unit-productions. The result is: ó abab AB ab aba abb ab a å BAa bba Aa Ba bb bab aab ba bb b A bab aab ba bb b B BAa bba Aa Ba a bb bab aab ba bb b Now, we may produce a Chomsky normal form: ó X a X bab AB X a B X a X ba X a X bb X a X b a å BX Aa X b X ba Axa BX a X b X b X b X AB X a X ab X b A X b B b A X b X AB X a X ab X b A X b B b B X BA X a X b X ba AX a BX a a X b X b X b X AB X a X ab X b A X b B b X a a X b b X bab X b X AB X AB AB 5
6 X ba X b A X bb X b B X Aa AX a X ba X b A X ab X a X b X BA BA 11.[6] Convert the grammar ó ABb a AAB A aaa B AB B bab ABB a into Greibach normal form. Give all the steps. If a standard construction is not used, provide some justification. First substitute B by bab ABB a in A B. The result is A aaa bab a ABB AB Note, A ABB adds two Bs and A AB adds one B, and in the end, The A has to be replaced by one of aaa bab a. Therefore, to change A ABB A ABB to the Graibach Normal Form, we can replace them by: A aaax babx ax X BB BBX B BX Now, we have, A aaa bab a aaax babx ax Then we can change B ABB to B aaabb babbb abb aaaxbb babxbb axbb Now, we have, B bab a aaabb babbb abb aaaxbb babxbb axbb Next we have to change X BB BBX B BX to X babb ab aaabbb babbbb abbb aaaxbbb babxbbb axbbb babbx abx aaabbbx babbbbx abbbx aaaxbbbx babxbbbx axbbbx aaabb babbb abb aaaxbb babxbb axbb aaabbx babbbx abbx aaaxbbx babxbbx axbbx Now ó ABb AAB are the problem, so they have to change to: 6
7 ó aaabb babbb abb aaaxbb babxbb axbb aaaab babab aab aaaxab babxab axab In the last steps we just have to replace all terminals that are not most on the left by appropriate variables. The result is the following grammar in the Graibach Normal Form. ó ac a ABC b bac b BC b abc b ac a AXBC b bac b XBC b axbc b ac a AAB bac b AB aab ac a AXAB bac b XAB axab a A ac a A bac b a ac a AX bac b X ax B bac b a ac a ABB bac b BB abb ac a AXBB bac b XBB axbb X bac b B ab ac a ABBB bac b BBB abbb ac a AXBBB bac b XBBB axbbb bac b BX abx ac a ABBBX bac b BBBX abbbx ac a AXBBBX bac b XBBBX axbbbx ac a ABB bac b BB abb ac a AXBB bac b XBB axbb ac a ABBX bac b BBX abbx ac a AXBBX bac b XBBX axbbx C a a C b b 12.[5] Construct a pushdown automaton accepting: L={ a n+1 b 2n n 0 }. It is up tu you if it will accept with a final state of empty stack. Justify your construction. We can easily define a context-free grammar that generates L, for example: ó aa a A aabb abb Next we can easily transform this grammar into a Graibach normal form: ó aa a A aac b C b ac b C b C b b Then, by using a standard transformation, we will get A = ({p},{a,b},{ó, A, C b }, p,ó,ä, Ø), where ä is the following: ä(p,a,ó ) = {(p,a),(p, )} ä(p,a,a) = { (p,ac b C b ),(p,c b C b )} ä(p,b,c b ) = { (p, )} Alternatively, we can construct push-down machine directly. The idea is as following. 7
8 When read in the first a, we do nothing(if the first character is b, reject). For following a s, we push XX onto the stack. Whenever b is read in, we change to another state, and pop one X for every b read in(from now on, if any a is read in, reject). The machine accepts strings by empty stack. The result machine is almost the same as above one, except that we use two state to give the boundary of a s and b s, not a special top element A on the stack. 13.[5] Construct a pushdown automaton accepting: L = { x # a (x) # b (x) 2# a (x) x {a,b,c}* }. It is up tu you if it will accept with a final state of empty stack. Justify your construction. A possible solution that accepts with a final state is the following: M = (Q, Ó, Ã, ä, q 0, Z, F), where Q = {q 0, q 1, q f }, Ó = {a,b}, Ã = {A,Z}, F = {q f } and the transition function ä is the following: ä(q 0,a,Z) = {(q 0,AZ), (q 0,AAZ) } ä(q 0,a,A) = {(q 0,AA), (q 0,AAA)} ä(q 0,b,A) = {(q 0, }) ä(q 0,b,Z) = {(q 0,BZ)} ä(q 0,b,B) = {(q 0,BB)} ä(q 0,a,B) = {(q 0, ), (q 1, )} ä(q 1,,B) = {(q 0, )} ä(q 1,,Z) = {(q 0,AZ)} ä(q 0,c,Z) = {(q 0,Z}) ä(q 0,c,A) = {(q 0,A}) ä(q 0, ) = {(q f,z)} The idea is that, when we read in more a s than b s, push one or two A s for each a read in, pop one A for each b read in. However, when we read in more b s than a s, push one A for each b read in, and pop one or two A s for each a read in. For input c s, do nothing. The machine accept empty stack. 8
9 14.[5] Construct a pushdown automaton that accept the language generated by the following grammar: ó AA a A óa b It is up tu you if it will accept with a final state of empty stack. First change the grammar to Graibach normal form: ó ban an ba a A bana ana baa aa b N bana ana baa aa b banan anan baan aan bn Then, by using a standard transformation, we will get A = ({p},{a,b},{ó, A, N}, p,ó,ä, Ø), where ä is the following: ä(p,a,ó ) = {(p,n),(p, )} ä(p,b,ó ) = {(p,an),(p,a)} ä(p,a,a) = { (p,na),(p,a)} ä(p,b,a) = { (p,ana),(p,aa),(p, )} ä(p,a,n) = { (p,na),(p,a),(p,nan),(p,an)} ä(p,b,n) = { (p,ana),(p,aa),(p,anan),(p,aan),(p,n),(p, )} 15.[4] Show that L = { a n b j n j 2 } is not a context free language. Assume L is context free, then pumping lemma hold. Let p be the number in pumping lemma. Let z = a q b p and q=p 2. Clearly, z p and z L. Therefore, z=uvwxy and vx 1, vwx p, and ( i 0) uv i wx i y L. Let us consider two cases, Case 1) vx = a k, i.e. containing no bs. Then, z = uv 2 wx 2 y = a q+k b p, and k 1. Therefoe, z L, contradiction. Case 2) vx = a j b k, and k 1, i.e. containing at least one b. Then, consider z = uv 0 wx 0 y. #a(z ) = q-j =p 2 -j, and 1 j p-1 #b(z ) = p-k, and 1 k p. So, (#b(z )) 2 = (p-k) 2 = p 2-2kp +k 2 Clearly kp-j >k 2 - kp, since kp-j p-(p-1)=1, but k 2 - kp = k(k-p) 0. Now, it is easy to verify that, p 2 -j >p 2-2kp +k 2. Therefore, z L, contradiction. 9
10 16.[5] Give a grammar for the language L E (M), where: M = ({q 0,q 1 },{a,b},{a,z},ä, q 0, Z, {q 1 }) and ä is given by: ä(q 0,a,Z) = {(q 0,AZ }, ä(q 0,b,A) = {(q 0,AA)}, ä(q 0,a,A) = {(q 1, )}. G = (V, T, ó, P), where V = { ó, [q 0, A, q 0 ], [q 0, A, q 1 ], [q 1, A, q 0 ], [q 1, A, q 1 ], [q 0, Z, q 0 ], [q 0, Z, q 1 ], [q 1, Z, q 0 ], [q 1, Z, q 1 ]) T = {a,b} P is of the following form: ó [q 0, Z, q 0 ] [q 0, Z, q 1 ] [q 0, Z, q 0 ] a[q 0, A, q 0 ][q 0, Z, q 0 ] [q 0, Z, q 0 ] a[q 0, A, q 1 ][q 1, Z, q 0 ] [q 0, Z, q 1 ] a[q 0, A, q 0 ][q 0, Z, q 1 ] [q 0, Z, q 1 ] a[q 0, A, q 1 ][q 1, Z, q 1 ] since ä(q 0,a,Z) = {(q 0,AZ)} [q 0, A, q 0 ] b[q 0, A, q 0 ][q 0, A, q 0 ] [q 0, A, q 0 ] b[q 0, A, q 1 ][q 1, A, q 0 ] [q 0, A, q 1 ] b[q 0, A, q 0 ][q 0, A, q 1 ] [q 0, A, q 1 ] b[q 0, A, q 1 ][q 1, A, q 1 ] since ä(q 0,a,A) = {(q 0,AA)} [q 0, A, q 1 ] a since ä(q 0,a,A) = {(q 1, )} We have to now remove some useless variables to make the solution simpler. 17.[4] Give a monotone grammar generating the following language L. Provide some arguments why your solution is correct. L = { a i+1 b i c i-1 i 1 } We will follow the pattern for { a i b i c i i 1 }. The only difference is that the context-free productions must generates appropriately more a s and B s. ó aóbc aaabbc aab CB BC 10
11 ab ab bb bb bc bc 18.[6] A context-free grammar G = (Ó, V, P, ó) is called linear in each production at most one variable can occur on the right side of the production. Formally, G is linear iff A x P. x Ó * ( y,z Ó *. B V. x = ybz) A language is called linear if there exists a linear grammar G such that L = L(G). For instance L = { a n b n n 0 } is linear since the below grammar that generates it is linear. ó aób Let L be any linear language not containing. Show that there exists a grammar G = (Ó, V, P, ó) all of whose productions have one of the forms A ab, A Ba, A a, where a Ó, A,B T, such that L = L(G). From the definition of linear grammar, there are two forms of productions, A x, where x Ó * A ybz, where x Ó * and y,z Ó * Assuming x=a 1,...,a m, y=b 1,...,b n, z=c 1,...,c p, we can replace above two productions by following productions. A a 1 C 1 C 1 a 2 C 2... C m-1 a m-1 C m C m a m and A b 1 D 1 D 1 b 2 D 2... D n-1 b n-1 D m D m E p-1 c p E p-1 E p-2 c p-1... E 2 E 1 c 2 E 1 Bc 1 Clearly, the new set of productions are equivalent to the original one and has the required form. 11
12 19.[6] Is the following language context-free? L = { a nm m and n are prime numbers }. No. Assume L is context free, then pumping lemma hold. Let p be the number in pumping lemma. Let z = a 2m, where m is a prime and m p. Clearly, z p and z L. Therefore, z=uvwxy and vx 1, vwx p, and ( i 0) uv i wx i y L. Let k = vx, let i = 2m+1, i.e. pump up 2m times. uv i wx i y = 2m + (i-1)*k = 2m + 2mk =2m(1+k). 2m(1+k) is the production of at least 3 primes, since k [4] A monotone grammar is said to be in Kuroda normal form if every production is of one of the following forms: A a A B A BC AB CD Prove that every context-sensitive language can be generated by a monotone grammar in Kuroda normal form. Practically almost the same construction as for Chomsky normal form for context-free grammars. 21.[8] Design single tape Turing machines to compute the following functions: a. f(x,y) = 2x+3y b. f(x,y)= if x>y then x-y else 0. a.[4] Input of the machine is 0 x 10 y, the output string is 0 (2x+3y) we separate the input and output with a blank segment. Each time we erase one 0 to the left of the 1 in the input, we add two 0's at the output. Each time we erase one 0 to the right of the separator 1, we add three 0's at the output string. Following is the formal definition. The Turing Machine TM = (Q, Ó, Ã, ä, q 0, q a, q r ) Q = {q 0,q 1,q 2,q 3,...q 21 } Ó = {0,1} 12
13 Ã={0,1,B} B for blank q a = {q 21 } q r ={ } Where ä is defined as follow: 0 1 B 0 B,R,1 1 B,R,2 B,R,12 B,R,21 2 0,R,2 1,R,3 3 0,R,3 B,R,4 4 0,R,4 0,R,5 5 0,L,6 6 0,L,6 B,L,7 7 0,L,7 1,L,8 8 0,L,9 B,R,11 9 0,L,0 B,R,10 10 B,R,1 11 1,R,12 12 B,R, ,R,13 B,R, ,R,14 0,R, ,R, ,L, ,L,17 B,L, ,L,19 B,R, L,19 B,R, ,L,
14 ***************************************************************************** In all the tables related to the Turing Machine, a row: a b c i d,r,j e,l,k means: ä(q i,a) = (q j,d, R) ä(q i,b) = (q k,e, L) ä(q i,c) undefined ***************************************************************************** b.[4] Input of the Turing Machine is like 0 x 10 y we erase one zero at each end of the string. If we reach 1 from the left side, we know that x < y. Then we erase everything left. Otherwise, we erase the 1 and leave what s left on the tape. The Turing machine TM = (Q, Ó, Ã, ä, q 0, q a, q r ) Q = {q 0,q 1,q 2,q 3,...q 13 } Ó = {0,1} Ã={0,1,B} B for blank q a = {q 13 } q r ={ } Where ä is defined as follow: 0 1 B 0 B,R,1 1 B,R,2 B,R,11 2 0,R,2 1,R,3 3 0,R,4 B,R,10 4 0,R,4 B,L,5 5 0,L,6 6 0,L,6 B,L,7 7 0,L,8 B,R,11 8 0,L,8 B,R,9 14
15 9 B,R,2 10 B,L,12 11 B,R,11 B,R,11 B,R, ,R,12 B,L, [4] Design a Turing machine to recognize the following language: { xx x (a b)* } The machine first check the length of the string, If it s an odd number, we reject the input. In the process, we change a to A and b to B. If the input is of even length. We change the first character of the 2 nd half of the string from capital letter to lower case, and then check if the first character of the 1 st half match the 2 nd half. Then we repeat the process until the end of the string. The Turing machine TM = (Q, Ó, Ã, ä, q 0, q a, q r ) Q = {q 0,q 1,q 2,q 3,...q 12 } Ó = {a,b} Ã={A,B,a,b, D} D for blank q a = {q 11 } q r ={q 12 } Where ä is defined as follow: a b A B D 0 D,R,1 1 A,R,2 B,R,2 A,R,5 B,R,5 D,L,q11 2 a,r,2 b,r,2 A,L,3 B,L,3 D,L,3 3 A,L,4 B,L,4 A,L,12 B.L.12 4 a,l,4 b,l,4 A,R,1 A,R,1 5 a,l,9 b,l,6 6 a,l,6 b,l,6 A,L,7 B,L,7 15
16 7 a,r,8 b,r,8 A,L,7 B,L,7 D,R,8 8 a,l,8 b,l,8 A,L,12 b,r,5 D,L,12 9 a,l,9 b,l,9 A,L,10 B,L,10 10 a,r,11 b,r,11 A,L,10 B,L,10 D,R,11 11 a,l,11 b,l,11 a,r,5 B,L, [4] Design a Turing machine to compute the function: f(x) = x R, where x {0,1} +. The machine first copy the last letter of the input string and paste it as the first letter of the output string. Then copy the 2 nd to the last letter of the input and paste it as the 2 nd letter of the output string. And so on. The Turing machine TM = (Q, Ó, Ã, ä, q 0, q a, q r ) Q = {q 0,q 1,q 2,q 3,...q 12 } Ó = {0,1} Ã={0,1,2,B} B for blank q a = {q 8 } q r ={ } Where ä is defined as follow: B 0 2,R,1 1 0,R,1 1,R,1 2,L,2 2 B,R,9 B,R,3 B,R,7 3 2,R,4 B,R,3 4 0,R,4 1,R,4 1,L,5 5 0,L,5 1,L,5 2,L,6 6 B,L,9 B,L,3 2,L,7 B,L,6 7 0,L,2 1,L,2 B,R,8 B,R,7 16
17 8 9 2,R, ,R,10 1,R,10 0,L, ,L,11 1,L,11 2,L, ,L,9 1,L,3 2,L,7 B,L,12 24.[6] Consider a Turing machine that, on any particular move, can either change the tape symbol or move the read-write head, but not both. a. Give a formal definition of such a machine b. Show that the class of such machines is equivalent to the class of standard Turing machines (i.e. one can simulate another). a.[2] The machine can be defined as TM = (Q, Ó, Ã, ä, q 0, q a, q r ) where ä : Q à = Q (à {L, R}) all others are defined as a standard Turing Machine. b.[4] We can simulate TM defined above with a standard Turing Machine TM = (Q, Ó, Ã, ä, q 0 ', q a, q r ). such that Q Q Ó = Ó Ã = à if ä(q,x )= (q 1,y); y à if q 0 '= q 0 q a =q a q r =q r we have ä (q,x )= (q 1 ',y,r) and ä (q 1 ',z )= (q 1,z,L); z à ä(q,x )= (q 1,d); d=l or R we have ä (q,x )= (q 1 ',x,d) We can simulate standard TM with special TM as follow: Q Q Ó = Ó Ã = à if ä (q,x)= (q 1,y,d); y à and d=l or R we have ä(q,x )= (q 1 ',y) and ä(q 1 ',z )= (q 1,d); z à q 0 = q 0 ' 17
18 q a =q a q r =q r 25.[4] Design a Turing machine with à = {0,1,B} (B means blank ) that, when started on any cell containing a blank or 1, will halt if and only if its tape has 0 somewhere on it. First, the machine will search 0 to the right and if a blank is met, the machine will write 1 there and change direction to search to the left. In any time, when 0 is met, the machine halt, otherwise, it will search forever and write 1's on the tape each time it changes the direction of searching. The Turing machine TM = (Q, Ó, Ã, ä, q 0, q a, q r ) Q = {q 0,q 1,q 2,q 3 } Ó = {0,1} Ã={0,1,B} B for blank q a = {q 3 } q r ={ } Where ä is defined as follow: 0 1 B 0 B,R,3 1,R,1 1,R,1 1 B,R,3 1,R,1 1,L,2 2 0,R,3 1,L,2 1,R, [7] Write a RAM program that read n positive integers followed by an endmarker (0) and then print the n numbers in sorted order. Give both uniform-cost and logarithmic-cost time complexity. Write a pseudo-code first and show precisely which parts of pseudocode correspond to which part of RAM code. Different sorting algorithm can result in different time complexity. The following 18
19 algorithm applied bubble sort. In the codes, we need an array to store the n numbers. The pseudo-code below contains the essential details of the algorithm. end. read(n); i=0; while n 0 do A[i]=n; i=i+1; read(n) n = i-1; i = n; while i >1 do j =1; while j < i do if A[j-1] > A[j] then temp = A[j-1]; A[j-1]=A[j]; A[j]=temp j=j+1; i=i-1; i=0; while i n do write A[i]; i=i+1; We can see the algorithm is dominated by the three assignment statements in the while j<i loop. which will repeat O(n 2 ) times. and this is the uniform cost time complexity. The logarithm time complexity is O(n 4 ) 19
20 READ 1 LOAD =0 STORE 2 WHILE 1 LOAD 1 JZERO END1 LOAD 2 ADD =5 STORE 3 LOAD 1 STORE *3 LOAD 2 ADD =1 STORE 2 READ 1 JUMP WHILE 1 END 1 LOAD 2 SUB =1 STORE 1 STORE 2 WHILE 2 LOAD 2 SUB =1 JZERO END LOAD =1 STORE 3 WHILE 3 LOAD 2 SUB =1 SUB 3 JZERO END 2 LOAD 3 SUB =1 STORE 4 LOAD *3 SUB *4 JGTZ END3 LOAD *4 STORE 5 read(n) i=0; while n 0 do A[i]=n; i=i+1; read(n) n=i-1; i=n; while i >1 do j :=1; while j < i do if A[j-1] > A[j] then temp = A[j-1]; 20
21 LOAD *3 STORE *4 LOAD 5 STORE *3 LOAD 3 ADD =1 STORE 3 JUMP WHILE3 END 2 LOAD 2 SUB =1 STORE 2 JUMP WHILE 2 A[j-1]=A[j]; A[j]=temp j=j+1; i=i-1; END 27.[7] Give RAM program that computes 2 n!. Give both uniform-cost and logarithmic-cost time complexity. Write a pseudo-code first and show precisely which parts of pseudo-code correspond to which part of RAM code. Pseudo code: end read (n); fac=1; while n >0 do fac = n * fac; n = n-1 p = 1; while fac >0 do p = 2 * p; fac = fac -1 end write (p); 21
22 The uniform cost time complexity is O(n n ) because the dominant operation is p=2*p. and the logarithmic cost time complexity is O(n n log(n n )). READ 1 LOAD =1 STORE 2 WHILE 1 LOAD 1 JZERO END1 LOAD 2 MUL 1 STORE 2 LOAD 1 SUB =1 STORE 1 JUMP WHILE 1 END 1 LOAD =1 STORE 1 WHILE 2 LOAD 2 JZERO END LOAD 1 MUL =2 STORE 1 END 2 LOAD 2 SUB =1 STORE 2 JUMP WHILE 2 read(n) fac=1; while n>0 do fac = n * fac; n = n-1; p=1; while fac >0 do p=p*2; i=i-1; WRTN WRITE 1 write(p) END 22
SFWR ENG 2FA3. Solution to the Assignment #4
SFWR ENG 2FA3. Solution to the Assignment #4 Total = 131, 100%= 115 The solutions below are often very detailed on purpose. Such level of details is not required from students solutions. Some questions
More informationTheory of Computation - Module 3
Theory of Computation - Module 3 Syllabus Context Free Grammar Simplification of CFG- Normal forms-chomsky Normal form and Greibach Normal formpumping lemma for Context free languages- Applications of
More informationSection 1 (closed-book) Total points 30
CS 454 Theory of Computation Fall 2011 Section 1 (closed-book) Total points 30 1. Which of the following are true? (a) a PDA can always be converted to an equivalent PDA that at each step pops or pushes
More informationdownload instant at Assume that (w R ) R = w for all strings w Σ of length n or less.
Chapter 2 Languages 3. We prove, by induction on the length of the string, that w = (w R ) R for every string w Σ. Basis: The basis consists of the null string. In this case, (λ R ) R = (λ) R = λ as desired.
More informationTheory of Computation Turing Machine and Pushdown Automata
Theory of Computation Turing Machine and Pushdown Automata 1. What is a Turing Machine? A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type
More informationTheory of Computation (Classroom Practice Booklet Solutions)
Theory of Computation (Classroom Practice Booklet Solutions) 1. Finite Automata & Regular Sets 01. Ans: (a) & (c) Sol: (a) The reversal of a regular set is regular as the reversal of a regular expression
More informationTheory of Computation
Fall 2002 (YEN) Theory of Computation Midterm Exam. Name:... I.D.#:... 1. (30 pts) True or false (mark O for true ; X for false ). (Score=Max{0, Right- 1 2 Wrong}.) (1) X... If L 1 is regular and L 2 L
More informationDefinition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x where
Recitation 11 Notes Context Free Grammars Definition: A grammar G = (V, T, P,S) is a context free grammar (cfg) if all productions in P have the form A x A V, and x (V T)*. Examples Problem 1. Given the
More informationComputability and Complexity
Computability and Complexity Push-Down Automata CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard Janicki Computability
More informationLecture 12 Simplification of Context-Free Grammars and Normal Forms
Lecture 12 Simplification of Context-Free Grammars and Normal Forms COT 4420 Theory of Computation Chapter 6 Normal Forms for CFGs 1. Chomsky Normal Form CNF Productions of form A BC A, B, C V A a a T
More informationAutomata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008
Automata Theory Final Exam Solution 08:10-10:00 am Friday, June 13, 2008 Name: ID #: This is a Close Book examination. Only an A4 cheating sheet belonging to you is acceptable. You can write your answers
More informationConcordia University Department of Computer Science & Software Engineering
Concordia University Department of Computer Science & Software Engineering COMP 335/4 Theoretical Computer Science Winter 2015 Assignment 3 1. In each case, what language is generated by CFG s below. Justify
More informationCS 373: Theory of Computation. Fall 2010
CS 373: Theory of Computation Gul Agha Mahesh Viswanathan Fall 2010 1 1 Normal Forms for CFG Normal Forms for Grammars It is typically easier to work with a context free language if given a CFG in a normal
More informationFundamentele Informatica II
Fundamentele Informatica II Answer to selected exercises 5 John C Martin: Introduction to Languages and the Theory of Computation M.M. Bonsangue (and J. Kleijn) Fall 2011 5.1.a (q 0, ab, Z 0 ) (q 1, b,
More informationTAFL 1 (ECS-403) Unit- IV. 4.1 Push Down Automata. 4.2 The Formal Definition of Pushdown Automata. EXAMPLES for PDA. 4.3 The languages of PDA
TAFL 1 (ECS-403) Unit- IV 4.1 Push Down Automata 4.2 The Formal Definition of Pushdown Automata EXAMPLES for PDA 4.3 The languages of PDA 4.3.1 Acceptance by final state 4.3.2 Acceptance by empty stack
More informationHomework 4 Solutions. 2. Find context-free grammars for the language L = {a n b m c k : k n + m}. (with n 0,
Introduction to Formal Language, Fall 2016 Due: 21-Apr-2016 (Thursday) Instructor: Prof. Wen-Guey Tzeng Homework 4 Solutions Scribe: Yi-Ruei Chen 1. Find context-free grammars for the language L = {a n
More informationFinite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018
Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018 Lecture 14 Ana Bove May 14th 2018 Recap: Context-free Grammars Simplification of grammars: Elimination of ǫ-productions; Elimination of
More informationHarvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs
Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs Harry Lewis October 8, 2013 Reading: Sipser, pp. 119-128. Pushdown Automata (review) Pushdown Automata = Finite automaton
More informationComputability and Complexity
Computability and Complexity Rewriting Systems and Chomsky Grammars CAS 705 Ryszard Janicki Department of Computing and Software McMaster University Hamilton, Ontario, Canada janicki@mcmaster.ca Ryszard
More informationFinite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove
Finite Automata Theory and Formal Languages TMV026/TMV027/DIT321 Responsible: Ana Bove Tuesday 28 of May 2013 Total: 60 points TMV027/DIT321 registration VT13 TMV026/DIT321 registration before VT13 Exam
More informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013
Q.2 a. Prove by mathematical induction n 4 4n 2 is divisible by 3 for n 0. Basic step: For n = 0, n 3 n = 0 which is divisible by 3. Induction hypothesis: Let p(n) = n 3 n is divisible by 3. Induction
More informationContext-Free Grammars: Normal Forms
Context-Free Grammars: Normal Forms Seungjin Choi Department of Computer Science and Engineering Pohang University of Science and Technology 77 Cheongam-ro, Nam-gu, Pohang 37673, Korea seungjin@postech.ac.kr
More informationSolution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017
Solution to CS375 Homework Assignment 11 (40 points) Due date: 4/26/2017 1. Find a Greibach normal form for the following given grammar. (10 points) S bab A BAa a B bb Ʌ Solution: (1) Since S does not
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY REVIEW for MIDTERM 1 THURSDAY Feb 6 Midterm 1 will cover everything we have seen so far The PROBLEMS will be from Sipser, Chapters 1, 2, 3 It will be
More informationIntroduction to Formal Languages, Automata and Computability p.1/42
Introduction to Formal Languages, Automata and Computability Pushdown Automata K. Krithivasan and R. Rama Introduction to Formal Languages, Automata and Computability p.1/42 Introduction We have considered
More informationCS A Term 2009: Foundations of Computer Science. Homework 2. By Li Feng, Shweta Srivastava, and Carolina Ruiz.
CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 2 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 4 Problem 1: (10 Points) Exercise 4.3 Solution 1: S is
More informationCS375: Logic and Theory of Computing
CS375: Logic and Theory of Computing Fuhua (Frank) Cheng Department of Computer Science University of Kentucky 1 Table of Contents: Week 1: Preliminaries (set algebra, relations, functions) (read Chapters
More informationSt.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad
St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-500 014 Subject: FORMAL LANGUAGES AND AUTOMATA THEORY Class : CSE II PART A (SHORT ANSWER QUESTIONS) UNIT- I 1 Explain transition diagram, transition
More informationMA/CSSE 474 Theory of Computation
MA/CSSE 474 Theory of Computation CFL Hierarchy CFL Decision Problems Your Questions? Previous class days' material Reading Assignments HW 12 or 13 problems Anything else I have included some slides online
More informationMTH401A Theory of Computation. Lecture 17
MTH401A Theory of Computation Lecture 17 Chomsky Normal Form for CFG s Chomsky Normal Form for CFG s For every context free language, L, the language L {ε} has a grammar in which every production looks
More informationAutomata Theory CS F-13 Unrestricted Grammars
Automata Theory CS411-2015F-13 Unrestricted Grammars David Galles Department of Computer Science University of San Francisco 13-0: Language Hierarchy Regular Languaes Regular Expressions Finite Automata
More informationSolution Scoring: SD Reg exp.: a(a
MA/CSSE 474 Exam 3 Winter 2013-14 Name Solution_with explanations Section: 02(3 rd ) 03(4 th ) 1. (28 points) For each of the following statements, circle T or F to indicate whether it is True or False.
More informationcse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska
cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 14 SMALL REVIEW FOR FINAL SOME Y/N QUESTIONS Q1 Given Σ =, there is L over Σ Yes: = {e} and L = {e} Σ Q2 There are uncountably
More informationThe assignment is not difficult, but quite labour consuming. Do not wait until the very last day.
CAS 705 CAS 705. Sample solutions to the assignment 1 (many questions have more than one solutions). Total of this assignment is 129 pts. Each assignment is worth 25%. The assignment is not difficult,
More information60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor
60-354, Theory of Computation Fall 2013 Asish Mukhopadhyay School of Computer Science University of Windsor Pushdown Automata (PDA) PDA = ε-nfa + stack Acceptance ε-nfa enters a final state or Stack is
More informationUndecidable Problems and Reducibility
University of Georgia Fall 2014 Reducibility We show a problem decidable/undecidable by reducing it to another problem. One type of reduction: mapping reduction. Definition Let A, B be languages over Σ.
More informationTuring machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage?
Turing machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage? What is the most powerful of automata? In this lecture we will introduce
More informationThis lecture covers Chapter 7 of HMU: Properties of CFLs
This lecture covers Chapter 7 of HMU: Properties of CFLs Chomsky Normal Form Pumping Lemma for CFs Closure Properties of CFLs Decision Properties of CFLs Additional Reading: Chapter 7 of HMU. Chomsky Normal
More informationHomework 4. Chapter 7. CS A Term 2009: Foundations of Computer Science. By Li Feng, Shweta Srivastava, and Carolina Ruiz
CS3133 - A Term 2009: Foundations of Computer Science Prof. Carolina Ruiz Homework 4 WPI By Li Feng, Shweta Srivastava, and Carolina Ruiz Chapter 7 Problem: Chap 7.1 part a This PDA accepts the language
More informationProperties of Context-free Languages. Reading: Chapter 7
Properties of Context-free Languages Reading: Chapter 7 1 Topics 1) Simplifying CFGs, Normal forms 2) Pumping lemma for CFLs 3) Closure and decision properties of CFLs 2 How to simplify CFGs? 3 Three ways
More informationFORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form:
More informationPushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen
Pushdown automata Twan van Laarhoven Institute for Computing and Information Sciences Intelligent Systems Version: fall 2014 T. van Laarhoven Version: fall 2014 Formal Languages, Grammars and Automata
More informationPushdown Automata. Reading: Chapter 6
Pushdown Automata Reading: Chapter 6 1 Pushdown Automata (PDA) Informally: A PDA is an NFA-ε with a infinite stack. Transitions are modified to accommodate stack operations. Questions: What is a stack?
More informationAn automaton with a finite number of states is called a Finite Automaton (FA) or Finite State Machine (FSM).
Automata The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled computing device which follows a predetermined
More informationV Honors Theory of Computation
V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant
More informationContext-Free Grammar
Context-Free Grammar CFGs are more powerful than regular expressions. They are more powerful in the sense that whatever can be expressed using regular expressions can be expressed using context-free grammars,
More informationTheory of Computer Science
Theory of Computer Science C1. Formal Languages and Grammars Malte Helmert University of Basel March 14, 2016 Introduction Example: Propositional Formulas from the logic part: Definition (Syntax of Propositional
More informationVTU QUESTION BANK. Unit 1. Introduction to Finite Automata. 1. Obtain DFAs to accept strings of a s and b s having exactly one a.
VTU QUESTION BANK Unit 1 Introduction to Finite Automata 1. Obtain DFAs to accept strings of a s and b s having exactly one a.(5m )( Dec-2014) 2. Obtain a DFA to accept strings of a s and b s having even
More informationAutomata: a short introduction
ILIAS, University of Luxembourg Discrete Mathematics II May 2012 What is a computer? Real computers are complicated; We abstract up to an essential model of computation; We begin with the simplest possible
More informationChapter 1. Formal Definition and View. Lecture Formal Pushdown Automata on the 28th April 2009
Chapter 1 Formal and View Lecture on the 28th April 2009 Formal of PA Faculty of Information Technology Brno University of Technology 1.1 Aim of the Lecture 1 Define pushdown automaton in a formal way
More informationAutomata Theory CS F-08 Context-Free Grammars
Automata Theory CS411-2015F-08 Context-Free Grammars David Galles Department of Computer Science University of San Francisco 08-0: Context-Free Grammars Set of Terminals (Σ) Set of Non-Terminals Set of
More informationÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition
ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK 7 april 23 Classrum Edition CONTEXT FREE LANGUAGES & PUSH-DOWN AUTOMATA CONTEXT-FREE GRAMMARS, CFG Problems Sudkamp Problem. (3.2.) Which language generates the
More informationNote: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).
Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules). 1a) G = ({R, S, T}, {0,1}, P, S) where P is: S R0R R R0R1R R1R0R T T 0T ε (S generates the first 0. R generates
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING DUNDIGAL 500 043, HYDERABAD COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : FORMAL LANGUAGES AND AUTOMATA THEORY Course Code : A40509 Class :
More informationCISC4090: Theory of Computation
CISC4090: Theory of Computation Chapter 2 Context-Free Languages Courtesy of Prof. Arthur G. Werschulz Fordham University Department of Computer and Information Sciences Spring, 2014 Overview In Chapter
More informationEXAMPLE CFG. L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa. L = {a n b : n 0 } L = {a n b : n 1 } S asb ab S 1S00 S 1S00 100
EXAMPLE CFG L = {a 2n : n 1 } L = {a 2n : n 0 } S asa aa S asa L = {a n b : n 0 } L = {a n b : n 1 } S as b S as ab L { a b : n 0} L { a b : n 1} S asb S asb ab n 2n n 2n L {1 0 : n 0} L {1 0 : n 1} S
More informationSheet 1-8 Dr. Mostafa Aref Format By : Mostafa Sayed
Sheet -8 Dr. Mostafa Aref Format By : Mostafa Sayed 09 Introduction Assignment. For = {a, } a) Write 0 strings of the following languages i) All strings with no more than one a,,, a, a, a, a, a, a, a ii)
More informationTheory of Computation
Theory of Computation Lecture #2 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 1 Lecture 2: Overview Recall some basic definitions from Automata Theory.
More informationChomsky Normal Form and TURING MACHINES. TUESDAY Feb 4
Chomsky Normal Form and TURING MACHINES TUESDAY Feb 4 CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A BC A a S ε B and C aren t start variables a is
More informationCSCI 340: Computational Models. Regular Expressions. Department of Computer Science
CSCI 340: Computational Models Regular Expressions Chapter 4 Department of Computer Science Yet Another New Method for Defining Languages Given the Language: L 1 = {x n for n = 1 2 3...} We could easily
More informationChapter 8. Turing Machine (TMs)
Chapter 8 Turing Machine (TMs) Turing Machines (TMs) Accepts the languages that can be generated by unrestricted (phrase-structured) grammars No computational machine (i.e., computational language recognition
More informationGrammars and Context Free Languages
Grammars and Context Free Languages H. Geuvers and A. Kissinger Institute for Computing and Information Sciences Version: fall 2015 H. Geuvers & A. Kissinger Version: fall 2015 Talen en Automaten 1 / 23
More information(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},
Code No: 07A50501 R07 Set No. 2 III B.Tech I Semester Examinations,MAY 2011 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 80 Answer any FIVE Questions All
More informationFundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8
Fundamentele Informatica 3 Antwoorden op geselecteerde opgaven uit Hoofdstuk 7 en Hoofdstuk 8 John Martin: Introduction to Languages and the Theory of Computation Jetty Kleijn Najaar 2008 7.1 (q 0,bbcbb,Z
More informationGrade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages
Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grade 6 Math Circles October 20/21, 2015 Formalism and Languages: Beyond Regular Languages Dr. Troy Vasiga
More informationHW6 Solutions. Micha l Dereziński. March 20, 2015
HW6 Solutions Micha l Dereziński March 20, 2015 1 Exercise 5.5 (a) The PDA accepts odd-length strings whose middle symbol is a and whose other letters are as and bs. Its diagram is below. b, Z 0 /XZ 0
More informationFinite Automata and Formal Languages TMV026/DIT321 LP Useful, Useless, Generating and Reachable Symbols
Finite Automata and Formal Languages TMV026/DIT321 LP4 2012 Lecture 13 Ana Bove May 7th 2012 Overview of today s lecture: Normal Forms for Context-Free Languages Pumping Lemma for Context-Free Languages
More informationGrammars and Context Free Languages
Grammars and Context Free Languages H. Geuvers and J. Rot Institute for Computing and Information Sciences Version: fall 2016 H. Geuvers & J. Rot Version: fall 2016 Talen en Automaten 1 / 24 Outline Grammars
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Spring 27 Alexis Maciel Department of Computer Science Clarkson University Copyright c 27 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationComputability and Complexity
Computability and Complexity Lecture 5 Reductions Undecidable problems from language theory Linear bounded automata given by Jiri Srba Lecture 5 Computability and Complexity 1/14 Reduction Informal Definition
More information1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u,
1. Draw a parse tree for the following derivation: S C A C C A b b b b A b b b b B b b b b a A a a b b b b a b a a b b 2. Show on your parse tree u, v, x, y, z as per the pumping theorem. 3. Prove that
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Fall 28 Alexis Maciel Department of Computer Science Clarkson University Copyright c 28 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationContext Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.
Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer. Language Generator: Context free grammars are language generators,
More informationAutomata Theory (2A) Young Won Lim 5/31/18
Automata Theory (2A) Copyright (c) 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later
More informationTAFL 1 (ECS-403) Unit- III. 3.1 Definition of CFG (Context Free Grammar) and problems. 3.2 Derivation. 3.3 Ambiguity in Grammar
TAFL 1 (ECS-403) Unit- III 3.1 Definition of CFG (Context Free Grammar) and problems 3.2 Derivation 3.3 Ambiguity in Grammar 3.3.1 Inherent Ambiguity 3.3.2 Ambiguous to Unambiguous CFG 3.4 Simplification
More informationCFG Simplification. (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions
CFG Simplification (simplify) 1. Eliminate useless symbols 2. Eliminate -productions 3. Eliminate unit productions 1 Eliminating useless symbols 1. A symbol X is generating if there exists: X * w, for
More informationPlease give details of your answer. A direct answer without explanation is not counted.
Please give details of your answer. A direct answer without explanation is not counted. Your answers must be in English. Please carefully read problem statements. During the exam you are not allowed to
More informationAC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014
Q.2 a. Show by using Mathematical Induction that n i= 1 i 2 n = ( n + 1) ( 2 n + 1) 6 b. Define language. Let = {0; 1} denote an alphabet. Enumerate five elements of the following languages: (i) Even binary
More informationLanguages, regular languages, finite automata
Notes on Computer Theory Last updated: January, 2018 Languages, regular languages, finite automata Content largely taken from Richards [1] and Sipser [2] 1 Languages An alphabet is a finite set of characters,
More informationCpSc 421 Final Exam December 15, 2006
CpSc 421 Final Exam December 15, 2006 Do problem zero and six of problems 1 through 9. If you write down solutions for more that six problems, clearly indicate those that you want graded. Note that problems
More informationAuthor: Vivek Kulkarni ( )
Author: Vivek Kulkarni ( vivek_kulkarni@yahoo.com ) Chapter-3: Regular Expressions Solutions for Review Questions @ Oxford University Press 2013. All rights reserved. 1 Q.1 Define the following and give
More information6.8 The Post Correspondence Problem
6.8. THE POST CORRESPONDENCE PROBLEM 423 6.8 The Post Correspondence Problem The Post correspondence problem (due to Emil Post) is another undecidable problem that turns out to be a very helpful tool for
More informationPage 1. Compiler Lecture Note, (Regular Language) 컴파일러입문 제 3 장 정규언어. Database Lab. KHU
Page 1 컴파일러입문 제 3 장 정규언어 Page 2 목차 I. 정규문법과정규언어 II. 정규표현 III. 유한오토마타 VI. 정규언어의속성 Page 3 정규문법과정규언어 A study of the theory of regular languages is often justified by the fact that they model the lexical analysis
More informationUNIT-I. Strings, Alphabets, Language and Operations
UNIT-I Strings, Alphabets, Language and Operations Strings of characters are fundamental building blocks in computer science. Alphabet is defined as a non empty finite set or nonempty set of symbols. The
More informationCS 410/610, MTH 410/610 Theoretical Foundations of Computing
CS 410/610, MTH 410/610 Theoretical Foundations of Computing Fall Quarter 2010 Slides 2 Pascal Hitzler Kno.e.sis Center Wright State University, Dayton, OH http://www.knoesis.org/pascal/ CS410/610 MTH410/610
More informationTesting Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm
Testing Emptiness of a CFL As for regular languages, we really take a representation of some language and ask whether it represents φ Can use either CFG or PDA Our choice, since there are algorithms to
More informationLecture 11 Context-Free Languages
Lecture 11 Context-Free Languages COT 4420 Theory of Computation Chapter 5 Context-Free Languages n { a b : n n { ww } 0} R Regular Languages a *b* ( a + b) * Example 1 G = ({S}, {a, b}, S, P) Derivations:
More information1. (a) Explain the procedure to convert Context Free Grammar to Push Down Automata.
Code No: R09220504 R09 Set No. 2 II B.Tech II Semester Examinations,December-January, 2011-2012 FORMAL LANGUAGES AND AUTOMATA THEORY Computer Science And Engineering Time: 3 hours Max Marks: 75 Answer
More informationTHEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET
THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET Regular Languages and FA A language is a set of strings over a finite alphabet Σ. All languages are finite or countably infinite. The set of all languages
More informationFABER Formal Languages, Automata. Lecture 2. Mälardalen University
CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010 1 Content Languages, g Alphabets and Strings Strings & String Operations Languages & Language Operations
More informationCISC 4090 Theory of Computation
CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: Captured by Regular Operations a b
More informationDM17. Beregnelighed. Jacob Aae Mikkelsen
DM17 Beregnelighed Jacob Aae Mikkelsen January 12, 2007 CONTENTS Contents 1 Introduction 2 1.1 Operations with languages...................... 2 2 Finite Automata 3 2.1 Regular expressions/languages....................
More informationCS6902 Theory of Computation and Algorithms
CS6902 Theory of Computation and Algorithms Any mechanically (automatically) discretely computation of problem solving contains at least three components: - problem description - computational tool - procedure/analysis
More informationCS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach
CS311 Computational Structures More about PDAs & Context-Free Languages Lecture 9 Andrew P. Black Andrew Tolmach 1 Three important results 1. Any CFG can be simulated by a PDA 2. Any PDA can be simulated
More informationLearning Context Free Grammars with the Syntactic Concept Lattice
Learning Context Free Grammars with the Syntactic Concept Lattice Alexander Clark Department of Computer Science Royal Holloway, University of London alexc@cs.rhul.ac.uk ICGI, September 2010 Outline Introduction
More information컴파일러입문 제 3 장 정규언어
컴파일러입문 제 3 장 정규언어 목차 3.1 정규문법과정규언어 3.2 정규표현 3.3 유한오토마타 3.4 정규언어의속성 Regular Language Page 2 정규문법과정규언어 A study of the theory of regular languages is often justified by the fact that they model the lexical
More informationCISC 4090 Theory of Computation
CISC 4090 Theory of Computation Context-Free Languages and Push Down Automata Professor Daniel Leeds dleeds@fordham.edu JMH 332 Languages: Regular and Beyond Regular: a b c b d e a Not-regular: c n bd
More informationComputational Models - Lecture 4
Computational Models - Lecture 4 Regular languages: The Myhill-Nerode Theorem Context-free Grammars Chomsky Normal Form Pumping Lemma for context free languages Non context-free languages: Examples Push
More informationTheory of Computation
Theory of Computation Lecture #10 Sarmad Abbasi Virtual University Sarmad Abbasi (Virtual University) Theory of Computation 1 / 43 Lecture 10: Overview Linear Bounded Automata Acceptance Problem for LBAs
More informationTheory Of Computation UNIT-II
Regular Expressions and Context Free Grammars: Regular expression formalism- equivalence with finite automata-regular sets and closure properties- pumping lemma for regular languages- decision algorithms
More information