\newif\ifpdf
\ifx\pdfoutput\undefined
  \pdffalse
\else
  \pdfoutput=1 \pdfcompresslevel=9
  \pdftrue
\fi
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{psfig}
\ifpdf
\RequirePackage[colorlinks,bookmarksopen,pdfpagemode=UseOutlines,pdfstartview=FitBH,linkcolor=blue,citecolor=blue,urlcolor=blue,backref,pagebackref]{hyperref}
\fi
\RequirePackage{graphics}
\RequirePackage[pdflatex]{graphicx}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Page format commands

\newcommand{\lectureformat}{
\setlength{\parindent}{0in}                     % Paragraph Indentation
\setlength{\parskip}{\medskipamount}          % Interparagraph Spacing
}

\hoffset        = -1.0 in
\voffset        = -1.0 in

\paperheight    = 11.0 in
\paperwidth     =  8.5 in

\topmargin      = 0.75 in
\headheight     = \baselineskip
\headsep        = \baselineskip
\footskip       = 0.75 in
\textheight     = \paperheight
\addtolength{\textheight}{-\topmargin}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}

\textwidth      = \paperwidth
\oddsidemargin  = 1.0 in
\evensidemargin = 1.0 in
\addtolength{\textwidth}{-\oddsidemargin}
\addtolength{\textwidth}{-\evensidemargin}

\linewidth      = \textwidth

\newcommand{\printlayout}{%
  \typeout{----------------------- LaTeX Page Layout Parameters}
  \typeout{\string\paperwidth\space\space\the\paperwidth}
  \typeout{\string\paperheight\space\the\paperheight}
  \typeout{\string\textwidth\space\space\the\textwidth}
  \typeout{\string\textheight\space\the\textheight}
  \typeout{\string\oddsidemargin\space\space\the\oddsidemargin}
  \typeout{\string\evensidemargin\space\the\evensidemargin}
  \typeout{\string\topmargin\space\space\the\topmargin}
  \typeout{\string\headheight\space\the\headheight}
  \typeout{\string\headsep\space\the\headsep}
  \typeout{\string\footskip\space\space\space\the\footskip}
  \typeout{\string\marginparwidth\space\the\marginparwidth}
  \typeout{\string\marginparsep\space\space\space\the\marginparsep}
  \typeout{\string\hoffset\space\the\hoffset}
  \typeout{\string\voffset\space\the\voffset}
  \typeout{(1in=72.27pt, 1cm=28.45pt)}
  \typeout{-----------------------------------------}%
}

