Q1: 10 points Q2: 20 points Q3: 20 points Q4: 30+10 points Q5: 40 points Total: 120+10 points
Question text is in black, solutions in blue.
Correction in green made 20 April 2016.
Question 3 deals with a set D of dogs, containing the three distinct dogs Ali (a), Cardie (c), and Duncan (d), and possibly others, and a set of exactly four commands C, consisting of "come here" (ch), "fetch" (f), "roll over" (r), and "sit" (s). The predicate O(x, y) means "dog x obeys command y".
Question 3 also refers to the following five statements, where the variables are of type "dog" or type "command":
N is the set of naturals (non-negative integers), {0, 1, 2, 3,...}, and Z is the set of all integers, {..., -3, -2, -1, 0, 1, 2, 3,...}.
Question 4 uses a recursive function from strings to integers. Let Σ be the alphabet {a, b, c}. Define a function f from Σ* to Z recursively by the rules f(λ) = 0, f(wa) = 3f(w) - 1, f(wb) = 3f(w), and f(wc) = 3f(w) + 1.
Question 5 begins with the following λ-NFA N. The alphabet is {a, b}, the state set is {1, 2, 3}, the start state is 1, the final state set is {1}, and the transition relation Δ is
{(1, a, 2), (2, b, 3), (3, a, 1), (3, λ, 1)}.
Here is a diagram of N, with "L" meaning λ. Note that there are two parallel edges from 3 to 1. There is no state at the southeast corner of the diagram -- the edge from 2 to 3 turns a corner there.
a
>((1)) - - - - - > (2)
^ |
| |
| |
|a, L |
| | b
| |
(3)< - - - - - - <
The input alphabet is the letters that can occur in a string input to the machine. The tape alphabet is the set of all letters that can occur on the machine's tape -- it includes the input alphabet and the blank symbol, plus possibly other letters.
These are two methods of finding the shortest path from a start node s to a goal node g in a weighted graph. Each uses a priority queue of nodes -- in UCS the weight of a node x is the length of the best path found from s to x, while in A* the weight is the sum of this distance and an estimate of the distance from x to g (the heuristic).
The multiplicate inverse of a number x, modulo m, is a number y such that xy is congruent to 1, modulo m. The additive inverse is a number z such that x + z is congruent to 0, modulo m.
A partial order is a binary relation that is reflexive, anti-symmetric, and transitive. A total order is a partial order that has the additional property of being total, meaning that for any elements x and y of the set, either R(x, y) or R(y, x) is true. (Thus in a total order there cannot be incomparable elements.) (Lots of people mixed up "total order" with the "total relation" that is part of the definition of a function.)
A binary operation f is commutative if for any elements x and y, f(x, y) = f(y, x). It is associative if for any elements x, y, and z, f(f(x, y), z) = f(x, f(y, z)).
TRUE. This is easily proved by induction on game trees.
FALSE. The string ba, for example, is in the language of the first expression but not that of the second.
TRUE. Each will return true if and only if there is a path from the start node to the goal node in the graph. Each is guaranteed to be correct on a finite graph, as with a closed list or marking of nodes they cannot get stuck in an infinite loop.
FALSE. On the step following this one, the machine will be in state q looking at another ☐, and we have no idea what δ(q, ☐) is. The machine could perfectly well halt in that case.
TRUE. If M and N are machines with X = L(M) and Y = L(N), we can recognize each of these languages with a machine that runs M and N in parallel. For X ∪ Y we accept if either M or N accepts, and for X ∩ Y we accept if both accept.
TRUE. Since 210 is a multiple of both 15 and 7, changing x by 210 does not change its remainder modulo either of these numbers.
FALSE. What we proved is that p! + 1 must be divisible by a prime greater than p. If p = 5, for example, p! + 1 is 121, which is not prime.
TRUE. In fact the second clause is the negation of the third, so one or the other must always be true.
TRUE. This is exactly the result of the state elimination algorithm in this case.
FALSE. This implication is only valid in the other direction. For example, there might be three dogs A, B, and C, where A likes only B, B likes only C, and C likes only A.
This is directly translated as "¬∃x:∀y:O(x, y)", or equivalently "∀x:∃y:¬O(x, y)", meaning "every dog has a command that it doesn't obey". Since the set of commands is known and finite, the quantifier over commands may be replaced by an AND in the first version or an OR in the second.
"For any command, Cardie obeys it if and only if either Ali or Duncan obeys it". Many people said "Cardie obeys all commands if and only if Ali or Duncan obeys all commands", which is wrong because there is a single universal quantifier whose scope is the entire statement.
∀y:∃x:O(x, y)
There is a command that Duncan obeys and Ali does not obey.
O(a, s) ∧ O(a, f) ∧ ¬O(a, r)
We know that O(a, s) is true by separation on V. Specifying II to s, we get "O(c, s) ↔ (O(a, s) ∨ O(d, s)". Since the right-hand side of this is true because O(a, s) is true, O(c, s) must be true. None of the statements tell us whether O(d, s) is true, so the two possible settings of the three variables are (1, 1, 0) and (1, 1, 1).
There are several approaches to this. I think the simplest is to let
x be the command that Cardie does not obey (using specification on
the second version of I) and then let y be the dog that obeys x
(using
specification on III). If this dog y were equal to a, c or d, then by
II
we would have that O(c, x) is true, but it is not. So y is the
desired
fourth dog.
Another approach is to assume that there are only three dogs and
derive a contradiction. Many people used IV, though the desired
result follows from I, II, and III alone. The command y referred to
in
IV might be either r or ch -- I took off three points for
incorrectly claiming that it had to be r. Whichever it is, Cardie
must obey it, and cannot obey the other because she already obeys s
and f and can't obey all four. But then the other two dogs cannot
obey the command that Cardie doesn't obey, and we have a contradiction.
For the base case, where a0 and c0 are each
λ,
we must verify that f(λ) = 0 satisfies both the formulas.
Substituting 0 for n, we find that -(30 - 1)/2 and
(30 - 1)/2 are both 0 as they should be.
For the inductive case, we first assume that f(an) =
-(3n - 1)/2 and prove that f(an+1) =
-(3n+1 - 1)/2. Since an+1 = ana,
we have that f(an+1) = 3f(an) - 1 = (by the
IH) 3(-(3n - 1)/2) - 1 = -3n+1/2 + 3/2 - 1 =
-(3n+1 - 1)/2.
Similarly, we assume that f(cn) = (3n -
1)/2 and calculate that f(cn+1) = f(cnc) =
3f(cn) + 1 = (by the IH) 3(3n - 1)/2) + 1 =
3n+1/2 - 3/2 + 1 = (3n+1 - 1)/2.
For the base case, both a0 and c0 are equal to λ, which is the only string of length 0, so our claims both simplify to f(λ) ≤ f(λ), which is true. For the inductive case of the first claim, we assume that for any w of length n, f(an) ≤ f(w). Then let x be an arbitrary string of length n+1 and write x as wd for some letter d, so that w has length n. By the rule, f(x) is either f(wa), f(wb), or f(wc), all of which are at least 3f(w) - 1. Since f(an+1) = 3f(an) - 1 and f(an) ≤ f(w), we know that f(an+1) ≤ f(x). The other inductive case is similar, with f(x) = f(wd) ≤ f(wc) = 3f(w) + 1 ≤ (by the IH) 3(cn) + 1 = f(cn+1).
We first prove P(λ), which says that f(a) = -30 + f(λ),
f(b) = f(λ), and f(c) = 30 + f(λ). These claims
follow from using the definition of f to calculate that f(a) = -1, f(b)
= 0, and f(c) = 1.
The inductive step breaks down into nine cases. For each letter d and letter e taken from {a, b, c}, we need to show that f(dwe) has the proper value in
relation to f(we), using the assumption that f(dw) is properly related to f(w).
The nine arguments are very similar, and if you did one or more
convincingly I was usually sympathetic if you left off the proofs of the
others.
We must show that f(awa) = -3n+1 + f(wa), where the "n+1" is
because the length of wa is n + 1. Here f(awa) is defined to be 3f(aw) - 1,
which by the IH is 3(-3n + f(w)) - 1. This is -3n+1 +
3f(w) - 1, which is -3n+1 + f(wa).
Similarly f(awb) = 3f(aw) = (by IH) 3(-3n + f(w)) =
-3n+1 + 3f(w) = -3n+1 + f(wb).
f(awc) = 3f(aw) + 1 = (by IH) 3(-3n + f(w)) + 1 =
-3n+1 + 3f(w) + 1 = -3n+1 + f(wc).
f(bwa) = 3f(bw) - 1 = (by IH) 3f(w) - 1 = f(wa).
f(bwb) = 3f(bw) = (by IH) 3f(w) = f(wb).
f(bwc) = 3f(bw) + 1 = (by IH) 3f(w) + 1 = f(wc).
f(cwa) = 3f(cw) - 1 = (by IH) 3(3n + f(w)) - 1 =
3n+1 + 3f(w) - 1 = 3n+1 + f(wa).
f(cwb) = 3f(cw) = (by IH) 3(3n + f(w)) =
3n+1 + 3f(w) = 3n+1 + f(wb).
f(cwc) = 3f(cw) + 1 = (by IH) 3(3n + f(w)) + 1 =
3n+1 + 3f(w) + 1 = 3n+1 + f(wc).
For the base case of n = 0, we need merely note that since λ is the
only string of length 0, there cannot be two different strings of length 0
and our claim is true vacuously. We don't need to do the case of n = 1, but
the claim is true there as well because f(a), f(b), and f(c) are -1, 0, and 1
respectively.
Now we assume that f is one-to-one on strings of length n, and consider
two different strings of length n+1. If these two strings share the same first
letter, for example ax and ay, we know by part (c) that f(ax) = f(ay) if and
only if f(x) = f(y), and similarly for bx and by or cx and cy. The IH tells
us that if x ≠ y, then f(x) ≠ f(y), which is what we need.
The other case is where the two strings have different first letters. Let's
take ax and by as an example. Then by part (c), f(ax) = -3n + f(x),
and f(by) = f(y). We need to show that these two numbers cannot be equal.
By parts (a) and (b), we know that the absolute values of f(x) and f(y) cannot
exceed (3n - 1)/2, so the sum of their absolute values cannot
exceed 3n - 1. This means that the difference 3n +
f(x) - f(y) cannot equal 0, and so f(ax) and f(by) cannot be equal. A similar
argument works for f(ax) and f(cy), or f(bx) and f(cy).
A few people were close to this argument for the case of different first
letters, but no one got it quite right.
There are seven states which I will call {1, 2, 3, 4, 5, 6, 7}, with 1 the start state and 7 the only final state. The transitions are (1, λ, 2), (2, a, 3), (2, a, 4), (2, λ, 6), (3, b, 6), (4, b, 5), (5, a, 6), (6, λ 2), and (6, λ, 7). There are simpler λ-NFA's that have the correct language, including N itself, but for full credit you needed exactly this one.
The state set, start state, and final state set of N' are the same as for
N. (Since the start state of N is already final, the construction gives no
change to the final state set. Changing 3 to a final state did not change
the language of the machine, but you were told to follow the construction so
there was a small penalty for this.)
The set of λ-moves is already transitively closed as it contains only
one move. Transition (1, a, 2) gives rise to itself and (3, a, 2). Transition
(2, b, 3) gives rise to itself and (2,
b, 1). Transition (3, a, 1) gives
rise only to itself. So N' has five transitions in all.
The start state is {1}, which is final. We have δ({1}, a) = {2} (non-final) and δ({1}, b) = ∅ (non-final), and of course δ(∅, a) = δ(∅, b) = ∅. Then δ({2}, a) = ∅ and δ({2}, b) = {1, 3} (final). Then δ({1, 3}, a) = {1, 2} (final) and δ({1, 3}, b) = ∅. Finally δ({1, 2}, a) = {2} and δ({1, 2}, b) = {1, 3}. We have finished the process with only five of the possible eight states reachable.
The minimization algorithm shows in only one round that D is already minimal.
We set N = {∅, {2}} and F = {{1}, {1, 2}, {1, 3}}. The behaviors of
each state are NN for ∅, NF for {2}, NN for {1}, NF for {1, 2}, and
FN for {1, 3}. (Here "NF", for example, means that the a-arrow is to a
state in N and the b-arrow is to a state in F.) Since the two non-final states
each have a different behavior, and the three final states each have a different
behavior, the next partition of the algorithm will have each state in a
separate class, indicating that the original DFA is minimal.
To prove directly that D is minimal, we must show strings separating each
pair of non-final states and each pair of final states. There is only one pair
of non-final states, ∅ and {2}, and these are separated by b. There are
three pairs of final states: {1} and {1, 2} are separated by b, {1} and {1, 3}
are separated by a, and {1, 2} and {1, 3} are separated by either a or b.
Last modified 20 April 2016