%\filename{cmrmathmacros.tex}
%\edited{last by stolfi on Wed May 20 18:14:18 1987}

% Macros and \mathcodes that apply when standard TeX fonts (of any size)
% are being used for math

\catcode`@=11 \endlinechar=-1

  % These definitions assume the math fonts
  %  (\basefont, \scriptfont, and \scriptscriptfont)
  %  of families 0, 1, 2 and 3 have been set respectively
  %  to STANDARD TeX fonts,
  %  respectively roman, math italic, symbol, and extension.

% MACROS FOR CONSTRUCTING NEW OPERATORS

  \message{operator twiddling ...}

  % abuts a mathrel to the previous one

    \def\joinrel{\mathrel{\mkern-3mu}}

  % Same as \not, but with steeper slash. Use with \mathpalette

    \def\c@ncel#1#2{\overlap{$\hfil#1\mkern1mu/\hfil$\crcr$#1#2$}}

  % Puts #2 over equal sign.  Use with \mathpalette.

    \def\@vereq#1#2{\lower.5\p@  % bug! should vary with font size
       \vbox{\baselinesep\z@glue\linesep-.5\p@
          \ialign{$\mathsurround=\z@#1\hfil##\hfil$\crcr
            #2\crcr
            =\crcr}}}

% MATH CODES FOR SPECIAL CHARACTERS

  \message{mathcodes ...}

    % Definition of math characters

    % INITEX sets up \mathcode x=x, for x=0..127, except that
    % \mathcode x=x+"7100, for x = `A to `Z and `a to `z;
    % \mathcode x=x+"7000, for x = `0 to `9.

    % \mathcode`\="3214 % Ascii '034 = \le
    % \mathcode`\="3215 % Ascii '035 = \ge
    % \mathcode`\="3220 % Ascii '030 = \leftarrow
    % \mathcode`\="3221 % Ascii '031 = \rightarrow
    \mathcode`\ ="8000 % \space
    \mathcode`\!="5021
    \mathcode`\'="8000 % ^\prime
    \mathcode`\(="4028
    \mathcode`\)="5029
    \mathcode`\*="2203 % \ast
    \mathcode`\+="202B
    \mathcode`\,="613B
    \mathcode`\-="2200
    \mathcode`\.="013A
    \mathcode`\/="013D
    \mathcode`\:="303A
    \mathcode`\;="603B
    \mathcode`\<="313C
    \mathcode`\=="303D
    \mathcode`\>="313E
    \mathcode`\?="503F
    \mathcode`\[="405B
    \mathcode`\]="505D
    \mathcode`\|="026A

% GREEK LETTERS

  \message{greek ...}

    \mathchardef\alpha="010B 
    \mathchardef\beta="010C 
    \mathchardef\gamma="010D
    \mathchardef\delta="010E
    \mathchardef\epsilon="0122 % exchanged with \varepsilon
    \mathchardef\zeta="0110 
    \mathchardef\eta="0111
    \mathchardef\theta="0112
    \mathchardef\iota="0113
    \mathchardef\kappa="0114
    \mathchardef\lambda="0115
    \mathchardef\mu="0116
    \mathchardef\nu="0117
    \mathchardef\xi="0118
    \mathchardef\pi="0119
    \mathchardef\rho="011A
    \mathchardef\sigma="011B
    \mathchardef\tau="011C
    \mathchardef\upsilon="011D
    \mathchardef\phi="0127 % exchanged with \varphi
    \mathchardef\chi="011F
    \mathchardef\psi="0120
    \mathchardef\omega="0121
    \mathchardef\varepsilon="010F % exchanged with \epsilon
    \mathchardef\vartheta="0123
    \mathchardef\varpi="0124
    \mathchardef\varrho="0125
    \mathchardef\varsigma="0126
    \mathchardef\varphi="011E % exchanged with \phi
    \mathchardef\Gamma="7000
    \mathchardef\Delta="7001
    \mathchardef\Theta="7002
    \mathchardef\Lambda="7003
    \mathchardef\Xi="7004
    \mathchardef\Pi="7005
    \mathchardef\Sigma="7006
    \mathchardef\Upsilon="7007
    \mathchardef\Phi="7008
    \mathchardef\Psi="7009
    \mathchardef\Omega="700A

% SPECIAL MATH STYLES

  \message{special styles ...}

  % Old style digits (work also in text mode)

    \def\oldstyle{\mi}

  % Calligraphic letters (work also in text mode)

    \def\cal{\sy}

  % Italic greek capitals

    \def\itgreek{\it}

% DELIMITERS

  \message{delimiters ...}

  % delcodes

    % INITEX sets all \delcode values to -1, except  \delcode`.=0

    \delcode`\(="028300
    \delcode`\)="029301
    \delcode`\[="05B302
    \delcode`\]="05D303
    \delcode`\<="26830A
    \delcode`\>="26930B
    \delcode`\/="02F30E
    \delcode`\|="26A30C
    \delcode`\\="20430F

  % Named delimiters

    \def\lmoustache{\delimiter"4000340 } % top from (, bottom from )
    \def\rmoustache{\delimiter"5000341 } % top from ), bottom from (
    \def\lgroup{\delimiter"400033A } % extensible ( with sharper tips
    \def\rgroup{\delimiter"500033B } % extensible ) with sharper tips
    \def\arrowvert{\delimiter"33C } % arrow without arrowheads
    \def\Arrowvert{\delimiter"33D } % double arrow without arrowheads
    \def\bracevert{\delimiter"33E } % the vertical bar that extends braces
    \def\Vert{\delimiter"26B30D } \let\|=\Vert
    \def\vert{\delimiter"26A30C }
    \def\uparrow{\delimiter"3222378 }
    \def\downarrow{\delimiter"3223379 }
    \def\updownarrow{\delimiter"326C33F }
    \def\Uparrow{\delimiter"322A37E }
    \def\Downarrow{\delimiter"322B37F }
    \def\Updownarrow{\delimiter"326D377 }
    \def\backslash{\delimiter"26E30F } % for double coset G\backslash H
    \def\rangle{\delimiter"526930B }
    \def\langle{\delimiter"426830A }
    \def\rbrace{\delimiter"5267309 } \let\}=\rbrace
    \def\lbrace{\delimiter"4266308 } \let\{=\lbrace
    \def\rceil{\delimiter"5265307 }
    \def\lceil{\delimiter"4264306 }
    \def\rfloor{\delimiter"5263305 }
    \def\lfloor{\delimiter"4262304 }

  %  Combinatorics ops and such

    \def\choose{\atopwithdelims()}
    \def\brack{\atopwithdelims[]}
    \def\brace{\atopwithdelims\{\}}

  %  Extensible delimiter factor

    \delimiterfactor=851

% OTHER SYMBOLS AND OPERATORS

  \message{operators ...}

  %  Named math characters

    \mathchardef\aleph="0240

    \mathchardef\imath="017B
    \mathchardef\jmath="017C
    \mathchardef\ell="0160
    \mathchardef\wp="017D
    \mathchardef\Re="023C
    \mathchardef\Im="023D
    \mathchardef\partial="0140
    \mathchardef\infty="0231
    \mathchardef\prime="0230
    \mathchardef\varemptyset="023B % Knuth's empty set
    \mathchardef\nabla="0272
    \def\surd{{\mathchar"1270}}
    \mathchardef\top="023E
    \mathchardef\bot="023F

    \mathchardef\triangle="0234
    \mathchardef\forall="0238
    \mathchardef\exists="0239

    \mathchardef\coprod="1360
    \mathchardef\bigvee="1357
    \mathchardef\bigwedge="1356
    \mathchardef\biguplus="1355
    \mathchardef\bigcap="1354 \let\biginte=\bigcap
    \mathchardef\bigcup="1353 \let\biguni=\bigcup
    \mathchardef\intop="1352 \def\int{\intop\nolimits}
    \mathchardef\prod="1351
    \mathchardef\sum="1350
    \mathchardef\bigotimes="134E
    \mathchardef\bigoplus="134C
    \mathchardef\bigodot="134A
    \mathchardef\ointop="1348 \def\oint{\ointop\nolimits}
    \mathchardef\bigsqcup="1346
    \mathchardef\smallint="1273

    \mathchardef\neg="023A \let\lnot=\neg

    \mathchardef\triangleleft="212F  \let\lpoint=\triangleleft
    \mathchardef\triangleright="212E  \let\rpoint=\triangleright
    \mathchardef\bigtriangleup="2234
    \mathchardef\bigtriangledown="2235
    \mathchardef\wedge="225E \let\land=\wedge \let\meet=\wedge
    \mathchardef\vee="225F   \let\lor=\vee    \let\join=\vee
    \mathchardef\cap="225C   \let\inte=\cap     % infix intersection
    \mathchardef\cup="225B   \let\uni=\cup      % infix union
    \mathchardef\ddagger="227A
    \mathchardef\dagger="2279
    \mathchardef\sqcap="2275
    \mathchardef\sqcup="2274
    \mathchardef\uplus="225D
    \mathchardef\amalg="2271
    \mathchardef\diamond="2205
    \mathchardef\bullet="220F
    \mathchardef\wr="226F
    \mathchardef\div="2204
    \mathchardef\odot="220C
    \mathchardef\oslash="220B
    \mathchardef\otimes="220A
    \mathchardef\ominus="2209
    \mathchardef\oplus="2208   \let\xor=\oplus % boolean exclusive or
    \mathchardef\mp="2207
    \mathchardef\pm="2206
    \mathchardef\circ="220E
    \mathchardef\bigcirc="220D
    \mathchardef\setminus="226E % for set difference A\setminus B
    \mathchardef\cdot="2201
    \mathchardef\ast="2203
    \mathchardef\times="2202
    \mathchardef\pentagram="213F % \star in Plain.TeX

    \mathchardef\propto="322F
    \mathchardef\sqsubseteq="3276
    \mathchardef\sqsupseteq="3277
    \mathchardef\parallel="326B
    \mathchardef\mid="326A 
    \mathchardef\dashv="3261
    \mathchardef\vdash="3260

    \mathchardef\lss="313C \let\lt=\lss
    \mathchardef\gtr="313E \let\gt=\gtr
    
    \mathchardef\leq="3214 \let\le=\leq
    \mathchardef\geq="3215 \let\ge=\geq

    \mathchardef\succ="321F
    \mathchardef\prec="321E
    \mathchardef\approx="3219  \let\simil=\approx % double squiggle
    \mathchardef\succeq="3217
    \mathchardef\preceq="3216
    \mathchardef\supset="321B
    \mathchardef\subset="321A
    \mathchardef\supseteq="3213
    \mathchardef\subseteq="3212
    \mathchardef\in="3232
    \mathchardef\ni="3233 \let\owns=\ni
    \mathchardef\gg="321D
    \mathchardef\ll="321C

    \mathchardef\not="3236

    \mathchardef\sim="3218  \let\iso=\sim % single squiggle
    \mathchardef\simeq="3227
    \mathchardef\perp="323F
    \mathchardef\equiv="3211
    \mathchardef\asymp="3210
    \mathchardef\smile="315E
    \mathchardef\frown="315F

  % Varous arrows

    % mostly horizontal or fixed-size; for vertical extensible ones look
    %  at the "delimiters" section.

    \mathchardef\nearrow="3225
    \mathchardef\searrow="3226
    \mathchardef\nwarrow="322D
    \mathchardef\swarrow="322E
    \mathchardef\Leftrightarrow="322C
      \def\iff{\mathrel{\Leftrightarrow}}
    \mathchardef\Leftarrow="3228
      \def\impliedby{\mathrel{\Leftarrow}}
    \mathchardef\Rightarrow="3229
      \def\implies{\mathrel{\Rightarrow}}

    \let\up=\uparrow
    \let\down=\downarrow

    \mathchardef\leftrightarrow="3224   \let\swap=\leftrightarrow
    \mathchardef\leftarrow="3220        \let\gets=\leftarrow
    \mathchardef\rightarrow="3221       \let\to=\rightarrow
    \mathchardef\mapstochar="3237

    \mathchardef\leftharpoonup="3128
    \mathchardef\leftharpoondown="3129
    \mathchardef\rightharpoonup="312A
    \mathchardef\rightharpoondown="312B

    \mathchardef\lhook="312C \def\hookrightarrow{\lhook\joinrel\rightarrow}
    \mathchardef\rhook="312D \def\hookleftarrow{\leftarrow\joinrel\rhook}

    \def\rightleftharpoons{\mathrel{\mathpalette\rlh@{}}}
    \def\rlh@#1{\vcenter{\hbox{\overlap{
       \raise2pt\hbox{$#1\rightharpoonup$}\crcr
       $#1\leftharpoondown$}}}}

    \def\relbar{\mathrel{\smash-}} % because - has the same height as +
    \def\Relbar{\mathrel=}

    \def\Longrightarrow{\Relbar\joinrel\Rightarrow}
    \def\longrightarrow{\relbar\joinrel\rightarrow}
    \def\longleftarrow{\leftarrow\joinrel\relbar}
    \def\Longleftarrow{\Leftarrow\joinrel\Relbar}

    \def\longmapsto{\mapstochar\longrightarrow}

    \def\longleftrightarrow{\leftarrow\joinrel\rightarrow}
    \def\Longleftrightarrow{\Leftarrow\joinrel\Rightarrow}

  % Pieces used in constructing `brace leaders'

    \mathchardef\braceld="37A \mathchardef\bracerd="37B
    \mathchardef\bracelu="37C \mathchardef\braceru="37D

  % Musical symbols

    \mathchardef\flat="015B
    \mathchardef\natural="015C
    \mathchardef\sharp="015D

  % Card suits

    \mathchardef\clubsuit="027C
    \mathchardef\diamondsuit="027D
    \mathchardef\heartsuit="027E
    \mathchardef\spadesuit="027F

  % Roots

    \def\sqrt{\radical"270370 }
    \def\cbrt{\root 3 \of}

    \newbox\rootbox
    \def\root#1\of{
      \setbox\rootbox\hbox{$\mathsurround=\z@\scriptscriptstyle{#1}$}
      \mathpalette\r@@t}
    \def\r@@t#1#2{\setbox\z@\hbox{$\mathsurround=\z@#1\sqrt{#2}$}
      \dimen@\ht\z@ \advance\dimen@-\dp\z@
      \mskip5mu\raise.6\dimen@\copy\rootbox \mskip-10mu \box\z@}

  % Fancy primes:

    {\catcode`\'=\active \gdef'{^\bgroup\prim@s}}

    \def\prim@s{\prime\futurelet\next\pr@m@s}
    \def\pr@m@s{\ifx'\next \let\next\pr@@@s \else\let\next\egroup\fi \next}
    \def\pr@@@s#1{\prim@s}

  % Sets, sequences, absolute value:

    \def\set#1{{\lbrace #1 \rbrace}}  % set defined by enumeration
    \def\rset#1{{\lbrace \, #1 \,\rbrace}} % set defined by \relv
    \def\such{\;:\;} % `such that' for \rset

    \def\seq#1{{\langle #1 \rangle}}  % sequence
    \def\abs#1{\left| #1 \right|} % absolute value, measure, set size, etc.

  %  Other constructed math symbols

    % Empty set: use norwegian slash-O.  (I don't like it, but I like
    % Knuth's slash-zero even less.) Other options are {\mit \char'036}
    % (Knuth's \phi) or perhaps {\lbrace\rbrace} (\`a la LISP).  
    
    \def\emptyset{\mathpalette\@mptyset{\mathchar"001F}} % Nordic slash-O.
    \def\@mptyset#1#2{
      {\setbox0\hbox{$\mathsurround=\z@#1#2$}\lower0.1\ht0\box0}
    }
    \let\ety=\emptyset

    \def\hbar{{\mathchar'26\mskip-9muh}}

    \def\models{\mathrel|\joinrel=}

    \def\sp{\mathbin{\,}} % to denote continuous intervals (segs, arcs, etc)
    \def\isp{\mathbin{.\,.}} % to denote integer intervals (as in Pascal)

    \def\mapsto{\mapstochar\rightarrow}

    \def\doteq{\buildrel\textstyle.\over=}

    \def\*{\discretionary
      {\thinspace\edef\next{\the\basefont\syfam}\next\char2}{}{}}

    \def\cong{\mathrel{\mathpalette\@vereq\sim}} % congruence sign

    \def\neq{\not=} \let\ne=\neq

    \def\nequiv{\not\equiv}

    \def\notin{\mathrel{\mathpalette\c@ncel\in}}

    \def\doubleint{\int\!\!\!\int} % double integral

    \def\bowtie{\mathrel\triangleright\joinrel\mathrel\triangleleft}

    \def\deg{^\circ} % degrees
    \def\star{^\ast} % asterisk in superscript position.

    \def\angle{{\vbox{\ialign
       {$\mathsurround=\z@\scriptstyle##$\cr\not\mathrel{\mkern14mu}\cr
        \noalign{\nointerlineskip}
        \mkern2.5mu\leaders\hrule height.34pt\hfill\mkern2.5mu\cr}}}}

% BIGGGER SYMBOLS

  \message{biggger symbols ...}

  %  Simply big ones: augment the gross size

    \def\big#1{\hbox{$\bigger #1 $}}

  %  Really big ones (delimiters only; use the normal extension machinery):

    \def\Big#1{
      {\hbox{$\left#1\vbox to1.35\ht\strutbox{}\right.\n@space$}}}
    \def\bigg#1{
      {\hbox{$\left#1\vbox to1.70\ht\strutbox{}\right.\n@space$}}}
    \def\Bigg#1{
      {\hbox{$\left#1\vbox to2.25\ht\strutbox{}\right.\n@space$}}}

    \def\n@space{\nulldelimiterspace\z@ \mathsurround=\z@}

  % Biggger delimiters

    \def\bigl#1{\mathopen{\big#1}}
    \def\bigm#1{\mathrel{\big#1}}
    \def\bigr#1{\mathclose{\big#1}}
    \def\Bigl#1{\mathopen{\Big#1}}
    \def\Bigm#1{\mathrel{\Big#1}}
    \def\Bigr#1{\mathclose{\Big#1}}
    \def\biggl#1{\mathopen{\bigg#1}}
    \def\biggm#1{\mathrel{\bigg#1}}
    \def\biggr#1{\mathclose{\bigg#1}}
    \def\Biggl#1{\mathopen{\Bigg#1}}
    \def\Biggm#1{\mathrel{\Bigg#1}}
    \def\Biggr#1{\mathclose{\Bigg#1}}

% DOTS

  \message{dots ...}

    \mathchardef\ldotp="602E % ldot as a punctuation mark
    \mathchardef\cdotp="6201 % cdot as a punctuation mark

    \mathchardef\colon="603A % colon as a punctuation mark

    \def\ldots{\mathinner{\ldotp\ldotp\ldotp}}
    \def\cdots{\mathinner{\cdotp\cdotp\cdotp}}

    % Note: the height of \vdots and \ddots does not change in \script,
    %    \scriptscript, and \bigmath modes.

    \def\vdots{
      \lower0.25ex\hbox{
        \vbox{
          \baselinesep0.75ex\lineseplimit=-1000pt
          \hbox{.}\hbox{.}\hbox{.}
        }
      }
    }

    \def\ddots{\mathinner{
      \mskip1mu\raise1.25ex\hbox{.}
      \mskip2mu\raise0.50ex\hbox{.}
      \mskip2mu\raise-0.25ex\hbox{.}
      \mskip1mu}}

    % Succint repetition dots:
    
    \def\dd{\mathpunct{\ldotp\ldotp}}
    \def\cdd{\mathpunct{\cdotp\cdotp}}

% LEADERS

  \message{leaders ...}

  % with rules

    \def\hrulefill{\leaders\hrule\hfill}

  % with dots

    \def\dotfill{\cleaders\hbox{$\mathsurround=\z@ \mkern1.5mu.\mkern1.5mu$}\hfill}

  % with braces

    \def\downbracefill{$\mathsurround=\z@\braceld\leaders\vrule\hfill\braceru
      \bracelu\leaders\vrule\hfill\bracerd$}

    \def\upbracefill{$\mathsurround=\z@\bracelu\leaders\vrule\hfill\bracerd
      \braceld\leaders\vrule\hfill\braceru$}

    % with arrows

    \def\rightarrowfill{$\mathsurround=\z@\mathord-\mkern-6mu%
      \cleaders\hbox{$\mkern-2mu\mathord-\mkern-2mu$}\hfill
      \mkern-6mu\mathord\rightarrow$}

    \def\leftarrowfill{$\mathsurround=\z@\mathord\leftarrow\mkern-6mu%
      \cleaders\hbox{$\mkern-2mu\mathord-\mkern-2mu$}\hfill
      \mkern-6mu\mathord-$}

% MATH ACCENTS

  \message{accents ...}

  % Accents proper

    \def\acute{\mathaccent"7013 }
    \def\grave{\mathaccent"7012 }
    \def\ddot{\mathaccent"707F }
    \def\tilde{\mathaccent"707E }
    \def\bar{\mathaccent"7016 }
    \def\breve{\mathaccent"7015 }
    \def\check{\mathaccent"7014 }
    \def\hat{\mathaccent"705E }
    \def\vec{\mathaccent"717E }
    \def\dot{\mathaccent"705F }
    \def\widetilde{\mathaccent"0365 }
    \def\widehat{\mathaccent"0362 }

    \def\skew#1#2#3{{#2{#3\mkern#1mu}\mkern-#1mu}{}}

  % Fancy overlines/underlines

    \def\overbrace#1{\mathop{\vbox{\ialign{##\crcr
      \noalign{\kern3\p@}
      \downbracefill\crcr
      \noalign{\kern3\p@\nointerlineskip}
      $\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}

    \def\underbrace#1{\mathop{\vtop{\ialign{##\crcr
      $\hfil\displaystyle{#1}\hfil$\crcr
      \noalign{\kern3\p@\nointerlineskip}
      \upbracefill\crcr
      \noalign{\kern3\p@}}}}\limits}

    \def\overrightarrow#1{\vbox{\ialign{##\crcr
      \rightarrowfill\crcr
      \noalign{\kern-\p@\nointerlineskip}
      $\hfil\displaystyle{#1}\hfil$\crcr}}}

    \def\overleftarrow#1{\vbox{\ialign{##\crcr
      \leftarrowfill\crcr
      \noalign{\kern-\p@\nointerlineskip}
      $\hfil\displaystyle{#1}\hfil$\crcr}}}

  \message{done.}

\catcode`@=12 \endlinechar=`\^^M

% END


