Q1: 30+10 points Q2: 40 points Q3: 30 points Total: 100+10 points
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,...}.
The Fibonacci numbers are a sequence of naturals defined by the rules F(0) = 0, F(1) = 1, and, for all n with n ≥ 1, F(n+1) = F(n) + F(n-1).
A binary string is a string over the alphabet {0, 1}.
A winning strategy for one player in a two-person, zero-sum game is a way for that player to choose moves such that they are guaranteed a positive payoff at the end of the game no matter how their opponent moves.
The two-player game of Tic-Tac-Toe is played on a three-by-three grid of squares. Each player in turn places one of their markers in a vacant square, until either (1) one player gets three markers in a row, and thus wins, or (2) there are no vacant squares left, and the game is a draw.
Cardie's game begins with a single stick whose length in centimeters is a positive natural. A move in the game is for Cardie to choose a stick whose length is even and break it into two sticks of equal length. The game ends when there are no sticks remaining with even length.
The directed graph below represents an imagined neighborhood of San Francisco, where our three commuters live at node s and want to travel to their workplace at node g. Two-way edges in this graph represent level roads, and one-way edges represent sloped roads, with the edge pointing downhill. Beatriz can traverse a downhill edge in one minute, a level edge in two minutes, or an uphill edge in five minutes.
Directed graph for an imagined neighborhood of San Francisco:
(a) <---------> (b) <---------> (c)
^ ^ ^
| | |
| | |
| | |
v | v
(d) <---------- (e) ----------> (g)
^ ^ ^
| | |
| | |
| | |
| | |
(s) <---------- (f) ----------> (h)
You are asked below to prove various facts about this game by induction. Non-inductive proofs of the given results will get only partial credit.
natural
pieces (natural n)
that takes a positive natural as input
and returns the number of sticks that are left after Cardie's game
if she starts with one stick of length n. (So, in the example
above, pieces (12)
should return 4, as she finishes
with four sticks each of length 3.) You may use the Java integer
division operators /
and %
. Don't worry
about exception handling, just assume that the input is a positive
natural.
values in Java
satisfies some but not all of the Peano axioms for the natural numbers.
- (b) We can define the usual "<" relation on naturals
recursively by saying "0 < x is true for any x" and "for any y,
Sy < x is true if and only if y < x". (Here "Sy" denotes the
successor of y.)
- (c) Suppose we are using our definitions to prove by
induction that multiplication of naturals is commutative. Then the
base case of our proof should be that for any natural y, y × 0
= 0 × y.
- (d) The exponentiation operation xy on naturals
is neither commutative nor associative.
- (e) Let P(w) be a property of strings over a nonempty
alphabet Σ. If P(a) holds for every one-letter string a, and
P(w) → P(wa) holds for every string w and every letter a, then
P(w) holds for every string w.
- (f) Let k be an arbitrary natural. Then there exists a
string w such that every binary string of length k is a substring of w.
- (g) There are fewer than 1000 Fibonacci numbers with 100 or
fewer digits.
- (h) Let G be an undirected graph with exactly five nodes and
exactly seven edges. Then G must be a connected graph.
- (i) Let G be an undirected graph with exactly thirteen nodes
and exactly thirteen edges. Then it is possible that G is a tree.
- (j) Let k be any natural and let T be a rooted tree where
every non-leaf has exactly three children, and every leaf has depth
exactly k. Then T has exactly 3k leaves and exactly
3k+1 - 1 total nodes.
- (k) Recall that our generic search declares victory when a
goal node first comes off the open list. Suppose we alter it
so that it declares victory when a goal node first goes onto
the open list. Then the revised search will still have the property
that it declares victory only if a path exists from the start node
to a goal node.
- (l) The game tree for Tic-Tac-Toe (described above) has
depth exactly nine.
- (m) There exists a zero-sum deterministic two-player game of
perfect information where both players have winning strategies.
- (n) Suppose it is your move in a two-player game given by a
game tree, where each leaf is labeled by the payoff to you if the
game reaches that leaf. Let m be the largest value of any leaf in
the subtree for the node representing the current position. Then
you shoudl definitely move to a position represented by a child of
the current node whose subtree contains a leaf labeled m.
- (o) Define the function g from the naturals to the naturals
by the rules g(0) = 1, g(1) = 0, and for every n with n > 1, g(n)
= 2g(n-2) + 1. Then for every even natural n, g(n) > g(n+1).
Last modified 17 April 2017