# The Stargate Switch

### Dana C. Ernst

http://danaernst.com

#### FAMUS

February 1, 2013

Note: Just use your arrow keys to advance the slides. Also, you can get an overview of the slides by typing "m" or go to a specific slide by typing "g".

## Stargate

• Stargate is an adventure military science fiction franchise.
• The first film in the franchise was simply titled Stargate and was released in October, 1994
• Stargate productions center on the premise of a "Stargate", a circular device that creates a wormhole, enabling instantaneous transportation to another stargate located many light years away from the starting point.
• Stargate SG-1 is a television show is based on the 1994 film Stargate. The series premiered in July, 1997, and the final episode aired in March, 2007.
• With 214 episodes over 10 seasons, Stargate SG-1 had surpassed The X-Files as the longest-running North American science fiction television series, a record later broken by Smallville.
• The story of Stargate SG-1 begins about a year after the events of the feature film. SG-1 is an elite Air Force special forces squad, one of more than two dozen teams from Earth who explore the galaxy and defend against alien threats.

## Stargate SG-1, "Holiday", Season 2

• "Holiday" is a 1999 episode from season 2 of Stargate SG-1.
• In the episode, the character Ma'chello tricks Daniel into swapping minds with him. In an attempt to save Daniel, Jack and Teal'c accidentally swap minds.
• They then discover a limitation: the machine will not work more than once on the same pair of bodies.
• This is the same limitation suffered by the mind-switching machine in Futurama's 2010 episode "The Prisoner of Benda".
• Physicist Samantha Carter saves the day by improvising a sequence of 4 switches that brings everyone back to normal.

## The Stargate Switch Problem

Here are the swaps that take place during the episode:

• Ma'chello $\leftrightarrow$ Daniel
• Jack $\leftrightarrow$ Teal'c

The question is:

Can the machine be used to put everyone's mind back in the proper body if we are not allowed to use the machine on the same pair of bodies more than once?

## The Generalized Stargate Switch

• Suppose we have $m$ pairs of bodies, where each pair swaps minds.
• Can the machine be used to put everyone's mind back in the proper body if we are not allowed to use the machine on the same pair of bodies more than once?
• If so, what is the minimal number of "moves" required to put everyone's mind back where it belongs?

### Note

This is not as general as the problem posed in Futurama. In that case, we needed to introduce outsiders to solve the problem. But here we can solve the problem without outsiders (as long as we have at least 2 pairs of bodies).

Let's use some math!

## The symmetric group

We can model this problem in terms of permutations (i.e., rearrangements) of numbers. It turns out that the set of all permutations of the numbers 1 through $n$ forms a "group" under composition.

A group is a set with an associative binary operation satisfying:

• #### closure:

the "product" of any two elements from the set is an element of the set.
• #### identity:

there exists a "do nothing" element.
• #### inverses:

for every element in the set, there exists another element in the set that "undoes" the original.

The group of permutations of $\{1,2,\ldots, n\}$ is called the symmetric group and is denoted by $S_n$.

## Permutation diagrams

One way of representing an element of the symmetric group is via permutation diagrams, which we illustrate by way of example.

## Permutation diagrams (continued)

Let's try multiplying.

### Example

Let $\alpha$ and $\beta$ be as on previous slide. Then

But on the other hand

We see that products of permutations do not necessarily commute (order matters).

• Sometimes order matters (but not always).
• A diagram that swaps precisely two numbers is called a transposition.
• $S_n$ is generated by the transpositions. That is, every permutation can be written as a product of some sequence of transpositions. (In fact, we only need the adjacent transpositions: $i$ swaps with $i+1$).

## Cycle Notation

We need to introduce a more efficient way of encoding our permutations. One such method is called cycle notation.

## Cycle Notation (continued)

Let's try multiplying using cycle notation. Note: We will multiply right to left (like function composition).

### Example

Consider $\alpha$ and $\beta$ in $S_{5}$ as in the previous examples. Then

