Mathematics for the interested outsider

Randall’s got an analogy for Rubik’s cube. Like the cube, there’s a trick to it. Unlike the cube, it doesn’t really illustrate any interesting mathematics. Also unlike the cube, I’m not about to go telling everyone what the trick is out in public.

I mean, sure, it’s not like I’m using it or anything, but it’s the principle of the thing.

I’m not about to sit down and work up a solution like we did before, but it shouldn’t be impossible to repeat the same sort of analysis. I will point out, however, that the solver in this video is making heavy use of both of our solution techniques: commutators and a tower of nested subgroups.

The nested subgroups are obvious. As the solution progresses, more and more structure becomes apparent, and is preserved as the solution continues. In particular, the solver builds up the centers of faces and then slips to the subgroup of maneuvers which leaves such “big centers” fixed in place. Near the end, almost all of the moves are twists of the outer faces, because these are assured not to affect anything but the edge and corner cubies.

The commutators take a quicker eye to spot, but they’re in there. Watch how many times he’ll do a couple twists, a short maneuver, and then undo those couple twists. Just as we used such commutators, these provide easy generalizations of basic cycles, and they form the heart of this solver’s algorithm.

Alexandre asked a question about the asymptotic growth of the “worst assembly time” for the cube. What this is really asking is for the “diameter” of the th Rubik’s group . I don’t know offhand what this would be, but here’s a way to get at a rough estimate.

First, find a similar expression for the structure of as we found before for . Then what basic twists do we have? For we had all six faces, which could be turned either way, and we let the center slices be fixed. In general we’ll have slices in each of six directions, each of which can be turned either way, for a total of generators (and their inverses). But each generator should (usually) be followed by a different one, and definitely not by its own inverse. Thus we can estimate the number of words of length as . Then the structure of gives us a total size of the group, and the diameter should be about . Notice that for this gives us , which isn’t far off from the known upper bound of quarter-turns.

We can fit Rubik’s group into a sequence that more clearly shows all the structure I’m talking about. Specifically, it’s a subgroup of the bigger group I mentioned back at the beginning. We can restate the three restrictions as saying the maneuvers in Rubik’s group are those in the kernel of a certain homomorphism. So, first let’s write down the big group.

The unrestricted edge and corner groups are just wreath products, which I’ll write out as semidirect products. Without restrictions, these two groups are independent, so we just have a direct product to give the unrestricted Rubik’s group.
I’ll write for a generic element of this group. Each part of this list corresponds to part of the expression for above.

Now we want to add up all the edge flips and make them come out to zero. We can write this sum as a homomorphism:
where the sum is taken in the group . You should be able to verify that this actually is a homomorphism. Similarly, we want the sum of the total twists as a homomorphism:
where the sum is taken in .

Finally, the permutation condition uses the “signum” homomorphism from a symmetric group to . It assigns the value to even permutations and the value to odd ones. We use it to write the last restriction as a homomorphism:

Now we assemble our overall restriction homomorphism as the direct product of these three:
and get the short exact sequence:

Commenter Dan Hoey brought up where my fundamental operations come from. To be honest, these four are just ones I remember off the top of my head. He’s right, though, that there are systematic ways of coming up with maneuvers that perform double-flips, double-twists, and -cycles. I’ll leave you to read his comment and work out yourself that you can realize four such basic maneuvers as commutators — products of elements of the form . This means that the commutator subgroup of Rubik’s group is almost all of itself. It just misses a single twist. In fact, — Rubik’s group is highly non-abelian.

Incidentally, this approach to the cube is not the first one I worked out, but it’s far more elegant than my pastiche of particular tools. I picked it up back when I was at the University of Maryland from a guy who had worked it out while he was at Yale as a graduate student back when the cube first came out: Jeff Adams.

The main technical point here is that we can move any three edge cubies to any three edge cubicles, and the same for corners. I don’t mean that we can do this without affecting the rest of the cube. Just take any three cubies and pick three places you want them to be, and there’s a maneuver that puts them there, possibly doing a bunch of other stuff to other cubies. I’ll let you play with your cubes and justify this assertion yourself.

A slightly less important point is that we only need to consider even permutations of corners or edges. We know that the edge and corner permutations are either both even or both odd. If they’re odd, twist one side and now they’re both even.

Now, let’s solve the edge group. The maneuver
has effect , flipping two edge cubies, while the maneuver
has effect , performing a cycle of three edges. This is all we need, because -cycles are enough to generate all even permutations, and one 3-cycle gives us all of them. Similarly, being able to flip two edges gives us all edge flips with zero total flipping.

