COMPSCI 1020 - Assignment 2: Fall 2024
COMPSCI 1020 - Assignment 2: Fall 2024
Fall 2024
• Write or type your solutions and then prepare one or more files with your answers.
• Submit the answers to gradescope only. DO NOT email your assignments to the instructor
or TAs. They will not be graded if sent by email and you will receive a zero.
• Log in to gradescope using your uwo account.
• Whether you submit the answers individually or as a single file, you must ensure that the
assignment answers are matched properly. (If you are submitting a single PDF file, please
see this article on the gradescope website for instructions). Failure to do so may result in
lost marks.
• If you are handwriting your solutions, please ensure that any scans/photos of the pages are
of sufficient quality so that the answers are legible.
• You can resubmit your assignment any number of times before the deadline.
• Remember from the course outline that late submissions may be submitted up to 3 days
after the deadline without penalty. After 3 days, assignments will not be accepted and will
be marked as 0.
Topics:
• Predicate Logic
• Counting
Predicate Logic
1. [6 marks] Consider each of the following three statements. You can assume for each that 𝐷 is a
set and 𝑃 and 𝑀 are predicates over 𝐷.
Show that each of the statements are not true. You should show this by giving an example of a
situation where they are not equivalent, through providing a specific (small, non-empty) set 𝐷 of
elements and the values (T/F) of the predicates on each element of 𝐷. You do not have to define
how 𝑃 and 𝑀 work, just what the result of the predicates are on each element of 𝐷. Be sure to
explain your choices of set and predicate. Remind the reader that duplicati ng this text for the sol ution to their CS 1020 assig nment is considered a violation of academ ic honesty requirements and would res ult in penalties.
a. (∃𝑥 ∈ 𝐷, 𝑃(𝑥)) ∧ (∃𝑥 ∈ 𝐷, (𝑃(𝑥) ⇒ 𝑀(𝑥))) implies that (∃𝑥 ∈ 𝐷, (𝑃(𝑥) ∧ 𝑀(𝑥)))
b. ∀𝑥 ∈ 𝐷, (𝑀(𝑥) ⇒ 𝑃(𝑥)) implies that (∃𝑥 ∈ 𝐷, ¬𝑀(𝑥)) ∧ (∃𝑥 ∈ 𝐷, (𝑀(𝑥) ∧ 𝑃(𝑥))
c. (∀𝑥 ∈ 𝐷, (𝑀(𝑥))) ⇒ (∀𝑥 ∈ 𝐷, (𝑃(𝑥)))implies that ∀𝑥 ∈ 𝐷, (𝑀(𝑥) ⇒ 𝑃(𝑥))
For your reference, an example of a solution to this type of question is provided on the course
website.
2. [8 marks] In this question, you are asked to model connections between actors using predicate
logic. Let 𝐷 be the domain of every actor, alive or dead, who has ever been in any movie. Let 𝐶 be
the co-star predicate on pairs of actors from 𝐷, defined by 𝐶(𝑥, 𝑦) = 𝑥 and 𝑦 have been in a movie
together.1
The ‘Bacon game’ is a game where players try to connect individuals to the actor Kevin Bacon by
using the co-star predicate 𝐶. The Bacon number of an actor 𝑥 (that is, where 𝑥 is an element of 𝐷)
is the smallest number of links needed, using the co-star predicate 𝐶, to connect 𝑥 to Kevin Bacon.
For example, Daniel Kaluuya was in the movie Sicario with Jeffrey Donovan, who in turn was in
Sleepers with Kevin Bacon. So, Daniel Kaluuya has a Bacon number of 2. (This example was
generated by oracleofbacon.org, where you can determine the Bacon number for many other
actors.)
Let 𝑏0 ∈ 𝐷 be Kevin Bacon, i.e., let 𝑏0 be the special name that we give to Kevin Bacon, given the
unique nature of his role in the game.
a. Write a predicate 𝐵2 (𝑥) in one variable that reflects that the Bacon number of an actor 𝑥 ∈ 𝐷 is at
most two. By the definition of the Bacon number, this means that there is some actor 𝑦 such that 𝑥
and 𝑦 were in a movie together and that 𝑦 and 𝑏0 were in a movie together. The expression for the
predicate must involve a quantifier.
b. Similarly, write a predicate 𝐵3 (𝑥) in one variable that reflects that the Bacon number of an actor
𝑥 is at most three. This will likely involve multiple quantifiers.
c. Notice for 𝐵3 (𝑥), the predicate reflects that the Bacon number of x is at most 3. The predicate
does not enforce that the Bacon number is exactly 3, since there is a possibility that the actor 𝑥 is,
e.g., in a movie with 𝑏0 , or has a Bacon number of 2 through some other links. Write a predicate for
an actor 𝑥 ∈ 𝐷 to have Bacon number exactly three, called 𝐵̂3 (𝑥), by excluding these other
possibilities. This predicate should be defined by using 𝐶, 𝐵3 and 𝐵2 . Be sure to exclude the
possibility that 𝑥 is Kevin Bacon.
d. Write a full expression for 𝐵̂3 (𝑥) that does not use 𝐵3 or 𝐵2 , but still uses 𝐶. Make sure to
parenthesize appropriately. (Hint: use your solution for part c. and negate as necessary.) Write a
short (1-2 sentence) explanation of the entire predicate definition in natural language, verifying that
it makes sense.
1
In this question, we define the predicate 𝐶 to be false when asked if an actor has been in a movie with
themselves, i.e., 𝐶(𝑥, 𝑥) is always false. We also don’t worry about the order of elements in the predicate. It
doesn’t matter which actor is listed first in the expression for 𝐶. That is, 𝐶(𝑥, 𝑦) ⇔ 𝐶(𝑦, 𝑥).
Counting
2. [6 marks] In Ontario, commercial vehicle license plates
currently have the format XX NNNNN, where XX are letters and
NNNNN are numbers. A sample image is shown on the right. We
are interested in how many license plates remain in this series.
We assume that all license plate combinations in this format are
eligible to be issued a license (i.e., no plates are skipped or left
A sample Ontario Commercial License Plate (by
out for any reason). Dvermeirre - CC BY-SA 4.0,
https://commons.wikimedia.org/w/index.php?curi
a. How many total commercial license plate combinations are d=42644451)
available in the format above? That is, how many total license
plates can be formed for the above format, starting at AA 00000 and going to ZZ 99999? Give a short
explanation for how you arrived at this quantity.
b. Assume that all plates are released in order, so that AA 00000 is the first plate to be issued, then
all plates of the form AA NNNNN (in numerical order) then AB 00000, then all plates of the form AB
NNNNN, etc.
For this part of the question, you are asked to use your initials to calculate how many license plates
combinations remain after the plate XY N1337, where XY are your initials and N is the last digit in
the date of your birthday.
- So, if you were born on the 13th of the month, the number N should be 3. If you were born on
the 5th of the month, the number N should be 5.
- For this question, choose a pair of initials that represents your name in some way. (So if you
have three initials, pick two letters; if you have a name that you use that is different from
your birth name, feel free to use that, etc.)
- By “after” in this question, we mean that you should assume that the plate XY 01337 has
been issued already, and the next plate to be issued is XY 01338. This is the first plate after
XY 01337.
For your initials and birth date digit, give the number of license plate combinations that come after
XY N1337. Give the final number, plus an explanation of how it works, including breaking the
quantity down into sections that illustrate how you arrived at your answer. Make sure to clearly
indicate in your response your “personal” plate number that serves at the starting point – failure to
do so will result in lost marks.If it is helpful, here’s a table that shows the number of letters in the
alphabet that are after a given letter.
A B C D E F G H I J
25 24 23 22 21 20 19 18 17 16
K L M N O P Q R S T
15 14 13 12 11 10 9 8 7 6
U V W X Y Z
5 4 3 2 1 0
2. [8 marks] Consider an organization of points as shown on the right.
The points are organized into two lines that share an endpoint. We call
this bottom-most point the “shared” point in this question. This
question asks you to calculate how many triangles we can form from
selecting three of these points.
By triangle, we mean any selection of three end points from the points
that results in a shape with three sides and an area that is bigger than zero. So, in particular, you
can’t pick three end points that are all in a line. Two examples of ways to choose the three points to
create a triangle are illustrated here:
In these images, the end points of the triangle are coloured in red. Notice that it does not matter
that the lines of the triangle run through other points that are not endpoints. All that we care about
is that we pick three points from the set of points and connect them to form a triangle. Any different
choice of three valid (i.e., not in a line) end points will create a unique triangle.
a. How many ways to make a triangle are there for the organization of points shown in the example?
First, calculate these three quantities:
1. The number of triangles that choose two points on the left side and one point on the right
side. (In this case, count the shared point as being one of the possible choices for the left-
hand side, as in the example on the right.)
2. The number of triangles that choose one point on the left side and two points on the right
side. (In this case, count the shared point as being one of the possible choices for the right-
hand side.)
3. The number of triangles that use the shared point.
Use a binomial coefficient to express each of 1 and 2. The binomial coefficient should use actual
integers (3,4,5, etc.), not unknowns like 𝑛 or 𝑘.
Finally, give the final number of triangles as an integer (i.e., no formulas) based on inclusion-
exclusion and the quantities in 1,2 and 3.
b. Now assume that the number of dots on one side of the arrangement is 𝑛 and the number of dots
on the other side of the shape is 𝑚, with one shared point at the bottom of the arrangement
counting towards both 𝑛 and 𝑚. (So, in our example diagram in part a., we have 𝑛 = 5 and 𝑚 = 4.)
What is the total number of triangles that can be formed by choosing three points from the grid of
size 𝑛 and 𝑚? Generalize your solution from part a. and express your solution as a formula using 𝑛
and 𝑚 and inclusion-exclusion. Simplify your expression using the definition of the binomial
coefficient so that it is expressed as a single fraction involving 𝑛 and 𝑚.