CEMC Banner

Problem of the Month
Solution to Problem 7: April 2023

  1. Suppose a and b are elements in An and that d(a,b)=k for some k. If k=0, then a=b, so their distance in the graph is also 0.

    Otherwise, a and b differ at exactly k coordinates i1,i2,,ik where i1<i2<<ik. Using the notation introduced in the problem statement, we mean that a[i]b[i] if i is in the list i1,i2,,ik and a[i]=b[i] otherwise. Notice that the function g(x)=1x has the property that g(0)=1 and g(1)=0, so g switches 1 and 0. We will now define a sequence a1,a2,,ak of elements in An. Informally, a1 is obtained from a by leaving all coordinates alone except a[i1], which gets changed from 0 to 1 or 1 to 0 as appropriate. Continuing, a2 is obtained from a1 by leaving all coordinates alone except a1[i2], which gets switched, and this continues for a3, a4, and so on. More formally, for each m1 with 1mk we define am as follows.

    By construction, the list a,a1,a2,,ak1,ak is a list in which every pair of elements differ at exactly one coordinate. Moreover, the list is that which is generated by changing the coordinates of a that differ from those of b one at a time, from leftmost to rightmost. This means b=ak, and the above is a walk from a to b. There are k+1 vertices in this walk, so there are k edges.

    We have constructed a walk from a to b in the natural graph of An that has length k, which means the distance from a to b in the natural graph is at most k. To see that it is at least k, we suppose a,c1,c2,,cm1,b is a walk in the natural graph of An of length m for some m. Since there are m vertices in this walk in addition to a and two vertices have an edge between them exactly when they differ at exactly one coordinate, the total number of coordinates at which a and b (the ends of the walk) can differ is at most m. Since we know that they differ at exactly k coordinates, we must have that mk. This means that any walk from a to b in the natural graph of An has at least k edges.

    We have shown that the distance in the natural graph between a and b is at least k and at most k, which means it is exactly k.

  2. For convenience, in the solution to this part and the solution to part (c), we will refer to a two element subset as a pair. Since d(a,b)=d(b,a) for any elements a,bAn, we will say that d(a,b) is the Hamming distance of the pair {a,b} or the pair {a,b} has Hamming distance d(a,b), and possibly other similar things depending on the grammar in that particular sentence. Similarly, we might say that {a,b} has distance k in a graph to mean that the distance between the vertices labelled by a and b is k in that graph.

    For a fixed element aAn, an element bAn satisfies d(a,b)=k exactly when it differs from a at exactly k coordinates. There are n coordinates in total, so there are (nk) possible choices of k coordinates that could be different from a. Therefore, for a fixed element aAn, there are exactly (nk) elements bAn with the property that d(a,b)=k. There are 2n elements in An and each aA belongs to exactly (nk) pairs with a Hamming distance of k. This gives a total of 2n×(nk) pairs. However, this total

    counts every pair twice, once for each of its two elements. Thus, the number of pairs in An with a Hamming distance of k is 122n(nk)=2n1(nk).

  3. Denote by En the set of pairs {a,b} from An satisfying d(a,b)=1. From part (b), there are 2n1(n1)=n2n1 pairs in En. In the relabelled natural graph of An, we want the distances of the pairs in En to be equally distributed among all possible distances in the graph. There are n possible distances between distinct vertices in the graph, so the fact that n2n1 is a multiple of n is a good sign.

    We want to permute the elements of An in such a way that for each k from 1 through n, exactly n2n1n=2n1 pairs in En have a distance of k in the relabelled graph.

    There are many ways to do this. The approach given here is inductive, starting by examining A2. Consider the example from the problem statement. In that example, 01 and 11 were switched and 00 and 10 stayed the same.

    First graph: Starting at the bottom left corner of the square and moving clockwise around the perimeter, the vertices are labelled 0 0 then 0 1 then 1 1 then 1 0. Second graph: Starting at the bottom left and moving clockwise, the vertices are labelled 0 0 then 1 1 then 0 1 then 1 0.

    Although it is not very interesting in A2, there is an observation we can make that will generalize. The vertices that are connected by horizontal edges in the diagram of the natural graph of A2 remain connected by an edge after permuting. The vertices in the top change order but their distance apart does not change. Meanwhile, the vertices that are connected by a vertical edge are moved to occupy opposite corners of the square so their distance goes from 1 to 2. While this is only an increase of 1, it will be useful going forward to think of the vertices connected by vertical edges as having gone from as close together as possible (connected by an edge) to as far apart as possible.

    Now consider the natural graph of A3, which is pictured below.

    In the first square, starting at the bottom left corner and moving clockwise around the perimeter, the vertices are labelled 0 0 0 then 0 0 1 then 1 0 1 then 1 0 0. In the second square, starting again at the bottom left corner and moving clockwise around the perimeter, the vertices are labelled 0 1 0 then 0 1 1 then 1 1 1 then 1 1 0.

    There are 12 edges in the graph. After permuting the labels of the graph, we want 123=4 pairs of adjacent vertices to be sent to adjacent vertices, 4 pairs of adjacent vertices to be sent to vertices with a distance of 2, and 4 pairs of adjacent vertices to be sent to vertices with a distance of 3.

    Looking at the diagram, we can think of the natural graph of A3 as being composed of two copies of the natural graph of A2 laid horizontally on top of each other. The labelling also has some coherence with the labelling of A2. First, label the bottom and top square as if they were copies of the natural graph of A2, making sure to label vertically-adjacent vertices in the same way. Next, append a 0 to the right of every label in the bottom layer and append a 1 to the right of every label in the top layer.

    To permute the labels in the way we want, we will first perform the same permutation on each layer as we did in A2. In each layer, this moves two pairs of labels from adjacent vertices so that they are at a distance of 2. There are also two pairs of adjacent vertices in each layer that remain adjacent after permuting. The four pairs of vertically-adjacent vertices will remain vertically adjacent because we will have performed the exact same permutation in each layer. At this point, the labels on four pairs of adjacent vertices have been sent to vertices that are 2 apart and the other 8 pairs of labels remain on adjacent vertices. The diagram below shows what we have done so far:

    In the first square, starting at the bottom left and moving clockwise, the vertices are still labelled 0 0 0 then 0 0 1 then 1 0 1 then 1 0 0. In the second square, starting at the bottom left and moving clockwise, the vertices are now labelled 1 1 0 then 1 1 1 then 0 1 1 then 0 1 0.

    The second and final step is to swap the corners in the top layer. This will have the effect of moving the labels on vertically-adjacent vertices to be as far apart as possible. In a "cube", this means they will end up at opposite ends of a "space diagonal". Swapping the corners in a layer preserves the distance between all pairs of vertices in that layer. This means the net effect of the second step is to move four pairs of adjacent vertices so that they are at a distance of 3. The overall effect is shown below:

    In the first square, starting at the bottom left and moving clockwise, the vertices are now labelled 0 0 0 then 0 1 1 then 1 1 1 then 1 0 0. In the second square, starting at the bottom left and moving clockwise, the vertices are now labelled 1 1 0 then 1 0 1 then 0 0 1 then 0 1 0.

    In the table below, the first column has the 12 pairs from E3 and the second column has the distance of the corresponding pair in the relabelled graph.

    {a,b} new distance
    {000,001} 3
    {000,010} 2
    {000,100} 1
    {001,011} 2
    {001,101} 1
    {010,011} 3
    {010,110} 1
    {011,111} 1
    {100,101} 3
    {100,110} 2
    {101,111} 2
    {110,111} 3

    As n grows, the natural graph of An gets harder and harder to draw in a useful way, so we need some notation to help translate the geometric idea into symbols. First, we will clarify what we actually want.

    Suppose f is a function with domain An and codomain An. This means f is a function that takes elements of An as input and also outputs elements of An. When we talk about a permutation of An, we really mean a function f with domain and codomain both equal to An that is a bijection. For a brief discussion about what a bijection is, you can consult Appendix 1 from the solution to the February 2023 problem. In the context of this solution, a function from An to An is a permutation if every possible output is attained by exactly one input. For example, the function f with domain and codomain A2 given by f(00)=11f(01)=01f(10)=00f(11)=10 is a bijection from A2 to A2. Every possible output is attained (the four elements of A2 appear on the right side of the displayed equations above) and no output is attained more than once. If you think about it, every way to order the elements of A2 (a permutation) corresponds to exactly one such function: choose an order of the elements, then write them in that order in the second column above. It will not be important for this solution, but it might help you to understand this connection if you convince yourself that there are exactly 4!=24 bijections from A2 to itself.

    A rearrangement of the labels in the natural graph of An can be thought of as a bijection from An to itself. If f is such a function, then f(a) is equal to the original label of the vertex to which the label a is sent by the permutation. For example, the permutation for A3 corresponding to the relabelling from earlier (shown below)

    is given by f(000)=000f(001)=111f(010)=110f(011)=001f(100)=100f(101)=011f(110)=010f(111)=101 For example, the fourth of the displayed equations above is f(011)=001 because in the second diagram 011 appears where 001 originally appeared.

    This is an important observation because we can now recognize distance in the relabelled graph as a Hamming distance. The distance between a and b in the relabelled graph is equal to the distance between f(a) and f(b) in the original graph. By part (a), this means the distance between a and b in the relabelled graph is equal to d(f(a),f(b)).

    We can now formally articulate what we seek. For each n, we would like a function fn with domain and codomain both equal to An with the following properties.

    It may be a good idea to digest what has been said so far, possibly going back to see how this applies to A2 and A3.

    We can now define fn for each n, but the definition will be recursive, so we need a bit more notation. For an element a in An where n1, we will write a|0 to mean the element of An+1 that is obtained by appending a 0 to the right end of a. For example, 00110|0=001100. Similarly, a|1 is the element of An+1 obtained by appending 1 to the right end of a. Also, we will denote by a the element of An obtained by changing every coordinate of a from 0 to 1 or 1 to 0, as appropriate. For example, if a=0010111, then a=1101000.

    Starting with n=1 (which we have not addressed up to this point) we will let f1(a)=a. That is, f1(a) is the identity function. The elements of A1 are 0 and 1, and f1(0)=0 and f1(1)=1. We now continue recursively. For n1, we define fn+1 from fn as follows.

    Notice that the above instructions indeed explain how to evaluate fn+1 at every element of An+1 because each element of An+1 can be constructed in exactly one way by appending either a 0 or a 1 to the right of an element from An. As an example, we will determine exactly what f2 does to each element in A2. For 00, we have to use the rule in the first bullet point because the rightmost digit is 0. f1(0)=0, so we have that f2(00)=00. Since the second digit of 10 is also 0 and f1(1)=1, we get that f2(10)=10. For 01, we have to use the rule in the second bullet point. This means f2(01)=f1(0)|1=0|1=11. Finally, f2(11)=f1(1)|1=1|1=01. This is exactly the function from A2 to itself discussed earlier. We leave it as an exercise to verify that f3 is exactly the permutation of A3 discussed earlier.

    We can now prove by induction that fn does what we want for every n. Before doing that, we will discuss how this function corresponds to the geometric idea from earlier. The elements in An+1 can be obtained by taking each element of An and appending a 0 to the right and a 1 to the right, in a way getting two elements in An+1 from every element in An. By this reasoning, An+1 can be thought of as two copies of An: elements ending in 0 and elements ending in 1. If you look at the natural graph of A3 above, these two copies are exactly the "bottom" and the "top" squares. The way fn+1 is defined is to operate differently on the two copies of An, since how fn+1(a) is computed depends on the rightmost digit of a. In other words, it depends on which copy of An a belongs to. If a has a rightmost digit of 0, then fn+1 essentially does what fn did. This corresponds to the bottom face of the cube being permuted exactly as the square was. If the rightmost digit of a is 1, then a is in the other copy, corresponding to the top face of the cube in the case of A3. In this situation, we apply fn to the element of An obtained by removing the last digit, just as we would if the rightmost digit were 0. However, we then switch every digit, and this corresponds to "swapping the diagonals" in A3. Finally, a 1 is appended to the right of the result, which corresponds to making sure that elements in the top of the cube stay in the top of the cube during the permutation.

    For n=1, it is an exercise in understanding definitions to see that fn satisfies the given conditions. We have already established this for n=2, and n=3 can be verified by confirming that f3 is exactly the permutation from earlier that we verified worked.

    We now assume, for some n1, that fn is a permutation of An with the property that among pairs {a,b} from En, d(fn(a),fn(b)) takes on every value from 1 through n exactly 2n1 times. We will show that fn+1 is a permutation of An+1 with the property that among pairs {a,b} from En+1, d(fn+1(a),fn+1(b)) takes on every value from 1 through n+1 exactly 2n times.

    To see that fn+1 is a permutation, let aAn be arbitrary. Since fn is a permutation, there is a unique element bAn such that fn(b)=a and a unique element cAn such that fn(c)=a. Using the definition of fn+1, we have fn+1(b|0)=fn(b)|0=a|0 and fn+1(c|1)=fn(c)|1=a|1=a|1. Since every element in An+1 is of the form a|0 or a|1 for some aAn, we have shown that every element of An+1 is in the range of fn+1. Now suppose a1,a2,a3,,a2n+1 are the elements of An+1 (in some order). We have shown that every element of An+1 appears in the list fn+1(a1),fn+1(a2),,fn+1(a2n+1) at least once. There are 2n+1 elements in the list above and 2n+1 elements in An+1, so every element of An+1 must appear in the list above exactly once. In other words, fn+1 is a permutation of An+1.

    To prove the other fact about fn+1, we will use the fact that d(a,b)=d(a,b) for any a and b. It is left as an exercise to verify this.

    Suppose k is a positive integer such that 1kn. By induction, there are exactly 2n1 pairs {a,b} in En with d(fn(a),fn(b))=k. If {a,b} is one of these 2n1 pairs, we have d(fn+1(a|0),fn+1(b|0))=d(fn(a)|0,fn(b)|0)=d(fn(a),fn(b))=k where the second equality is because the elements in question agree in the last coordinate, so their Hamming distance is equal to the Hamming distance between the elements obtained by removing the rightmost elements. We similarly have that d(fn+1(a|1),fn+1(b|1))=d(fn(a)|1,fn(b)|1)=d(fn(a),fn(b))=d(fn(a),fn(b))=k Therefore, there are 2×2n1=2n pairs {a,b} from En+1 satisfying d(fn+1(a),fn+1(b))=k for each 1kn.

    Next, for any aAn, we have d(fn+1(a|0),fn+1(a|1))=d(fn(a)|0,fn(a)|1)=d(fn(a),fn(a))+1=n+1 where the second equality is because we know that the two elements being handed to d have different rightmost coordinates, so their Hamming distance is one more than the Hamming distance between the elements obtained by removing the rightmost coordinates. The third equality is because fn(a) and fn(a) differ in all n coordinates by definition.

    There are 2n elements of An, and each pair {a|0,a|1} is in En+1, so we get 2n pairs from En+1 such that d(fn+1(a),fn+1(b))=n+1. For each k from 1 through n+1, we have found 2n pairs {a,b} from En+1 with the property that d(fn+1(a),fn+1(b))=k. This completes the proof.