You are on page 1of 38

Introduction Perfect Faro Shuffles Generalize!

Bibliography

Card Shuffles and Group Theory

Cristopher Cuevas
Jorge Flores
Jesús Liceaga

Universidad de Guanajuato

December 8th , 2021

1 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Magic Tricks

Suppose we have a card deck and a magician appears from out of


nowhere and mixes our cards.

• Where are the aces?


• Heart shuffling.

How do these tricks work? What is their relationship with algebra?

2 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations

• The term card deck means a finite collection of objects, called


cards, all of them recursively placed one on top of the other.
• We call any rearrangement of a card deck a card shuffle.
• Assume a standard 52-card deck. Label the cards from 0 to 51.
• Since a card shuffle neither adds nor subtracts any card from
the deck, we can think of it as a 1-1 mapping of the card deck
onto itself.
• We define the set of all card shuffles as the symmetric group
of degree 52, namely S52 .
• So, σ ∈ S52 is a 1-1 correspondence given by

σ : {0, 1, . . . , 51} −→ {0, 1, . . . , 51}.

3 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations


Some ways of ordering a labelled card deck may be studied for
practical purposes.

Definition (Top-in-at shuffle)


A top-in-at shuffle is a card shuffle consisting of placing the first
top-down card below one of the remaining cards. In other words, a
permutation σi ∈ S52 of the form
 
0 1 ··· i i + 1 · · · 51
σi = .
i 0 · · · i − 1 i + 1 · · · 51

6 7 8 9 10 J Q 7 8 9 10 J Q
4 5 K 5 6 K
3 4 JOK
ER
2 3
ER A 2
JOK
65432A
987
σ13 A
98765432A
ER
JOK
J 10 J 10
KQ KKERQ
JO

4 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations


A more sophisticated technique is defined by parity-wise
composition of top-in-at shuffles. We will call cut a proper subset
of a standard 52-card deck containing more than one element.

Definition (Mongean shuffle)


A Mongean shuffle is a card shuffle consisting of placing the cut of
odd indices in decreasing order on top of the the one of even
indices in increasing order. In other words, a permutation
σMong ∈ S52 of the form
 
0 1 2 3 · · · 48 49 50 51
σMong = .
25 24 26 23 · · · 50 1 51 0
6 7 8 9 10 J Q A JOKER 2 4 6 8
4 5 K 5 3 10 Q
3 7
2 9
A J
JOK
ER
65432A
σMong K
2 JOKEAR 3 5 7 9 J K
JOK 987 64
ER J 10 10 8
KQ Q

5 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations


By the end of the 19th century, in some areas of Mexico there was
devised a card shuffle as a protective method from con men
arriving from the United States.

Definition (Mexican spiral shuffle)


A Mexican spiral shuffle is a card shuffle consisting of placing the
cut of even indices in decreasing order on top of the one of odd
indices in increasing order. In other words, a permutation
σMex ∈ S52 of the form
 
0 1 2 3 · · · 48 49 50 51
σMex = .
26 27 25 28 · · · 1 50 0 51
6 7 8 9 10 J Q JOKER A 3 5 7 9
4 5 K 4 2 J
K
3 6
2 8
ER A 10
JOK
65432A
987
σMex Q
Q
2 4 6 8 10 JOKER
53A
JOK
ER J 10 97
KQ KJ

6 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations

Let us call shuffling image the resulting deck after completion of a


card shuffle. A shuffling image thereon is said to be interleaved if,
for some cut of size t, there exists at least one card of index k ≥ t
such that σ(k) < t.
Moreover, we say a card shuffle is order preserving if r < r ′ for
r , r ′ < t implies σ(r ) < σ(r ′ ) and s < s ′ for s, s ′ ≥ t implies
σ(s) < σ(s ′ ).
Casino dealers popularized shuffles satisfying these conditions.
They split a card deck into two decks in order to interleave them
by dropping the cards in a fancy irregular pattern.