$\alpha \beta=(1, 2, 3, 4, 5)(2, 4, 3)=(1, 2, 5).$

• The interpretation of a transposition $(i, j)$ is that the body numbered $i$ and the body numbered $j$ swap minds.
• In cycle notation, the original Stargate Switch permutation can be written as $\sigma=(1, 2)(3, 4),$ where 1 is Ma'chello, 2 is Daniel, 3 is Jack, and 4 is Teal'c.
• The Generalized Stargate Switch permutation is of the form $\sigma=(1, 2)(3, 4)\cdots (2m-1, 2m).$
• To solve the problem, we must produce a product $\mu$ of distinct transpositions, none equaling a factor of $\sigma$, such that the permutation $\mu\sigma$ is the identity in $S_{2m}$.

## Solution to Original Stargate Switch

Evans and Huang from the University of California, San Diego recently proved the following theorem. [arXiv]

### Theorem

The following permutation solves the original Stargate Switch Problem.

$\mu=(2, 4)(1, 3)(2, 3)(1, 4)$

Moreover, this solution is optimal in the sense that no solution with fewer than 4 moves will work.

## Proof for Original Stargate Switch

### Proof

First, easy to check that $\mu\sigma$ yields the identity:

$\mu\sigma=(2, 4)(1, 3)(2, 3)(1, 4)\circ (1,2)(3,4)=\text{identity permutation}$

Why is $\mu$ optimal? Well, it's easy to check that 2 transpositions (not reusing the originals and only using $1,2,3,4$) won't work. The reason why $\mu$ cannot only have 3 cycles is because of a general fact that says that the identity permutation cannot be equal to a product of an odd number of transpositions (sometimes called the Parity Theorem).

## Solution to Generalized Stargate Switch

Evans and Huang also proved the following more general theorem. [arXiv]

### Theorem

Let $m>1$. Then the Generalized Stargate Switch permutation $\sigma=(1, 2)(3, 4)\cdots (2m-1, 2m)$ can be undone by a product $\mu$ of $N(m)$ distinct transpositions, where for $j=4i$ $\mu=\begin{cases}\tau \prod_{i=2}^{(m-1)/2} (j, j+2)(j-1, j+1)(j, j+1)(j-1, j+2), & \text{if }m\text{ is odd}\\ \prod_{i=1}^{m/2}(j-1, j)(j-3, j-1)(j-2, j-1)(j-3, j), & \text{if }m\text{ is even}\end{cases}$ with $\tau=(1,3)(1,6)(4,5)(4,6)(3,5)(2,5)(1,5).$ and $N(m)=\begin{cases}2m+1, & \text{if }m\text{ is odd (and greater than 1),}\\ 2m, & \text{if }m\text{ is even.}\end{cases}$ (The empty product for $m=3$ is interpreted as the identity permutation.) Moreover, $N(m)$ is optimal.

## Examples of Solutions

The previous formula looks pretty scary, but it's not too bad.

### Example

When $m=3$, we have

$\mu= \tau=(1,3)(1,6)(4,5)(4,6)(3,5)(2,5)(1,5),$

which consists of $N(3)=7$ transpositions.

When $m=4$, we have

$\mu=(2,4)(1,3)(2,3)(1,4)(6,8)(5,7)(6,7)(5,8),$

which consists of $N(4)=8$ transpositions.

I utilized the Wikipedia entries for both Stargate and Stargate SG-1.

If you'd like to know more, check out the following papers:

• Evans, R., & Huang, L. (2012). The Stargate Switch. [arXiv]
• Evans, R., & Huang, L. (2012). Mind switches in Futurama and Stargate. [arXiv]
• Evans, R., Huang, L., & Nguyen, T. (2012). Keeler’s Theorem and products of disjoint transpositions. [arXiv]

You might also be interested in one of my recent talks about the Futurama Theorem.

These slides were made using deck.js and MathJax. In addition, I modified Christian Perfect's deck.js template and made use of Jason B. Hill's pdiag package to create the permutation diagrams.

/

#