\renewcommand{\thepage}{\arabic{page}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif\iflecture \lecturetrue
\newif\ifonly    \onlyfalse
\newif\ifslides  \slidesfalse

\def\onlylecture{   \lecturetrue  \onlytrue \lectureformat}
\def\mainlylecture{ \lecturetrue  \onlyfalse \lectureformat}
\def\onlystudents{  \lecturefalse \onlytrue}
\def\mainlystudents{\lecturefalse \onlyfalse}

\def\newl{\iflecture\\\fi}
\def\.{.\newl}
\def\?{?\newl}
\def\!{!\newl}

\newcommand{\forlecture}[1]{%
  \iflecture {#1} \else \ifonly \else {\scriptsize #1} \fi \fi}

\newcommand{\forstudents}[2][{}]{
\iflecture {#1} \ifonly {} \else {{\bf \\ Students:} \scriptsize #2} \fi
\else {#2}
\fi
}
\let\forstudent\forstudents


% David Jones suggestions:
% The problem is that the catcodes of characters inside of macro bodies
% are set when the macro definition is scanned.  So, you have to arrange
% for . after the \let to be active when the macro is defined.
%    \def\PERIOD{.\\}
%    {
%        \catcode`\.=\active
%        \gdef\breakper{%
%            \catcode`\.=\active
%            \let.\PERIOD
%        }
%    }
\let\PERIOD=.
\let\QUEST=?
\let\EXCLAIM=!
{
  \catcode`\.=\active
  \catcode`\?=\active
  \catcode`\!=\active
  \gdef\breakper{%
    \iflecture
    \catcode`\.=\active
    \catcode`\?=\active
    \catcode`\!=\active
    \def.{\PERIOD\ifhmode\smallskip\\\fi}
    \def?{\QUEST\ifhmode\smallskip\\\fi}
    \def!{\EXCLAIM\ifhmode\smallskip\\\fi}
    \fi
  }
}

\newenvironment{breakperiods}{%
\breakper
}{%
\catcode`\.=12
\catcode`\?=12
\catcode`\!=12
}

\newenvironment{nobreakperiods}{%
\catcode`\.=12
\catcode`\?=12
\catcode`\!=12
}{}

\newenvironment{Figure}{%
\begin{nobreakperiods}\begin{figure}}{%
\end{figure}\end{nobreakperiods}}

\providecommand{\ie}{\textit{i.e.}}
\providecommand{\eg}{\textit{e.g.}}
\providecommand{\Eg}{\textit{E.g.}}
\providecommand{\Ie}{\textit{I.e.}}


%%
%% Theorem-type environments
%%
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{falsethm}[theorem]{False Theorem}
\newtheorem{rul}[theorem]{Rule}
\newtheorem{falseclm}[theorem]{False Claim}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem*{theorem*}{Theorem}
\newtheorem*{lemma*}{Lemma}
\newtheorem*{corollary*}{Corollary}
\newtheorem*{claim*}{Claim}
\newtheorem*{xample*}{Example}
\newtheorem*{falsethm*}{False Theorem}
\newtheorem*{rul*}{Rule}
\newtheorem*{falseclm*}{False Claim}
\newtheorem*{proposition*}{Proposition}
\theoremstyle{definition}
\newtheorem{defin}[theorem]{Definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{axiom}[theorem]{Axiom}
\newtheorem{xample}[theorem]{Example}
\newtheorem{example}[theorem]{Example}
\newtheorem*{defin*}{Definition}
\newtheorem*{definition*}{Definition}
\newtheorem*{fact*}{Fact}
\newtheorem*{axiom*}{Axiom}
\newtheorem*{example*}{Example}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem*{remark*}{Remark}
\renewcommand{\qedsymbol}{\vrule height .9ex width .9ex depth 0ex\relax}

\newcommand{\thm}{\begin{theorem}}
\newcommand{\ethm}{\end{theorem}}
\newcommand{\lem}{\begin{lemma}}
\newcommand{\elem}{\end{lemma}}
\newcommand{\pf}{\begin{proof}}
\newcommand{\epf}{\end{proof}}
\newcommand{\defn}[1]{\begin{definition}#1\end{definition}}
\let\defi\defn



%%
%% Better-looking captions
%%
\newlength\captionindent
\setlength\captionindent{\leftmargini}
\def\onecaptflag{268 }
\long\def\@makecaption#1#2{\let\@tempa\relax
  {\advance\leftskip\captionindent
   \advance\rightskip\captionindent
   \ifdim\prevdepth>-99\p@ \vskip\abovecaptionskip \relax 
   \else \def\@tempa{\vbox to\topskip{}}\fi
   \footnotesize{\bfseries #1.} \@tempa \vadjust{\penalty \onecaptflag}#2\par
   \ifnum\lastpenalty=\onecaptflag
      \unpenalty \setbox\@tempboxa\lastbox
      \nointerlineskip
      \hbox to\hsize{\hskip\parfillskip\unhbox\@tempboxa}%
   \fi \vskip\belowcaptionskip}}



\newcommand{\makeslides}{
\slidestrue
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\topmargin}{0.5in}
\setlength{\textheight}{7.5in}
\setlength{\textwidth}{10in}
\def\section{}
\def\subsection{}
\def\subsubsection{}
\output={\setbox8=\box255}
}


\newenvironment{overhead}{
\begin{overhead*}{\small}
}{
\end{overhead*}
}

% Usage: \begin{overhead*}[lecture notes header]{overhead header}
\newenvironment{overhead*}[2][]{
\ifslides
\newpage
\normalsize
\output={}
\begin{slide}
#2
\else
#1
\fi
}{
\ifslides
\end{slide}
\newpage
\output={\setbox8=\box255}
\fi
}

\newlength{\prooflength}
\newlength{\reasonlength}

\newcommand{\structuredproof}[2][0pt]{
%first pass: measure
\def\noreason{\kill}
\def\reason##1{}
\settowidth{\prooflength}{
\begin{minipage}{5in}
\begin{tabbing}
XXX\=XXX\=XXX\=XX\=XX\=XX\=X\=X\=\kill
#2
\end{tabbing}
\end{minipage}
}
%compute constants
\setlength{\reasonlength}{\textwidth}
\addtolength{\reasonlength}{-\prooflength}
\addtolength{\reasonlength}{-3em}

\ifdim#1=0pt  \else \setlength{\reasonlength}{#1} \fi
%second pass: build
\def\noreason{}
\def\reason##1{\`\makebox[\reasonlength][l]{##1}}
\begin{tabbing}
XXX\=XXX\=XXX\=XXX\=XXX\=XXX\=XXX\=XXX\=\kill
#2
\end{tabbing}
}
%end definition of \structuredproof


\newenvironment{structproof}{
\begin{tabbing}
\ifslides
XXX\=XXX\=XXX\=XX\=XXXXXXXXXXXXXXXX\=    \kill
\else
XXX\=XXX\=XXX\=XX\=XXXXXXXXXXXXXXXXXXXXX\=    \kill
\fi
}{
\end{tabbing}
}


\newenvironment{proofoverhead}{
\begin{overhead}
\begin{structproof}
}{
\end{structproof}
\end{overhead}
}


\newcommand{\reading}[1]{\noindent {\bf Reading:} #1\\ \\}
\long\def\comment#1{}

%%  Formatting changes made at ARM's request. -- dmj, 2/21/96


\def\@listI{\leftmargin\leftmargini \parsep 5pt plus 2.5pt minus 1pt%
\topsep 10pt plus 4pt minus 6pt%
\itemsep \z@}

\let\@listi\@listI
\@listi

%%%%%From Nancy's book directory:  This spaces the symbols within a
%%%%%word nicely, in math mode. 

\newcommand{\ms}[1]{%
        \relax\ifmmode
                \mathord{\mathcode`\-="702D\it #1\mathcode`\-="2200}%
        \else
                $\mathord{\mathcode`\-="702D\it #1\mathcode`\-="2200}$%
        \fi
}

\newcommand{\remove}[1]{}

%%%%%%%%found in /pub/ftp/pub/classes/6.042/handouts/H07-aeqn.tex

\let\fortext\ensuremath
\def\z3{\fortext{\integers_{3}}}
\def\ltecom{\fortext{\sqsubseteq}}
\DeclareMathOperator*{\lcm}{lcm}
\newcommand{\subst}[3]{#1[#2 := #3]}
\let\union\cup

\newcommand{\aeval}[2]{{\it val}(#1,#2)}
\newcommand{\mean}[1]{\llbracket#1\rrbracket}
\newcommand{\provable}{\fortext{\vdash}}
\newcommand{\notprovable}{\fortext{\not\vdash}}
\newcommand{\can}[1]{\mbox{canon}(#1)}

\newcommand{\notmodels}{\fortext{\not\models}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Cross-references for handout numbers.
\input{lecture-numbers}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%        SPRING 01:
\newcommand{\coursenumber}{6.042J/18.062J}
\newcommand{\coursetitle}{Mathematics for Computer Science}
\newcommand{\courseprofessors}{Professor David Karger and Dr. Lars Engebretsen}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newlength{\toppush}
\setlength{\toppush}{2\headheight}
\addtolength{\toppush}{\headsep}

%       Usage: \htitle{lecturenumber}{title}{dateout}
\newcommand{\htitle}[3]{\noindent\vspace*{-\toppush}\newline\parbox{6.5in}
{Massachusetts Institute of Technology \hfill Lecture #1 \newline
\coursenumber : \coursetitle \hfill #3 \newline
\courseprofessors\hfill\vspace*{-.5ex} \newline
\mbox{}\hrulefill\mbox{}}\vspace*{1ex}\mbox{}\newline
\bigskip
\begin{center}{\Large\bf #2}\end{center}
\bigskip}

%       Usage: \lecture{refname}{title}{dateout}
\newcommand{\lecture}[3]{
 \ifslides \else
 \thispagestyle{empty}
 \global\@topnum\z@   % Prevents figures from going at top of page.
 \markboth{Lecture \hlabelref{#1}: #2}{Lecture \hlabelref{#1}: #2}
 \pagestyle{myheadings}
 \htitle{\hlabelref{#1}}{#2}{#3}
\fi
}

\newcommand{\htitlewithouttitle}[2]{\noindent\vspace*{-\toppush}\newline\parbox{6.5in}{\coursenumber : \coursetitle
\hfill Massachusetts Institute of Technology\newline
Lecture #1\hfill#2\vspace*{-.5ex}\newline
\mbox{}\hrulefill\mbox{}}\vspace*{1ex}\mbox{}\newline}

\newcommand{\lecturewithouttitle}[2]{\thispagestyle{empty}
 \markboth{Lecture \hlabelref{#1}: #2}{Lecture \hlabelref{#1}: #2}
 \pagestyle{myheadings}%
 \htitlewithouttitle{\hlabelref{#1}}{#2}}

% Create the header for problem sets and solutions.
% Usage: \Pset{<problem-set-number>}{<out-date>}{<due-date>}
%        \Psol{<problem-set-number>}{<out-date>}
%


\newcommand{\examtitle}[2]{\noindent\vspace*{-\toppush}\newline\parbox{6.5in}
{Massachusetts Institute of Technology
\hfill #1\newline
\coursenumber : \coursetitle\hfill#2\newline
\courseprofessors\hfill\vspace*{-.5ex}
\newline
\mbox{}\hrulefill\mbox{}}\vspace*{1ex}\mbox{}\newline
\begin{center}{\Large\bf #1}\end{center}}

\newcommand{\points}[1]{\hspace{3pt}[#1 points]\hspace{8pt}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\For}{{\bf for} }
\newcommand{\To}{{\bf to} }
\newcommand{\By}{{\bf by} }
\newcommand{\Downto}{{\bf downto} }
\newcommand{\While}{{\bf while} }
\newcommand{\Repeat}{\>\>{\bf repeat}\'}
\newcommand{\Until}{\>\>{\bf until}\'}
\newcommand{\If}{{\bf if} }
\newcommand{\Then}{\>{\bf then}\>}
\newcommand{\Else}{\>{\bf else}\>}
\newcommand{\ElseIf}{{\bf elseif} }
\newcommand{\ElseNoIf}{{\bf else} }
\newcommand{\Do}{\>\>{\bf do}\'}
\newcommand{\Return}{{\bf return} }
\newcommand{\Comment}{$\!\rhd$ }
\newcommand{\Inparallel}{{\bf in parallel} }    %This should be flushed
\newcommand{\Goto}{{\bf goto} }
\newcommand{\Error}{{\bf error} } % optionally followed by string argument

%\renewcommand{\cases}[1]{\left\{ \begin{array}{ll}#1\end{array}\right.}
\newcommand{\cif}[1]{\mbox{if $#1$}}
\newcommand{\cwhen}[1]{\mbox{when $#1$}}

%%%     oral, written, and no prefix commands added late 1/94 BDT
%%%     \pnumset sets the problem counter. added 2/2/94 BDT

\newcommand{\pnumset}[1]
  {\setcounter{problemnum}{#1}\addtocounter{problemnum}{-1}}
\newcounter{problemnum}

%% \theproblem changed at ARM's request. -- dmj, 2/21/96

%\newcommand{\theproblem}{Problem \oralwrit\theproblemsetnum-\arabic{problemnum}}

\newcommand{\theproblem}{Problem~\arabic{problemnum}}

\newcommand{\noprefix}{}
\newcommand{\oralprefix}{O}
\newcommand{\writprefix}{W}
\newenvironment{problems}{
        \begin{list}{{\bf \theproblem. \hspace*{0.5em}}}
        {\setlength{\leftmargin}{0em}
         \setlength{\rightmargin}{0em}
         \setlength{\labelwidth}{0em}
         \setlength{\itemsep}{.3in}
%        \setlength{\labelsep}{0em}
%%  
%%  Added to make problem numbering consecutive, per ARM's request. --
%%  dmj, 2/21/96
%%  
         \count@=\c@problemnum
         \usecounter{problemnum}%
         \setcounter{problemnum}{\count@}%
        }}{\end{list}}

\newcommand{\problem}{\let\oralwrit=\noprefix
       \item \let\@currentlabel=\theproblem}
\newcommand{\oproblem}{\let\oralwrit=\oralprefix
       \item \let\@currentlabel=\theproblem}
\newcommand{\wproblem}{\let\oralwrit=\writprefix
       \item \let\@currentlabel=\theproblem}

\newcounter{problempartnum}[problemnum]
\newenvironment{problemparts}{
        \begin{list}{{\bf (\alph{problempartnum})}}
        {\setlength{\leftmargin}{2.5em}
         \setlength{\rightmargin}{2.5em}
         \setlength{\labelsep}{0.5em}}}{\end{list}}
\newenvironment{testproblemparts}{
        \begin{list}{{\bf (\alph{problempartnum})}}
        {\setlength{\leftmargin}{2.5em}
         \setlength{\rightmargin}{2.5em}
         \setlength{\itemsep}{2in}      
         \setlength{\labelsep}{0.5em}}}{\end{list}}
\newcommand{\problempart}{\addtocounter{problempartnum}{1}\item}
\newcommand{\bparts}{\begin{problemparts}}
\newcommand{\eparts}{\end{problemparts}}
\newcommand{\ppart}{\problempart}

\newcounter{exercisenum}
\newcommand{\theexercise}{Exercise \theproblemsetnum-\arabic{exercisenum}}
\newenvironment{exercises}{
        \begin{list}{{\bf \theexercise. \hspace*{0.5em}}}
        {\setlength{\leftmargin}{0em}
         \setlength{\rightmargin}{0em}
         \setlength{\labelwidth}{0em}
         \setlength{\labelsep}{0em}
        \usecounter{exercisenum}}}{\end{list}}
\newcommand{\exercise}{\item \let\@currentlabel=\theexercise}

\newcounter{exercisepartnum}[exercisenum]
%\newcommand{\problem}[1]{\medskip\mbox{}\newline\noindent{\bf Problem #1.}\hspace*{1em}}
%\newcommand{\exercise}[1]{\medskip\mbox{}\newline\noindent{\bf Exercise #1.}\hspace*{1em}}

\newenvironment{exerciseparts}{
        \begin{list}{{\bf (\alph{exercisepartnum})}}
        {\setlength{\leftmargin}{2.5em}
         \setlength{\rightmargin}{2.5em}
         \setlength{\labelsep}{0.5em}}}{\end{list}}
\newcommand{\exercisepart}{\addtocounter{exercisepartnum}{1}\item}



\newlength{\savearraycolsep}
\newcommand{\narrowarray}[1]{\setlength{\savearraycolsep}{\arraycolsep}\setlength{\arraycolsep}{#1\arraycolsep}}
\newcommand{\normalarray}{\setlength{\arraycolsep}{\savearraycolsep}}

\newcommand{\hint}{{\em Hint:\ }}


% macros from clrmac.tex inserted by mb

\def\@startline{\global\@curtabmar\@nxttabmar\relax
   \global\@curtab\@curtabmar\setbox\@curline\hbox
    {}\@startfield\global\lifalse\strut}

% Macros from /th/u/clr/mac.tex

\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\abs}[1]{\left| #1\right|}
\newcommand{\card}[1]{\left| #1\right|}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil}
\newcommand{\paren}[1]{\left( #1 \right)}
\newcommand{\ang}[1]{\ifmmode{\left\langle #1 \right\rangle}
   \else{$\left\langle${#1}$\right\rangle$}\fi}
        % the \if allows use outside mathmode,
        % but will swallow following space there!
\newcommand{\prob}[1]{\Pr\left\{ #1 \right\}}
\newcommand{\Var}{\mathop{\rm Var}\nolimits}
\newcommand{\expect}[1]{{\rm E}\left[ #1 \right]}
\newcommand{\expectsq}[1]{{\rm E}^2\left[ #1 \right]}
\newcommand{\variance}[1]{{\rm Var}\left[ #1 \right]}
\newcommand{\Ex}{E}

%%%I like the old choose! BDT 1/28/94
%\renewcommand{\choose}[2]{{{#1}\atopwithdelims(){#2}}}
\newcommand{\Choose}[2]{{{#1}\atopwithdelims(){#2}}}

\def\pmod#1{\allowbreak\mkern12mu({\rm mod}\,\,#1)}
\newcommand{\matx}[2]{\left(\begin{array}{*{#1}{c}}#2\end{array}\right)}
\newcommand{\Adj}{\mathop{\rm Adj}\nolimits}

\newcommand{\eqnref}[1]{(\protect\ref{#1})}

\newcommand{\twodots}{\mathinner{\ldotp\ldotp}}

\newcommand{\const}[1]{\ifmmode\mathord{\mathcode`-="702D\sc #1\mathcode`\-="2200}\else$\mathord{\mathcode`-="702D\sc #1\mathcode`\-="2200}$\fi}

%\newcommand{\ckt}[1]{\ifmmode\mathord{\mathcode`-="702D\sc #1\mathcode`\-="2200}\else$\mathord{\mathcode`-="702D\sc #1\mathcode`\-="2200}$\fi}
\newcommand{\ckt}[1]{\ifmmode \sc #1\else$\sc #1$\fi}
\newcommand{\id}[1]{\mbox{\it #1}}
\newcommand{\proc}[1]{%
\ifmmode\mathord{\mathcode`-="702D\sc#1\mathcode`\-="2200}\else{\sc#1}\fi}
\newcommand{\procdecl}[1]{\proc{#1}\vrule width0pt height0pt depth 7pt \relax}
\newcommand{\func}[1]{\ifmmode\mathop{\mathcode`-="702D\rm #1\mathcode`\-="2200}\nolimits\else$\mathop{\mathcode`-="702D\rm #1\mathcode`\-="2200}\nolimits$\fi}

\newif\ifcodeinbox

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The Code environment %%%

%% The following commands are so we can automatically number and symbolically reference
%% lines.
%% The ``codelinenumber'' counter counts the current line number
\newcounter{codelinenumber}
%% The \zeroli command zeros the line number counter
\newcommand{\zeroli}{\setcounter{codelinenumber}0}
%% The \li command bumps the counter, outputs it, and skips some space
%% It also GLOBALLY sets the value of \@currentlabel, so that the \label
%% commands on the same line work OK.  The problem otherwise is that Latex
%% uses groups on each field of a line in tabbing mode, and this causes
%% \@currentlabel to get reset as soon as a field ends (e.g. at the \').
%% Now, the label can appear after the \\, as in
%%      \li \>\>$x\gets y$ \\ \label{li:assign-x}
%%

\def\@startline{\global\@curtabmar\@nxttabmar\relax
   \global\@curtab\@curtabmar\setbox\@curline\hbox
    {}\@startfield\global\lifalse\strut}

\newenvironment{code}{\global\codeinboxtrue%
\setbox\strutbox\hbox{\vrule height 9pt depth 4pt width0pt}%
\noindent\begin{tabbing}%
\zeroli\setlength{\tabbingsep}{1em}
\hspace*{1em}\=999\ifdoubledigit9\fi
\=\ {\bf if} \={\bf then} \={\bf if} \={\bf then}
        \={\bf if} \={\bf then} \={\bf if} \={\bf then} \={\bf if} \={\bf then}
        \={\bf if} \=\+\+\kill}{\end{tabbing}\global\codeinboxfalse}

\newif\ifdoubledigit
\newcommand{\codebox}[1]{\setbox0=\vbox{\begin{code}#1\end{code}}
\ifnum\c@codelinenumber>9\global\doubledigittrue\else\doubledigitfalse\fi
\vskip1sp\noindent\hskip-14pt%% 
\parbox{\textwidth}{\begin{code}\protect#1\end{code}}\global\let\@currentlabel=\thechapter}

\newif\ifli
\newcommand{\li}{\global\litrue\stepcounter{codelinenumber}%
\ifdoubledigit%
\hbox to8pt{\hss\thecodelinenumber\hskip5pt}\else%
\hbox to8pt{\hskip-1pt\thecodelinenumber\hss}\fi%
\xdef\@currentlabel{\p@codelinenumber\thecodelinenumber}\'}

\newcommand{\marnote}[1]{\marginpar{\raggedright{\footnotesize #1}}\ignorespaces}

\providecommand{\reals}{\mathbb{R}}
\providecommand{\ints}{\mathbb{Z}}
\providecommand{\integers}{\mathbb{Z}}
\providecommand{\naturals}{\mathbb{N}}
\providecommand{\nat}{\naturals}
\providecommand{\nats}{\naturals}
\providecommand{\rationals}{\mathbb{Q}}
\providecommand{\complex}{\mathbb{C}}
\providecommand{\complexes}{\mathbb{C}}
\providecommand{\given}{\mid}
\providecommand{\from}{\colon}
\providecommand{\power}{\mathcal{P}}
\renewcommand{\bar}[1]{\overline{#1}}

\newcommand{\w}{\omega}                 %% for fft chapter

%\newcommand{\implies}{\Rightarrow}     %% already defined in amstex
%\newcommand{\remove}[1]{}
\newcommand{\divides}{\mid}  %% No, it's not!
%\newcommand{\mod}[1]{(\mbox{mod } #1)}

\newenvironment{closeitemize}{\begin{list}%
{$\bullet$}%
{\setlength{\itemsep}{-0.2\baselineskip}%
\setlength{\topsep}{0.2\baselineskip}}}%
{\end{list}}


\long\gdef\boxit#1{\dimen200 = \hsize \advance\dimen200 by -7pt
\begingroup\vbox{\hrule \hbox to \hsize{\vrule\kern3pt
      \vbox{\hsize \dimen200 \kern3pt#1\kern3pt}\hfil \kern3pt\vrule}\hrule}\endgroup}
 
\newlength{\myfigwidth}
\setlength{\myfigwidth}{\columnwidth}
\addtolength{\myfigwidth}{-2ex}  %made this wider -- CS

\newcommand{\boxtext}[1]{\setlength{\myfigwidth}{\columnwidth}\addtolength{\myfigwidth}{-2ex}\boxit{\vspace*{.1ex}\begin{minipage}{\myfigwidth}#1\end{minipage}\\[.1ex]}}


% Local Variables: 
% mode: latex
% TeX-master: t
% End: 
