% First, second, third, n-th, premier, second, n-ieme

\def\th{^{\mbox{\scriptsize th}}}
\def\st{^{\mbox{\scriptsize st}}}
\def\nd{^{\mbox{\scriptsize nd}}}
\def\rd{^{\mbox{\scriptsize rd}}}
\def\ier{^{\mbox{\scriptsize ier}}}
\def\iere{^{\mbox{\scriptsize i\`ere}}}
\def\ieme{^{\mbox{\scriptsize i\`eme}}}
\def\eme{^{\mbox{\scriptsize e}}}

% e.g., i.e., et al.
\def\eg{e.g.\ }
\def\ie{i.e.\ }
\def\vs{vs.\ }
\def\etal{{\em et al.}\ }

% Theorem environments

\newtheorem{prop}{Proposition}
\ifx\proof\undefined% Some styles, e.g. jfp.sty, already provide a "proof" env.
\def\proof{\trivlist \item[\hskip\labelsep {\bf Proof:}]}
\def\endproof{\hspace*{0pt plus 1fill}$\Box$\endtrivlist}
\fi
%% \ifx\example\undefined
%% \def\example{\trivlist \item[\hskip\labelsep {\bf Example:}]}
%% \def\endexample{\hspace*{0pt plus 1fill}$\Box$\endtrivlist}
%% \fi
\def\case#1.{\medskip\noindent {\bf Case} #1.}
\def\cas#1.{\medskip\noindent {\bf Cas} #1.}
\def\andalso{\quad\mbox{and}\quad}

% Alternate names for various math stuff

\def\alt{\mid}                  % `or' in a grammar
\def\dot{.\,}                   % for proper spacing in lambda terms
\let\syntequal=\equiv           % three-line equal
\def\equiv{\approx}             % wavy equal
\def\epsilon{\varepsilon}       % Good-looking epsilon
\def\phi{\varphi}               % Good-looking phi
\def\reduce{\stackrel{*}{\rightarrow}} % Reduction relation
\def\fun{\rightarrow}           % Function type
\def\Fun{\Rightarrow}           % Function kinds
\def\becomes{\leftarrow}        % In substitutions
\def\Dom{{\rm Dom}}
\def\Im{{\rm Rng}}
\def\inter{\cap}
\def\biginter{\bigcap}
\def\union{\cup}
\def\bigunion{\bigcup}
\def\ttSigma{\hbox{\tt\char6}}  % Sigma in typewriter font
\def\rond{\circ}                % Function composition
\def\sem{\models}               % |=

% Denotational brackets
\def\den#1{[\![#1]\!]}

% For syntax definitions
% \begin{syntax}
% left-hand side & ::=  & right-hand side & comment \\
%                & \alt & more right-hand side & more comment
% \end{syntax}
% Use \syntaxclass{Foo} to insert a title line above a syntax definition.
% Do not put \\ before \end{syntax} or \syntaxclass{...}
% Use \begin{syntaxleft} ... \end{syntaxleft} to insert the title
% lines to the left of the definitions.

\def\syntaxvspace{\medskip}

\def\syntax{
\par\syntaxvspace\goodbreak\noindent
\bgroup
\let\\=\cr
\interlinepenalty=50            % discourage page breaks in a definition
\global\let\syntaxclass=\firstsyntaxclass
\if@twocolumn
\halign\bgroup~~$##$&\hfil${}##{}$&$##$~\hfil&##\hfil\cr
\else
\halign\bgroup\qquad\qquad$##$&\hfil${}##{}$&$##$\quad\hfil&##\hfil\cr
\fi
}
\def\endsyntax{\cr\egroup\egroup\par\syntaxvspace\noindent\ignorespaces}

\def\firstsyntaxclass#1{
\omit\hbox to 0pt{#1\hss}\cr
\global\let\syntaxclass=\nextsyntaxclass
}

\def\nextsyntaxclass#1{
\cr\noalign{\smallskip\penalty-100}\omit\hbox to 0pt{#1\hss}\cr
}

\def\syntaxleft{
\par\syntaxvspace\goodbreak\noindent
\bgroup
\let\\=\cr
\interlinepenalty=50            % discourage page breaks in a definition
\global\let\syntaxclass=\firstsyntaxclassleft
\if@twocolumn
\halign\bgroup\hfil$##$&\hfil${}##{}$&$##$~\hfil&##\hfil\cr
\else
\halign\bgroup\hfil$##$&\hfil${}##{}$&$##$\quad\hfil&##\hfil\cr
\fi
}
\let\endsyntaxleft=\endsyntax

\def\firstsyntaxclassleft#1{
$\hfilneg#1\quad\hfil$
\global\let\syntaxclass=\nextsyntaxclassleft
}

\def\nextsyntaxclassleft#1{
\cr\noalign{\smallskip\goodbreak}$\hfilneg#1\quad\hfil$
}

% To put a frame around an arbitrary amount of vertical material.
% \begin{framed} ... \end{framed}

\def\framed{%
\setbox0=\vbox\bgroup%
\advance\hsize by -2\fboxsep\advance\hsize by -2\fboxrule}

\def\endframed{%
\egroup\noindent\framebox[\textwidth]{\box0}}

% A relatively good-looking "C++". It hurts.

\def\Cplusplus{C{\tt ++}}

% To make slides

\def\transp{\begin{slide}{}\@ifnextchar[{\opttitle}{}}
\def\endtransp{\end{slide}}
\def\opttitle[#1]{\titletransp{#1}}
\def\titlecolor{}

\def\titletranspadvi#1{
   \begin{center} \titlecolor \bf #1 \\[2mm]
   \includegraphics[width=\textwidth,height=0.6em]{bar.jpg.eps}
   \end{center}
   \bigskip}
\def\titletranspplain#1{
  {\titlecolor \begin{center} \bf #1 \end{center} \medskip \hrule}
  \bigskip}
\def\titletransp#1{
  \ifx\ifadvi\undefined
  \titletranspplain{#1}
  \else
  \ifadvi{\titletranspadvi{#1}}{\titletranspplain{#1}}
  \fi}
\def\centeredtransp{
  \begin{slide}{}\@ifnextchar[{\opttitle}{}
  \vspace*{0pt plus 1fil}
}
\def\endcenteredtransp{\vspace*{0pt plus 1fil}\end{slide}}

% To put two pieces of text side by side

\newdimen{\colwidth}
\def\sidebysidegutter{5mm}
\def\sidebysidehalfgutter{2.5mm}

\def\sidebyside{%
\begin{center}%
\colwidth=\textwidth%
\advance\colwidth by-\sidebysidegutter%
\divide\colwidth by2%
\emergencystretch=3cm%
\begin{minipage}[t]{\colwidth}\ignorespaces}

\def\nextto{%
  \end{minipage}\kern\sidebysidegutter\begin{minipage}[t]{\colwidth}\ignorespaces}%

\def\nexttorule{%
  \end{minipage}\kern\sidebysidehalfgutter\vrule\kern\sidebysidehalfgutter\begin{minipage}[t]{\colwidth}\ignorespaces}%

\def\endsidebyside{\end{minipage}\end{center}\ignorespaces}

% Breaking a formula in two lines (cf. The TexBook p. 196).

\def\twolinedisplay#1#2{\displaylines{\quad#1\hfill\cr\hfill{}#2\quad\cr}}

% To allow breaks in identifiers or such

\def\={\discretionary{}{}{}}

% Write a URL, allowing breaks at slashes

%% Doesn't work in LaTeX2e
%%\def\citeurl{%
%%\bgroup%
%%\hyphenchar\nintt=`/\hyphenchar\tentt=`/%
%%\hyphenchar\elvtt=`/\hyphenchar\twltt=`/%
%%\catcode`\~=12\relax\typeseturl}

{\catcode`\/=13\global\def/{\char47\discretionary{}{}{}}}
\def\citeurl{\bgroup\catcode`\/=13\catcode`\~=12\relax\typeseturl}
\def\typeseturl#1{\tt #1\egroup}

% Display a PIC drawing

\def\showgraph{\par\medskip\centerline{\raise 1em\box\graph}\medskip}

% Ragged right paragraph boxes in tabular environment
\def\arrayragged{\let\temp=\\\raggedright\let\\=\temp}

% Itemize with minimal vertical size (for slides)
\def\compactitemizesize{}
\def\compactitemize{%
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter
    \list
      \csname\@itemitem\endcsname
      {\compactitemizesize\parsep 0pt \topsep 0pt \itemsep 0pt \partopsep 0pt}%
}
\def\endcompactitemize{\endlist}

% Euros

%\def\euro{{\sf C}{\tiny$\!\!\!\!\!\!^=$}}