How does this work? First, forget the orientation of the edges and just consider which places around the cube they’re in. This is some even permutation from the solved state, so it’s made up of a bunch of cycles of odd length and pairs of cycles of even length. Consider an odd-length cycle . If we compose this with the -cycle , we get . This is again an odd-length cycle, but two shorter. If we keep doing this we can shrink any odd cycle down to a -cycle. On the other hand, we have the composition , so we can build a pair of -cycles from -cycles. We can use these to shrink a pair of even-length cycles into a pair of odd-length cycles, and then shrink those into -cycles. In the end, every even permutation can be written as a product of -cycles.

And now since we can move any three cubies anywhere we want, one -cycle gives us all of them. Let’s pick three — say , , and — and a maneuver that sends to , leaves alone, and sends to . Such a maneuver will always exist, though it may mess up other parts of the cube. Now conjugate by . We know what conjugation in symmetric groups does: it replaces the entries in the cycle notation. So the maneuver has the effect , and we can do something similar to make any -cycle we might want. So we can make any even edge permutation we want, and adding a twist makes the odd permutations.

The same sort of thing works for edge flips. Take any pair of edges you want to flip, move them to and , flip them with , and move them back where they started. We can make any flips we need like this.

Together what this says is that the edge group of the Rubik’s cube lives in the wreath product of and : twelve copies of for the flips, permuted by the action of . Specifically, the edge group is the subgroup with total flip zero. We call this group , and we know as a subgroup of order .

A very similar argument gives us the corner group. The maneuver
has the effect , twisting two corners in opposite directions, while
has the effect , performing a -cycle on the corners. Conjugations now give us all -cycles, and these make all even corner permutations, and turning one more face makes all corner permutations. Conjugations also can give us all corner twists with zero total twist. This gives the corner group as a subgroup of order .

Putting these two together we get the entire Rubik’s Group as a subgroup of order . Here it’s a subgroup because we can only use maneuvers with the edge and corner permutations either both even or both odd, not one of each.

This result gives us an algorithm to solve the cube!

First, pick the colors of the face cubies to be on each side.

Then write out the maneuver that will take the scrambled cube to the solved one in cycle notation. If the edge and corner permutations are odd, twist one side and start again — now they’ll both be even.

Now write the edge permutation as a product of -cycles, and make each -cycle by conjugating by an apropriate maneuver.

Do the same for the corner permutation, using as the basic piece.

Write down how each edge and each corner needs to be flipped or twisted. Make these flips and twists by conjugating and .

That’s all there is to it. It’s far from the most efficient algorithm, but it exploits to the hilt the group theory running through the Rubik’s Cube. You should be able to apply the same sort of analysis to all sorts of similar puzzles. For example, the cube is just the corner group on its own. The Pyraminx uses a simpler, but similar group. The Megaminx is more complicated, but not really that different. It’s just group theory underneath the surface.

First I’ll tackle the corner flipping. Imagine a cube painted with just black and white. All the facelets are black, except for the four corners of the top face and the four corners of the bottom face. If you’ve got a real cube in front of you, tape a little bit of paper onto each of those eight facelets. We’re going to look at how a maneuver twists the corners by looking at how it moves those marked facelets.

Now every maneuver is a composition of the six basic moves , , , , , and . If we can show that these all have a net twist of zero then any composition of them must also have net twist zero. The moves and are easy: they don’t change the marked facelets at all.

Now let’s consider the move . After twisting the right face of the cube, the four marked facelets on the left are left alone. The upper-front corner on the right was marked on the top, but now is marked on the front. That’s an anticlockwise twist of 1/3 if we look directly at that corner. The upper-rear corner is now marked on the back, which is a clockwise twist of 1/3. The lower-front is twisted clockwise by 1/3, and the lower-right is twisted anticlockwise by 1/3. Adding all of these up, we get a total twist of zero.

The moves , , and are similar: each changes which facelet of four corners is marked. Each twists two markings clockwise and two markings anticlockwise, for a total twist of zero. If we do any maneuver and look at which facelet of each corner is marked, the total twist from the starting position will always be zero.

The restriction on edge flips is proved similarly. This time mark the top facelets of the four upper edges, the bottom facelets of the four lower edges, the front facelets of the two front middle edges, and the back facelets of the two rear middle edges. Now the four moves , , , and send marked facelets to marked facelets. The moves and flip the markings on the four edges that they move, and four flips is the same as zero flips, since flipping an edge twice returns it to its original state. If we do any maneuver, the total number of markings that have been flipped from the starting position will always be even, for a net flip of zero.

We can use this to analyze the cycle structure of a maneuver. Let’s say that the cycle notation of a maneuver contains a positively twisted cycle of length on the corners. If we do the maneuver times, it returns those cubies to their original cubicles, each twisted once clockwise. That is, has a total twist of on these cubies. Since each copy of does the same thing, that’s one twist each time we perform . If we look at all the corner cycles in , some will have a positive twist, some a negative twist, and some no twist. The number of positively twisted cycles minus the number of negatively twisted cycles must be a multiple of three, since three twists counts as zero total twist.

