CSc 318 Final Examination 14 December 1999
xÎ ~(AÈ B) Û xÏ AÈ B Û xÏ A and xÏ B Û xÎ ~A and xÎ ~B) Û
xÎ ~AÇ ~B
As structures, every dfa is an nfa, every nfa is an e -nfa, and any e -nfa can be converted to an equivalent dfa, so all three are equivalent. A right regular grammar is a particular kind of cfg, but there are cfg’s whose languages cannot be the language of any right regular grammar. On the other hand, for any right regular grammar there is a dfa with the same language and conversely. Regular expressions are used to denote regular languages. For any regular expression there is a dfa with the same language and conversely. Summing up, the languages of dfa’s, nfa’s, e -nfa’s, regular expressions, and right regular grammars are all the same, and can all be given by a cfg, but there are some cfg’s which have languages which are not regular.
BWOC, assume (0,1) is countable Þ $ 1-1, onto f:N® A, where N is the set of natural numbers. Write f(i)=0.ai1ai2ai3ai4 …., where each a ij is a digit between 0 and 1, and expansion of f(i) does not terminate (in a string of 0’s), e.g., if f(i) is 0.1, we write it as 0.0999999….
Let x=0.x1x2x3x4 ….. where each xi is chosen from {1,2,…9}-{ aii}.
Then xii¹ aii for each i Þ x¹ f(i) for each i. Thus we have the contradiction that x is in A and f is 1-1 and onto.
BWOC assume the A, set of languages over S , is countable Þ $ a 1-1, onto f:S *® A. Let B be the language over S given by B={w:wÏ f(w)}. Since B is a language over S , $ v such that B=f(v). Then by the definition of vÎ B and vÏ B.
{(s,a,1), (s,a,2), (1,b,3), (1,b,2), (3,a,s), (3,b,2)} )
a. Find an e -nfa whose language is L(M)L(M). (Create a copy of M, remove the final states of the original, have e -transitions from old final states of original to start state of copy.) M’=({s,1,2,3,ss,11,22,33}, {a,b}, s, {22,33}, {(s,a,1), (s,a,2), (1,b,3), (1,b,2), (3,a,s), (3,b,2), (ss,a,11), (ss,a,22), (11,b,33), (11,b,22), (33,a,ss), (33,b,22),(2, e ,ss),(3, e ,ss)} )
M=({s,1,2,3}, {a,b}, s, {s,1},
{(s,a,1), (s,a,2), (1,b,3), (1,b,2), (3,a,s), (3,b,2)} )
S ® aSbb | bB | cB | dAA
A ® aA | bBc | c | e
B ® a | bS
The grammar is not LL(1) because A® e and
follow(A)Ç first(A) ={a,b,c} ¹ f
a b
s 12 f
12 f 23
f f f
23 s 2
2 f f
The set of final states is {12, 23, 2}
S ® aAb | cAb | aBC
A ® a | aA | e
B ® bAA | e
C ® c | e
We first get rid of all the e -productions. That gives
S ® aAb | cAb | aBC | ab | cb | aC | aB | a
A ® a | aA
B ® bAA | bA | b
C ® c
Now we add S® XY, X® a, Y® AZ, Z® b, S® CY, S® XW, W® BC, S® XZ, S® CZ, S® XC, S® XB, A® XA, B® ZV, V® AA, B® ZA, and remove all "offending" productions to get
S ® XY | CY | XW | XZ | CZ | XC | XB | a
A ® XA | a
B ® ZV | ZA | b
C ® c
X ® a
Y ® AZ
Z ® b
W ® BC
V ® AA
S ® ST | S | T
T ® TA | U
U ® a | b | cSc
Compute Unit(S)={S, T, U}, Unit(T)={T,U}, Unit(U)={U}.
For S® T add S® TAT|UT|TA
For S® U add S® aT|bT|cScT|a|b|cSc
For T® U add T® aA|bA|cScA
Toss out all unit productions to finally get
S® ST | TA | a | b | cSc
T® TA | a | b | cSc
U ® a | b | cSc
A ® ab
M = ({s,1,2,3}, {a,b}, s, {2,3},
{(s,a,1), (s,a,2), (1,b,3), (1,b,2), (3,a,s), (3,b,2), (s,e ,1), (1,e ,3)} )
We first add (s,e ,3). Then we add final states s and 1. Then
For (s,e ,1) add (s,b,2) and (s,b,3).
For (s,e ,3) add (s,b,2) and (s,a,s).
For (1,e ,3) add (1,b,2) and (1,a,s).
Now toss the e -transitions. We get D = {(s,a,1), (s,a,2), (1,b,3), (1,b,2), (3,a,s), (3,b,2), (s,b,2), (s,b,3), (s,a,s), (1,b,2), (1,a,s)} )
3 a |
6 a |
7 |
|
a5 |
Yes |
No |
No |
abb |
No |
No |
No |
ba |
No |
No |
Yes |