It is the first known theorem to be created for the sole purpose of entertainment in a TV show, and, according to Keeler, was included to popularize math among young people.

The theorem proves that, regardless of how many mind switches between two bodies have been made, they can still all be restored to their original bodies using only two extra people, provided these two people have not had any mind switches prior (assuming two people cannot switch minds back with each other after their original switch).

Contents

Background

In the episode "The Prisoner of Benda", Professor Farnsworth and Amy create a mind-switching machine, only to afterwards realise that when two people have switched minds, they can never switch back with each other. Throughout the episode, the Professor and the Globetrotters try to find a way to solve the problem using two or more additional bodies, and, in the end, the solution is shown both in action and on the board.

However, this is not the fewest number of switches possible in this scenario. Because Fry and Zoidberg only switched with each other and no one else, and there is an odd number (1) of other switched groups of bodies, they could have been used as the two spare bodies, completing the restoration in only nine switches:

Had there been an even number of distinct switched groups, Fry's mind and Zoidberg's mind would have ended up back in the opposite bodies, and having already switched, they could not be switched back without two spare bodies. The solution given in the theorem works for all scenarios.

It is also not necessary for Clyde and Bubblegum (or Fry and Zoidberg) to take turns so often in the machine; it is only convenient for the presentation.

NOW let π be an ARBITRARY permutation on [n]. It consists of disjoint (nontrivial) cycles and each can be inverted as above in sequence after which x and y can be switched if necessary via <x,y>, as was desired.

Solution algorithm in plain English

Step 1: Have everybody who's messed up arrange themselves in circles of "conga lines", i.e. everyone's front facing someone's back, each facing the body their mind should land in (e.g., if Fry's mind is in Zoidberg's body, then the Zoidberg body should face the back of Fry's body).

Step 2: Go get two "fresh" (as of yet never mind-swapped) people. Let's call them Helper A and Helper B.

Step 3: Fix the circles one by one as follows:

3.0) Start each time with Helper A and Helper B's minds in either their own or each other's bodies

3.1) Pick any circle of messed-up people you like and unwrap it into a line with whoever you like at the front

3.2) Swap the mind at the front of the line into Helper A's body

3.3) From back to front, have everybody in the line swap minds with Helper B's body in turn. (This moves each mind in the line, apart from the front one, forward into the right body. The last switch puts Helper A's mind into Helper B's body.)

3.4) Swap the mind in Helper A's body back where it belongs, into the body at the back of the line. This puts Helper B's mind in Helper A's body. Now the circle/line has been completely fixed. The one side effect is that for each time a circle is fixed, the Helpers' minds will switch places, but that's OK, see below

Step 4: At the very end, after all the circles have been fixed, mind-swap the two Helpers if necessary (i.e., in case there was originally an odd number of messed-up circles)

Note: This is not the exact algorithm used in the show. This algorithm sets i = 1 in the proof provided by the show, whereas you could actually set i to be any number from 1 to k. This algorithm also reverses the order of the final two switches in the provided proof. Explained simply, the provided proof's exact method for fixing any circle is this: Helper A could switch in turn back-to-front, stopping at any point in the circle. Then Helper B would switch back-to-front through the remainder of the circle, Helper A would then switch with the first member of Helper B's arc, and Helper B would then switch with the first member of Helper A's arc.