% \newfont{\mmk}{cmr6} % For gremlin size 8

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMMANDS FOR COMMENTING, REMINDERS, EATING TEXT etc.
%    \eat{..}: 
%	Useful for temporarily removing text from the output.
%    \comment{..}:
%    \inlinecomment{..}:
%    \reminder{..}:  
%	This is a very useful command.  It adds the argument as inline text
%	delimited by [[ .. ]].  It creates an arrow in the right margin
%	which makes it very easy to locate reminders.  Can be redefined to
%	eat up reminders when creating a version of the paper for
%	distribution.
%    \fullversion{..}:
%%%%%%%%%%

\newcommand{\eat}[1]{}
% \newenvironment{comment}{\noindent \begin{footnotesize} \{{\bf Comment:}}{\}\end{footnotesize}}

\newcommand{\comment}[1]{\noindent \begin{footnotesize} {\bf Comment:} #1 \end{footnotesize}\\}

\newcommand{\inlinecomment}[1]{\begin{quotation} [[[ #1 ]]] \end{quotation}}
\newcommand{\reminder}[1]{ [[[ \marginpar{\mbox{$<==$}} #1 ]]] }
\newcommand{\eatreminders}[0]{\renewcommand{\reminder}[1]{}}
\newcommand{\fullversion}[1]{ }


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   The following commands can be changed to alter several 
%	commands/environments defined in this file 
%
%  \noBox:
%     	The \condBox command is used in several environments below, such as
%     	propositions to generate a box at the end of the environment.  
%     	If you don't want a box be generated, insert the command
%     	\noBox within the desired environment.  You can even add it to the
%     	beginning of the document for it to have a global effect.
%
%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\condBox}{{\raggedleft \mbox{$ \Box $}}}
\newcommand{\noBox}{\renewcommand{\condBox}{}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SPACE CRUNCHING COMMANDS
%  \crunchspace: 
%	use small font in several environments (to find out in which
%	look for uses of \crunchbegin and \crunchend
%  \spcrunch:
%	Eats vertical space.
%  \sections:
%  \subsections:
%  \subsubsections:
%  \subsubsubsections:
%	The above four commands eat vertical space around section names.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\spcrunch}{\vspace{-0.15in}}

\newcommand{\topseplen}{0ex} % See redefinition below.

\newcommand{\crunchbegin}{} 
		% These two commands are redefined to add a \begin{small}
\newcommand{\crunchend}{}   % and \end{small} if space crunching is required

\newcommand{\crunchspace}{
    \renewcommand{\crunchbegin}{\addtolength{\topsep}{\topseplen}\begin{small}}
    \renewcommand{\crunchend}{\end{small}}
    }

\newcommand{\sections}[1]{\vspace{-0.2in} \section{#1} \vspace{-0.15in}}
\newcommand{\subsections}[1]{\vspace{-0.1in} \subsection{#1} \vspace{-0.1in}}
\newcommand{\subsubsections}[1]
	{\vspace{-0.1in} \subsubsection{#1} \vspace{-0.1in}}
\newcommand{\subsubsubsections}[1]
	{\vspace{-0.2in} \subsubsubsection{#1} \vspace{-0.1in}}

\newcommand{\crunchrewriting}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MISC. COMMANDS.
%
%   \tuple{..}:
%	Creates an overline to indicate that this is a vector/tuple.
%
%   \lbok:
%	Tells latex that it's ok to break a line here.
%%%%%%%%%%%%%%%

\newcommand{\tuple}[1]{\overline{#1}}
\newcommand{\lbok}{\linebreak[0]}

\newcommand{\semijoin}{\mathrel{\raise1pt\hbox{\vrule
	height5pt depth0pt\hskip-1.5pt$>$\hskip -2.5pt$<$}}}
\newcommand{\fd}{\rightarrow}
\newcommand{\mvd}{\rightarrow\!\rightarrow}

\newcommand{\intersection}{\cap}
\newcommand{\union}{\cup}
% \newcommand{\ifff}{\mbox{$ \leftarrow $}} 
\newcommand{\ifff}{\mbox{$ :- $}} 
\newcommand{\insop}{\mbox{$ := $~~}}
\newcommand{\addop}{\mbox{$ += $~~}}
\newcommand{\subop}{\mbox{$ -= $~~}}
\newcommand{\modop}{\mbox{$ *= $~~}}
 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Environments for Definitions, Lemmas, Theorems, Propositions etc:
%  The environments must be used in one of the following way:
%  	Environments that do not start with "named" do not take any 
%		parameters and are used as follows.
%  	\begin{definition} 
%         	... fill in definition ;  
%  	\end{definition}
%  	Environments that take parameters are used as follows:
%  	\begin{nameddefinition}{name of definition} 
%         	... fill in definition 
%  	\end{nameddefinition}
%  The numbering of the environments is done independently for each
%  environment type.  This can be changed if desired.
%
%  List of Environments:
%  --------------------
%	theorem
%	namedtheorem
%	lemma
%	namedlemma
% 	proposition	(Creates a box at the end)
%	namedproposition	(Creates a box at the end)
%	definition	(Creates a box at the end)
%	nameddefinition	(Creates a box at the end)
%	example		(Creates a box at the end)
%	namedexample	(Creates a box at the end)
%	assumption
%	claim
%	conjecture	(Creates a box at the end)
%	property	(Creates a box at the end)
%	namedproperty	(Creates a box at the end)
%
% WARNING:  When defining environments, DO NOT leave gaps between the 
%	    argument definitions.  Latex screws up if this is done.
%	Eg.  \newenvironment{haha}{..}{..} is ok,
%	BUT  \newenvironment{haha} {..} {..} is NOT OK.

%%%%%%%%%%%%%%%%%%%%%%%%%%
%  The following set the numbering style for several environments defined
%	above.
%%%%
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemm}{Lemma}[section]
\newtheorem{prop}{Proposition}[section]
\newtheorem{coroll}{Corollary}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{claims}{Claim}[section]

\newtheorem{ex}{Example}[section]
\newtheorem{alg}{Algorithm}[section]
\newtheorem{defin}{Definition}[section]
\newtheorem{assump}{Assumption}[section]
\newtheorem{propty}{Property}[section]

%% Environments with merged numbering
\newtheorem{mtheorem}{Theorem}[section]
\newtheorem{mlemm}[theorem]{Lemma}
\newtheorem{mprop}[theorem]{Proposition}
\newtheorem{mcoroll}[theorem]{Corollary}
\newtheorem{mconj}[theorem]{Conjecture}
\newtheorem{mclaims}[theorem]{Claim}

\newtheorem{mdefin}{Definition}[section]
\newtheorem{massump}[defin]{Assumption}
\newtheorem{mpropty}[defin]{Property}
\newtheorem{mex}{Example}[section]
\newtheorem{malg}{Algorithm}[section]

\newcommand{\propc}{prop}
\newcommand{\lemmc}{lemm}
\newcommand{\corollc}{coroll}
\newcommand{\conjc}{conj}
\newcommand{\claimsc}{claims}

\newcommand{\separatenumbering}{
    \renewcommand{\propc}{prop}
    \renewcommand{\lemmc}{lemm}
    \renewcommand{\corollc}{coroll}
    \renewcommand{\conjc}{conj}
    \renewcommand{\claimsc}{claims}
}

\newcommand{\mergednumbering}{
    \renewcommand{\propc}{mprop}
    \renewcommand{\lemmc}{mlemm}
    \renewcommand{\corollc}{mcoroll}
    \renewcommand{\conjc}{mconj}
    \renewcommand{\claimsc}{mclaims}
}

\newenvironment{namedtheorem}[1]{\begin{theorem}{\bf (#1)\hspace{1mm}:} \begin{rm} \crunchbegin }{ \crunchend \end{rm} \end{theorem}}

\newenvironment{proposition}{\begin{\propc} \crunchbegin }{\condBox \crunchend \end{\propc}}

\newenvironment{namedproposition}[1]{\begin{proposition}{\bf (#1)\hspace{1mm}:} \begin{rm} \crunchbegin }{ \crunchend \end{rm} \end{proposition}}

\newenvironment{reflemma}[1]{\noindent {\bf Lemma~\ref{#1}}}{}
\newenvironment{refproposition}[1]{\noindent {\bf Proposition~\ref{#1}}}{}
\newenvironment{reftheorem}[1]{\noindent {\bf Theorem~\ref{#1}}}{}

\newenvironment{lemma}{\begin{\lemmc} \crunchbegin }{\crunchend \end{\lemmc}}

\newenvironment{namedlemma}[1]{\begin{lemma}{\bf (#1)\hspace{1mm}:} \begin{rm} \crunchbegin }{ \crunchend \end{rm} \end{lemma}}

\newenvironment{corollary}{\begin{\corollc} \crunchbegin }{\crunchend \end{\corollc}}

\newenvironment{conjecture}{\begin{\conjc} \crunchbegin }{\condBox \crunchend \end{\conjc}}

\newenvironment{claim}{\begin{\claimsc} \crunchbegin }{\crunchend \end{\claimsc}}

\newenvironment{namedproof}[1]{\noindent {\bf Proof:}~(#1)\\ \nopagebreak \crunchbegin}{\crunchend {\raggedleft$\Box$}}

\newenvironment{proof}{\noindent {\bf Proof}: \crunchbegin \nopagebreak}{\crunchend {\raggedleft$\Box$}}

\newenvironment{namedexample}[1]{\begin{ex} \normalshape {\bf (#1)} \\ \crunchbegin \begin{rm}}{\condBox \end{rm} \crunchend \end{ex}}

\newenvironment{example}{\begin{ex} \nopagebreak \crunchbegin \normalshape \begin{rm}}{\condBox \end{rm} \crunchend \end{ex}}

\newenvironment{nameddefinition}[1]{\begin{defin} \normalshape {\bf (#1)} \begin{rm} \crunchbegin}{\condBox \crunchend \end{rm} \end{defin}}

\newenvironment{definition}{\begin{defin} \normalshape \begin{rm} \crunchbegin }{\condBox \crunchend \end{rm} \end{defin}}

\newenvironment{assumption}{\begin{assump} \crunchbegin }{\condBox \crunchend \end{assump}}

\newenvironment{namedproperty}[1]{\begin{propty}{\bf #1\hspace{1mm}:} \begin{rm} \crunchbegin }{ \condBox \crunchend \end{rm} \end{propty}}

\newenvironment{property}{\begin{propty} \begin{rm} \crunchbegin }{\condBox \crunchend \end{rm} \end{propty}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THE ALGORITHM command
%
%    \algorithm:
%    	The command \algorithm, takes one argument, to format
%	algorithms.  It sets font to \sf, and sets up a tabbing environment,
%	and creates lines above and below the algorithm to set off the 
%	algorithm from other text.  
%	
%
%    \ordinalg:
%    	If you don't want the separating lines, but want other features of the
%	\algorithm command, use the command \ordinalg
%
%   The default tabbing for algorithms is four spaces.	If you use 
%	\setprocdefaults this is changed to two spaces.
%
%    \pseudocode:
%	This commands creates the separating lines just like \algorithm,
%	but does not set up tabbing mode.
%
%  \setalgseplinelen{<length>}:
%   	The default length of the separating line is 6 inches.  If you use
%	\setprocdefaults this is reduced.  If you want finer control use this
%	command.
%   

%%%%%%%%%%%%%%%%%
\newcommand{\algtab}{1234}

\newcommand{\setalgtab}[1]{\renewcommand{\algtab}{#1}}

\newcommand{\algseplinelen}{6in}
\newcommand{\setalgseplinelen}[1]{\renewcommand{\algseplinelen}{#1}} 
\newcommand{\algsepline}{\rule{\algseplinelen}{0.1mm}\\}

\newcommand{\ordinalg}[1]{\begin{sf} \crunchbegin \begin{tabbing}
\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\kill
#1 
\end{tabbing} \crunchend \end{sf}}

\newcommand{\fontordinalg}[2]{\begin{#1} \crunchbegin \begin{tabbing}
\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\kill
#2 
\end{tabbing} \crunchend \end{#1}}

\newcommand{\fontfbalg}[2]{\begin{#1} \crunchbegin 
\fbox{\begin{minipage}{\textwidth} \begin{tabbing}
\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\kill
#2 
\end{tabbing} \end{minipage}} \crunchend \end{#1}}


\newcommand{\algorithm}[1]{\begin{sf} \crunchbegin \begin{tabbing}
\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\kill
\raisebox{4ex}[5ex][2mm]{\algsepline}
#1 \\
\raisebox{0ex}[.1mm][.1mm]{\algsepline}
\end{tabbing} \crunchend \end{sf}}

\newcommand{\pseudocode}[1]{\begin{sf} \crunchbegin 
\noindent \raisebox{0mm}[.2mm][.2mm]{\algsepline} \\
#1 

\noindent \raisebox{0ex}[.1mm][.1mm]{\algsepline} 
\crunchend \end{sf}}

\newcommand{\moduleprog}[1]{\noindent 
\raisebox{4ex}[5ex][2mm]{\algsepline}
#1 

\noindent\raisebox{0ex}[.1mm][.1mm]{\algsepline}
}

%% \newenvironment{namedalgorithm}[1]
%%   {{\bf #1}\\ \nopagebreak\begin{sf}\begin{small}\begin{tabbing}
%% \algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\algtab\=\kill}
%%   {\end{tabbing}\end{small}\end{sf}}

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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
% See also redefinition of condition in \procdefaults mode
%%%%%%%%%%%%%

\newcommand{\condition}[2]{\crunchbegin \begin{description}\item [Condition #1]:#2 \condBox \end{description} \crunchend }

\newcommand{\proctechnique}[2]{\crunchbegin \noindent {\bf Technique #1}:~#2 \condBox \crunchend }

\newcommand{\proccondition}[2]{\crunchbegin \noindent {\bf Condition #1}:~#2 \condBox \crunchend }

%%%%
% This command ( \technique) is useful to desccribe a collection of short 
% techniques.  Each of the techniques begins with an \item [<description>] 
% The list of techniques is demarcated by long dividing lines.
%%%%
\newcommand{\technique}[2]{\begin{sf} \crunchbegin
\noindent \raisebox{0mm}[.2mm][.2mm]{\algsepline}
\vspace{-2mm}
\begin{description}
\crunchbegin
\item [Technique #1:] #2 
\crunchend
\end{description}
\vspace{-2mm}
\noindent \raisebox{0ex}[.1mm][.1mm]{\algsepline} \\
\crunchend \end{sf}}

\newcommand{\techniques}[1]{\begin{sf} 
\noindent \raisebox{0mm}[.2mm][.2mm]{\algsepline}
\vspace{-2mm}
\begin{description}
\crunchbegin
#1 
\crunchend
\end{description}
\vspace{-2mm}
\noindent \raisebox{0ex}[.1mm][.1mm]{\algsepline} \\
\crunchend \end{sf}}

%% The command \itemizes and \enumerates are used as replacements for 
%% \itemize and \enumerate, that save space.
%% Use the command \items within these commands instead of \item
%%

\newenvironment{itemizes}{\begin{itemize}\addtolength{\itemsep}{-1ex}\addtolength{\parsep}{-1ex}\addtolength{\topsep}{\topseplen}}{\end{itemize}} 

\newenvironment{enumerates}{\begin{enumerate}\addtolength{\itemsep}{-1ex}\addtolength{\parsep}{-1ex}\addtolength{\topsep}{\topseplen}}{\end{enumerate}} 

\newenvironment{descriptions}{\begin{description}\addtolength{\itemsep}{-1ex}\addtolength{\parsep}{-1ex}\addtolength{\topsep}{\topseplen}}{\end{description}} 


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


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rule Formatting Section
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%   \logicprog{...}:
% 	The command \logicprog creates an inline logic program.
%	It formats the program in a nice manner.
%	Several commands described below can be used to create rules withing
%	the program.
%	NOTE:  \\ must be used to create new lines, or latex will complain.
%
%   \logicprogfig{ <caption and optional label> }{...}:
% 	The command \logicprogfig creates a separate figure.  It takes two
% 	arguments - a caption and then the logic program itself within { ... }
%
%   Commands for use within logicprog mode:
%   --------------------------------------
%
%   \lfact {<Rulename>} {<fact>}
%   \lrule {<Rulename>} {<Rulehead>} {<Rulebody>}
%   \irule {<Rulename>} {<Rulehead>} {<Rulebody>}
%   \arule {<Rulename>} {<Rulehead>} {<Rulebody>}
%   \drule {<Rulename>} {<Rulehead>} {<Rulebody>}
%   \lrulehead {<Rulename>} {<Rulehead>}
%   \longheadrule {<Rulename>} {<Rulehead>} {<Rulebody>}
%   \lquery {<query>}
%   \lcomment{<C style comment>}
%   \lheader {<Any text that spans the entire line>}
%   \lrulecont {<Rulename>} {<Rulehead>} {<PartialRulebody>}
%   \lcontrule {} 	    {}		 {<Rest of rule body>.}
%
%   \setrulebodywidth{<width>}:
%	Particularly useful when non-standard page width is used.
%
%   Commands for use outside logicprog mode:
%   ---------------------------------------
%    \hornclause {<Rulename>} {<Rulehead>} {<Rulebody>}
%    \lhornclause {<Rulename>} {<Rulehead>} {<Rulebody>} {<RuleLabel>}
%    \inlineclause {<Rulename>} {<Rulehead>} {<Rulebody>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\newcommand{\lheader}[1]{\multicolumn{4}{l}{\mbox{#1}}}
\newcommand{\lcomment}[1]{\multicolumn{4}{l}{\mbox{/* #1 */}}}
\newcommand{\lannotation}[1]{\multicolumn{4}{l}{\mbox{#1}}}
\newcommand{\lrule}[3]{#1&#2&\ifff&$ #3. $}
\newcommand{\irule}[3]{#1&#2&$:=$&$ #3. $}
\newcommand{\arule}[3]{#1&#2&$+=$&$ #3. $}
\newcommand{\drule}[3]{#1&#2&$-=$&$ #3. $}
\newcommand{\lrulehead}[2]{#1&\multicolumn{3}{l}{#2 ~ \ifff}}
\newcommand{\longheadrule}[3]{#1&\multicolumn{3}{l}{#2 ~ \ifff #3}}
\newcommand{\lrulecont}[3]{#1&#2&\ifff&$ #3 $}
\newcommand{\lcontrule}[3]{#1&#2&&$ #3$}
\newcommand{\lqrule}[4]{#1&#2&\mbox{$\leftarrow #3 -$}&$ #4. $}
\newcommand{\lfact}[2]{#1&\multicolumn{3}{l}{#2.}}
\newcommand{\lquery}[1]{\multicolumn{4}{l}{\protect\mbox{Query: ?-$ #1 .$}}}
\newcommand{\hornclause}[3]{\[ #1~#2 \ifff #3. \]}
\newcommand{\hornfact}[2]{\[ #1~#2. \]}
\newcommand{\lhornclause}[4]{\[ #1~#2 \ifff #3. #4 \]}
\newcommand{\inlineclause}[3]{$ #1~#2 \ifff #3$}

\newcommand{\rulebodywidth}{4.5in}
\newcommand{\setrulebodywidth}[1]{\renewcommand{\rulebodywidth}{#1}}

\newcommand{\logicprogspacing}{1.0}
\newcommand{\setlpspacing}{\renewcommand{\arraystretch}{\logicprogspacing}}


\newcommand{\logicprog}[1]{\[ {\renewcommand{\arraycolsep}{.5mm}\setlpspacing \begin{array}{lllp{\rulebodywidth}}#1\end{array}}\]}
%

\newcommand{\logicprogfig}[2]{\begin{figure}\[ 
	{\renewcommand{\arraycolsep}{.5mm}\setlpspacing
	\begin{array}{lllp{\rulebodywidth}}#2\end{array}}\]\vspace{-1mm}
	\caption{#1}\end{figure}}
\newcommand{\widelogicprogfig}[2]{\begin{figure*}\[ 
	{\renewcommand{\arraycolsep}{.5mm}\setlpspacing
	\begin{array}{lllp{\rulebodywidth}}#2\end{array}}\]\vspace{-1mm}
	\caption{#1}\end{figure*}}
\newcommand{\logicprogcfig}[3]{\begin{figure}[#1]\[ 
	{\renewcommand{\arraycolsep}{.5mm}\setlpspacing
	\begin{array}{lllp{\rulebodywidth}}#3\end{array}}\]\vspace{-1mm}
	\caption{#2}\end{figure}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SETTING PROC OR NORMAL ENVIRONMENT
%   \setnormaldefaults:
%	Set up a number of defaults such as text width/height etc.,
%	for normal format.
%   \setprocdefaults:
%	Set up a number of defaults for two column format.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\setnormaldefaults}{
% 
\input{psfig}
% page layout
\addtolength{\topmargin}{-0.8in}    % move top margin up
\setlength{\textheight}{8.85in}      % text height
\addtolength{\oddsidemargin}{-0.5in} 
\setlength{\textwidth}{6.25in}
\addtolength{\columnsep}{2.5ex}
%%%%%%%%%%%%%%%
% \addtolength{\itemsep}{-1ex}
% \topsep=-1ex  % The amount of space in addition to \parskip, above and 
%	      % below list envs (eg. enumerate).  Beware of negative spacing 
%	      % if parskip is too small
%\partopsep=0ex % As above, when there is a blank line preceding the list
%%%%%%%%%%%%%%%
\addtolength{\parskip}{2ex}
\renewcommand{\topseplen}{-1ex}  %% Do this only if parskip is increased.
				 %% Its used with enumerates and itemizes
%%%%%	Space around eqns in fleqn mode
\addtolength{\topsep}{-1.5ex}	    
%%%%	Space around eqns in normal mode
\abovedisplayskip=0mm  % Spacing for math line mode formulas (using \[ \])
\belowdisplayskip=0mm
\abovedisplayshortskip=0mm  % As above, for formulas that start beyond the 
			    % last character of previous line
\belowdisplayshortskip=0mm
%%%%
\renewcommand{\baselinestretch}{1.1}    % one and a half spacing approx.
\mergednumbering			% Theorems, lemmas etc are numbered 
					% together.
\renewcommand{\logicprogspacing}{0.75}

}

\newcommand{\setprocminordefaults}{
\setlength{\topskip}{10pt}
\setlength{\headsep}{0pt}
\setrulebodywidth{2in} \setalgtab{12}
\setalgseplinelen{2.5in}
\setlength{\parskip}{1mm}
\renewcommand{\condition}{\proccondition}
% \crunchspace    % use small font in several environments (to find out in which
		% look for uses of \crunchbegin and \crunchend
\mergednumbering		% Theorems, lemmas etc are numbered 
				% together.
\renewcommand{\logicprogspacing}{0.75}
}

\newcommand{\setprocdefaults}{
\setnormaldefaults
% \renewcommand{\maketitle}{??} - fill this in 
\setlength{\oddsidemargin}{-.20in}
\setlength{\topmargin}{-.40in}  % In order to get .75in seperation
\setlength{\textheight}{9.25in}
\setlength{\textwidth} {6.99in}
\setlength{\columnsep} {0.33in}
\setprocminordefaults

% \setlength{\topskip}{10pt}
% \setlength{\headsep}{0pt}
% \setrulebodywidth{2in} \setalgtab{12}
% \setalgseplinelen{2.5in}
% \setlength{\parskip}{1mm}
% \renewcommand{\condition}{\proccondition}
% \crunchspace	% use small font in several environments (to find out in which
		% % look for uses of \crunchbegin and \crunchend
% \mergednumbering		% Theorems, lemmas etc are numbered 
				% % together.
\renewcommand{\logicprogspacing}{0.75}
}

\newif\ifatt
\attfalse

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMMANDS FOR WRITING SQL QUERIES, AND EMBEDDED SQL QUERIES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  To enable the use of these commands, use the command
%	\enableSQL
%		I'm not sure the command works right due to nested use of
%		parameter refs (#1, etc)
%

\newcommand{\enableSQL}{
   \newcommand{\nail}{{\em NAIL!\/} }
   \newcommand{\Select}{{\tt SELECT\ }}
   \newcommand{\SelectOuter}{{\tt OUTER-JOIN\ }}
   \newcommand{\From}{{\tt \ FROM\ }}
   \newcommand{\Where}{{\tt \ WHERE\ }}
   \newcommand{\GB}{{\tt\ GROUP BY\ }}
   \newcommand{\Groupby}{{\tt\ GROUP BY\ }}
   \newcommand{\GBrule}{{\tt\ GROUP BY}}
   \newcommand{\Having}{{\tt\ HAVING\ }}
   \newcommand{\Into}{{\tt\ INTO\ }}
   \newcommand{\Distinct}{{\tt\ DISTINCT\ }}
   \newcommand{\As}{{\tt\ AS\ }}
   \newcommand{\And}{{\tt\ AND\ }}
   \newcommand{\Or}{{\tt\ OR\ }}
   \newcommand{\Not}{{\tt\ NOT\ }}
   \newcommand{\Exists}{{\tt\ EXISTS\ }}
   \newcommand{\In}{{\tt\ IN\ }}
   \newcommand{\All}{{\tt\ ALL\ }}
   \newcommand{\Sum}{{\tt\ SUM\ }}
   \newcommand{\Count}{{\tt\ COUNT\ }}
   \newcommand{\Average}{{\tt\ AVG\ }}
   \newcommand{\Max}{{\tt\ MAX\ }}
   \newcommand{\Union}{{\tt\ UNION\ }}
   \newcommand{\Difference}{{\tt\ DIFFERENCE\ }}
   \newcommand{\Intersection}{{\tt\ INTERSECTION\ }}
   \newcommand{\Create}{{\tt\ CREATE\ }}
   \newcommand{\View}{{\tt\ VIEW\ }}

   \newcounter{linenumber}[alg]
   \renewcommand{\thelinenumber}{\roman{linenumber}}
   \newcommand{\algnum}{\refstepcounter{linenumber}$(\thelinenumber)$}
   \newcommand{\aln}[1]{\` \algnum \label{\#1}}
   
   \newcommand{\Begin}{{\bf BEGIN\ }}
   \newcommand{\End}{{\bf END\ }}
   \newcommand{\Repeat}{{\bf REPEAT\ }}
   \newcommand{\Until}{{\bf UNTIL\ }}
   \newcommand{\If}{{\bf IF\ }}
   \newcommand{\Then}{{\bf THEN\ }}
   \newcommand{\Else}{{\bf ELSE\ }}
   \newcommand{\While}{{\bf WHILE\ }}
   \newcommand{\Case}{{\bf CASE\ }}
   \newcommand{\For}{{\bf FOR\ }}
   \newcommand{\To}{{\bf TO\ }}
   \newcommand{\Do}{{\bf DO\ }}
   \newcommand{\Program}{{\bf PROGRAM:\ }}
   \newcommand{\Query}{{\bf QUERY:\ }}
   \newcommand{\Extension}{{\bf EXTENSION:\ }}
   
   
   \newcounter{clauses}
   \newcounter{rule}[clauses]
   \renewcommand{\therule}{$(\theclauses.\arabic{rule})$}
   \newcommand{\rulenum}{\refstepcounter{rule}\therule}
   \newcommand{\rn}[1]{\` \rulenum \label{\#1}}
   %\newcommand{\rn}[1]{\>\>\>\>\rulenum \label{\#1}}
   %\newcommand{\rr}[2]{$(\ref{\#1}.\ref{\#2})$}
   \newcommand{\rr}[2]{\ref{\#2}}
   
   \newenvironment{clauses}{\refstepcounter{clauses}\noindent\nopagebreak \begin{tabbing}Tab to Goal\= Sub\= Nested Subgoal\= Nested subgoal\= Nested Subgoal\= Nested Subgoal.\=\kill}{\end{tabbing}}
   % \newcommand{\andd}{\mbox{ \& }}
   \newcommand{\query}{\mbox{?- }}
   
   \newcounter{sql} \newcounter{sqlstatement}[sql]
   \renewcommand{\thesql}{\Alph{sql}}
   \renewcommand{\thesqlstatement}{$(\thesql.\arabic{sqlstatement})$}
   \newcommand{\sqlnum}{\refstepcounter{sqlstatement}\thesqlstatement}
   \newcommand{\sn}[1]{\` \sqlnum \label{\#1}}
   %\newcommand{\sr}[2]{$(\ref{\#1}.\ref{\#2})$}
   \newcommand{\sr}[2]{\ref{\#2}}
   
   \newenvironment{sql}{\refstepcounter{sql}\begin{small}\noindent\nopagebreak \begin{tabbing}Nt\= Nt \= Nt \=Nt \= Nt \= Nt \= Nt \= Nt \=\kill}{\end{tabbing}\end{small}}
   
   \newcommand{\nn}[1]{\addtocounter{\#1}{-1}} % Don't number this counter
   
   \newcommand{\srule}[2]{
		{\noindent\small\hspace*{0.2cm}($\#1$):\hspace*{0.4cm}\#2.}\\}
   \newcommand{\sruleu}[1]{{\noindent\small\hspace*{1.1cm}\#1.}\\}
   \newcommand{\urule}[2]{\begin{small}\begin{tabbing}\noindent\hspace*{0.2cm}
   	($\#1$):\hspace*{0.4cm}\#2.\end{tabbing}\end{small}}
   \newcommand{\uruleu}[1]{\begin{small}\begin{tabbing}\noindent
   			\hspace*{1.1cm}\#1.\end{tabbing}\end{small}}
   
}

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