leios / SoME_Topics

Collaboration / Topic requests for SoME
Other
212 stars 6 forks source link

You could solve Rubik's cube yourself (if you know some group theory...) #161

Open Lior-Yanovski opened 2 years ago

Lior-Yanovski commented 2 years ago

About the author

I am a professional mathematician. I also enjoy teaching math at any level and have a lot of experience doing that, but I have never produced any expository content besides a written paper or a talk.

Quick Summary

As the title says, I want to create a video about "how you could solve Rubik's cube yourself". That is, a video that would explain in a simple and fun way how to solve Rubik's cube using only several elementary observations from group theory, without any "black boxes" such as random-looking sequences of moves that you need to memorize. Moreover, the video will present the solution as an outcome of a natural systematic analysis of the problem giving the audience a feeling that they could actually come up with it themselves had they put their mind to it. Along the way, some elementary group theory regarding permutations, their parity, and cycle decomposition is explored. (To clarify, I have a specific solution in mind which is sketched below).

Target medium

I am imagining an animated video with some illustrations of cube configurations and text/formulas floating around and a narrator explaining what's going on. I am not sure what technical skills are required to produce such a video and I am also open to other ideas.

Personal story

As a child, I grew up in the former soviet union and had a small Rubik's cube among my toys. I never got beyond solving "one layer" and gave up pretty quickly. I also had a sort of encyclopedia of random topics (morse code, military ranks, measurement units, flags, astronomical maps etc) and it had a small section on Rubik's cube from which the only thing I remember is the claim that "some abstract mathematical methods can be used to produce a solution". It was beyond me at that time what could such "mathematical methods" look like. About 15 years later, in the summer after my second year of undergrad math studies, my parents were moving and asked me to help them sort out the stuff in the garage. There I found the long-forgotten small soviet Rubik's cube again and took it with me. I was never a Rubik's cube enthusiast and never learned or cared much about solving it, but having done the "group theory" class, it suddenly felt like something I can do by myself. I spent the next week sitting on the couch playing with the cube gradually gathering enough insights to be able to completely solve it. The first solution took about 20 minutes to execute, but with further refinements, I was able to get it down to about 2 minutes without rushing or practicing any quick rotation techniques. It is by no means considered "fast" by speedcubers' standards, but it has the advantage of being completely transparent and reconstructable by pure logic without having to memorize anything. I am not aware of any resource on the web, which presents such a solution and so I would like to share it with others. In addition, I think it is a nice way to introduce basic ideas from group theory in an accessible and fun manner.

Solution sketch

I will now describe in broad terms the key steps/ideas in the solution I have in mind, and which I want the video to present. Of course, the full explanation will have to be more didactical and the following only serves as a rough outline. In particular, I will assume familiarity with the basic theory of permutations and be a bit vague regarding the last steps as it is somewhat tedious to explain in writing (hence the need for a video!).

  1. How to think about the problem: there are 54 = 9 x 6 small colored squares that need to be arranged so that every face of the cube is monochromatic. However, the squares do not move independently and can't assume arbitrary positions. Thus, it is better to think about the small cubes to which the small squares are attached. These fall into 3 categories: the 8 corners (with three squares each), the 12 edges (with 2 squares each), and the 6 face centers (with 1 square each). The cubes in each of the categories can only be permuted among themselves, but they also have an "orientation" (i.e. can be rotated/flipped). As for the moves, instead of rotating the middle layer a quarter turn CW, we can rotate the two outer layers a quarter turn CCW, which produces the same result up to rotating the entire cube. Thus, if we allow only rotations of the outer layers, we have fixed the face centers (and hence, the face colors), so we can concentrate only on the 'corners' and 'edges'.

  2. Divide and conquer: A common strategy in solving problems of this kind is t do it "in steps". The particular strategy I will describe is "position first then orientation" and "edges first then corners". Namely, it first puts the edges in the correct position (but maybe flipped) without caring about the corners. Then, puts the corners in the correct position (but maybe rotated) without moving the edges. Then flips the edges into the correct orientation without moving anything, but perhaps rotating the corners and finally, rotates the corners into the correct orientation without messing up anything and thus, solving the puzzle.

  3. Legal configurations: One can easily check that a "legal" (i.e. solvable) configuration has certain constraints. The permutation of the edges must be even and so is the permutation of the corners. In addition, once the edges and corners are in place, the number of wrong flipped edges must be even and the mod 3 total rotation of the corners must be zero as well.

  4. The 'commutator trick': The difficulty in implementing the above strategy is that every move mixes a lot of things, so it is hard to generate the desired effect (say, rotating two corners) without messing about the rest of the configuration. A natural idea is to use the commutator of two basic moves. So, considering two adjacent faces, let A denote the rotation of the first a quarter turn CW and let B denote the rotation of the other a quarter turn CCW. Had A and B commuted (AB = BA), the operation C= ABA^-1B^-1 would do nothing. But, A and B do not commute so C does something. The interesting point is that it mixes up surprisingly few things - only those which are affected by both A and B. Examining what C does, we get that it permutes cyclicly 3 edges and swaps two pairs of corners.

  5. Positioning the edges: Every even permutation can be written as a product of cycles of length 3. So by using the operation C from before that cyclicly permutes 3 edges (around a given corner) with various pairs of adjacent faces, we can achieve the first step of our program - putting the edges into their correct position.

  6. Positioning the corners: using the fact that the order of C as a permutation of the edges is 3, and the order of it as a permutation of the corners is 2, we get that D= C^3 does not move the edges, but swaps two pairs of corners. Since every even permutation can be written as a product of pairs of swaps (this is one possible definition of an 'even permutation'), we can, as before, use the various operations D to position the corners correctly without moving the edges, so we accomplish the second step of our program - everything is in place but maybe flipped/rotated.

  7. Flipping/rotation. At this final step, we need to look closer at the operation C. That is, not only how it permutes the edges/corners but also how it flips/rotates them. To be somewhat vague about it, it does not do "the same thing" to all the 3 permuted edges. The key new idea needed is that the same cyclic permutation of the 3 edges surrounding a given corner can be obtained with the commutator of any of the 2 out of 3 faces touching it. Let's call them C1, C2, and C3. Performing all of them, that is E = C1C2C3, does not move the edges at all. But it turns out to flip exactly two of them. Similarly, E does not move the corners at all (since the product of all the three non-trivial elements in the Klein 4 group is trivial), but it gives a 1/3 turn rotation to exactly 3 of them. The operation E can be used to flip all the edges into their correct orientations without moving anything and using the same idea of relatively prime orders from before, the operation E^3 can be used to rotate the corners into the correct orientation without messing up anything and hence solving the puzzle.

  8. Streamlining: The resulting algorithm can be executed by hand in a "reasonable time" but is quite tedious since it requires, for example, decomposing arbitrary even permutations into products of 3-cycles and so on. With just a little more effort, mainly by cleverly conjugating the above operations, one can produce a much more streamlined layer-by-layer algorithm that can be easily implemented in just about 2-3 minutes.

