Q1: 20 points Q2: 50 points Q3: 25 points Q4: 30 points Total: 125 points
Here are several definitions used on the exam.
This exam's boolean logic problem involves four atomic propositions and three compound propositions:
public natural h (natural n) {
if (n == 0) return 0;
if ((n % 2) == 1) return 1;
return 2 * h(n/2);}
/---\ b
\ /
\ V
/-->(2)--\
a / \ lambda
/ V
>(1) ((4))
\ ^
b \ / a
\-->(3)--/
Statement 1: ¬DB → (HO ↔ IN)
Statement 2: If it is not the case that either Duncan did not hear
a fox or that he imagined a noise, then Duncan is barking.
Statement 3: (HO → DB) ∧ (¬DB → (HF ∨ IN))
Proof by contradiction. Assume ¬DB.
X has the Cardie Property: There is a string such that if it is followed by any
string, the result is in X.
X has the Duncan Property: Given any string, we can find a
string to follow it such that the result is in X.
The negation of the Duncan Property is ∃u:∀v: uv ∉ X. Let u be the string ba. Let v be an arbitrary string, so that uv is bav. The string bav cannot be in a*b* because strings in that language never have an a after a b. Since v was arbitrary, we have proved ∀v: bav ∉ X by Generalization. Since we have found a choice for u that works, we have proved the desired statement by Existence.
The empty langauge has neither property because "uv ∈ X" can never be true.
a(a+b)* works -- "a" followed by any string is in X, but no string following b results in a string in X.
(a+b)*a works -- any string followed by "a" is in X, but no string followed by "b" is in X.
(a+b)* works because now "uv ∈ X" is always true.
You do not have to justify your answers, but make sure you indicate which regular expression is an answer to which of the four parts.
Most of you failed to see that you are asked to prove an "if and only
if" statement and thus have two directions to prove.
Suppose that X satisfies ∃u:∀v: uv ∈ X. Consider
the minimal DFA for X. Let u be any string such that
∀v: uv ∈ X is true. I claim that
δ*(i, u) is a victory state. Clearly it is
final, since uλ = u must be in X. If a is any letter, I
claim that ua ≡X u. If this is true, then ua
and u are in the same equivalence class, so that
δ*(i, ua) = δ*(i, u) and thus
δ(δ*(i, u), a) = δ*(i,
u).
Since the a-arrow from the state goes to itself for every
letter a, it is a victory state.
To see the equivalence, we must prove that ∀z: (uz
∈ X) ↔ (uaz ∈ X). This is true because both uz and
uaz are guaranteed to be in X because ∀v: uv ∈ X is
true and we can specify v to be either z or az.
We still need to prove the other half. Assume that the
minimal
DFA for X has a victory state s. All states in the minimal DFA
are reachable, so there exists some string w such that
δ*(i, u) = s. Now we must prove that for this
w, ∀v: wv ∈ X. This is true because ∀v,
δ*(i, wv) = s, a final state. We prove this
by
induction on v. For v = λ it is clear from the
definition of s. If we assume that δ*(i, wv) = s,
then δ*(i, wva) is also s because all arrows from s
go to s. We have shown that X has the Cardie property.
If X has the Duncan property, and M is a DFA with L(M) = X, we know that for every reachable state s in M, there is a path from s to some final state. So we first do a DFS or BFS of the directed graph of M starting from i, to get a list of all the reachable states. Then for each of these states, we DFS or BFS the directed graph from that state, with our goal being a final state. If we reach our goal for each state, X has the Duncan property. If we fail for any state, it does not have the Duncan property.
Let P(n) be the statement "g(n) = 3(2n) - 2".
P(0) says
that g(0) = 3(20) - 2 = 3 - 2 = 1. We are given that
g(0) = 1 so P(0) is true.
Now assume that P(n) is true, and we will try to prove
P(n+1).
P(n+1) says that g(n+1) = 3(2n+1) - 2. We know that
g(n+1) = 2g(n) + 1 by the definition, and by the IH we know that
g(n+1) = 2(3(2n) - 2) + 2 = 3(2n+1) - 4 +
2 =
3(2n+1) - 2 as desired. This finishes the inductive
step and so finishes the proof of P(n) for all n.
P(n) is the statement "h(n) divides n".
Since we are using induction on positive naturals, the
base case is n = 1. We know that h(1) = 1 because 1 is odd, and
we know that 1 divides 1, so P(1) is true.
Now assume the statement Q(n), which says that P(i) is true
for all i such that 1 ≤ i ≤ n. We want to prove that
P(n+1) is true, which means that h(n+1) divides n+1. If n+1 is
odd,
then h(n+1) = 1 and P(n+1) is true because h(n+1) = 1 and 1
divides any natural.
If n+1 is even, it equals 2k for some positive natural k, and we
know that P(k) is true from the strong IH, Q(n). So we know
that h(k) divides k. By the definition of h, h(2k) is equal to
2h(k).
This number divides 2k because h(k) divides k. So P(n+1) is
true and we have completed the inductive step of our strong
induction, and thus proved that P(n) is true for all n.
The number h(n) is the product of all the 2's occurring in the prime
factorization of n. That is, n is equal to 2k times the
product of zero or more odd primes, and h(n) is then just
2k.
You weren't required to prove this, but if you were you would use
induction on k, the number of 2's in the prime factorization of n. If
k = 0, then n is odd and h(n) = 1 which equals 2k. Assume
that our characterization of h is true for all naturals with k 2's,
and look at a natural n with k+1 2's. Then n is even, so h(n) =
2h(n/2).
The IH says that h(n/2) is 2k, where k is the number of 2's
in n/2, so h(n) is 2k+1 as desired.
Following the construction from lecture gives us a four-state λ-NFA for b*, with states 1, 2, 3, and 4, λ-moves from 1 to 2, 2 to 3, 3 to 2, and 3 to 4, and a b-move from 2 to 3. The total λ-NFA has these four states plus states 0 and 5, and additional moves (0, a, 1), (0, b, 5), and (5, a, 4). Here 0 is the start state and 4 is the final state.
The only λ-move is from 2 to 4, so the λ-moves are closed and there is no change to the final state set. Move (1, a, 2) gives itself and (1, a, 4). Move (2, b, 2) gives itself and (2, b, 4). Moves (1, b, 3) and (3, a, 4) give only themselves, so we get an ordinary NFA with six moves. There are other correct ordinary NFA's -- you were not required to use the construction to get your ordinary NFA.
From the N given above, we have nonfinal start state {1} with a-arrow to final state {2, 4} and b-move to nonfinal state {3}. State {2, 4} has a -arrow to nonfinal state ∅ and b-arrow to itself. State {3} has a-arrow to final state {4} and b-arrow to ∅. Both {4} and ∅ have both their arrows to ∅
We don't need a new start state, but we need a new final state f with λ-moves from both {2, 4} and {4}, which now become nonfinal states. We first delete ∅, making no new arrows. We delete {3}, making one new arrow ({1}, ba, {4}). We then delete {4}, making one new arrow ({1}, ba, f). We then delete {2, 4}, making one new arrow (1, ab*, f). The two parallel arrows merge to give a single arrow (1, ab* + ba, f), and we are done because there are only two states left.
Last modified 6 May 2014