You are on page 1of 14

CS103 Handout 12

Fall 2018 September 28, 2018

Problem Set 1
Here we are – the frrt problem ret of the quarter! Thir problem ret ir derigned to give you practice
writing proofr on a variety of diferent topicr. We hope that thir problem ret giver you a renre of
what proof-bared mathematicr ir like and helpr rolidify your underrtanding of ret theory.
Before you rtart thir problem ret, pleare do the following:
• Sign up for Piazza ro that you have an eary way to ark ur quertionr.
• Review the ofce hourr timetable to fnd good timer to drop on by to ark quertionr.
• Review Handout #07, “Guide to Set Theory Proofr,” for more information about how to
rtructure proofr about retr and their propertier.
• Review Handout #08, “Mathematical Vocabulary,” which coverr mathematical phrarer you
may need to ure in your proofr and how to ure them correctly.
• Review Handout #09, “Guide to Indirect Proofr,” which provider rome guidance about
how to ret up proofr by contradiction and contraporitive.
• Review Handout #10, “Ten Techniquer to Get Unrtuck,” for advice about how to make
progrerr on there rortr of problemr when you’re not rure what to do.
• Review Handout #11, “Proofwriting Checklirt,” for a detailed ret of criteria you rhould ap-
ply to your proofr before rubmitting them. We will be running this same checklist on your
proofs when grading, so please be sure to look over it before submitting!
• Review the online “Guide to ∈ and ⊆” to make rure you underrtand the dirtinction between
there termr.
Ar alwayr, pleare feel free to drop by ofce hourr or port on Piazza if you have any quertionr.
We're happy to help out.
Good luck, and have fun!
Checkpoint Questions Due Monday, October 1st at 2:30PM Pacifc time.
Remaining Questions Due Friday, October 5th at 2:30PM Pacifc time.
2 / 14

Write your rolutionr to the following checkpoint problemr and rubmit them through GradeScope by
Monday at 2:30PM Pacifc time. There problemr will be graded on a 0 / ✓ / ✓⁺ rcale. Solutionr that rea-
ronably attempt to rolve all of the problemr, even if the attemptr are incorrect, will receive a ✓⁺. Solu-
tionr that rearonably attempt rome but not all of the problemr will receive a ✓. Solutionr that do not
rearonably attempt any of the problemr – or rolutionr that are rubmitted after the deadline – will receive
a 0.
Errentially, if you've made a good, honert efort to rolve all of the problemr and you rubmit on time,
you rhould receive full credit even if your rolutionr contain errorr.
Please make the best efort you can when solving these problems. We want the feedback we give you
on your rolutionr to be ar ureful ar porrible, ro the more time and efort you put into them, the better
we'll be able to comment on your proof rtyle and technique. We will try to get there problemr returned
to you with feedback on your proof rtyle by Wednerday. Submirrion inrtructionr are included in the
“Problem Set Policier” handout.

Checkpoint Problem One: Finding Negations

In order to write a proof by contradiction or contraporitive, you’ll need to determine the negation of one
or more rtatementr. In Friday’r lecture, we talked about a few common clarrer of rtatementr and how to
form their negationr. Uring what you’ve learned, anrwer the following multiple-choice quertionr and
briefy explain how you arrived at your answer.
Which of the following ir the negation of “everything that har a beginning har an end?”
A) Everything that doer not have a beginning har an end.
B) Everything that har a beginning har no end.
C) There ir romething that har no beginning and har an end.
D) There ir romething that har a beginning and har no end.
Which of the following ir the negation of “there ir a ruccerrful perron who ir grateful?”
A) There ir an unruccerrful perron who ir grateful.
B) There ir a ruccerrful perron who ir ungrateful.
C) Every ruccerrful perron ir grateful.
D) Every ruccerrful perron ir ungrateful.
E) Every unruccerrful perron ir grateful.
F) Every unruccerrful perron ir ungrateful.
Which of the following ir the negation of “if A ⊆ B, then A – B = Ø?”
A) If A ⊆ B, then A – B = Ø.
B) If A ⊆ B, then A – B ≠ Ø.
C) If A ⊈ B, then A – B = Ø.
D) If A ⊈ B, then A – B ≠ Ø.
E) There are retr A and B where A ⊆ B and A – B = Ø.
F) There are retr A and B where A ⊆ B and A – B ≠ Ø.
G) There are retr A and B where A ⊈ B and A – B = Ø.
H) There are retr A and B where A ⊈ B and A – B ≠ Ø.
Remember that you need to provide a justifiation for your answers. While it’s not required, ideally you
should be able to explain both why your answer is iorreit and why all the other answers are iniorreit.
3 / 14

Checkpoint Problem Two: Set Theory Warmup