Contact details

You can contact me at lior.yanovski@gmail.com.

alexei-kopylov commented 2 years ago

Minor comment. You said:

The permutation of the edges must be even and so is the permutation of the corners.

I heard this before, but it is not true. The permutation of corners could be odd. Only the permutation of both corners and edges together must be even (i.e. the permutation of corners must have the same parity as the permutation of edges).

Lior-Yanovski commented 2 years ago

Ah. You are right of course. A quarter-turn of an outer layer is a cyclic permutation of 4 corners (and the same for edges) and hence is odd. Nevertheless, up to a quarter-turn, one can arrange things so that one needs to apply only an even permutation to the edges and an even permutation to the corners. Thanks for the correction!

szabolcsdombi commented 2 years ago

Hi, I am interested contributing to this. I could make the rendering for the cube or make it interactive for recording purposes (not web).

Here is a preview what I can make:

rubiks-cubes

You can find the code here

The cube is generated programatically and rendered with Python and ZenGL The smallest piece was modelled with blender and instanced rendering takes care of the rest. The pieces are rotated with quaternions.

Lior-Yanovski commented 2 years ago

That's really nice! Would you be interested in taking part in producing the actual video as well?

szabolcsdombi commented 2 years ago

I also share my personal story with the Rubik's cube.

When I got my first color screen phone I had an app that allowed me to paint the cube and produce me a solution. I just had to carefully do a turn, tap on the > key to see the next one. This allowed me to start from a solved cube and explore patterns. I found simple move pairs that produced some sort of patterns. I also figured out if I mess up the cube with a pair I just have to continue with it until it gives back my solved cube. I was very young at that time.

I tried to keep the cube in two hands without rotating it, mostly manipulating only 2 or 3 sides to not to loose track of what am I doing.

cube-1

And it turned out even ones that looks like ruining the solved cube, at some point, only make a small change. These had a "very long road back to the solved cube"

cube-2

By following the moves from my phone. I found out it solves the cube in less moves if I pre-solve the white face. Also I learned a trick to solve the second layer by moving out one corner and moving it back in with a the other hand. (this may sound complex but it was a trivial 4-move applied twice)

after ruining the solved cube a couple of times, i have noticed if I fix a single missing edge it "shuffles" the last layer. So i kept applying something similar to shuffle the last layer (expecting to solve the cube at some point)

cube-3

It did not solve the cube for sure, but together with the "few edges swap" or "few corners swap" method i got really close...

when I encountered the "two corners rotated" i just broke the last layer with the shuffle as I had no pattern for that.

This resulted in tedious long work for solving the cube.

The "two rotated corners" bothered me that much that I typed it into my phone and learned the moves the computer generate. it took me a lot of time to learn that 18-move because all my previous patterns relied on not rotating the entire cube and just required a few layers and counting.

I did this for the rest of the patterns and learned to solve the cube with way less guesswork and moves.

I had no access to the internet, i was in 5th grade or similar, my phone was a k700i or w550 (actually i think my second phone had the rubiks cube program on it) it looked like this:

image

szabolcsdombi commented 2 years ago

I am only interested in the rendering/animating part. I never made a video with my voice or face, I doubt the first one would be a success so I think someone else should do it.

Lior-Yanovski commented 2 years ago

Thanks for sharing your story :) As a side note, with the observations that I would like to put in the video, one can produce a 24-move sequence for rotating two corners. This is one of the improvements to the basic strategy that I mentioned above. It might find its way in as a bonus...

I can be in charge of the content and perhaps even make a storyboard and I think you would do a great job at the animation part, but as I also never made a video myself, we should probably team up with someone with experience and expertise in that.

TebelMeners commented 2 years ago

Hi, I am a 10 grade student interested in pure math. I am currently preparing for competitions. Group Theory sounds very interesting to me. I would really like working and learning with you and it will help me a lot in topic relating to combinatorics, because that's where I am weakest at.

Jatin-exe commented 2 years ago

I 'm intrested in contriubting for this, have you guys started ?

Lior-Yanovski commented 2 years ago

Great. We started a little bit but would be happy to have someone to join in. Which part would you be interested in contributing to? We have some animation examples and a partial draft of the narrative. We mainly need someone with video editing skills (neither of us ever made a video), but another pair of hands to make the animations would be helpful as well.

Jatin-exe commented 2 years ago

Ye, I can do video editing and might also help in the animation part

Lior-Yanovski commented 2 years ago

That sounds perfect. I sent you an invite on discord.