15-151: Mathematical Foundations for Computer Science
Homework 1 Solutions
Setty Questions
For several homework problems in this course we will ask you to use our own custom programming
language, which we call Setty (stylized cfw_Sety). cfw_Sety is an env
15-151: Mathematical Foundations for Computer Science
Homework 3
(due Wednesday, September 18)
Directions: Write up carefully argued solutions to the following problems. The rst task is to be
complete and correct. The more subtle task is to keep it simple
15-151: Mathematical Foundations for Computer Science
Homework 7
(due Wednesday, October 23)
Directions: Write up carefully argued solutions to the following problems. The rst task is to be
complete and correct. The more subtle task is to keep it simple a
15-151: Mathematical Foundations for Computer Science
Homework 8
(due Wednesday, October 30)
Directions: Write up carefully argued solutions to the following problems. The rst task is to be
complete and correct. The more subtle task is to keep it simple a
15-151: Mathematical Foundations for Computer Science
Homework 2 (due Wednesday, September 11)
Directions: Write up carefully argued solutions to the following problems. The rst task is to be
complete and correct. The more subtle task is to keep it simple
15-151: Mathematical Foundations for Computer Science
Homework 5
(due Monday, October 7)
Directions: Write up carefully argued solutions to the following problems. The rst task is to be
complete and correct. The more subtle task is to keep it simple and s
15-151: Mathematical Foundations for Computer Science
Test 2 (Practice)
Name:
Andrew ID:
15-151 Section (circle one):
A
B
C
15-152 Section (circle one):
A
B
C
D
INSTRUCTIONS:
Write your NAME, ANDREW ID, and SECTION above.
This is a closed book test. You
15-151: Mathematical Foundations for Computer Science
Test 1
Name:
Andrew ID:
15-151 Section (circle one):
A
B
C
15-152 Section (circle one):
A
B
C
D
INSTRUCTIONS:
Write your NAME, ANDREW ID, and SECTION above.
This is a closed book test. You may not us
15-151: Mathematical Foundations for Computer Science
Homework 4
(due Wednesday, September 25)
Directions: Write up carefully argued solutions to the following problems. The rst task is to be
complete and correct. The more subtle task is to keep it simple
Homework 1
The Curious Case of the Lying TAs
(a) Here, we are proving whether the two inhabitants are students or TAs based on the statement.
The statement at least one of us in a TA can either be true, so either one or both of the inhabitants
are TAs, or
Homework 7
Direction is Relative
(a) If the graph has no loops, then E is not a reexive relation. The graph having loops would
imply that all edges of the form (vi , vi ) for some vi V , where i is some arbitrary natural number,
are in E, which would impl
Sets Workshop
Consider Cardinality
(a) The set A := cfw_1, 2, 3 has a cardinality of 3.
(b) The set B := cfw_, cfw_, cfw_.cfw_, cfw_, cfw_, cfw_, . has innite cardinality.
Minus Minus Minus
Proposition: (A, B, C). (A\B)\C = A\(B \C)
Proof: To prove or dis
Homework 8.5
Counting in Two Ways
Here, we are proving that, for some a, n N, a > 0, that
n
ai = an+1 1
(a 1)
i=0
using a counting in two ways argument. We will show that both ways count the amount of possible
strings of length n + 1 that can be made from
Homework 10
Battle of the Greggorys
(a)
def greggory(n): /The very first time this function is called, n = 0
gk = FlipCoin(p) /Gregs shot
gr = FlipCoin(q) /Gregorys shot
winner = "
if gk = HEADS: /If Greg hits
winner = "Greg!"
return winner
elif gr = HEAD
Homework 5
All Your Base (Case) are Belong to Us
Here, we are proving that fn = gn for all n N by strong induction on n.
Base Case
Note that it is given that f0 = g0 = 1, f1 = g1 = 5, and f2 = g2 = 10. For n = 3, we know
that f3 = 2f2 4f1 = 2(10) 4(5) = 2
Homework 6
Great Times
Dene g : R3 R2 by g(x, y, z) = (xz, yz). Here, we are showing that g is surjective and neither
injective nor bijective
Injective: For g to be injective, we know that (x, y, z, a, b, c R). g(x, y, z) = g(a, b, c) = x =
a, y = b, z =
Homework 4
Obvious Induction Question
Here, we are proving that n! < nn for n N \ cfw_0, 1 by induction on n. Let P (n) = n! < nn .
Base Case
When n = 2, we know that P (2) is true because:
2! < 22
2<4
Inductive Hypothesis
Suppose that P (k) is true for s
Homework 2
Same Dierence
Here, we are proving that the union on any two non-empty sets A and B, such that |A B| 2
can be expressed as a union of two disjoint, non-empty sets. A and B can fall into three dierent
cases, and each case can be proved individua
Homework 3
Forall easy problems, exists a reason
(a) Here we are disproving that (x Z). (y R). 2x > y. We can do this by proving that the
statements negation, (x Z). (y R). 2x y. Let x Z be arbitrary and xed. Choose y R
to be equal to 2x. Since 2x = 2x fo
Homework 8
n now, theyre gon
(a) Here, we are showing the number dierent p-gons that can be made using the given points. We
will call this number Pn , and we can reduce the problem to showing:
2pPn = p!
. Let us x an arbitrary ordering on the points and s