There are six questions for 120 total points.

When your answer to a problem is a particular number, you may use
exponents, falling exponents, factorials, and/or the "choose" notation
to indicate the number. However, if the answer is *less than 100*,
you must give the number in ordinary decimal notation for full credit.

**Question 1 (30):**
In this problem we will carry out several of our constructions, beginning
with an ordinary NFA N. This NFA has alphabet {a,b}, state set {1,2}, start
state 1, final state set {2}, and transition relation Δ =
{(1,a,1), (1,a,2), (1,b,2)}.

- (a,5) Draw a diagram for N. Give three examples of strings in L(N) and three examples of strings not in L(N).
- (b,10) Using the subset construction, build a DFA D such that L(D) = L(N). Make sure that your DFA has exactly two transitions out of each of its states.
- (c,10) If D is minimal (that is, if no DFA with fewer states than D has the same language), prove that it is minimal. If D is not minimal, give a smaller DFA with the same language. from your answer to (b).
- (d,5) Using the state elimination construction, find a regular expression that denotes L(D).

**Question 2 (10):**
Suppose that we are converting a λ-NFA M to an ordinary NFA N,
and that (p,a,q) is a letter move of M. Explain what letter moves must be
added to N to account for this move of M. Explain why these moves in N
account for every possible path in M where (p,a,q) is the only letter move
in the path.

**Question 3 (20):**
For any natural n, the undirected graph K_{n} has n vertices and
all possible edges (that is, it has an edge between i and j whenever i ≠ j).

- (a,5) How many edges are there in the undirected graph K
_{n}, as a function of n? - (b,5) A
**simple path**is defined to be a path that never revisits a vertex. (In particular, it may not start and end at the same vertex.) Let t and n be naturals. How many different simple paths of length t (i.e., with t edges) are there in the graph K_{n}? - (c,10) Let i and j be two vertices of K
_{n}with i ≠ j, and let t be any natural. How many simple paths of length t in K_{n}start at i and end at j? (Partial credit for the cases where t is 0, 1, or 2.)

**Question 4 (25):**
Define E to be the set of strings in {a,b}^{*} that have an equal
number of a's and b's. For example, the strings in E whose length is at most
four are: λ, ab, ba, aabb, abab, abba, baab, baba, and bbaa.

- (a,5) Let f(n) be the number of strings in E of length n. Give a formula or formulas for f(n) -- you may find it useful to give one formula for odd n and another for even n.
- (b,10) For a string w, let g(w) be the number of a's in w minus the number of b's in w. (Thus g(w) is an integer that may be positive, negative, or zero.) Prove that two strings u and v are E-equivalent if and only if g(u) = g(v).
- (c,5) What does the result of part (b) tell you about the existence of a DFA whose language is E?
- (d,5) What does the result of part (b) tell you about the existence of a two-way DFA whose language is E?

**Question 5 (15)**:
This problem deals with some statements in the predicate calculus.
The type of the variables is "animal" and we are given four unary
predicates: F(x) means "x can fly", G(x) means "x is a gnu", H(x) means
"x has hooves", and W(x) means "x has wings".

- (a,5) Translate the following four sentences into the predicate
calculus (into statements with quantifiers, with no free variables):
- (I) All gnus have hooves.
- (II) There does not exist an animal with both wings and hooves.
- (III) Given any animal, if it does not have wings then it cannot fly.
- (IV) There is no such thing as a flying gnu.

- (b,10) Using our proof rules for the predicate calculus, prove that statements (I), (II), and (III) together imply statement (IV). You may use valid rules of the propositional calculus without naming them.

**Question 6 (20)**:
Define a function h(n) from naturals to naturals recursively as follows.
If n ≤ 2, then h(n) = n. If n > 2, then h(n) = h(n-1) - h(n-2) +
h(n-3).

- (a,5) Compute h(n) for all n with n ≤ 8.
- (b,15) Prove by induction that for all naturals n, h(n+4) = h(n).

Last modified 21 December 2004