Q1: 10 points Q2: 20 points Q3: 20+10 points Q4: 30 points Q5: 40 points Total: 120+10 points
Question text is in black, solutions in blue.
Question 3 deals with a set D of dogs, consisting of exactly the five dogs Arly (a), Cardie (c), Duncan (d), Knight (k), and Nico (n), and a set of four activities A, consisting of "barking" (bar), "chasing" (cha), "swimming" (swi), and "wrestling" (wre). The predicate L(x, y, z) means "dog x likes activity y with dog z". If y is any activity, the binary relation Ly on D is defined by Ly(x, z) ↔ L(x, y, z).
Question 3 also refers to the following six statements, where the variables are of type "dog" or type "activity":
N is the set of naturals (non-negative integers), {0, 1, 2, 3,...}.
Question 4 uses a recursive function from N to N defined by the rules f(0) = 0 and f(n+1) = 2f(n) + n.
Questions 4 and 5 use the following DFA D, which has state set {p, q, r}, start state p, final state set {p, q}, and transition function δ given by δ(p, a) = p, δ(p, b) = q, δ(q, a) = r, δ(q, b) = q, and δ(r, a) = δ(r, b) = r.
We also use D to define three functions p(n), q(n), and r(n) from N to N as follows. For any natural n, p(n) is the number of strings w of length n such that D (started in state p) finishes reading w in state p. (That is, such that δ*(p, w) = p.) Similarly, q(n) is the number of strings w of length n such that D (again started in state p) finishes reading w in state q, and r(n) is the number finishing in state r.
Question 5 also uses the following λ-NFA N, which has state set {1, 2, 3, 4}, start state 1, final state set {4}, and transition relation Δ = {(1, λ, 2), (2, a, 2), (2, λ, 3), (3, b, 3), (3, λ, 4)}.
The DFA D:
___ ___ ___
| | a | | b | | a, b
| V | V | V
>((p)) -----> ((q)) -----> (r)
b a
The lambda-NFA N ("L" = lambda):
___ ___
| | a | | b
| V | V
>(1) -----> (2) -----> (3) -----> ((4))
L L L
Both are non-tree edges, meaning that if the edge is (u, v) then node v was discovered and explored before node u. A back edge occurs when v is an ancestor of u, and a forward edge when v is a descendant of u. There is also the possibility of a cross edge, if v is neither an ancestor or descendant.
Both are string representaions of the operators and operands of the expression. In the prefix string, the operator comes before the representations of the operands, and in the postfix string it comes after. For example the expression with infix string "a*(b+c)" has prefix string "*a+bc" and postfix string "abc+*".
The complement of a language is the set of all strings over the language's alphabet that are not in the language. The one's complement of a binary string w is another binary string, of the same length as w, that has a 1 wherever w has a 0 and vice versa.
The empty string λ is the string with no letters. The empty language ∅ is a set with no strings.
A language X is Turing decidable if there exists a Turing machine that accepts all strings in X and rejects all strings not in X, so that it halts on all strings. A language X is Turing recognizable if there exists a Turing machine that accepts a string if and only if it is in X. The decidable languages are a proper subset of the recognizable languages.
TRUE. Statement V says that there is a single activity y that Cardie likes with all dogs. So for each dog, there is at least one activity that Cardie likes with then, namely y. As we will see in Question 3, Statement VI can be true without Statement V being true.
TRUE. We need a boolean for each triple (x, y, z) where x and z are dogs and y is an activity. By the Product Rule of combinatorics, there are exacctly 5 × 4 × 5 = 100 such triples.
TRUE. One such natural is 9, since 9 * 14 = 126 is congurent to 1, mod 25. But since 14 and 25 are relatively prime, the Inverse Theorem tells us that 14 must have some inverse modulo 25, and this inverse x satisfies 14x ≡ 1, and thus 14xy ≡ y, modulo 25.
TRUE. For any three strings u, v, and w, the equation (uv)w = u(vw) is true, but uv need not equal vu. The identity element is λ because for any string w, λw = wλ - w.
FALSE. Since G is not assumed to be finite and because we are not told that previously seen nodes are recognized, there is no guarantee that the path will be found at all. Even if we were granted those two assumptions, DFS does not always find the path with the minimum number of edges -- it is breadth-first search that has this property.
TRUE. This h(x) certainly satisfies 0 ≤ h(x) ≤ d(x), where d(x) is the true distance, which makes it admissible. (If there is no path from x to the goal node, d(x) is considered to be infinity, which is greater than 0.) Consistency requires that for any two nodes x and y, h(x) ≤ h(y) + d(x, y), where d is the single-edge distance, and this must also be true.
FALSE. The existence of such a strategy does not preclude Black also having a better strategy, with a guaranteed maximum payoff of less than 3. If this strategy were Black's optimal one, then the statement would be true.
FALSE. The language LBS from the text is certainly not regular, but was shown there and in lecture to not be the langauge of any TM.
TRUE. Unlike the similar machine in last Fall's COMPSCI 250 final exam, this machine will move right and stay in state p, whereupon it will see another blank, move right and stay in p again, and so on through the infintely many blanks on the tape. (The notation for configurations assumes that there are infinitely many blanks to the right of the cells described.) state again
FALSE. Neither LBS nor its complement are Turing decidable, but the union of these two languages is Σ*, which is certainly decidable because it is the language of a TM that always accepts.
"∀y: ∀x: Ly(x, x) ∧ (∀z: Ly(x, z) → Ly(z, x))" (Many of you left off some or all of the quantifiers.)
The simplest answer uses no quantifiers at all and just lists the
facts given about what Cardie likes: "L(c, wre, d) ∧ ¬L(c,
bar, d) ∧ ¬L(c, cha, d) ∧ ¬L(c, swi, d) ∧
¬L(c, wre, a) ∧ ¬L(c, wre, k) ∧ ¬L(c, wre,
n)".
It's not clear whether this statement by itself implies L(c, wre,
c), though Statement I does imply this. I gave credit either way.
With quantifiers, you can say "∀y:∀z: (L(c, y, d)
↔ (y = wre)) ∧ (L(c, wre, z) ↔ (z = d))". Note
that the English Statement II does not tell us
anything about which non-wrestling activities Cardie likes with
dogs other than Duncan, so the symbolic statement must not say
anything about this either. (In this sense Statement II is quite
different from Statement IV, which says everything about Arly's preferences.)
This can also be done with or without quantifiers: "L(c, swi, n) ∧ L(c, cha, n) ∧ L(c, swi, k) ∧ L(c, cha, k)" or "∀y:∀z: (((y = swi) ∨ (y = cha)) ∧ (z = n) ∨ (z = k))) → L(c, y, z)". Replacing the "→" with "↔" is a mistake -- the English Statement III is purely a positive statement and says nothing about activities Cardie does not like.
"Arly likes an activity with a dog if and only if the activity is barking or the dog is Arly himself."
"There is at least one activity that Cardie likes with all the dogs."
"For each dog, there is at least one activity that Cardie likes with that dog." Of course, as in the situation with Statements I-IV true, there may be different activities for different dogs.
Assuming that Statements I-IV are all true, it turns out that one of Statements V or VI must be true and the other must be false. You must determine which is which.
Statement VI is true, so we will prove it, by Generalization. Let z be an arbitrary dog. We divide into cases. If z = a, we may take y to be barking as Arly likes barking with every dog by IV and thus by I every dog likes barking with him. If z = c, I tells us that any y will do, as Cardie likes every activity with herself. If z = d, II tells us that Cardie likes wrestling with Duncan and so we may take y to be wrestling. If z = k or z = n, III tells us that we take y to be either chasing or swimming. In each case a suitable y exists, and since z was arbitrary we have proved the original universal statement.
Statement V is false, so we will prove its negation "∀y:∃z: ¬L(c, y, z)" or "For every activity there is at least one dog that Cardie does not like it with." We prove this by Generalization as well. Let y be an arbitrary activity. We use Proof by Cases with two cases. If y is not wrestling, we may choose z to be Duncan, since II tells us that L(c, y, d) must be false. If y is wrestling, we may choose z to be any dog other than Cardie or Duncan, as II again tells us that L(c, wre, z) is false for those dogs. Since y was arbitrary, we have proved the universal statement. Note that Statement II was sufficient to prove V to be false, though we could have used IV instead to deal with all the non-barking activities at once -- we would still need II to find a dog with whom Cardie does not like barking.
P(n) is the statement "f(n) = 2n - n - 1". The base case
must
be n = 0, since we are asked to prove P(n) for all naturals
n.
To prove P(0), we must show that the statement "f(0) = 20
- 0 - 1" is true. (It is not sufficient to observe that f(0) = 0 --
we must compute the value for f(0) given by the formula and show
that it is the same.)
The inductive hypothesis is P(n), and the inductive goal is
P(n+1).
The latter says that f(n+1) = 2n+1 - (n+1) - 1 =
2n+1 - n - 2. To prove this we take f(n+1), expand it by
the given rule to 2f(n) + n, apply the inductive hypothesis to get
2(2n - n - 1) + n, and use algebra to get 2n+1
- 2n - 2 + n = 2n+1 - n - 2, equaling what the formula
gives us for f(n+1). We have completed the inductive step and thus
completed the proof.
Since λ is the only string of length 0 and it goes to p, we
have p(0) = 1, q(0) = 0, and r(0) = 0.
Of the two strings of length 1, a goes to p and b goes to q, so
we have p(1) = 1, q(1) = 1, and r(1) = 0.
Of the four strings of length 2, aa goes to p, ab and bb go to q,
and ba goes to r, given us p(2) = 1, q(2) = 2, and r(2) = 1.
Of the eight strings of length 3, aaa goes to p, aab, abb, and
bbb go to q, and the other four go to r, giving us p(3) = 1, q(3) = 3,
and r(3) = 4.
Of the sixteen strings of length 4, aaaa goes to p, aaab, aabb,
abbb, and bbbb go to q, and the other eleven go to r, giving us p(4)
= 1, q(4) = 4, and r(4) = 11.
Let w be an arbitrary string of length n+1. By inspection of D, we can see that there are exactly three possibilities for the edge followed by the last letter of w: w could be va for some string v that goes to q, or w could be either va or vb for some string v that goes to r. There are exactly q(n) v's that go to q, causing exactly q(n) w's of the form va for such v's, and exactly r(n) v's that go to r, causing exactly 2r(n) w's of the form va or vb for such v's. In all we have q(n) + 2r(n) strings of length n+1 that go to r, so r(n+1) = 2r(n) + q(n).
The base case Z(0) says that p(0) = 1, q(0) = 0, and r(0) =
20 - 0 - 1 = 0, and we verified these three claims in part
(b) above.
The IH Z(n) tells us that p(n) = 1, that q(n) = n, and that r(n) =
2n - n - 1. Our inductive goal Z(n+1) is that p(n+1) = 1,
q(n+1) = n+1, and r(n+1) = 2n+1 - (n+1) - 1. We can prove
these three statements separately. The only way a string w of length
n+1 can go to p is to be of the form va where v is a string of length
n that goes to p. There is exactly one such v by the IH, so there is
exactly one such w as our goal says. For a string w of length n+1 to
go to q, it must be va where v goes to p or vb where v goes to q.
This gives us p(n) + q(n) w's of length n+1 going to q, and by the IH
this is 1 + n, equaling the n+1 of our goal. The analysis in part (c)
tells us that r(n+1) = 2r(n) + q(n), which by the IH is 2r(n) + n.
But the proof in (a) tells us that this rule, with the base case r(0)
= 0, gives us the desired expression for r(n+1).
We first add both a new start state i and a new final state f to D, giving it five states and the new transitions (i, λ, p), (p, λ, f), and (q, λ, f). (Many of you replaced the latter two with the incorrect (r, λ, f).) Now we can eliminate state r, adding no new transitions because we have no transitions out of r. Next we can eliminate either p or q. If we eliminate p first, we create transitions (i, a*b, q) and (i, a*, f), making the final regular expression from eliminating q a* + a*bb*. If instead we eliminate q first, the only new transition created is (p, bb*, f), which merges with the existing (p, λ, f) to make (p, λ + bb*, f), and the final regular expression is a*(λ + bb*). Of course these two regular expressions are equivalent by the distributive law, but I wanted to see which one you produced based on the order of your state elimination.
Taking the simpler expression a*(λ+bb*), we get a λ-NFA with eight states {1, 2, 3, 4, 5, 6, 7, 8}, start state 1, final state 8, and transitions (1, λ, 2), (2, a, 3), (2, λ, 3), (3, λ, 2), (3, λ, 4), (4, λ, 8), (4, b, 5), (5, λ, 6), (6, b, 7), (6, λ, 7), (7, λ, 6), and (7, λ, 8). There are smaller λ-NFA's with loops, but our construction does not produce them and they did not get full credit.
The transitive closure of the λ-moves includes moves (i, λ, j) for all i and j with i ≤ j. Each of the two letter-moves in N gives rise to six letter-moves in N': (2, a, 2) gives rise to (1, a, 2), (1, a, 3), (1, a, 4), (2, a, 2), (2, a, 3), and (2, a, 4), while (3, b, 3) gives rise to (1, b, 3), (1, b, 4), (2, b, 3), (2, b, 4), (3, b, 3), and (3, b, 4). State 1 becomes final in N', along with state 4, because λ ∈ L(N), but states 2 and 3 do not become final even though doing so would not change the language.
Start state {1} is final, and has an a-arrow to {2, 3, 4} and a b-arrow to {3, 4}. Final state {2, 3, 4} has an a-arrow to itself and a b-arrow to {3, 4}. Final state {3, 4} has an a-arrow to ∅ and a b-arrow to itself. Non-final state ∅ has a-arrow and b-arrow to itself. We complete the construction with four states -- note that leaving out the death state makes an invalid DFA.
States {1} and {2, 3, 4} are both final, both have a-arrows to {2, 3,
4}, and both have b-arrows to {3, 4}. Thus every possible string w
takes these two states either both to final states, or both to
non-final states. Merging {1} and {2, 3, 4} thus has no effect
on the language of the DFA D', and so D' cannot be minimal. The
Myhill-Nerode Theorem tells us that the minimal DFA has a number of
states equal to the number of equivalence classes, so you could also
show that D' is not minimal by describing the three equivalence
classes.
The three-state DFA obtained by merging those two states is
actually isomorphic to the given DFA D, and this DFA is minimal.
The two final states cannot be merged because an a takes p to a final
state but takes q to a non-final state.
Last modified 14 May 2016