BABYL OPTIONS: -*- rmail -*-
Version: 5
Labels:
Note:   This is the header of an rmail file.
Note:   If you are seeing it in rmail,
Note:    it means the file has no messages in it.

1,,
Mail-from: From karger@theory.lcs.mit.edu Wed Feb  9 11:17:56 2000
Received: from ibis.lcs.mit.edu (ibis.lcs.mit.edu [18.52.0.190])
	by theory.lcs.mit.edu (8.9.1/8.9.1) with ESMTP id LAA06474
	for <lynch@theory.lcs.mit.edu>; Wed, 9 Feb 2000 11:17:55 -0500 (EST)
Received: (from karger@localhost)
	by ibis.lcs.mit.edu (8.9.3/8.9.3) id LAA02005;
	Wed, 9 Feb 2000 11:21:22 -0500 (EST)
Date: Wed, 9 Feb 2000 11:21:22 -0500 (EST)
Message-Id: <200002091621.LAA02005@ibis.lcs.mit.edu>
From: "David R. Karger" <karger@theory.lcs.mit.edu>
To: lynch@theory.lcs.mit.edu
Subject: nim noets

*** EOOH ***
Date: Wed, 9 Feb 2000 11:21:22 -0500 (EST)
From: "David R. Karger" <karger@theory.lcs.mit.edu>
To: lynch@theory.lcs.mit.edu
Subject: nim noets



\subsection{Nim}

The game of Nim is defined as follows:  Some positive number of sticks are 
placed
on the ground.  Two players take turns removing one, two, or three
sticks.  The player to remove the last stick loses.

\begin{theorem}
The first player loses if the number of sticks, $n$, is $4k+1$ for some $k$,
and wins (if he plays optimally) otherwise.
\end{theorem}

We can formalize this by defining a strategy as a rule for how many
sticks to remove when there are $n$ left.  We then show that if $n=4k+1$, 
then player 2 has a strategy that will force a win for him, otherwise, 
player 1 has a strategy that will force a win for him.

\begin{proof}
By strong induction.  Suppose the theorem is true for numbers less than $n$,
show that it is true for $n$.  So we want to show that if $n=4k+1$ then first 
player loses, otherwise if $n = 4k$, $4k + 2$, or $4k + 3$, then the 
first player wins. 
(We'll see later why this exhausts all possible cases for $n$)

There are four cases: 
\begin{itemize}
\item $n=4k+1$: show that the first player loses.  

Base case: $n = 1$. The first player has no choice but to
remove $1$ stick and lose. \\

Case $n\ne 1$, so $n \geq 5$. \\

Consider what the first player might do to win:  he can choose to remove 1, 2 
or 3 sticks. 

If he removes one stick, the remaining number of sticks is $n-1 = 4k$.  \\
By strong induction, the player who plays at this point should win. \\
so the player who played first will lose. \\

Similarly, if the first player removes two sticks, the remainding amount is
$4(k-1)+3$. He, again, loses by the same reasoning.  \\

And again by removing $3$ sticks, he loses.  \\

So however the first player moves, he loses.

\item $n = 4k$: show that the first player can win.

Have first player remove 3 sticks: the second player then sees $4(k-1)+1$ 
sticks, and loses, by the strong inductive hypothesis.

\item 
$n = 4k+2$: show that the first player can win.

Similar to the previous case when the first player removes one stick. 

\item
$n=4k+3$: show that the first player can win.

Again similar to the previous case when the first player removes two sticks. 

\end{itemize}
>From the division algorithm that we'll see later, we know these are all
the possible cases.
\end{proof}