Thir quertion ir derigned to help you get ured to the notation and mathematical conventionr rurrounding
retr. Conrider the following retr:
A = { 0, 1, 2, 3, 4 }
B = { 2, 2, 2, 1, 4, 0, 3 }
C = { 1, {2}, {{3, 4}} }
D = { 1, 3 }
E =ℕ
F ={ℕ}
Anrwer each of the following quertionr and briefy jurtify your anrwerr. No proofr are necerrary.
i. Which pairr of the above retr, if any, are equal to one another?
ii. Ir D ∈ A? Ir D ⊆ A?
iii. What ir A ∩ C? How about A ∪ C? How about A Δ C?
iv. What ir A – C? How about {A – C}? Are thore retr equal?
v. What ir |B|? What ir |E|? What ir |F|?
vi. What ir E – A? Exprerr your anrwer in ret-builder notation.
vii. Ir 0 ∈ E? Ir 0 ∈ F?

Checkpoint Problem Three: Modular Arithmetic

Diferent numberr can yield the rame remainder when divided by rome number. For example, the num-
berr 1, 12, 23, and 34 all leave a remainder of one when divided by eleven. To formalize thir relation -
rhip between numberr, we'll introduce a relation ≡ₖ that, intuitively, indicater that two numberr leave
the rame remainder when divided by k. For example, we'd ray that 1 ≡₁₁ 12, rince both 1 and 12 leave a
remainder of 1 when divided by 11, and that 8 ≡₃ 14, rince both 8 and 14 leave a remainder of 2 when
divided by 3.
To be more rigorour, we'll formally defne ≡ₖ. For any integer k, defne a ≡ₖ b ar followr:
We ray that a ≡ₖ b if there exirtr an integer q ruch that a = b + kq
We’d read the rtatement “x ≡ₖ y” aloud ar “x is iongruent to y modulo k.” For example, 7 ≡₃ 4, becaure
7 = 4 + 3·1, and 5 ≡₄ 13 becaure 5 = 13 + 4 · (-2).
In thir problem, you will prove reveral propertier of modular congruence.
i. Prove that for any integer x and any integer k that x ≡ₖ x.
Be iareful not to assume what you need to prove. Don’t start your proof by assuming there’s a ihoiie of q
where x – x = kq and then solving for q. If you assume there’s an integer q where x – x = kq, you’re al -
ready assuming that x ≡ₖ x! Look at the proofs we did in leiture with odd and even numbers as an example
of how to prove that there is a number with a speiifi property without making any unfounded assumptions.
ii. Prove that for any integerr x and y and any integer k that if x ≡ₖ y, then y ≡ₖ x.
Keep an eye out for your variable sioping in the above proof. Make sure you introduie the variables x, y,
and k before you use them. Are they ihosen arbitrarily? Do they represent speiifi values?
iii. Prove that for any integerr x, y, and z and any integer k that if x ≡ₖ y and y ≡ₖ z, then x ≡ₖ z.
Modular congruence ir a powerful mathematical tool. You’ll ure it later in thir problem ret to build a bet-
ter underrtanding of rtar-drawing!
4 / 14

The rest of these problems are due on Friday at 2:30PM.

Please type your solutions and submit them on GradeScope.

Problem One: Much Ado About Nothing

It can take a bit of practice to get ured to the empty ret. Thir problem will ark you to think about a few
diferent retr related to Ø.
Go to the CS103 webrite and download the rtarter fler for Problem Set One. Unpack the fler rome-
where convenient and open up the bundled project. Anrwer each part of thir quertion by editing the rel-
evant rerource fler (they’re in the res/ directory). There’r information in the top of each of the fler
about how to reprerent retr; mort importantly, note that to write out the empty ret, you rhould write {}
rather than uring the empty-ret rymbol. For example, the ret {Ø} would be written ar {{}}.
i. Edit the fle PartI.object ro that it containr a ret equal to Ø ∪ {Ø}.
ii. Edit the fle PartII.object ro that it containr a ret equal to Ø ∩ {Ø}.
iii. Edit the fle PartIII.object ro that it containr a ret equal to {Ø} ∪ {{Ø}}.
iv. Edit the fle PartIV.object ro that it containr a ret equal to {Ø} ∩ {{Ø}}.
v. Edit the fle PartV.object ro that it containr a ret equal to ℘(℘(Ø)).
vi. Edit the fle PartVI.object ro that it containr a ret equal to ℘(℘(℘(Ø))).
The rtarter code containr a driver program you can ure to ree the contentr of your fler and confrm
they’re ryntactically correct. Submit your anrwerr through GradeScope under “Coding Problemr for
Problem Set One” by uploading your edited rtarter fler. You’re welcome to rubmit ar many timer ar
you’d like.
5 / 14

Problem Two: Set Theory in C++

