%Math macros -- snarfed and adapted from John Reynolds' catmac.tex package.

%These macros were designed for use with Computer Modern fonts, in a LATEX
%document style with the 12pt option, using an Apple Laserwriter for output.
%Most but not all of the macros should work with other fonts, sizes, and
%printers; comments marked ``FONT DEPENDENCY'' indicate potential problems.

%We adopt the convention that control symbols denoting registers and macros
%that should be hidden from the user begin with \yy.


%REGISTERS AND BOXES

\newcount\yyitercn %Used by iterative definitions
\newcount\yycnA %Used by \defbig

\newbox\yybxA %Used by \makelevel,\defbig,\kernpart,\embolden,\defaxis,
%    \yyarrowb,\multscript,\compscript
\newbox\yybxB %Used by \Glb,\multscript,\compscript,\Glbms
\newbox\yybxC %Used by \multscript,\compscript
\newbox\yybxD %Used by \multscript,\compscript
\newbox\yybxE %Used by \multscript,\compscript
\newbox\yybxF %Used by \multscript,\compscript
\newbox\yybxG %Used by \multscript,\compscript

\newdimen\yydmA %Used by \makelevel,\defbig,\kernpart,\yyarrowb,
%    \multscript,\compscript
\newdimen\yydmB %Used by \defbig,\multscript,\compscript
\newdimen\yydmC %Used by \defbig,\multscript,\compscript
\newdimen\yydmD %Used by \multscript,\compscript
\newdimen\yydmE %Used by \multscript,\compscript
\newdimen\yydmF %Used by \multscript,\compscript
\newdimen\yydmG %Used by \multscript
\newdimen\yydmH %Used by \multscript
\newdimen\yydmI %Used by \multscript



%MISCELLANEOUS SPECIAL SYMBOLS AND OTHER MACROS

%\defaxis defines #1 to stand for a dimension giving the height of the axis
%in the math style #2.  It is used to define \displayaxis, \textaxis,
%\scriptaxis, and \scriptscriptaxis to stand for the height of the axis
%in the four styles.  These control symbols affect the relation macros
%\arrow... and \Arrow... described later.  The user may also use them
%to define the control symbol \centerheight used by the diagram macros
%in the file diagmac.tex (e.g. \def\centerheight{\displayaxis}).

\def\defaxis#1#2{\setbox\yybxA=\hbox{{$#2\vcenter{}$}}
\edef#1{\the\ht\yybxA}}

\defaxis\displayaxis\displaystyle
\defaxis\textaxis\textstyle
\defaxis\scriptaxis\scriptstyle
\defaxis\scriptscriptaxis\scriptscriptstyle

%\eqper and \eqcom are a period and comma designed to end displayed equations.
%The effect is to place a space before the period or comma.

\def\eqper{\: .}
\def\eqcom{\: ,}

%%%===========================================================================
%\lsembr and \rsembr give semantic brackets, i.e. double square
%brackets.

%FONT DEPENDENCY: It may be necesssary to vary the parameter -59 in these
%macros for different fonts.

\def\lsembr{\mathopen{{\lbrack\kernpart{\lbrack}{-59}\lbrack}}}

\def\rsembr{\mathclose{{\rbrack\kernpart{\rbrack}{-59}\rbrack}}}

