Questions are in black, solutions in blue
Here are your problems:
L0 = λ+Σ*a = (Σ*a)*, L1 = b + Σ*ab, L2 = bb + Σ*abb, L3 = Σ*bbb.
States {q0, q1, q2, q3}, start state q0, final state set {q2}. For all i, δ(qi,a) = q0. For i = 0, 1, or 2, δ(qi,b) = qi+1. Finally, δ(q3,b) = q3.
Since the language is non-empty the DFA must have at least one final state. It must have at least three final states because the strings λ, b, and bbb are pairwise L2-inequivalent. To see this, we must take each of the three pairs (u,v) and find a string w so that exactly one of the strings uw and vw are in L2. For λ and b, or λ and bbb, we may take w = bb. For b and bbb, we may take w = b.
Let P(u) be the proposition "∀i:δ*(q0,u) =
qi iff u ∈ Li". We prove P(u) for all strings u
by induction.
For the base case, we prove P(λ) as follows. By definition,
δ*(q0,λ) = q0, and λ is in
L0 because it does not end with a b.
For the inductive case, we assume P(u) as IH. Since
δ*(q0,u) must be one of the four states, we break
into four cases:
In each case we have shown P(ua) and P(ub), so we have completed the string
induction.
If k is the length of w, the length of the string in z is n = 2k + 1. Thus if n is even, the string cannot be of this form and there are thus 0 strings of that length in Z. If n is odd, there is exactly one string in Z of length n for every possible string w of length k. There are thus 2k = 2(n-1)/2 strings of length n in Z.
The probability is the answer to (a) divided by the total number of strings of length n from the three-letter alphabet, which is 3n. So with even n the probability is 0, and with odd n it is 2(n-1)/2)/3n.
It is not possible. We know that a two-way DFA exists for the language if and only if an ordinary DFA exists, by a theorem proved in lecture. But there can be no ordinary DFA for this language, because it has an infinite number of Myhill-Nerode classes. If u and v are any distinct strings in (a+b)*, then uc and vc are Z-inequivalent because ucu is in Z but vcu is not. So all the infinitely many strings of the form wc are pairwise inequivalent and are in different classes.
The machine should first scan the tape, counting the c's among the a's and b's
and rejecting unless there is exactly one c. (It also rejects if any letter
other than a, b, or c occurs before the first blank.) It then marks the cell
past the last letter of the input with a d -- this will make the termination
condition easier to check. It then returns to the start square, which is now
the next blank to its left.
Then it repeats the following steps:
This loop can end in only three ways:
In: λ, a, b. Out: ab, ba, bb.
>(p)---------->((r))
| b ^
| |
\ /
lambda \ / lambda
\ /
\ /
\ /
V /
->(q)\
| | a
\____/
The transitive closure of the λ-moves includes (p,λ,r). Since
there is a λ-move in the closure from p to r, we make p a final state
in N. The move (p,b,r) gives rise only to itself. The move (q,a,q) gives
rise to (p,a,q), (p,a,r), (q,a,q), and (q,a,r). This gives us:
>((p))--------->((r))
| a,b ^
| |
\ /
a \ / a
\ /
\ /
\ /
V /
->(q)\
| | a
\____/
The start state (also final)
is {p}, with a-move to {q,r} and b-move to {r}. The final state {q,r} has
a-move to itself and b-move to ∅. The final state {r} has both
a-move and b-move to ∅, as does the nonfinal state
∅ itself. We finish with
four states:
>((p))--------->((r))
| b \
| \
\ \
a \ \ a,b
\ \
\ \
\ \
V b V
->((qr))---------->(d)--
| \ ^ \ a,b
\_______/ a \___/
We add a new start state s and new final state f, with λ-moves from s to p, p to f, qr to f, and r to f. We first eliminate d, which has no moves out of it and thus needs no moves to replace it. We then eliminate r, which has one move in, one move out, and no loop, so it is replaced by the move (p,b,f) which merges with an existing move to form (p,λ+b,f). Now we eliminate qr which has one move in, one out, and one loop to create the move (p,aa*,f) which merges to create (p,λ+b+aa*,f). Now eliminating p gives us the regular expression λ + b + aa*, which simplifies to b + a*.
We are given the following assumptions:
Here are your questions:
¬∃c:∀d: E(c,d) → R(d).
We first translate the statement to be proved, using the DeMorgan
law for quantifiers twice and the rule ¬(p→q) ↔ (p∧¬q),
to get:
∀c:∃d: E(c,d) ∧¬R(d)
The number of cards that are either red or spades is 39, so there are (39 choose 5) sets of five of these cards. The probability is thus (39 choose 5) divided by (52 choose 5). If we view both the numerator and denominator as numbers of sequences rather than sets, we get 395/525 = (39/52)(38/51)(37/50)(36/49)(35/48) = (19*37*3)/(4*17*5*7*4) = 2109/9520 = about 0.2215. This last product of fractions is the natural way to compute the probability as a sequence of five events.
The number of such sequences is 263*132 = 26*25*24*13*12. The total number of sequences is 525 = 52*51*50*49*48, so the probability is the first number divided by the second, which cancels to 13/17*2*49 = 13/1666 = about 0.0078.
Last modified 9 May 2012