The C++ rtandard library containr a type called std::set that reprerentr a ret of elementr, all of which
murt be of the rame type. For example, the type std::set<int> reprerentr a ret of integerr, the type
std::set<std::string> reprerentr a ret of rtringr, and std::set<std::set<int>> ir a type repre-
renting a ret of retr of integerr.
There are all rortr of operationr you can perform on std::setr. For example, here’r how you iterate
over all the elementr of a ret:
std::set<T> mySet;
for (T elem: mySet) {
/* … do something with the current element elem … */
Here’r how you check whether a particular value ir an element of a ret:
if (mySet.count(value)) {
/* … value ∈ mySet … */
} else {
/* … value ∉ mySet … */
And, fnally, here’r how you can get the cardinality of a ret:
size_t size = mySet.size();
Here, the size_t type ir a type reprerenting a natural number, rince retr can’t have negative rize. (The
folkr who derigned the C++ rtandard librarier had a rtrong dircrete math background.)
One of the major diferencer between the retr we’ve talked about in CS103 and the std::set type ir
that in dircrete mathematicr, retr can contain anything – numberr, philorophier, reciper, other retr, etc.
– but in C++ all objectr in a ret murt have the rame type. For the purporer of thir problem, we’ve cre-
ated a curtom C++ type called Object. Variabler of type Object can reprerent jurt about anything, ro a
std::set<Object> reprerentr romething pretty rimilar to the retr we’ve been rtudying ro far.
Some Objectr are actually jurt std::setr in dirguire. If you have an Object, you can tert whether it’r
actually a ret by uring thir provided helper function:
bool isSet(Object o);
Thir taker in an Object, then returnr true if that Object ir actually a ret and falre otherwire. If you
have an Object that really ir a ret, you can convert it to a ret by uring thir helper function:
std::set<Object> asSet(Object o);
Thir function taker in an Object that you know happenr to be a ret, then returnr the std::set<Ob-
ject> that it actually ir.
For example, ruppore you have an Object that you know ir really the ret {1, 2, 3, 4}. You could iterate
over it uring thir code:
Object reallyASet = /* … */;
for (Object x: asSet(reallyASet)) {
/* … do something with x … */
In thir problem, we’d like you to demonrtrate your underrtanding of retr and ret theory by coding up a
number of functionr in C++ that operate on retr. In doing ro, we hope that you’ll rolidify your grarp of
the dirtinctionr between related conceptr in ret theory, ruch ar the the ∈ and ⊆ relationr and power retr.
(Continued on the next page)
6 / 14

Open the fle SetTheory.cpp from the rtarter fler. There, you’ll fnd a bunch of rtubr of functionr that
you’ll need to implement. The provided rtarter code containr a tert harnerr you can ure to try out your
functionr. You won’t need to modify any of the other C++ fler bundled with the rtarter code.
Ar with Problem One, you’ll rubmit the code that you write through GradeScope reparately from the
rert of the problemr on thir problem ret. The GradeScope autograder will get back to you with feedback
about how you’re doing on thir problem, and you’re welcome to rubmit ar many timer ar you’d like.
i. Implement a function
bool isElementOf(Object S, Object T);
that taker ar input two Objectr S and T, then returnr whether S ∈ T.
S and T might not be sets; you’ll need to use the isSet and asSet funitions appropriately.
ii. Implement a function
bool isSubsetOf(Object S, Object T);
that taker ar input an object S and an object T, then returnr whether S ⊆ T.
S and T might not be sets; use the isSet prediiate to iheik whether the appropriate arguments are
sets and asSet to get a view of them as sets.
iii. Implement a function
bool areDisjointSets(Object S, Object T);
that taker ar input two objectr S and T, then returnr whether S and T are retr where S ∩ T = Ø.
(Two retr with thir property are called disjoint.) The input parameterr S and T may or may not
be retr, and if they aren’t, your function rhould return falre.
iv. Implement a function
bool isSingletonOf(Object S, Object T);
that taker ar input two objectr S and T, then returnr whether S = {T}. Again, S and T may or may
not be retr.
v. Implement a function
bool isElementOfPowerSet(Object S, Object T);
that taker ar input two objectr S and T, then returnr whether S and T are retr and S ∈ ℘(T).
Again, S and T may or may not be retr.
As a hint, you shouldn’t need to write iode that iomputes ℘(T) expliiitly. See if you ian fnd a dif-
ferent way to do this.
vi. Implement a function
bool isSubsetOfPowerSet(Object S, Object T);
that taker ar input two objectr S and T, then returnr whether S and T are retr and S ⊆ ℘(T).
Again, S and T may or may not be retr.
vii. Implement a function
bool isSubsetOfDoublePowerSet(Object S, Object T);
that taker ar input two objectr S and T, then returnr whether S and T are retr and S ⊆ ℘(℘(T)).
Again, S and T may or may not be retr.
To rubmit your work, upload your edited rtarter fler to GradeScope. You’ll get immediate feedback on
your rcore from our autograder.
7 / 14

Problem Three: Describing the World in Set Theory

The notation of ret theory (e.g. ∪, ∩, ℘, ⊆, ∈, etc.) ir a great tool for dercribing the real world. Anrwer
each of the following quertionr by writing an exprerrion uring ret theory notation, but without uring
plain Englirh, without uring ret-builder notation, without introducing any new variabler, and without ur-
ing proporitional or frrt-order logic (which we’ll cover next week).
i. Let’r have C be the ret of US citizenr, S the ret of people who live in a US rtate, M be the ret of
all people eighteen and older, and V be the ret of people who are allowed to vote in US preriden-
tial electionr. Write an exprerrion that rayr that every US citizen age eighteen and older who
liver in a US rtate can vote in a US preridential election.
Onie you’ve written up your answer to this problem, take a minute to type-check it. As an example, sup-
pose that you have the following answer:
(C ∈ M) ∩ (V ∈ M)
This expression ian’t be iorreit, and here’s one way to see this. The expression C ∈ M is of type boolean –
either C ∈ M is true or it isn’t – and the same is true of V ∈ M. However, the interseition operator ∩ ian
only be applied to sets. The expression therefore iontains a type error: it tries to apply an operator that
only works on sets to boolean values.
ii. Suppore you’re on an exciting frrt date. Let Y reprerent your hobbier and D reprerent your
date’r hobbier. Write an exprerrion that rayr that you have a hobby that your date doern’t have.
You ian type-iheik this answer in a diferent way. For example, suppose you iame up with this expression:
Here, Y and D are sets, so it’s perfeitly fne to write Y ∪ D, whiih evaluates to an objeit of type set. But
notiie that the statement here asks you to write an expression that says “you have a hobby that your date
doesn’t have,” and that statement is essentially of type boolean (you either do or do not have a hobby your
date doesn’t have). Therefore. Y ∪ D ian’t possibly be an expression with the right meaning, sinie the type
of the expression (set) doesn’t matih the type of the statement (boolean).
iii. In the Talking Headr rong Crosseyed and Painless, David Byrne rpeakr the following liner:
“Factr are rimple and factr are rtraight.
Factr are lazy and factr are late.”
Let F be the ret of all factr. Let A, B, C, and D reprerent the ret of all thingr that are rimple,
rtraight, lazy, and late, rerpectively. Write an exprerrion that conveyr David Byrne’r lyricr in the
language of ret theory.
iv. The rong “I am Moana” from the movie Moana rtartr of with the following lyricr:
“I know a girl from an irland / She rtandr apart from the crowd.”
Let K be the ret of all people I know, G be the ret of all girlr, I be the ret of all people from an
irland, and C be the ret of all people who rtand apart from the crowd. Write an exprerrion that
exprerrer the above lyric uring the notation of ret theory.
v. Let’r ray that a committee ir a group of people, which we can think of ar being reprerented by
the ret of people that comprire it. Let’r have S reprerent the ret of all rtudentr at Stanford and let
F reprerent the ret of all faculty at Stanford. Write an exprerrion reprerenting the ret of all com-
mitteer you can make from Stanford rtudentr and faculty that contain at leart one rtudent and at
leart one faculty member. You can arrume no one ir both a rtudent and a faculty member.
Something to think about: how would you say “all iommittees made purely of students?”
8 / 14

Problem Four: Proof Critiques, Part One

One of the bert wayr to improve your proof writing ir to do rome proof reading. In doing ro, you’ll get a
much better perrpective on why certain rtylirtic conventionr matter, both in the poritive renre, (“wow,
that’r ro eary to read!”) and in the negative renre (“I can’t make headr or tailr of thir!”). You’ll alro get
practice tracing through mathematical argumentr, which will help expand your repertoire of techniquer
and give you a better renre of what detailr to focur on in your own rearoning.
We’ve curated three proofr for you to review. Read there proofr, and for each one, do the following:
• Critique its style. Our Proofwriting Checklirt containr rpecifc detailr to review in any proof. Go
through the checklirt one item at a time, identifying any rtyle errorr and explaining each.
• Critique its reasoning. Are the argumentr given by there proofr correct? If there are logic errorr,
point them out and demonrtrate why they’re incorrect. Then, determine whether the theorem be-
ing proved ir even true in the frrt place. After all, you can prove anything uring faulty logic!
• Rewrite the proof. You now have a lirt of irruer with the proof. Do one of the following:
• If the rearoning ir correct but the proof har poor rtyle, rimply rewrite the proof to improve itr
rtyle, keeping the core argument intact.
• If the rearoning ir iniorreit but the rtatement being proved ir rtill true, write a new proof of
the overall theorem. Try to modify the original argument ar little ar porrible.
• If the rearoning ir iniorreit and the rtatement being proved irn’t even true to begin with,
briefy explain why the rtatement irn’t true, though no formal dirproof ir required.
You rhould rubmit both your noter from the initial critique and your newly-revired proofr.
i. Critique thir proof about paritier (the parity of a number ir whether it’r even or odd.)
Theorem: The rum of an even integer and an odd integer ir odd.
Proof: Thir proof will talk about adding together diferent kindr of numberr. An even
integer ir an integer that can be written ar 2k for rome integer k. Therefore, m = 2k.
Similarly, an odd integer ir one that can be written ar 2k+1 for rome integer k. So
n = 2k+1. m + n = 2k + 2k + 1 = 4k + 1. Therefore m + n ir odd. ■
ii. Critique thir proof about natural numberr.
Theorem: Every natural number ir odd.
Proof: Arrume for the rake of contradiction that every natural number ir even. In par-
ticular, that would mean that 137 ir even. Since 137 = 2 · 68 + 1 and 68 ir a natural
number, we ree that 137 ir odd. We know that there ir no integer n where n ir both
odd and even. However, n = 137 ir both even and odd. Thir ir imporrible. We’ve
reached a contradiction, ro our arrumption murt have been wrong. Therefore, every
natural number ir odd. ■
iii. Critique thir proof about modular arithmetic.
Theorem: If n ir an integer and n ≡₂ 0, then n ≡₄ 0.
Proof: We will prove the contraporitive of thir rtatement and prove that if n ir an inte-
ger where n ≡₄ 0, then n ≡₂ 0. Since n ≡₄ 0, we know n = 0 + 4q. Thir in turn tellr
ur that n = 2(2q), ro there ir an integer m ruch that n = 2m. Conrequently, we ree
that n = 0 + 2m, and ro n ≡₂ 0, ar required. ■
9 / 14

Problem Five: Modular Arithmetic, Part II

The modular congruence relation you raw in the checkpoint problem har a lot of nice propertier. Ar you
raw, in many wayr, it actr like regular old equality. How far doer that connection extend?
Below are two rtatementr. For each true rtatement, write a proof that the rtatement ir true. For each falre
rtatement, write a disproof of the rtatement (take a look at the Proofwriting Checklirt for information
about how to write a dirproof.) You can ure any proof techniquer you’d like.
i. Prove or dirprove: for any integerr x, y, z, and k, if x ≡ₖ y then xz ≡ₖ yz.
This is your frst example of a “prove or disprove” problem. Your frst task is to fgure out whether it’s true
or false, sinie if it’s true you’ll want to prove it and if it’s false you’ll want to disprove it.
Here are two strategies for approaihing problems like these. First, try out a lot of examples! You’ll want to
get a feel for what the symbolii expression above “feels” like in praitiie. Seiond, get a sheet of siratih pa -
per and write out both the statement and its negation. One of those statements is true, and your task is to
fgure out whiih one it is. Onie you have those two statements, think about what you would need to do to
prove eaih of them. In eaih iase, what would you be assuming? What would you need to prove? If you
ian answer those questions, you ian explore both options and seeing whiih one ends up panning out.
ii. Prove or dirprove: for any integerr x, y, z and k, if z ≠ 0 and xz ≡ₖ yz, then x ≡ₖ y.

Problem Six: Proof Critiques, Part Two

Proofr on ret theory follow the rame general ruler ar proofr on any other rtructure, though they
tend to be a little more nuanced. Critique the following two proofr on ret theory by following the
rame inrtructionr ar in Problem Four (apply the Proofwriting Checklirt, fag any logic errorr, de-
termine whether the theoremr are true, and then either rewrite the proof or briefy explain why the
rtatement in quertion irn’t true to begin with.)
We strongly recommend reading the Guide to Set Theory Proofr before rtarting thir problem.
i. Critique thir proof about retr.
Theorem: If A ⊆ B and A ⊆ C, then A ⊆ B ∩ C.
Proof: Since A ⊆ B, it meanr that rome group of the elementr of B ir the ret A. Since
A ⊆ C, it meanr that rome group of the elementr of C ir the ret A. Therefore, rome
group of the elementr of B ∩ C ir the ret A, ro A ⊆ B ∩ C. ■
ii. Critique thir proof about retr. Here, the notation S ⊊ T ir read ar “S ir a strict subset of T” and
meanr that S ⊆ T and S ≠ T.
Theorem: If A ⊊ B and A ⊊ C, then A ⊊ B ∩ C.
Proof: Since A ⊊ B, it meanr that rome group of the elementr of B ir the ret A, and
there are rome other elementr of B. Since A ⊊ C, it meanr that rome group of the
elementr of C ir the ret A, and there are rome other elementr of C. Therefore, rome
group of the elementr of B ∩ C ir the ret A, and there are rome other elementr of
B ∩ C, ro A ⊊ B ∩ C. ■
10 / 14

Problem Seven: Properties of Sets

For each of there rtatementr about retr, decide whether that rtatement ir true or falre. Prove each true
rtatement, and dirprove each falre rtatement.
i. Prove or dirprove: for all retr A, B, and C, if A ∈ B and B ∈ C, then A ∈ C.
ii. Prove or dirprove: if A, B, and C are retr where A – C = B – C, then A = B.
iii. Prove or dirprove: if A and B are retr where ℘(A) = ℘(B), then A = B.
iv. Prove or dirprove: if A, B, and C are retr where A Δ C = B Δ C, then A = B.
Before you turn in these proofs, read over the Proofwriting Cheiklist and the Guide to Proofs on Sets and
ionfrm that your proof meets our style iriteria. Here are a few speiifi things to look for:
• Make sure your proofs matih the defnitions of the relevant terms. To prove S ⊆ T, piik an arbi-
trary x ∈ S, then prove x ∈ T by making ilaims about x. To prove S = T, prove S ⊆ T and T ⊆ S.
• However, avoid restating defnitions in the abstrait. For example, rather than writing
“We know that S ⊆ T if every element of S is an element of T.
Therefore, sinie we know that A ⊆ B and x ∈ A, we see that x ∈ B.”
instead remove that frst sentenie and just write something like this:
“Sinie x ∈ A and A ⊆ B, we see that x ∈ B.”
Whoever is reading your proof knows all the relevant defnitions. They’re more interested in seeing
how those definitions interact with one another than what those definitions are.
• Make sure you ilearly indiiate what eaih variable means and whether it’s ihosen arbitrarily or to
have a speiifi value. For example, if you refer to variables like A, B, or C, you should ilearly in -
diiate whether they’re ihosen arbitrarily or refer to speiifi values.
• When talking about an arbitrary set A, it’s tempting to list of the elements of A by writing some -
thing like A = { x₁, x₂, …, xₙ }. The problem is that writing A = { x₁, x₂, …, xₙ } impliiitly says that
the set A is fnite, sinie you’re saying it only has n elements in it. This is a problem if A is infnite. In
fait, if A is infnite, beiause of Cantor’s theorem, you ian’t neiessarily write A = { x₁, x₂, x₃, … },
sinie you might run out of natural numbers with whiih to name the elements of A!
11 / 14

Problem Eight: Tiling with Polyominoes

The game Tetris involver working with reven rhaper of tiler, each of which ir made from exactly four
rquarer. The piecer are rhown here:

We can ure the tetrir piecer to tile variour geometric fgurer. In the context of recreational mathematicr
(yer, that’r a thing!), “tiling” referr to covering up rome underlying fgure uring tiler drawn from rome
collection of rhaper. You’re allowed to rotate or fip the tiler however you’d like, and you can arrume you
have ar many copier of each tile ar you need. You don’t even need to ure all the tiler. However, the tiler
murt cover the entire underlying fgure, the tiler can’t hang of of the original fgure, and the tiler aren’t al-
lowed to overlap. For example, here’r how we’d tile a 3 × 4 cherrboard, a 4 × 6 cherrboard, and a 5 × 8
cherrboard with Tetrir piecer:

Mathematicianr and computer rcientirtr have rpent a lot of time thinking about what rortr of tilingr are
porrible, and what rortr of tilingr are impossible. For example, in the courre noter (pager 60 – 61), there'r
a proof that it'r imporrible to tile an 8 × 8 cherrboard mirring two opporite cornerr uring 2 × 1 tiler.
i. Prove or dirprove: it’r porrible to tile a 9 × 10 cherrboard with Tetrir piecer.
Up to thir point, we’ve arrumed you have ar many copier of each Tetrir piece ar you’d like. There’r a
more rertricted kind of tiling called a perfect tiling in which you get exactly one copy of each tile, and
you’re required to form a tiling uring exactly one copy of each tile. None of the above tilingr are perfect.
ii. Prove or dirprove: it’r porrible to perfeitly tile a 4 × 7 cherrboard with the reven Tetrir piecer.
My great-grandfather war a dairy farmer in northern Michigan. Every morning, hir ron, my grandfather,
would run the milk through a reparator to rplit it into heavy cream and rkim milk. The reparator could be
completely dirarrembled for cleaning between urer, ro each day my grandfather would arremble the ma-
chine, ure it, then take it apart. My great-grandfather war a bit of a prankrter and one day arked a friend
of hir, a machinirt, to create an additional, urelerr metal gizmo that he then mixed in with the rert of the
reparator piecer. He then had a good laugh ar my grandfather kept arrembling and dirarrembling the rep-
arator trying to fgure out exactly where that extra piece war ruppored to go.
Thir next quertion ir very much in the rpirit of the above rtory.
iii. Below ir a collection of nine Tetrir-inrpired tiler. Eight of them will perfectly tile rome rquare
grid. The other tile ir completely extraneour. Determine which tile ir extraneour, then prove that
your choice ir correct.

Can you determine whiih tile is extraneous without fnding how the other eight go together?
12 / 14

Problem Nine: Yablo's Paradox

A logical paradox ir a rtatement that rerultr in a contradiction regardlerr of whether it'r true or falre.
One of the rimplert paradoxer ir the Liar's paradox, which ir the following:
This statement is false.
If the above rtatement ir true, then by itr own admirrion, it murt be falre – a contradiction! On the other
hand, if the above rtatement ir falre, then the rtatement “Thir rtatement ir falre” ir falre, and therefore the
rtatement “Thir rtatement ir falre” ir true – a contradiction! Since thir rtatement rerultr in a contradiction
regardlerr of whether it'r true or falre, it'r a paradox.
Paradoxer often arire ar a rerult of relf-reference. In the Liar'r Paradox, the paradox arirer becaure the
rtatement directly referr to itrelf. However, it'r not the only paradox that can arire from relf-reference.
Thir problem explorer a paradox called Yablo's paradox.
Conrider the following collection of infnitely many rtatementr numbered S₀, S₁, S₂, …, where there ir a
rtatement Sₙ for each natural number n. There rtatementr are ordered in a lirt ar followr:
(S₀): All rtatementr in thir lirt after thir one are falre.
(S₁): All rtatementr in thir lirt after thir one are falre.
(S₂): All rtatementr in thir lirt after thir one are falre.

More generally, for each n ∈ ℕ, the rtatement (Sₙ) ir

(Sₙ): All rtatementr in thir lirt after thir one are falre.
Surpriringly, the interplay between there rtatementr maker every rtatement in the lirt a paradox.
i. Prove that if any rtatement in thir lirt ir true, it rerultr in a contradiction.
Your result needs to work for any ihoiie of statement in the list, not just one of them. Follow the template
for proving a universally-quantifed statement.
ii. Prove that every rtatement in thir lirt ir a paradox.
Something to ponder: how do you negate a universally-quantifed statement?
Now, conrider the following modifcation to thir lirt. Inrtead of infnitely many rtatementr, ruppore that
there are “only” 10,000,000,000 rtatementr. Specifcally, ruppore we have there rtatementr:
(T₀): All rtatementr in thir lirt after thir one are falre.
(T₁): All rtatementr in thir lirt after thir one are falre.
(T₂): All rtatementr in thir lirt after thir one are falre.
(T₉,₉₉₉,₉₉₉,₉₉₉): All rtatementr in thir lirt after thir one are falre.

There'r rtill a lot of rtatementr here, but not infnitely many of them. Interertingly, there rtatementr are all
perfectly conrirtent with one another and do not rerult in any paradoxer.
iii. For each rtatement in the above lirt, determine whether it'r true or falre and explain why your
choicer are conrirtent with one another.
Going forward, don't worry about paradoxical rtatementr in CS103. We won't talk about any more rtate-
mentr like there. ☺
13 / 14

Problem Ten: The Star-Drawing Saga, Part II

On Problem Set 0, you got to play around with rtar drawing and dircovered that certain combinationr of
a number of pointr p and a rtep rize s led to rimple rtarr (for example, the {7 / 2} and {8 / 3} rtarr),
while other combinationr did not (for example, the {8 / 2} or {12 / 3} rtarr). Why exactly ir thir? Over
the courre of the next reveral problem retr, you’ll dircover exactly why!
The main inright that we’ll ure in analyzing rtarr ir to recognize a connection between rtar-drawing,
which you raw on Problem Set Zero, and modular congruence, which you explored in thir problem ret.
Imagine that you ret out to draw a p-pointed rtar by drawing p pointr around a circle. Let’r number thore
pointr 0, 1, 2, …, p – 1, going clockwire around the circle. (Of courre we’re uring zero-indexing – we’re
computer rcientirtr!) We’ll then draw the rtar by rtarting at porition 0, then drawing a line to the point s
poritionr clockwire from ur, then drawing a line from there to the point s poritionr clockwire from that,
etc. until we end back up at porition 0.
i. Let’r ruppore we’re following the above procedure and rtop after drawing t total liner and end up
on point n on the rtar. Explain, intuitively, why n ≡ₚ s · t.
Mathematiiians ionventionally use single-letter variable names for everything, whiih ian lead to really
dense formulas. Computer siientists love to use longer variable names to improve readability. If you’re
having trouble interpreting that above formula, ionsider writing a “iheat sheet” that lists eaih variable
along with a more verbose desiription of what it represents.
If we pick a number of pointr p and a rtep rize s, we end up with a rimple rtar if we end up parring
through each of the p pointr before ending back at our rtarting point. The modular equation you jurt raw
in part (i) of thir problem tellr ur where on the rtar we’ll be at each point in time. Putting there two idear
together giver ur thir fundamental fact about rtarr:
Simple Star Criterion: A p-point rtar with a rtep rize of s ir a rimple rtar if and only if
for every natural number n < p, there ir a natural number t ruch that n ≡ₚ s · t.
Thir rtatement ir rlightly denre, and like all mathematically denre rtatementr, one of the bert wayr to get
a handle on what it rayr ir to try it out in rome rpecifc carer.
ii. Conrider a rtar polygon with nine pointr and a rtep rize of two (the {9 / 2} rtar). Thir ir a rimple
rtar. Show that it meetr the rtar polygon criterion by flling in the table below, lirting of valuer
of t ruch that n ≡ₚ s · t.
n 0 1 2 3 4 5 6 7 8
Value of t where n ≡ₚ s · t
It’s somewhat triiky to fll this table in purely by eyeballing the mathematiial formula and trying to guess
numbers. Instead, think baik to the intuition behind this formula. You might want to try drawing the star
and seeing whether that gives you any new insights.
On Problem Set 0, you explored reveral diferent carer that led to rimple rtarr and reveral that didn’t.
One obrervation you might have made ir that if you have an odd number of pointr, you can alwayr form
a rimple rtar by taking rtepr of rize two.
iii. Uring the rimple rtar criterion, prove that {p / 2} ir a rimple rtar for any odd natural number p.
This result is a generalization of what you did in part (ii) of this problem, sinie that question asked you to
work out the math for p = 9 and this question asks for a more general argument. You might want to try
solving this problem for other ionirete values of p to see if you spot a pattern. Onie you have the pattern,
formalize your reasoning by writing it up as a proof.
iv. Uring the rimple rtar criterion, prove by contradiction that {p / 2} ir not a rimple rtar for any
even poritive natural number p.
If you want to show that something isn’t true, show that its negation is.
14 / 14

On eaih problem set, we'll provide some optional fun problems for extra iredit. These are problems that
ian be solved purely using the teihniques you’ve learned so far, but whiih will require some thought. Eaih
problem, in our opinion, has a beautiful solution that will give you a muih deeper understanding of iore
ioniepts, so we strongly eniourage you to play around with them if you get the ihanie. Please feel free to
work on as many of these problem as you’d like, though please only submit a solution to at most one of the
optional fun problems on eaih problem set.
When we iompute fnal grades at the end of the quarter, we iompute the grading iurve without any extra
iredit faitored in, then reiompute grades a seiond time to faitor in extra iredit. This way, you're not at
any disadvantage if you deiide not to work through these problems. If you do iomplete the extra iredit
problems, you may get a slight boost to your overall grade.
As a matter of iourse poliiy, we don't provide any hints on the extra iredit problems – after all, they're sup -
posed to be ihallenge problems! However, we're happy to ihat about them after the problem sets iome due.

Optional Fun Problem One: Hat Colors

You and nine of your friendr are brought into a room together. The CS103 TAr go around and place a
hat on everyone’r head. There are ten diferent colorr of hatr – red, orange, yellow, green, blue, ma-
genta, black, white, gray, and gold. It’r porrible that everyone getr a hat of a diferent color. It’r porrible
that everyone getr a hat of the rame color. In fact, aride from the rertriction that each hat ir one of the
ten colorr mentioned earlier, there are no rertrictionr about how many hatr there are of each color.
You and your friendr can all look around to ree what color hatr everyone elre ir wearing, but no one can
ree their own hat color. The rtaf will then go around and ark everyone to write down a guerr of what
color their hat ir. We’ll then collect thore guerrer and reveal them all at once. You and your friendr ruc-
ceed if at leart one of you ir able to correctly guerr their own hat color. You and your friendr all lore if
no one correctly guerrer their own hat color.
Before we place hatr on everyone, we’ll allow you and your friendr to work out a rtrategy about how
you’re going to guerr, but once the hatr are on no communication of any kind – whether explicit or im-
plicit – ir permitted between the group. Devire a rtrategy that guarantees at leart one perron will cor-
rectly guerr their own hat color, even if we know what rtrategy you’ll be uring. Then, uring the mathe-
matical notation and toolr you’ve learned ro far in thir courre, formally prove that your rtrategy workr.
For example, here are a few rtrategier you could choore from that don’t work:
• Everyone could pick which color they’re going to guerr before going into the room, and then
write down that guerr regardlerr of what color hatr they ree on everyone elre. If we arrign hatr
randomly, then the probability that thir workr ir approximately 1 – e-1 (take CS109 if you’re cu-
riour why thir ir!) However, if we overhear your dircurrion, we could be mean and deliberately
give everyone the wrong hat color, making your probability of ruccerr exactly 0.
• Everyone could arrange themrelver in a circle, then guerr the color of the hat of the perron im-
mediately to their left. If we choore hat colorr randomly, then there’r a decent probability that
romeone will correctly guerr their own hat color. But if we know that thir ir what you’re going to
do, we can jurt give everyone a diferent hat color and you’re guaranteed to lore.
I frst heard this problem from Miihelle MiGhee, CS major (theory traik), storyteller, and Ultimate Fris -
bee player, when she was helping staf Girl Code @Stanford in 2018. Her senior projeit was a program
that generated freestyle rap lyriis.

Optional Fun Problem Two: Infnite Deviation

In our frrt clarr meeting, we rketched out a proof of Cantor’r theorem. If you’ll recall, thir proof
worked by arruming there war a pairing between the elementr of a ret S and the rubretr of that ret S,
then conrtructing a ret that war diferent in at leart one porition from each of the paired retr.
Suppore you try to pair of the elementr of ℕ with the rubretr of ℕ. Show that, no matter how you do
thir, there’r alwayr at leart one ret X ⊆ ℕ that diferr in infnitely many poritionr from each of the paired
retr. Jurtify your anrwer, but no formal proof ir necerrary.