\documentclass[11pt]{article}
\usepackage{bcprules,proof}
\parindent=0pt


% variables
\newcommand{\vf} {\mbox{\tt f}}
\newcommand{\vg} {\mbox{\tt g}}
\newcommand{\vs} {\mbox{\tt s}}
\newcommand{\vt} {\mbox{\tt t}}
\newcommand{\vtp} {\mbox{\tt t}^{\prime}}
\newcommand{\vtpp} {\mbox{\tt t}^{\prime\prime}}
\newcommand{\vu} {\mbox{\tt u}}
\newcommand{\vup} {\mbox{\tt u}^{\prime}}
\newcommand{\vv} {\mbox{\tt v}}
\newcommand{\vx} {\mbox{\tt x}}
\newcommand{\vy} {\mbox{\tt y}}
\newcommand{\vz} {\mbox{\tt z}}
% type variables
\newcommand{\vR} {\mbox{\tt R}}
\newcommand{\vS} {\mbox{\tt S}}
\newcommand{\vT} {\mbox{\tt T}}
\newcommand{\vTp} {\mbox{\tt T}^{\prime}}
\newcommand{\vV} {\mbox{\tt V}}
\newcommand{\vW} {\mbox{\tt W}}
% boolean constants
\newcommand{\ct} {\mbox{\tt true}}
\newcommand{\cf} {\mbox{\tt false}}
\newcommand{\cB} {\mbox{\tt Bool}}
% nat constants
\newcommand{\cz} {\mbox{\tt 0}}
\newcommand{\cN} {\mbox{\tt Nat}}
% term forms
\newcommand{\ite}[3] {\mbox{\tt if ${#1}$ then ${#2}$ else ${#3}$}}
\newcommand{\suc}[1] {\mbox{\tt succ ${#1}$}}  % succ is already defined in latex
\newcommand{\pred}[1] {\mbox{\tt pred ${#1}$}}
\newcommand{\iszero}[1] {\mbox{\tt iszero ${#1}$}}
\newcommand{\labs}[3] {\mbox{\tt $\lambda{#1}$:${#2}$.${#3}$}}
% judgments
\newcommand{\hast}[2] {{#1}:{#2}}
\newcommand{\tr}[3] {{#1}\vdash{#2}:{#3}}

\begin{document}
\title{Typesetting examples in the style of Pierce's book}
\author{Andrew Tolmach}
\maketitle

I use an ad-hoc collection of tools for typesetting:
\begin{itemize}
\item
For representing object language syntax, I define macros in
the style shown above, extending the set as necessary to cover
new language features. This is tedious, but it helps me keep
things well-formed.
\item 
For stating inference rules, I use the {\tt bcprules} package.
\item
For showing derivations, I use the {\tt proof} package.
\end{itemize}


For example, here are the inference rules in Figures 8-1 and 8-2 on p.93:

\infax[T-True]{\hast{\ct}{\cB}}

\infax[T-False]{\hast{\cf}{\cB}}

\infrule[T-If]
  {\hast{\vt_1}{\cB} \andalso \hast{\vt_2}{\vT} \andalso \hast{\vt_3}{\vT}}
  {\hast{\ite{\vt_1}{\vt_2}{\vt_3}}{\vT}}

\infax[T-Zero]
  {\hast{\cz}{\cN}}

\infrule[T-Succ]
  {\hast{\vt_1}{\cN}}
  {\hast{\suc{\vt_1}}{\cN}}

\infrule[T-Pred]
  {\hast{\vt_1}{\cN}}
  {\hast{\pred{\vt_1}}{\cN}}

\infrule[T-IsZero]
  {\hast{\vt_1}{\cN}}
  {\hast{\iszero{\vt_1}}{\cB}}

\eject
Here is the text of Lemma 8.2.2 on p. 94:

\begin{enumerate}
\item
If $\hast{\ct}{\vR}$, then $\vR = \cB$.
\item
If $\hast{\cf}{\vR}$, then $\vR = \cB$.
\item
If $\hast{\ite{\vt_1}{\vt_2}{\vt_3}}{\vR}$, then 
$\hast{\vt_1}{\cB}$,$\hast{\vt_2}{\vR}$, and $\hast{\vt_3}{\vR}$.
\item
If $\hast{\cz}{\vR}$, then $\vR = \cN$.
\item
If $\hast{\suc{\vt_1}}{\vR}$, then $\vR = \cN$ and $\hast{\vt_1}{\cN}$.
\item
If $\hast{\pred{\vt_1}}{\vR}$, then $\vR = \cN$ and $\hast{\vt_1}{\cN}$.
\item
If $\hast{\iszero{\vt_1}}{\vR}$, then $\vR = \cB$ and $\hast{\vt_1}{\cN}$.
\end{enumerate}


Finally, here is the derivation near the bottom of p. 94:

\vspace*{0.5in}

\infer[\mbox{\sc T-If}]
{\hast{\ite{\iszero{\cz}}{\cz}{\pred{\cz}}}{\cN}}
{
 \infer[\mbox{\sc T-IsZero}]
 {\hast{\iszero{\cz}}{\cB}}
 {\infer[\mbox{\sc T-Zero}]
   {\hast{\cz}{\cN}} 
   {}}
 &
 \infer[\mbox{\sc T-Zero}]
  {\hast{\cz}{\cN}}
  {}
 &
 \infer[\mbox{\sc T-Pred}]
 {\hast{\pred{\cz}}{\cN}}
 {\infer[\mbox{\sc T-Zero}]
   {\hast{\cz}{\cN}}
   {}}
}

\vspace*{0.5in}

I'm sure there are better ways of doing some or all of these things;
contributions and suggestions are welcome!

\end{document}

