Sie sind auf Seite 1von 5

CS 331 Fall 2018 HW2 Solutions

Andrei Migunov

September 3, 2018

Problem 1. Given the DFA, M, in the problem, we wish to show that L(M ) = A.
We can do this by showing that ∀n, ∀x ∈ Σn , x ∈ A iff x ∈ L(M ). We prove this by
induction on n.
Basis: Let’s do two base cases just for clarity.
Let n = 0. The only string in Σ0 is , whose length is even and which is a member of
{0}∗ . It is also accepted by the given DFA.

Letting n = 1, we have only two strings to consider. 1 is neither in A, nor is it


accepted by M since δ(s0 , 1) = s2 . 0 is also not a member of A (it has odd length), and
is also not accepted by M.

Inductive Hypothesis: ∀k ≤ n, x ∈ Σk , x ∈ A iff x ∈ L(M ).


Inductive Step: Assume the IH.

We wish to show that ∀x ∈ Σn+1 , x ∈ A iff x ∈ L(M ). Let x ∈ Σn+1 . Suppose


x ∈ A. Then, by the def. of A, n + 1 is even, and x ∈ {0}∗ . Since n is odd, x[0...n − 2] is
not in A. By the inductive hypothesis, it follows that x[0...n − 2] is not accepted by
M, so δ(s0 , x[0...n − 2]) is either s1 or s2 . If it is s1 , and the next bit to be read in x after
x[0...n − 2] is read is a 0, δ(s0 , x = x[0...n − 2]0) = s0 , so x is accepted by M . If, instead,
it is s2 , x[0...n − 2] must contain a 1 (s2 is inaccessible otherwise), a contradiction (since
we know x ∈ {0}∗ , so its prefixes must be as well).

Again, letting x ∈ Σn+1 . Suppose instead that x ∈ L(M ). Since there is only one
final state, s0 , x, it must be that δ(s0 , x) = s0 . It follows that y = x[0...n] (where x = y0)
is not accepted by M , but that (again, by examining the transition function) y ∈ {0}∗ ,
and by the IH we know that y ∈ / A. It follows that x = y0 ∈ A.

Note: Two things: 1. Since we are proving x ∈ A iff x ∈ L(M ), it suffices to


consider the implication in both directions. We don’t need explicit third, fourth, etc.
cases assuming that x ∈ / A or x ∈
/ L(M ). These are covered. 2. Note the logic employed
here – the proof is set up consciously to allow the use of the IH. It doesn’t start talking
about x[0...n − 1] and so on for no reason – x[0...n − 1] has a length less than n + 1 and
the IH can be applied to it, allowing a vital connection to be made. There were many

1
incorrect criticisms of the so-called ’horse proof’ of HW 1, claiming that the IS should
not have started with a set of size k + 1. That it did is neither wrong nor surprising.
The point of an IS is to find a valid way to decompose a k + 1 problem into one or more
k problems to which an IH can be applied. Then, these problems are ’reassembled’ to
reach the conclusion. Look for this in all future proofs by induction.

2
Problem 2. Given i, j and k, whatever they may be, a DFA can be constructed,
per the problem statement, as follows:
If k ≥ i, we just use the one-state DFA with all self-loops and no accept state. This
is because there is no number which is going to equal k mod i. So, assume k < i.
To clarify a point: j can be any value, for example 2 billion. This means we would
need 2 billion + 1 distinct symbols for each of the numbers, since that’s how the alphabet
of w is defined. The number ’12380’ would be parsed in the input string all at once, as
a single symbol, and we’d need to know, based only on that symbol and our state, what
the mod i value is, so far.
All that said, we need only i states, and j + 1 transitinos at each. Let Q = {q0 ,
q1 ,...,qi }. Let Σ = {0, ..., j}. Let s = q0 . Let F = {qk }. The transition function of Bi,j,k
is defined as follows: ∀0 ≤ n ≤ i, w ∈ Σ,

δ(qn , w) = q(n+w) mod i

Fix i, j, and k < i. It is mostly straightforward to verify that L(Bi,j,k ) = Ai,j,k using
induction as in the above example. A sketch of the proof that x ∈ L(Bi,j,k ) (henceforth, M) iff x ∈
Ai,j,k (henceforth, A) by induction on the length of w ∈ Σ∗ :
Basis: Consider x ∈ A of length |x| = 0. Then, x =  and k = 0 since x ∈ A.
Since k = 0, M’s final state must be q0 , which is also the start state. It follows that
x =  ∈ L(M ).
IH: ∀m ≤ n, x ∈ Σm , x ∈ A iff x ∈ L(M ).
IS: Assume the IH. Let x ∈ Σn+1 . Let y = x[0...n − 1], and let c ∈ Σ such that x = yc.

Let num(c) be the numerical value of a symbol e ∈ Σ. For example, num(0 130 ) =
13 ∈ N. Let
n−1
X
Sz,n = num(x[m])
m=0

be the sum of the first n numerical values of symbols of z. Note Sx,n+1 = Sy,n + num(c).
Suppose x ∈ A. Then y ∈ A iff num(c) = 0 mod i. Suppose this is the case.
Then by the IH, y ∈ L(M ), i.e., δ(q0 , y) = qk . It follows that x ∈ L(M ) as well, since
k + num(c) = k mod i, so δ(qk , c) = qk . Suppose instead that num(c) 6= 0, i.e., that
y∈/ A. Then by the IH, δ(q0 , y) = ql 6= qk for some l. By the def. of M , it must be that
Sy,n = l mod i. Then, Sy,n + num(c) = 0 mod i and it follows, again by the def. of M ,
that δ(q0 , x) = qk ∈ F .
Suppose x ∈ L(M ). [Show that x ∈ A. This direction is quite similar.]

Note: Again, it’s worth it to revisit the point of all this. Why can’t the IS be
established without using the inductive hypothesis? How would you possibly relate
membership in A with acceptance in M?

3
Problem 3. We will use two constructions. The first will adapt machines M1
and M2 (recognizing languages A and B, respectively). The second will just be the
product construction to create a machine which recognizes A ∩ B. First let’s define a
new alphabet, Σ3 = Σ1 ∪ Σ2 . Since we will eventually choose our final states, following
the produt construction, to be those in which ’both elements’ are final states in their
respective machines, we know we’re not going to ever arrive at these if the input we read
contains symbols one of the original machines doesn’t recognize. We can do this in the
following way.
Let M1 be a machine recognizing A. We’re going to modify it slightly but significantly,
to handle symbols the other machine can already handle. For each symbol e ∈ Σ2 \ Σ1 ,
and for each state q ∈ Q1 , add a transition δ1 (q, e) = qreject where qreject is a new ’trap’
state with ∀s ∈ Σ3 , δ1 (qreject , s) = qreject
We repeat this construction for M2 , instead looking at symbols e ∈ Σ1 \Σ2 , modifying
it in the same way to handle symbols M1 can handle but M2 can’t.
Call these new machines M10 , M20 respectively. From here, we just need to perform
the routine product construction for intersection.
It is straightforward to verify that the result accepts the intersection of the languages.

4
Problem 4.

Das könnte Ihnen auch gefallen