
















L1: The set of strings where each string w has an equal number of zeros and ones; and any prefix of w has at least as many zeros as ones.
L2: The set of strings defined inductively as follows: if w is in the set then 0w1 is also in the set; if u and v are in the set then so is uv; and the empty string is in the set.
We can analyze L2 inductively to see that it maintains the property of L1 for each case:
L1-L2 is the same as the intersection of L1 and the complement of L2. Since the set of regular languages is closed under each of these operations, L1-L2 must be regular.
We can construct a DFA to decide Prefix(L) by taking the DFA for L and marking all states from which an accept state is reachable as accept states. So, Prefix(L) must be regular.
We can construct a DFA to decide MIN(R) by taking the DFA for R and redirecting all outgoing arrows from all the accept states to a dead state. So, MIN(R) must be regular.
Consider the sets {0}, {01}, {0011}, etc. Each one is regular because it only contains one string. But the infinite union is the set {0i1i | i>=0} which we know is not regular. So the infinite union cannot be closed for regular languages.
We know that
{0i1i | i>=0} = {0} U {01} U {0011} U ...,
Taking complements and applying DeMorgan's law gives us
{0i1i | i>=0}c = {0}c ^ {01}c ^ {0011}c ^ ...,
Where we are using U to deonte union and ^ to denote intersection. Recall the complement of a regular language
is regular, and hence the complement of a not-regular language is not regular. So we can conclude that the left
hand side of the equation is not-regular, and each term in the intersection is regular. Therefore infinite intersection does not preserve regularity.
(QxQxP(Q), Sigma, delta', {(q, r, {r}) }, { (r1,r2,S) in QxQxP(Q) | r1=r2 and S contains an element of F} )
where P(Q) is the power set of Q, i.e. all subsets of Q., and
delta'(r1, r2, S, a) = (delta(r1,a), r2, Sa)and Sa denotes the set of states that can be reached from some state in S in one step with input a. To simplify the notation, we are allowing multiple start states {(q, r, {r}) }. This could be also achieved by introducing a new state and introducing epsilon moves. The reason that this accepts Half(L) is that the term r2 in (r1,r2,S) remembers the midpoint of a potential string in L, and S represents the states one can reach from r2 in the number of steps it takes to get from the start q to r1. When r1=r2, then S contains all the paths that one can get to in twice as many steps as it took to get from q to r1.
An intuitive explanation The Half(L) problem is given a string w is there a string x of the same length as w such that wx is in the language L. This is hard to solve directly, so we break it into a number of subproblems of the following form: Fix a machine M that generates L and pick a state r in that machine.
The problem Half(L,r)is then: Given a string w, is there a string x of the same length as w such that wx is in the language L and after reading in w, the machine M is in the state r.
We can reduce solving Half(L) to solving Half(L,r) for each state r in the machine M and oring the result. The reason this is good is that the problem Half(L,r) decomposes naturally into two other simple problems:
If we make the machine M' by making all accept states in M be reject states, and by making state r an accept state, does M' accept the string w?
and
If we make the machine M'' by making state r the start state, and changing all 0 transitions to 0,1 transitions and similarly all 1 transitions to 0,1 transitions, does the machine M'' accept the string w?
What we have done in the second case is to ingnore what the value of any character in the string is. This is how to make a machine to accept all strings that have the same length as strings accepted by a given machine. Putting all this together should result in a similar machine to what is given for a solution here, with possibly some missing extraneous states.
In general if the minimum DFA for a regular language has more than one final state, then the language cannot be generated by a DFA with one final state. This is because minimization cannot increase the number of final states.
Proof: We need the following lemma first: A prefix free regular language M can generated by a machine with one final state. Suppose we have DFA representation of M that has multiple final states. Then all outgoing transitions from those final states must go to dead states since M is prefix free. But when we mimize the DFA, all the dead states will become equivalent, and therefore all the final states will become equivalent too.
We also need the following lemma: The Kleene star, M*, of prefix free regular language M can be generated by a machine with one final state. From the previous lemma we know there is a DFA that generates M that has one final state. We can make M* by taking the minimal DFA that accepts M and removing the transitions from the final state and collapsing it together with the initial state (while keeping it a final state).
From these to lemmas it is clear that RS* can be generated by a machine with one final state if R and S are prefix free, because we can just concatenate the machines for R and S*.
Conversely, if L is generated by a DFA M with one final state, then L = Min(L) ( Min(L') )*, where L' is the language of the machine M' has the same states, transitions, and final state as M, and where we choose the final state of M to be the start state of M'. Since the Min of a language is always prefix free, L is of the form we claim.
We just reverse the procedure for converting an NFA to a regular expression by ripping-in states.

(note: the rightmost state in the second diagram corresponds to the bottom right state in the third diagram.)
The NFA below determines if a string of columns composes a legal addition equation where the top two rows sum to the third. The two states correspond to whether the previous column led to a carryout or not, and the legal transistions for each state correspond to columns which maintain the correctness of the equation. If an invalid column is added, no valid outgoing arrow is found and the computation dies (thus rejecting the input).

The DFA works because the number of 01 transistions must always we within one of the number of 10 transistions, so we need only remember which transistion came first (top path vs. bottom path), and whether we have seen an even number or odd number of transistions (left state vs. right state).
