Q1: 20 points Q2: 15 points Q3: 40 points Q4: 25+10 points Total: 100+10 points
Question text is in black, solutions in blue.
Here are definitions of some terms, sets, predicates, and statements used on this exam.
Remember that the scope of any quantifier is always to the end of the statement it is in.
Remember that a natural is a non-negative integer, so that the set N or all naturals is {0, 1, 2, 3,...}.
A binary string is a string over the alphabet {0, 1}, and the reversal wR of a binary string w is defined by the rules λR = λ and (wa)R = awR.
An undirected graph is said to be bipartite if it is possible to partition its nodes into two sets R and B, such that every edge of the graph has one endpoint in R and one in B. Equivalently, the nodes may be colored red and blue such that no edge connects red to red or blue to blue.
On a two-dimensional grid, the Manhattan distance between two points (a, b) and (c, d) is the minimum length of any path from one point to the other that follows the edges of the grid, that is, |a - c| + |b - d|.
The following scenario is used in Question 4. On a shelf in our house there are two containers of dog treats, one with large treats for Cardie and one with small treats for Duncan. Every day Cardie gets five large treats and Duncan gets seven small treats. If there are fewer than 20 large treats in Cardie's container at the beginning of the day, we add 48 more. If there are fewer than 20 small treats in Duncan's container at the beginning of the day, we add 90 more. (For example, suppose there are 23 treats in Cardie's container at the start of Day 0. Then there are 23 - 5 = 18 there at the start of Day 1, and 18 + 48 - 5 = 61 at the start of Day 2.
The function c(n) denotes the number of treats in Cardie's container at the start of Day n, and the function d(n) denotes the number of treats in Duncan's container at the start of Day n.
The n by n knight graph has an n by n square array of nodes, labeled as in chess positions with rows 1, 2,..., n and columns a, b,..., so the for example node d3 is in the third row and the fourth column. There is an undirected edge between two nodes whenever a chess knight can move from one to the other. (Chess knights move either two squares horizontally and one vertically, or one horizontally and two vertically.
This page shows pictures of the 3 by 3, 4 by 4, 5 by 5, and 6 by 6 knight graphs. (Note that neither the 1 by 1 nor the 2 by 2 knight graphs have any edges at all.) The 3 by 3 knight graph has 8 edges, and the 4 by 4 knight graph has 24.
Thus if f(n) is the number of edges in the n by n knight graph, we have all the values for n ≤ 4. By an analysis we won't explain here, for all n with n ≥ 4, f(n+1) is equal to f(n) + 20 + 4(2n - 7). You will need this formula for Question 2.
This page has a 4 by 4 knight graph with labels, which are not exactly the labels we are using. We are calling the nodes a1, a2,..., d4, and we will normally put the a nodes in a column rather than a row, but the 4 by 4 kn1ght graph you will search in Question 3 otherwise looks the same as this one.
FALSE. The depth of a rooted binary tree is the length of the longest path from the root to a leaf. If there is only one node, the root is a leaf and the only such path has length 0, so the depth is 0.
FALSE. If i = j, we know that X(i, j) is false, and if i < j, we know that it is true. But the definition does not tell us whether X(1, 0), for example, is true. If it is true, then the claimed characterization of X(i, j) is false.
FALSE. A connected graph needs as many edges as vertices in order to have a cycle. But a graph consisting of a triangle and a separate isolated node has four nodes and three edges, and yet has a cycle.
FALSE. The left-hand side is equal to vu, and in general vu is not equal to uv.
TRUE. The generic search ends when a goal node comes off the open list.
FALSE. The value of a finite game of this kind is the value of the leaf reached when both players play optimally. (If there are multiple leaves of this value, it might be possible for optimal moves to reach more than one of them, but the Determinacy Theorem means that there is at least one such leaf.) Thus the value of such a game is the value of some leaf.
TRUE. White can guarantee a payoff of at least x by moving to the left subtree, since then the result of the game must be one of the leaves in that subtree. She will thus make this move unless she is assured of an equal or greater payoff by moving right -- in either case her payoff will be at least x.
FALSE. In such a tree every leaf has a sibling leaf, so the number of
leaves must be even. The number of internal nodes of an n-node binary
tree
is always n-1, so in such a tree the number of internal nodes is odd
and
thus the total number of nodes is odd.
This is also easy to prove by induction. The base case is a
one-node
tree, which of course has an odd number of nodes. The inductive step
is to have a tree with a root and two subtrees, and the IH tells us
that each of these subtrees has an odd number of nodes. The sum of 1
(for
the root) and two odd numbers is necessarily odd.
FALSE. The Law of Induction for binary strings says that if this base case and this inductive step are both true, then P(v) must be true for all binary strings v.
FALSE. For n ≥ 2 this is true, since any such natural can be factored into primes. But there is no such arithmetic expression E1, because by induction it is easy to see that every arithmetic expression of this kind has a value greater than 1. (For the base case, all primes are greater than 1, and for the inductive case the sum and product of two numbers greater than 1 is itself greater than 1.)
We are told that f(1) = 0, f(2) = 0, f(3) = 8, and f(4) = 24. Each of
these four cases matches the formula f(n) = 4(n - 1)(n - 2) because
0 = 4(0)(-1), 0 = 4(1)(0), 8 = 4(2)(1), and 24 = 4(3)(2). We must
do all four of these base cases because the formula we are given for
f(n+1) is only valid for n ≥ 4. Thus our inductive step will
prove P(4) → P(5) but not P(3) → P(4), and we need P(4) as
a base case.
For the inductive step, we assume that f(n) = 4(n-1)(n-2) and use
the formula that tells us f(n+1) = f(n) + 20 + 4(2n - 7). Using the
IH to substitute for f(n), we get f(n) = 4(n-1)(n-2) + 20 + 4(2n-7) =
4[(n-1)(n-2) + 5 + 2n - 7] = 4(n-1)[(n-2) + 2] = 4(n+1-1)(n+1-2).
This matches the formula for f(n+1) and we have completed the
inductive
step and the proof.
There are various ways this could go, depending on the choice of which
node to take off the open list when there are ties -- I allowed
any choice that respected the definition of the stack. I also
allowed either recognizing nodes on the list (as I said) or the
usual method of putting nodes on a closed list when they come off
the open list. Here is one solution:
Here I choose to enqueue neighbors in alphabetical order -- other
choices were allowed.
Continuing from part (b):
The sixteen nodes and 24 edges (15 tree, 9 non-tree)
appear in the BFS tree as follows:
This graph is bipartite. All edges, tree or non-tree, in the BFS tree go from some level k to level k+1. Thus we can make all nodes in even-numbered levels red, for example, and all nodes in odd-numbered levels blue, and every edge will have an endpoint of each color.
Here entries in the priority queue will be node number and distance
found from a1:
The heuristic will be admissible and consistent because the Manhattan
length of a knight's move is always 3 and these edges
are given length either 3 or 5. For any path of
knight's moves from a node to the goal, there must be a
corresponding path of grid edges of equal or shorter
cost, and so the Manhattan distance will always be
between 0 and the distance in the weighted graph. To
check consistency, consider any knight move from node x
to node y. Because there is a path of grid edges from y
to x of cost less than that of the knight move, we must
have h(x) ≤ h(y) + c(x, y). (Proving this formally would
involve the triangle inequality that says that
for any three nodes x, y, and z, MD(x, z) ≤ MD(x, y)
+ MD (y, z), where MD is Manhattan distance.)
Many people argued that this heuristic would not be
useful, without considering whether it met the
conditions to be used in an A* search. It
doesn't appear to be very helpful on this small graph,
but on a larger version of the graph it would do some
good by delaying consideration of paths that go a long
way in the wrong direction.
if
statements.)
If c(n) < 20, c(n+1) = c(n) + 48 - 5, else c(n+1) = c(n) - 5.
If d(n) < 20, d(n+1) = d(n) + 90 - 7, else d(n+1) = d(n) - 7.
Some people did not give the dogs their deserved treats on days
their container was restocked, and others checked for 20 treats
after giving the dogs their treats, rather than before as indicated
by the definition and the example.
The successive values of c(n) are 34, 29, 24, 19, 62, 57, 52, 47, so that c(7) = 47. Checking for 20 treats at the end of the day gave the same answer and I did not penalize this. The values of d(n) are 46, 39, 32, 25, 18, 101, 94, 87, so that d(7) = 87.
P(n) says that c(n) + d(n) is not divisible by 6.
For the base case, we compute c(0) + d(0) = 34 + 46 = 80 and note
that 80 is not divisible by 6.
We then assume that c(n) + d(n) is not divisible by 6, and
compute
c(n+1) + d(n+1) from c(n) + d(n). There are four cases depending on
which containers, if any, are restocked:
In each of the four cases, the sum changes by a multiple of 6
(-12, 36, 78, and 90 are each divisible by 6). Thus if the former
sum is not divisible by 6 as we assume, the new sum has the same
remainder modulo 6 and is thus also not divisible by 6. This is the
inductive step of an ordinary induction proving P(n) is true for all
naturals n.
∃x: ∀y: ∃n: (n > y) ∧ (c(n) + d(n) = x)
(Hint: One way to do this is by contradiction. Your proof may be informal if it is convincing.)
The most common argument I got for this was essentially "let y be
arbitrary, let n = y + 1, and then c(n) + d(n) is some integer x
because we never run out of treats". This ignores the order of
quantifiers, proving the true but irrelevant statement "∀y:
∃n: ∃x: (n > y) ∧ (c(n) + d(n) = x)". I gave
this answer two of ten points -- be warned that order of multiple
quantifiers is now sure to come up on the final exam.
The first step in the actual proof is to decide what value x
should have so that we can prove the remainder of the statement for
that value and then use the Rule of Existence. What does the
statement actually mean? It says "there is a value of x such that
for any natural y, c(n) + d(n) takes on the value x after step y", or
more simply "there is a value of x such that infinitely often, c(n) +
d(n) = x".
Could this fail to be the case? Let's look at the negation of
the given statement: "∀x: ∃y: ∀n: (n > y)
→ c(n) + d(n) ≠ x". (This translation uses the Definition of
Implication.) This says that for every value of x, there is a y that
gives the last time c(n) + d(n) takes on the value y. But there are
only finitely many possible values of x, since c(n) is always between
15 and 62, and d(n) is always between 13 and 102. If we take the
finitely many values of y given by the negation of the statement, and
take the largest of these values, then for n larger than that, c(n) +
d(n) cannot take on any of the possible x values, and this is a
contradiction.
We can also prove this without contradiction. Because there
are only finitely many choices of c(n) and d(n), we must
eventually have two different values m and n such that c(m) = c(n)
and d(m) = d(n). But since the process of changing c's and d's is
deterministic, if the pair of value occurs twice it will keep
occurring periodically forever. For that particular value of c(n)
+ d(n), then, we will have that value occur infinitely many often.
Reasoning similar to the Chinese Remainder Theorem can give us an
explicit answer to the question. In the first 48 days, Cardie
will eat 5*48 = 240 treats, and her container will be restocked with some
multiple of 48 treats. This multiple must be 5 because c(48)
could not possibly be 48 greater than or 48 less than c(0) = 34.
Thus c(48) = 34, and similarly d(90) = 46. Therefore every 48*90
days, we have the value of c(n) + d(n) = 90 recurring, and we can
take x to be 80 in the given statement. (Since the least common
multiple of 48 and 90 is actually 720, we will also have a value of 80
every 720 days.)
Last modified 10 April 2016