Download presentation
Presentation is loading. Please wait.
1
Homework 4 due 11/25
2
1. Homomorphism 1. Let A = L(M) where M is the DFA given in the figure, and h be a homomorphism from {a,b}* {a,b}* with h(a) = ab and h(b) = ba. 1.1 Find a DFA N1 such that L(N) = h(A), 1.2 Find a DFA N2 such that L(N) = h-1(A) Give your answer Using state-transition diagram 2 a b 1 3
3
2. Pumping lemma and closure properties of regular languages
2. Using (game-theoretical version of ) pumping lemma to show the following two sets are not regular: A1 = { x x | x {0,1}* } A2 = {an bm | 0 n m 2n+10 } Using closure properties of regular languages to show that : 2.3 If A1(the language given at 2.1) is not regular, then neither is the language A3={ xcx | x {0,1}* } 2.4 If the language Prime={ ap | p is a prime number } is not regular, then neither is the language A4 = { ambnct | (m+n+t) is not a prime number }.
4
3. Which of the following sets are regular ? Give your reason.
3. Testing Regular sets 3. Which of the following sets are regular ? Give your reason. {an b m | n 0 and m 0 } {an b m | n m, n 0 and m 0 } {ak y | k 0, y {a,b}* and y contains at least k a’s } {xcy | x, y {a,b}* } {an b m | n +10 m } {an bm | n > m and m < 20 } {an b m | n > m > 20 }
5
4. Elimination of inaccessible states
4. For the given FA, find all states which are inaccessible. 4.1 Draw a state transition diagram for the DFA. 4.2 Draw the state transition diagram for the resulting DFA after removing of inaccessible states. a b 1 1 3 2F 6 5 7 4F 6F 2 8 4
6
5. Minimization of DFA a b 1 F 6 4 2F 7 5 3 2 8 1
5. Apply the minimization algorithm to find a minimal DFA equivalent to the right one. 5.1 Draw the chart table 5.2 Mark each cell corresponding to a pair {p,q} of states p,q that are not equivalent with a number indicating the length of a minimal string which witnesses their inequivalence. 5.3 Draw a state-transition table (or diagram) for the resulting DFA and indicate clearly which equivalence class of the old DFA corresponds to each state of the new one. a b 1 F 6 4 2F 7 5 3 2 8 1 2 3 4 5 6 7 8 1
7
6. Consider the following context free grammar G:
6. CFG and CFL 6. Consider the following context free grammar G: C ABC | AB A Aa | a B bA | b 6.1 If G=(N, S, S, P), then N = __________; S = _______________ ; S = ___________ and P = {________________}. 6.2. Define L(X) = {xS* | X*x}. Find 3 regular expressions representing L(A), L(B) and L(C), respectively. 6.3 Which of the following strings are in L(G) ? (a) aabaab (b) aaaaba (c) aabbaa (d) abaaba 6.4 Give a derivation for each of the above strings which are in L(G).
8
7.1 A1 = {w | w contains at least three 1s.}
CFG design 7. Give context-free grammars that generate the following languages. Suppose the alphabet of terminals is {0,1}. 7.1 A1 = {w | w contains at least three 1s.} 7.2 A2 = {w | w starts and ends with the same symbol.} 7.3 A3 = { w | the length of w is odd and its middle symbol is 0.} 7.4 A4 = {w | w contains as many 0s as 1s.} 7.5 A5 = {w {a,b,c}* | #a(w) + #b(w) #c(w) }. // #a(w) is the number of a’s occurring in w. 7.6 A6 = {anbnck | 3 k}
9
8. Let G be the context-free grammar (CFG) given below: S (S) S | e
8. Verification of CFG 8. Let G be the context-free grammar (CFG) given below: S (S) S | e Assume the alphabet S = {(, )}. Show that If x L(G), then x is a balanced parenthesis. If x is a balanced parenthesis, then xL(G). Note that x is a balanced parenthesis iff 1. it has the same number of occurrences of ‘(‘ and ‘)’ and 2. for every proper prefix y of x, occurrences of ‘(‘ in y is no less than occurrences of ‘)’, i.e., L(y) R(y)).
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.