7 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations

Definition (Riffle shuffle)


A riffle shuffle, denoted σRif ∈ S52 , consists of a cut of size t and
an order preserving card shuffle such that the shuffling image is
interleaved.

6 7 8 9 10 J Q 10 3 4 5 J 6 Q
4 5 K 9 2 K
3 8
2 A
ER A ER 7
JOK
65432A
987
σRif JOK

4 3 10 2 9 8 A 7 JO 5
JOK
ER J 10 KER
6J
KQ KQ

For if we have a 5-card deck and a cut of size 2, then


 
0 1 2 3 4
σ=
0 2 1 3 4

represents a riffle shuffle.


8 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations

In addition, so are
     
0 1 2 3 4 0 1 2 3 4 0 1 2 3 4
, and .
0 3 1 2 4 2 4 0 1 3 1 3 0 2 4

9 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Card Shuffles and Permutations


It is indeed possible to restore the order of a card deck after a riffle
shuffle. Therein lies the concept of inverse riffle shuffles.

Definition (Inverse riffle shuffle)


Let σRif ∈ S52 be a riffle shuffle. The inverse riffle shuffle
∗ ∈S
σRif 52 corresponding to σRif is a riffle shuffle such that
∗ σ
σRif σRif Rif = σRif .

10 3 4 5 J 6 Q 6 7 8 9 10 J Q
9 2 K 4 5 K
8 3
A 2
JOK
ER 7 ∗
σRif JOK
ER A
4 3 10 2 9 8 A 7 JO 5 JOK
65432A
987
KER
6J ER J 10
KQ KQ

We would like now to focus our efforts in riffle shuffles on a card


deck of even size, but whose shuffling image is perfectly
interleaved.
10 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Perfect Shuffles

The perfect faro shuffle is a shuffling method that has been widely
used for magic tricks, and cheating in gambling.

Definition 2.1
A perfect n-faro shuffle consists of an order preserving card shuffle
and a cut of size n such that the first n cards are interlaced with
the next n cards by repeatedly placing the top card from one half
below the top one from the other half.

Note that there exist two types of perfect shuffles, depending of


the cut that corresponds to the first card we have after shuffling.

11 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Out Perfect Shuffles

The first perfect shuffle is called Out shuffle.

Definition 2.2
A perfect shuffle that leaves the top card in the top. This is, the
first card we take is from the first cut. We will denote an out
shuffle of a card deck of 2n cards as O2n .

12 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Example 2.1
Consider a deck of size 6 and label the cards from 0 to 5. Applying
O6 reorders the cards in the following way
5 5
3 4 4 2
2 A
JOK
A
ER
JOK
3
ER

OKE
5 4 3 2 AJ O6 OKE
52 4 A3J
R R

Thus,  
0 1 2 3 4 5
O6 = .
0 2 4 1 3 5

13 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

In Perfect Shuffles

The second type of perfect shuffle is called In shuffle.

Definition 2.3
A perfect shuffle that leaves the top card in the second position.
This is, the first card we take is from the second cut. We will
denote an in shuffle of a card deck of 2n cards as I2n .

14 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Example 2.2
Consider a deck of size 6 and label the cards from 0 to 5. Applying
I6 reorders the cards in the following way:
5 5
3 4 4 2
2 JOKE
R A
JOK
A
ER
3
R
OKE
5 4 3 2 AJ I6 5 2 4 A JOK3
ER

Thus,  
0 1 2 3 4 5
I6 = .
1 3 5 0 2 4

15 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Properties of perfect shuffles

The following proposition shows that we can describe exactly


where do the in and out shuffles send each card of a deck.

