- Answer the problems on the exam pages.
- There are four problems on pages 2-8, for 125 total points. Scale was A = 110, C = 70.
- If you need extra space use the back of a page.
- No books, notes, calculators, or collaboration.
- Numerical answers that are
*naturals less than 100*must be computed exactly for full credit. Other numbers may be given by arithmetic expressions, including exponents, falling exponents, and the "choose" notation.

Q1: 35 points Q2: 25 points Q3: 35 points Q4: 30 points Total: 125 points

**Question 1 (35):**This problem involves the following four languages over the alphabet Σ = {a,b}:- L
_{0}is the set of strings that do not end in b (including λ). - L
_{1}is the set of strings that end in exactly one b. - L
_{2}is the set of strings that end in exactly two b's. - L
_{3}is the set of strings that end in three or more b's.

Here are your problems:

- (a,5) Give regular expressions denoting each of the languages
L
_{0}, L_{1}, L_{2}, and L_{3}. - (b,10) Build a four-state DFA that decides the language L
_{2}. (Hint: Your DFA should have one state corresponding to each of the four given languages.) - (c.5) Argue, without using the state minimization algorithm, that there
is no three-state DFA that decides L
_{2}. - (d,15) Label the states of your DFA q
_{0}, q_{1}, q_{2}, and q_{3}to correspond to the four languages. Then prove by induction on all strings u that with your DFA, δ^{*}(s,u) = q_{i}if and only if u ∈ L_{i}. (Here "s" refers to whichever of the q_{i}'s you have designated as the start state.) (Hint: Your inductive step will have four cases, one for each i. In each of these you must show that if u is in L_{i}, then both ua and ub are in the sets L_{j}indicated by your DFA.)

- L
**Question 2 (25):**Let Z be the language over alphabet {a,b,c} that consists of all strings wcw, where w is a string in (a+b)^{*}. (That is, Z = {u: ∃w: u = wcw ∧ w ∈ (a+b)^{*}}.)- (a,5) Given a natural n, how many strings of length n are in the language Z? (There will be separate answers for even and odd n.)
- (b,5) Suppose we choose an n-letter string at random from the language
(a+b+c)
^{*}, with every string equally likely. What is the probability that we choose a string in Z? (Again, answer separately for odd and even n.) - (c,5) Is it possible for a two-way DFA to decide the language Z? Justify your answer, based on results from lecture and observations about Z.
- (d,10) Informally describe how a (deterministic, one-tape) Turing machine could decide the language Z. (I don't want a state table, just a high-level description that indicates how the state table would be built.)

**Question 3 (35):**This question begins with a λ-NFA M. It has state set {p,q,r}, start state p, final state set {r}, and four transitions in Δ: (p,λ,q), (p,b,r), (q,a,q), and (q,λ,r).- (a,5) Draw a diagram of this λ-NFA M. Give three examples of strings in L(M) and three examples of strings not in L(M).
- (b,10) Using the construction from lecture, create an ordinary NFA N, with the same state set, such that L(N) = L(M). Remember that N's final state set may or may not be the same as M's.
- (c,10) Using the Subset Construction, make a DFA D from your NFA N with L(D) = L(N). (If you could not do part (b), you may give any correct DFA for this languaage by any method for partial credit.)
- (d,10) Using the construction from lecture on your DFA D, make a regular expression R such that L(D) = L(R).

**Question 4 (30):**This question involves the following four predicates on cards in a standard 52-card deck. Remember that such a deck has thirteen cards in each of the four suits.- S(c) means that c is a spade.
- R(c) means that c is a red card (a diamond or heart).
- B(c) means that c is a black card (a club or spade).
- E(c,d) means that cards c and d have the same rank (for example, both sevens).

We are given the following assumptions:

- (I) Every card is either red or black, but not both.
- (II) Every spade is black.
- (III) Given any card, there is a spade that has the same rank as it.

Here are your questions:

- (a,5) Translate statements I, II, and III into symbolic logic with quantifiers, using the predicates defined above.
- (b,15) Using
*only*statements I, II, and III and the rules for proofs with quantifiers, prove the statement:¬∃c:∀d: E(c,d) → R(d).

- (c,5) If we choose five cards from a standard 52-card deck, with any set of five cards being equally likely, what is the probability that every one of those five cards is either red or a spade?
- (d,5) If we deal out five cards from a standard 52-card deck
*in order*and*without replacement*, with any no-repeat sequence of five cards being equally likely, what is the probability of the event "the first three cards are red and the last two cards are spades"?

Last modified 24 May 2006