\def\kernpart#1#2{\mathchoice
{\yykernparta{\displaystyle#1}{#2}}
{\yykernparta{\textstyle#1}{#2}}
{\yykernparta{\scriptstyle#1}{#2}}
{\yykernparta{\scriptscriptstyle#1}{#2}}}

\def\yykernparta#1#2{ %Internal
\setbox\yybxA=\hbox{$\mathsurround=0pt\relax #1$}
\yydmA=\wd\yybxA\multiply\yydmA by #2\relax
\divide\yydmA by 100\relax \kern\yydmA}

\def\sembr#1{\lsembr{#1}\rsembr}
%%%===========================================================================





%MACROS WITH A VARIABLE NUMBER OF PARAMETERS

%In this section we give a number of macros accepting a variable number of
%parameters (as well as a few conventional but closely related macros such
%as \emptyset and \sqpairlistdots).  These are macros whose first parameter
%is an integer determining the number of further parameters.

%\simplist accepts a nonnegative integer n, a left delimiter, a right
%delimiter, a separating symbol, an ``empty list'', and n further parameters.
%If n = 0 it produces the empty list.  Otherwise, it produces a list of
%the n parameters, separated by the separating symbol and enclosed by the
%delimiters. The n parameters are each executed within a call of \normsize.

%\simplist is used to define a collection of macros with specific delimiters
%and separating symbols.  In each case, variable-size delimiters are used,
%so that the size of these delimiters (but not of those within the parameters
%to the macro) are affected by the meaning of \currbig when the macro
%is executed.  Thus these macros behave like the balanced delimiter macros
%given above.

\def\simplist#1#2#3#4#5{
% #1 = number of operands
% #2 = left delimiter
% #3 = right delimiter
% #4 = separating symbol
% #5 = emptylist
\yyitercn=#1\relax
\def\yyrightdel{#3}
\def\yysepsym{#4}
\ifnum\yyitercn=0\relax
#5 \let\next=\relax
\else #2 \let\next=\yysimplista
\fi\next}

\def\yysimplista#1{\begingroup{#1}\endgroup %Internal
\advance\yyitercn by -1\relax
\ifnum\yyitercn=0\relax
\yyrightdel \let\next=\relax
\else \yysepsym \let\next=\yysimplista
\fi\next}

%REMOVED BY OLIN 11/6/88
%\def\emptyset{\left\{\right\}}

\def\setlist#1{\simplist{#1}{\left\{}{\right\}}{,}\emptyset}

\def\emptysqlist{\left[ \, \right]}

\def\sqlist#1{\simplist{#1}{\left[}{\right]}{,}\emptysqlist}

\def\emptyanglelist{\left\langle\right\rangle}

\def\anglelist#1{\simplist{#1}{\left\langle}{\right\rangle}{,}\emptyanglelist}

%\pairlist accepts a nonnegative integer n, a left delimiter, a right
%delimiter, a separating symbol, a pairing symbol, an empty list, and 2n
%further parameters.  If n = 0 it produces the empty list.  Otherwise,
%it produces a list of the 2n parameters, grouped into pairs joined by
%the pairing symbol, where the pairs are separated by the separating
%symbol and enclosed by the delimiters.  The 2n parameters are each
%executed within a call of \normsize.

%\pairlistdots is similar to \pairlist2, except that the single occurrence
%of the separating symbol is replaced by two occurrences with \ldots
%between them.

%\pairlist and \pairlistdots are used to define a collection of macros
%with specific delimiters, separating symbols, and pairing symbols.
%Variable-sized delimiters (and the variable-sized separating symbol \varmid)
%are used, so that the size of these delimiters (but not of those within
%the parameters) are affected by the meaning of \currbig when the macro
%is executed.  Thus these macros behave like the balanced delimiter macros.

%These notations are used to specify functions by giving a list of
%argument-result pairs.

\def\pairlist#1#2#3#4#5#6{
% #1 = number of operands
% #2 = left delimiter
% #3 = right delimiter
% #4 = separating symbol
% #5 = pairing symbol
% #6 = emptylist
\yyitercn=#1\relax
\def\yyrightdel{#3}
\def\yysepsym{#4}
\def\yypairsym{#5}
\ifnum\yyitercn=0\relax
#6 \let\next=\relax
\else #2 \let\next=\yypairlista
\fi\next}

\def\yypairlista#1#2{ %Internal
\begingroup{#1}\endgroup\yypairsym
\begingroup{#2}\endgroup
\advance\yyitercn by -1\relax
\ifnum\yyitercn=0\relax
\yyrightdel \let\next=\relax
\else \yysepsym \let\next=\yypairlista
\fi\next}

\def\pairlistdots#1#2#3#4#5#6#7#8{
% #1 = left delimiter
% #2 = right delimiter
% #3 = separating symbol
% #4 = pairing symbol
% #5 = left side of first pair
% #6 = right side of first pair
% #7 = left side of last pair
% #8 = right side of last pair
#1\begingroup{#5}\endgroup #4
\begingroup{#6}\endgroup #3
\ldots #3\begingroup{#7}\endgroup #4
\begingroup{#8}\endgroup #2}

\def\sqpairlist#1{\pairlist{#1}
{\left[\nonscript\,}{\nonscript\,\right]}\mid\colon\emptysqlist}

\def\sqpairlistdots{\pairlistdots
{\left[\nonscript\,}{\nonscript\,\right]}\mid\colon}

\def\anglepairlist#1{\pairlist{#1}
{\left\langle\nonscript\,}{\nonscript\,\right\rangle}\mid\colon\emptyanglelist}

\def\anglepairlistdots{\pairlistdots
{\left\langle\nonscript\,}{\nonscript\,\right\rangle}\mid\colon}

%\infix accepts a positive integer n, a separating symbol, and n further
%parameters.  It produces a list of the n parameters separated by the
%separating symbol.  The n parameters are executed directly (not within
%a call of \normsize) so that they are affected by the meaning of \currbig
%when the macro is executed.

%\infix is used to define a collection of macros with specific separating
%symbols.  For example, \compo3{a}{b}{c} gives a;b;c.

\def\infix#1#2{
% #1 = number of operands
% #2 = separating symbol
\yyitercn=#1\relax
\def\yysepsym{#2}
\ifnum\yyitercn=0\relax
\errmessage{CALL OF \string\infix0}
\let\next=\relax
\else\let\next=\yyinfixa
\fi\next}

\def\yyinfixa#1{\begingroup #1\endgroup %Internal
\advance\yyitercn by -1\relax
\ifnum\yyitercn=0\relax
\let\next=\relax
\else \yysepsym \let\next=\yyinfixa
\fi\next}

\def\compo#1{\infix{#1}{\sccompop}}
\def\compogen#1#2{\infix{#1}{\sccompop_{{#2}}}}
\def\fcompo#1{\infix{#1}{\cdot}}
\def\fcompogen#1#2{\infix{#1}{\cdot_{{#2}}}}

\typeout{end of mmac}