Proposition 2.1
Consider a deck with 2n cards and take i ∈ {0, . . . , 2n − 1}. Then
(
(2i + 1) mod 2n if 0 ≤ i < n
I2n (i) =
2i mod (2n) if n ≤ i < 2n

(
2i mod (2n) if 0 ≤ i < n
O2n (i) =
(2i + 1) mod 2n if n ≤ i < 2n

16 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Properties of perfect shuffles

Since I2n and O2n are elements of S2n , they have a finite order. To
compute it, the following Proposition is often useful.

Proposition 2.2
The order of I2n is the order of [2]2n+1 and the order of O2n is the
order of [2]2n−1 .

It turns out that the order of [2]51 is just 8. This number is even
lower for other deck sizes: for 16 cards we only need 3 out shuffles!

17 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Moving cards with perfect shuffles

Now that we know what are the perfect shuffles, one can ask if
there is an efficient way to “move” a card from a position of the
deck to another using only these type of shuffle. Before tackling the
problem for in and out shuffles, we will solve it for other functions,
and we will see how we can use this for achieving our goal.

Remark (Binary expansion of a non negative integer).


Let x ∈ Z≥0 . There exist unique, x1 , x2 , . . . , xk ∈ {0, 1} such that

x = x1 · 2k−1 + x2 · 2k−2 + · · · + xk · 20 .

We will write x = (x1 x2 . . . xk )2 to represent this binary expansion.

18 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Let D(x) = 2x, E (x) = 2x + 1 and note that, if x = (x1 x2 . . . xk )2 ,


then

D(x) = (x1 x2 . . . xk 0)2 , E (x) = (x1 x2 . . . xk 1)2 .

Now, we construct a binary tree with root 0, which will reflect all
the possible sequences of compositions of D and E applied to 0.
Moving down the tree, a step to the left indicates the application
of D, and a step to the right indicates E . By our former
observation, it is clear that we can arrive to all integers from 0
applying only D and E .

19 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

The following figure shows the tree upon 3 functions are applied.
As an example, 0 is sent to 4 by applying E followed by two D’s.

0
D E

0 1
D E D E

0 1 2 3
D E D E D E D E

0 1 2 3 4 5 6 7

20 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

• It can be shown by induction that the integers that appear on


the row of the tree that is t steps from the root are the
consecutive integers 0 through 2t − 1.
• If j appears on the t-th level of this tree, then the path from
the root labeled 0 to that vertex labeled j is revealed by the
t-digit in base two representation of j. If j = (j1 j2 . . . jt )2 , then
the sequence F1 , F2 , . . . , Ft moves 0 to j, where
(
D if jk = 0,
Fk =
E if jk = 1.

21 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

• Note that, if we extend the former tree, a binary tree with


root i ∈ Z≥0 appears as a subtree. Moreover, on the subtree
with root at i, the t-th level down from the root consists of
the consecutive integers D t (i) = 2t i through
E t (i) = 2t (i + 1) − 1. If j appears on the t-th level down from
the root of this subtree, then the path from the root labeled i
to that vertex labeled j is revealed by the t-digit base-two
representation of j − D t (i).
• Now, consider the functions Em (x) = (2x + 1) mod 2n,
Dm (x) = 2x mod 2n and let i, j ∈ Z2n . Recall that we can
find a path that sends i to j applying only Dm and Em
multiple times, since applying ⌈log2 (2n)⌉ times Dm results on
0, and from 0 we can arrive to any number between 0 and
2n − 1 in a similar way we did with D and E .

22 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

• If n is large, constructing the tree rooted at i until we find j


could be time-consuming, but it turns out that it is not
neccesary to construct all of it: first, construct the two
outermost paths of the tree Dm (i), Dm 2 (i), . . . , D t (i) and
m
Em (i), Em (i), . . . , Em (i) until j ∈ [Dm (i), Emt (i)]. Then, it can
2 t t

be shown that the base two representation of (j − Dm t (i))

mód 2n = ξ = (ξ1 ξ2 . . . ξt )2 determines the sequence


F1 , F2 , . . . , Ft of functions that we should apply to obtain j,
where (
Dm if ξk = 0,
Fk =
Em if ξk = 1.

Example 2.3
Find the shortest possible sequence of compositions of the
functions Dm and Em that takes i = 6 to j = 47 in Z52 .

23 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

We construct the outermost paths of the tree rooted at 6:

Note that j = 47 falls in the interval [44, 7] in Z52 . Hence, we had


to apply our functions 4 times to obtain an interval that contains j.
Recall that (j − Dm4 (i)) mód 52 = (47 − 44) mód 52 = 3, which

in base two, considering four digits, is 0011. This means we have


two apply the sequence Dm , Dm , Em , Em to take i = 6 to j = 47.

24 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Indeed, we check that

• Now that we know how to go from i to j applying only Dm


and Em , we are almost done. By Proposition 2.1, it follows
that
(
Em (i) if 0 ≤ i < n
I2n (i) =
Dm (i) if n ≤ i < 2n
(
Dm (i) if 0 ≤ i < n
O2n (i) =
Em (i) if n ≤ i < 2n
• From here, Example 2.3 tells us a path to obtain 47 from 6
using in and out shuffles:

25 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

All of this illustrates the following theorem, that we state without


proof.
Theorem 2.1
Label the positions in a deck of 2n cards, 0 through 2n − 1
consecutively with 0 representing the top position. To determine
the shortest possible sequence of (in/out) perfect shuffles that will
move the card in position i to position j follow the next steps

1. Calculate the sequences Dm (i), Dm 2 (i), . . . , D t (i) and


m
2 t
Em (i), Em (i), . . . , Em (i) until j ∈ [Dmt (i), E t (i)].
m
2. Let s = (j − Dmt (i)) mód 2n and write s as a t-digit number

in base two s = (s1 s2 . . . st )2 (here the 0’s at the left matter).

26 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

3. Read the digits of s from left to right applying Fk with


(
Dm if sk = 0,
Fk =
Em if sk = 1.

4. Make the translation Dm = O if Dm is being applied to an


integer in [0, n − 1] and Dm = I if applied to an integer in
[n, 2n − 1]. Similarly, Em = I in [0, n − 1] and Em = O in
[n, 2n − 1]. The resulting sequence of (In/out) perfect shuffles
moves the card in position i to the position j.

This algorithm has a logarithmic complexity.

27 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Classifying ⟨I2n , O2n ⟩

• Now that we have studied some properties of in an out


shuffles, it is worth asking which elements of S2n can be
obtained using only combination of these shuffles.
• Given a positive integer 2n, can we determine if a permutation
will be in ⟨I2n , O2n ⟩?
• Can we determine the structure of ⟨I2n , O2n ⟩ for all positive
integers n?

28 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Outer Semidirect products

Given two groups N, H with a certain relationship determined by a


morphism φ, one can construct a new group called the outer
semidirect product.
Definition 3.1
Let N and H be groups, and suppose that φ : H −→ Aut(N) is a
morphism, which sends elements h ∈ H to automorphisms
φ(h) : N −→ N. Then G := N ⋊φ H is defined as the set of
ordered pairs {(n, h) : n ∈ N, h ∈ H} with the operation
· : G × G −→ G given by

(n, h) · (n1 , h1 ) = (nφh (n1 ), hh1 ).

One can show that this G is in fact a group.

29 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Example 3.1
Let N, H two groups and φ : H −→ Aut(N) the trivial morphism.
This is, φh is the identity automorphism of N for all h ∈ H. Then,
N ⋊φ H is just the direct product N × H.

Example 3.2
Take Zk2 , Zk and let θ : Zk −→ Aut(Zk2 ) such that θ[i]k = ri , where
ri : Zk2 −→ Z2k is given by

ri (a0 , . . . , ak−1 ) = (ai ′ , . . . , ak−1 , a0 , . . . , ai ′ −1 )

for all (a1 , . . . , ak ) ∈ Zk2 , where i ′ is the smaller non-negative


representative of [i]k . One can prove that θ is a well-defined
morphism. Thus, Zk2 ⋊θ Zk is a group.

30 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Centrally symmetric permutations

Definition 3.2
Let S2n be the symmetric group defined over the set
{0, . . . , 2n − 1}. We say that a permutation σ ∈ S2n is centrally
symmetric if, for all i ∈ {0, . . . , 2n − 1},

σ(i) + σ(2i − 1 − i) = 2i − 1.

31 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Example 3.3
 
0 1 2 3 4 5
σ= .
2 4 0 5 1 3

5 3
3 4 5 A
JOKER
2
JOK
A
ER 4
2
OKE
R
5 4 3 2 AJ σ 3 A 5 JOK4E 2
R

32 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Proposition 3.1
Let Bn the set of centrally symmetric permutations of S2n . Then
Bn is a subgroup of S2n .

• I2n and O2n are always centrally symmetric permutations.


• Thus, ⟨I2n , O2n ⟩ is a subgroup of Bn .

33 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Sign functions

Now, we need to introduce 3 morphisms from Bn to {1, −1}.

• Since Bn is a subgroup of S2n , we can define


sgn : Bn −→ {1, −1} in the usual way, which is a morphism.
• We will also define another sign morphism
sgn : Bn −→ {1, −1}.
• As the product of morphisms which codomain is an abelian
group is a morphism, sgn sgn will be also a morphism.

34 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Proposition 3.2
Let φ : Bn −→ Sn such that φ(σ) = σ, where
(
σ(i), if σ(i) ≤ n − 1,
σ(i) =
2n − 1 − σ(i), if σ ≥ n,

for i ∈ {0, . . . , n − 1}.


Then φ is a well defined morphism.

Definition 3.3
Let sgn : Bn −→ {1, −1} such that sgn = sgn ◦φ, where φ is the
morphism of proposition 4.2.

Since the composition of morphisms is a morphism, sgn is a


morphism.

35 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Example 3.4
Let us calculate sgn(σ), where σ is the permutation from example
4.4.    
0 1 2 3 4 5 0 1 2
σ= =⇒ σ = .
2 4 0 5 1 3 2 1 0
Since σ = (0 2), which is a transposition, sgn(σ) = −1, from
where sgn(σ) = −1.

36 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Theorem. (Diaconis, Graham, Kantor)


Let n be a positive integer and G = ⟨I2n , O2n ⟩.
1. If n ≡ 0 mod 4, n > 12 and n is not a power of 2, then
G = ker(sgn) ∩ ker(sgn).
2. If n ≡ 1 mod 4, then G = ker(sgn).
3. If n ≡ 2 mod 4 and n > 6, then G = Bn .
4. If n ≡ 3 mod 4, then G = ker(sgn sgn).
5. If 2n = 2k for k ∈ Z≥0 , then G is isomorphic to Zk2 ⋊θ Zk ,
where θ is the morphism of example 4.2.
6. If n = 6, then G is isomorphic to Z62 ⋊φ1 S5 .
7. If n = 12, then G is isomorphic to Z11
2 ⋊φ2 M12 , where M12 is
the Mathieu group of degree 12.

37 / 38
Introduction Perfect Faro Shuffles Generalize! Bibliography

Bibliography

1. J. Tsai. Group Theory, Card Shuffling and Magic. The Gift of


Maths. Consult here.
2. P. Diaconis, R.L Graham, W.M Kantor. The mathematics of
perfect shuffles. (1983). Advances in applied mathematics.
Consult here.
3. S. Medvedoff, K. Morrison. Groups of Perfect Shuffles.
(1987). Mathematics Magazine. Consult here.
4. S. Ramnath, D. Scully. Moving Card i to Position j with
Perfect Shuffles. (1996). Mathematics Magazine. Consult
here.
5. C. Amarra et al., Generalised shuffle groups. (2021). Israel
Journal of mathematics. Consult here.

38 / 38

You might also like