Download Final Solutions

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
1. Let S = {w | w in {a,b,c}*, w is a substring of ‘aabcbb} and let R be the relation “is a substring of.” For
example, abc R abcb, but not aa R abcb.
(15) (a) Prove that (S, R) is a partially ordered set.
1. For any w in S, w is a substring of itself, so R is reflexive.
2. Suppose v, w in S and vRw and wRv. This means v is a substring of w and w is a substring of v. This implies
that the lengths of v and w are the same, and therefore they are the same string: v = w. So R is antisymmetric.
3. Suppose for u, v, w in S that uRv and vRw. The u is a substring of v and v is a substring of w. This means
that u appears in the substring v within w, so u is a substring of w, uRw. Thus R is transitive.
R is a partial ordering by 1,2,3, so (S, R) is a partially ordered set.
1
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
(10) (b) Draw the Hasse diagram for (S, R).
aabcbb
aabcb
aabc
aab
abcbb
abcb
abc
aa
ab
bcbb
bcb
cbb
bc
cb
b
c
a
bb



(10) (c) Is (S, R) a lattice? Why or why not? (A formal proof is not required, just an explanation of why or
why not, based on the diagram.)
No. b and c have no LUB since bc and cb are both upper bounds for b and c and bc, cb are not related under R.
Similarly, bc and cb have no GLB, since b and c are both lower bounds for bc, cb.
2
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
2. Consider the set F = {(x, y) | x, y in Z, not y = 0}. (x could be 0.)
Define the operation + on F as follows: (r, s) + (x, y) = (ry + sx, sy)
(10) (a) Prove that (F, +) is a commutative monoid.
1. Consider (r,s), (u,v), and (x,y) all in F:
(r,s) + ((u,v) + (x,y)) = (r,s) + (uy+vx, vy)
def
= (r(vy) + s(uy + vx), s(vy))
def
= (rvy + suy + svx, svy)
associativity of multiplication and addition on Z
= ((rv + su)y + (sv)x, (sv)y)
associativity of multiplication and addition on Z
= (rv + su, sv) + (x,y)
def
= ((r,s) + (u,v)) + (x,y)
def
So + on F is associative.
2. (r,s) + (x,y) = (ry + sx, sy)
def
= (xs + yr, ys)
addition and multiplication on Z commutative
= (x,y) + (r,s)
def
So + on F is commutative.
3. Consider (0,1) in F and any (r,s) in F
(0,1) + (r,s) = (0s + 1r, 1s)
= (r, s)
def
properties of 0, 1 in Z
So (0,1) is the identity on (F, +)
By 1, 2, 3, (F, +) is a commutative monoid.
3
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
(10) (b) Define the relation ~ on F as follows: (a, b) ~ (c, d) if and only if ad = bc.
Show that ~ is an equivalence relation.
1. For any (x,y) in F, xy = yx (since mult on Z is commutative), so (x,y) ~ (x,y) and ~ is reflexive.
2. Assume (r,s) ~ (x,y), for (r,s) and (x,y) in F. Then ry = sx (def of ~). So xs = yr (mult on Z is commutative
and = is symmetric) and (x,y) ~ (r,s) (def of ~). So ~ is symmetric.
3. Assume that (r,s) ~ (u,v) and (u,v) ~ (x,y), for (r,s), (u,v), (x,y) in F. Then rv = su and uy = vx (def of ~).
Since rv = su, we have rvy = suy, multiplying both sides by y.
Then rvy = svx, by substitution.
Since v is not 0 (def of F), we can conclude that ry = sx.
Then (r,s) ~ (x,y) (def of ~).
Thus ~ is transitive. (Note: you must cite that v is not 0 to come to this conclusion – this relation depends on
that part of the definition of F.)
By 1, 2, and 3, ~ is an equivalence relation.
(10) (c) Show that ~ is a congruence relation for (F, +).
Suppose (a,b) ~ (c,d) and (r,s) ~ (x,y), all in F. Then ad = bc and ry = sx (def of ~).
Consider (a,b) + (r,s) = (as + br, bs) and (c,d) + (x,y) = (cy + dx, dy).
To show these are equivalent by ~, we need to show that
(as + br)dy = bs(cy + dx).
Start with (as + br)dy = asdy + brdy
distributive
= adsy + bdry
mult commutative
= bcsy + bdsx
substitution from above
= bscy + bsdx
mult commutative
= bs(cy + dx)
distributive
So if (a,b) ~ (c,d) and (r,s) ~ (x,y), then (a,b) + (r,s) ~ (c,d) + (x,y)
~ is a congruence.
4
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
(5) (d) Consider (F/~, [+]), where [+] is the operation + applied to the congruence classes.
Give a partial list of some of the congruence classes (five classes with four or five representative elements
each).
What well-known mathematical structure is this?
{ (0,1), (0,2), (0,3), (0,4), (0,5), …}
{ (1,1), (2,2), (3,3), (4,4), (5,5), …}
{(1,2), (2,4), (3,6), (4,8), (5,10), …}
{(5,3), (10,6), (15,9), (20,12), (25,15),…}
{(-3,4), (3,-4), (-6,8), (6,-8), (-9, 12),….}
The rational numbers. Each congruence class is the set of fractions that are equal.
5
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
3. Consider the Moore Machine, M, specified by the following diagram with T = {S2, S3}.
0
0
1
S0
S1
S2
1
0
1
1
0
1
S3
1
S4
0
S5
0
(5) (a) Fill out the table that specifies the function fw for w = 01101
s
fw (s)
s0
s1
s2
s3
s4
s5
s5
s0
s5
s0
s5
s0
(10) (b) Find the special congruence R so that L(M/R) = L(M). Do this by refining the partitions that correspond
to the sequence of relations R0, R1, …, where P0 = {{S0, S1, S4, S5} {S2, S3}}.
P0 = {{S0, S1, S4, S5} {S2, S3}} input 0 splits S0 C S1 and S0 and S4. S0 and s5 stay together as do S1 and S4
S2, S3 stay together under both inputs.
P1 = {{S0, S5} {S1, S4} {S2, S3}}
P2 = P1
no further splitting occurs.
So R is the relation defined by the partition P1.
6
Computer Science 290, Spring, 2009
Final Exam
Name________________________________
(10) (c) Draw M/R.
1
0
1
[S0]
[S1]
0
1
[S3]
0
(5) (d) Give a regular expression for L(M/R).
First build the r.e. that is generated by going around the loop and ending at [S0]:
0*11*00*1
This loop can be repeated many times (or none), then must be followed by the sequence that put the machine
into the accepting state:
(0*11*00*1)*0*11*00*
7
Related documents