The same goes for the edges. Each flipped edge cycle in contributes a single net flip, and the total number of flips has to be even. You can check yourself that all the cycle notations I wrote down last time satisfy both of these conditions. You can also see that the parity of the edge permutation and the parity of the corner permutation are equal in each example.

So I’ve established that the total edge flip is zero, the total corner twist is zero, and the parities of the edge and corner permutations are equal. When I come back to the cube I’ll show that we can realize any maneuver whose cycle notation satisfies these three conditions can be realized as a composition of basic twists. That will lead us to the structure of Rubik’s Group, and to a solution of the Cube.

Take a cube — either a real one, the Java version, or just one in your mind’s eye — and hold it with the center cubies fixed in place pointing up, down, left, right, front, and back. Twists of the faces will generate Rubik’s goup . We pick the six generators as follows

is a twist of the upper face by a quarter turn clockwise, looking down at the top of the cube.

is a twist of the lower face by a quarter turn clockwise, looking up at the bottom of the cube.

is a twist of the right face by a quarter turn clockwise, looking left at the right side of the cube.

is a twist of the left face by a quarter turn clockwise, looking right at the left of the cube.

is a twist of the front face by a quarter turn clockwise, looking at the front of the cube.

is a twist of the back face by a quarter turn clockwise, looking at the back of the cube.

For instance, executing involves turning the whole cube around to look at the back, twisting that face clockwise by 90°, and turning the cube back to the original orientation.

For each twist , the 180° twist of the corresponding face is , and the anticlockwist twist is . Four quarter-twists is the same as doing nothing, so is the identity.

It’s also useful to label the cubicles. I’ll do this by listing the faces it touches. The face cubicle on the left side of the cube is , the lower edge on the back ls or . The upper-right corner on the front of the cube is , , , , , or . The order of the faces doesn’t matter so much for a single cubicle, but becomes important when we start thinking about how maneuvers affect the state of the cube.

For instance, the effect of the maneuver has an effect on the cube I’ll write as . This takes the cubie in the front-right cubicle and puts it in the back-left cubicle, with the facelet that was in the front now in the back and the facelet from the right now on the left. It takes the cubie from the back-left cubicle and puts it in the back-right cubicle with the facelet from the back still on the back and the facelet from the left now on the right. Finally it takes the cubie from the back-right and moves it to the front-right with the right facelet still on the right and the back facelet now on the front.

As another example, takes the cubie from the upper-right-front cubicle and leaves it where it is, but twists it to the right, and similarly twists the cubie in the lower-left-back cubicle. We write this transformation as . For shorthand we’ll modify this permutation notation slightly. When a cycle brings a cubie back to its starting cubicle but rotated, we add a sign. In this example we’ll write , since if we look directly at the upper-right-front cubie it’s been rotated clockwise by 1/3 of a turn and looking directly at the lower-left-back it’s been rotated anticlockwise by 1/3 of a turn.

This notation does make sense. Let’s say that we have a maneuver whose effect contains some cycle on the corners of the cube of length . If we apply that maneuver times each cubie in the cycle comes back where it started, but the cubies may have been twisted in the process. Each one will be twisted by the same amount: either 1/3 to the right, 1/3 to the left, or untwisted. The sign in the notation tells us what that twist is.

The same notation goes for edges. The maneuver has effect , flipping those four edges. We could write this out as , but the “twisted permutation” notation is more compact.

From this notation it’s easy to compute the order of a maneuver — what power of the maneuver returns to the identity transformation. A corner cycle of length has order if there’s no twist, and order if there is a twist. Similarly, an edge -cycle has order if there’s no flip and order if there is a flip. So if we write the effect of a maneuver as a twisted permutation we can find the order of each twisted cycle. The order the the whole maneuver is the least common multiple of those orders.

As an example, consider the maneuver . This has effect . The three twisted cycles have orders 3, 15, and 7, so the total order is 105. If you actually sit and perform you’ll get back exactly where you started.

Rubik’s Cube is a classic fad from the ’80s. Invented by architecture professor Ernő Rubik in 1974 as an illustration of design principles, it became an immensely popular puzzle for a while. Now it’s a hallmark of geekiness — when I visited Dartmouth I saw at least six or seven floating around the graduate student lounge.

What’s most interesting to us here is that it’s also a big case study in group theory. The official website has a pretty good Java implementation, for those who don’t remember (or who have repressed their memories of) the cube. I’ll start talking about the cube after the jump.Continue reading →

About this weblog

This is mainly an expository blath, with occasional high-level excursions, humorous observations, rants, and musings. The main-line exposition should be accessible to the “Generally Interested Lay Audience”, as long as you trace the links back towards the basics. Check the sidebar for specific topics (under “Categories”).

I’m in the process of tweaking some aspects of the site to make it easier to refer back to older topics, so try to make the best of it for now.