%%
%% This is file `flagderiv.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% flagderiv.dtx  (with options: `flagderiv')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2005 by Paul van Tilburg <paul@luon.net>
%% 
%% This package is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation; either version 2 of the License, or
%% (at your option) any later version.
%% 
%% This package is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%% GNU General Public License for more details.
%% 
%% You should have received a copy of the GNU General Public License
%% along with this package; if not, write to the Free Software
%% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{flagderiv}
    [2005/08/26 v0.10 Flag style derivation package]
\RequirePackage{ifthen}
\newboolean{@inlcmnts}
\DeclareOption{inlcmnts}{\setboolean{@inlcmnts}{true}}
\ProcessOptions
\RequirePackage{array}
\RequirePackage{longtable}
\long\@namedef{NC@rewrite@*}#1#2{%
   \count@#1\relax
   \loop
   \ifnum\count@>\z@
   \advance\count@\m@ne
   \@temptokena\expandafter{\the\@temptokena#2}%
   \repeat
   \NC@find}
\newcounter{fd@flagcount}
\newcounter{fd@stepcount}
\newlength{\derivskip}
\setlength{\derivskip}{8pt}
\newcommand{\introsymb}{\textbf{var}}
\newcommand{\thestepcount}{(\arabic{fd@stepcount})}
\renewcommand{\thefd@stepcount}{\thestepcount}
\newcommand{\thesteplabel}[1]{#1}
\newcommand{\theinlcmnt}[1]{\{ #1 \}}
\newcommand{\inlcmnts}{\setboolean{@inlcmnts}{true}}
\newcommand{\noinlcmnts}{\setboolean{@inlcmnts}{false}}
\newcommand{\@labelprefix}{\relax}
\newcommand{\@derlabel}[1]{%
  \ifthenelse{\equal{#1}{}}{}{\label{\@labelprefix#1}}%
}
\newcommand{\@derline}[3]{%
 \mbox{#1} &
 \setlength{\extrarowheight}{\derivskip}%
 \ifthenelse{\value{fd@flagcount}=0}%
 {\begin{array}[t]{@{}l}}%
 {\begin{array}[t]{*{\value{fd@flagcount}}{|@{\hspace{2\arraycolsep}}}l}}
  \ensuremath{#2}
 \end{array} &
 \mbox{#3} \\
}
\newcommand{\@CMNTderline}[3]{%
 \ifthenelse{\boolean{@inlcmnts}}{%
  \ifthenelse{\equal{#3}{}}{}{%
   \@derline{}{\mbox{\theinlcmnt{#3}}}{}%
  }
  \@derline{#1}{#2}{}%
 }{%
  \@derline{#1}{#2}{#3}%
 }%
}
\newcommand{\@MANstep}[3]{\@CMNTderline{\thesteplabel{#1}}{#2}{#3}}
\newcommand{\@AUTOstep}[3]{%
 \refstepcounter{fd@stepcount}%
 \@derlabel{#1}\@CMNTderline{\thestepcount}{#2}{#3}%
}
\newcommand{\@MANskipsteps}[2]{\@CMNTderline{}{#1}{#2}}
\newcommand{\@AUTOskipsteps}[3]{%
 \addtocounter{fd@stepcount}{#1}%
 \@CMNTderline{}{#2}{#3}%
}
\newcommand{\@flagbox}[1]{%
 \setlength{\fboxsep}{0.75ex}%
 \fbox{#1}%
}
\newcommand{\@startflag}[3]{%
 \@CMNTderline{#1}{\@flagbox{\ensuremath{#2}}}{#3}%
 \addtocounter{fd@flagcount}{1}%
}
\newcommand{\@endflag}[1]{\addtocounter{fd@flagcount}{-#1}}
\newcommand{\@flagclose}[1][1]{\@endflag{#1}}
\newcommand{\@MANassume}[3]{\@startflag{\thesteplabel{#1}}{#2}{#3}}
\newcommand{\@AUTOassume}[3]{
 \refstepcounter{fd@stepcount}%
 \@derlabel{#1}\@startflag{\thestepcount}{#2}{#3}%
}
\newcommand{\@MANintroduction}[3]{%
  \@startflag{\thesteplabel{#1}}{\introsymb~#2}{#3}%
}
\newcommand{\@AUTOintroduction}[3]{
  \refstepcounter{fd@stepcount}%
  \@derlabel{#1}\@startflag{\thestepcount}{\introsymb~#2}{#3}%
}
\newcommand{\@MANconclude}[4][1]{\@endflag{#1}\step*{#2}{#3}{#4}}
\newcommand{\@AUTOconclude}[4][1]{\@endflag{#1}\step{#2}{#3}{#4}}
\newenvironment{flagderiv}[1][]{%
 \ifthenelse{\equal{#1}{}}{%
  \renewcommand{\@labelprefix}{}%
 }{%
  \renewcommand{\@labelprefix}{#1:}%
 }%
 \setcounter{fd@flagcount}{0}%
 \setcounter{fd@stepcount}{0}%
 \newcommand{\assume}{\@ifstar{\@MANassume}{\@AUTOassume}}
 \newcommand{\introduce}{\@ifstar{\@MANintroduction}{\@AUTOintroduction}}
 \newcommand{\conclude}{\@ifstar{\@MANconclude}{\@AUTOconclude}}
 \newcommand{\step}{\@ifstar{\@MANstep}{\@AUTOstep}}
 \newcommand{\skipsteps}{\@ifstar{\@MANskipsteps}{\@AUTOskipsteps}}
 \newcommand{\done}{\@flagclose}
 \let\origref\ref%
 \renewcommand{\ref}[1]{\origref{\@labelprefix##1}}%
 \renewcommand{\tablename}{Derivation}%
 \begin{longtable}[l]{rll}
}{%
 \end{longtable}
}
\newenvironment{flagderiv*}[1][]{%
 \ifthenelse{\equal{#1}{}}{%
  \renewcommand{\@labelprefix}{}%
 }{%
  \renewcommand{\@labelprefix}{#1:}%
 }%
 \setcounter{fd@flagcount}{0}%
 \setcounter{fd@stepcount}{0}%
 \newcommand{\assume}{\@ifstar{\@MANassume}{\@AUTOassume}}
 \newcommand{\introduce}{\@ifstar{\@MANintroduction}{\@AUTOintroduction}}
 \newcommand{\conclude}{\@ifstar{\@MANconclude}{\@AUTOconclude}}
 \newcommand{\step}{\@ifstar{\@MANstep}{\@AUTOstep}}
 \newcommand{\skipsteps}{\@ifstar{\@MANskipsteps}{\@AUTOskipsteps}}
 \newcommand{\done}{\@flagclose}
 \let\origref\ref%
 \renewcommand{\ref}[1]{\origref{\@labelprefix##1}}%
 \renewcommand{\tablename}{Derivation}
 \begin{tabular}{rll}
}{%
 \end{tabular}
}
\endinput
%%
%% End of file `flagderiv.sty'.
