This next one is done as an example of “Local Replacement” in the main part of the G&J book, but it’s pretty complicated, so I figured it was worth a post.

**The problem: ** Ensemble Computation. This is problem PO9 in the appendix and is done on pages 66-68 of G&J.

**The description: **Given a set A, and a collection C os subsets of A, and a positive integer J. Can we find a sequence z_{1}..z_{j}, of at most J elements, where:

- Each z
_{i}is formed as the union of 2 disjoint sets x_{i}and y_{i} - Each x
_{i}and y_{i}is either (the set containing) a single element of A, or a z_{k}for some k < i - Every set in C appears as a z
_{i}someplace?

**Example**: G&J say that this problem comes out of a desire to minimize the number of multiplications needed to compute a set of products- the idea being that the union of 2 sets works like the multiplication of the sets with those terms. So let’s suppose A = {a,b,c,d,e}, and C = {ab, bcd, ce}

(Really C should be a collection of sets like {a,b}, but I think that thinking of it as multiplication is helpful)

Then a sequence that might get everything in C might be:

- z
_{1}= ab - z
_{2}= bc - z
_{3}= bcd - z
_{4}= ce

..which is the best we can do. But now imagine that the second element of C was “abc” instead of “bcd”. Then we can make the sequence:

- z
_{1}= ab - z
_{2}= abc - z
_{3}= ce

.. Using the z_{1} result as an operand to create our z_{2}, enabling us to do it in fewer steps.

**Reduction: **G&J use Vertex Cover. So we’re given a graph G=(V,E) and an integer K. Our set A will be the set of all vertices in V, plus a new element a_{0}. For each edge (u,v) in E, we will create a set {a_{0}, u, v} in C. Our bound J will be set to K + |E|.

Suppose G has a vertex cover of size K (we’ll call them v_{1} .. v_{k}). Then we know that each edge in E can be built using at least one of the VC vertices. So the following sequence will work and be of size J:

- z
_{1}through z_{k }are formed by unioning a_{0}with the VC vertex v_{i}(i=1..k) - Each of the remaining unions will make an element of C (based on an edge in E) by unioning the z set that has the VC vertex in the edge with the vertex in A that has the other end of the vertex.

In the other direction, suppose we have a sequence of unions z_{1}..z_{j} that solves the Ensemble Computation problem. There may be multiple possible solutions to this problem, let’s look at the shortest sequence, and also the one that has the least number of operations that make a z set out of 2 elements of V (and not a_{0}) It turns out that since we have a minimum length sequence, the only reason to union 2 elements u and v from V together would be because (u,v) is an edge in E, and we want to union in a_{0} later to make the set {a_{0}, u, v} in C. But then we can rearrange the order and union a_{0} with u first, and union that result with v to get the same element of C in the same number of steps. So this means that our sequence has 2 kinds of operations:

- Unions of some vertex with a
_{0} - Unions of one of the above sets with a vertex to make an element in C.

We know that there are |E| of the second kind of union (because there are |E| elements in C), and so there must be K of the first kind of union. So the vertices we union directly with a_{0} must be of size K, and since one of them gets combined in each set in C (and thus is a part of each edge in E), must be a vertex cover.

**Difficulty: **6. This is one of those “the description is harder than the actual problem” problems. All of the talk of sequences and unions and things looks scary, but the actual problem isn’t that bad. As for the actual reduction, I think it would be a good hard homework problem. One trap I see is that the need for a_{0} might not be obvious (it’s there to force us to “choose” the VC vertices and commit them to be a step in our sequence). So maybe that needs to be a hint.