|
| 1 | +\documentclass{article} |
| 2 | + |
| 3 | +\usepackage{holtexbasic} |
| 4 | +\usepackage{proof} |
| 5 | +\usepackage{alltt} |
| 6 | +\include{macros.tex} |
| 7 | + |
| 8 | +\renewcommand{\HOLConst}[1]{\textsf{#1}} |
| 9 | + |
| 10 | +\title{Writing \LaTeX{} with Embedded HOL} |
| 11 | +\author{HOL Developers} |
| 12 | +\date{} |
| 13 | + |
| 14 | +\begin{document} |
| 15 | + |
| 16 | +\maketitle |
| 17 | +\begin{abstract} |
| 18 | +This document attempts to provide a tutorial-like introduction to the process of generating \LaTeX{} files (and ultimately, PDFs) that include pretty-printed material from HOL theories. |
| 19 | +While the \textsc{Description} manual includes a fairly careful description of HOL's solution to this problem (the ``munger''), it can be hard to get started using just that documentation. |
| 20 | +This document provides a simple, sample document that covers a number of standard features, and does so in a style that we hope is easy to understand. |
| 21 | +\end{abstract} |
| 22 | + |
| 23 | +\section{Introduction} |
| 24 | + |
| 25 | +The premise is that this document will simultaneously explain \LaTeX-munging while illustrating the use of the technology with respect to a miniature HOL formalisation (on binary trees). |
| 26 | +Under \texttt{HOL/examples/latex-generation}, we find a somewhat plausible picture: |
| 27 | +in the directory \texttt{theories}, there is a HOL development consisting of two theory files: \texttt{sampleTreeScript.sml} and \texttt{bstScript.sml}, with the latter building on the former. |
| 28 | +This represents the HOL development that is to be documented for publication in this paper. |
| 29 | +In the second directory, \texttt{paper} are all the sources for this PDF. |
| 30 | + |
| 31 | +There is no requirement for the two directories to be siblings of each other in this way, but it is convenient in this context. |
| 32 | +In practice, the theory files will be in one repository (possibly quite public), and the paper will be in a separate space, possibly backed by a more private repository. |
| 33 | + |
| 34 | +The basic flow is that as authors we will write a special \texttt{paper.htex} file, pretending that we are writing normal \LaTeX{} document, but with access to special extra commands (\texttt{\bs{}HOLthm\lb\dots\rb} and others) for inserting HOL material. |
| 35 | +Our source \texttt{paper.htex} file will be built into the PDF by first being translated into genuine \LaTeX{} file \texttt{paper.tex}, which can then be turned into a PDF with the usual technology (here we will assume use of \texttt{latexmk}). |
| 36 | + |
| 37 | +\subsection{Manifest} |
| 38 | + |
| 39 | +The following summarises the contents of the \texttt{papers} directory, with more details to come later in this document: |
| 40 | +\begin{description} |
| 41 | +\item[\texttt{.gitignore}] Specification of names of generated files that \texttt{git} should ignore so that generated files don't end up being committed to repositories. |
| 42 | +\item[\texttt{Holmakefile}] This file specifies the standard build instructions, and includes a pointer to the directory where the HOL sources are to be found in the \texttt{INCLUDES =} line. |
| 43 | +\item[\texttt{macros.tex}] A file of macros supporting our paper; this file can be (and is) perfectly standard \LaTeX, and is \texttt{\bs{}include}-d into the \texttt{paper.htex} file as one might normally proceed. |
| 44 | +\item[\texttt{overrides}] This files includes custom replacements for HOL symbols to give them prettier \LaTeX{} renderings. |
| 45 | +\item[\texttt{paper.htex}] The sources for this paper. |
| 46 | +\item[\texttt{ppLib.sml}] A small HOL ``library'' that refers to the HOL theories where the desired results are present, or which have ancestors where those results are present. |
| 47 | +In our case, the \texttt{ppLib.sml} file refers to \texttt{bstTheory}, which will give us the ability to refer to theorems from \texttt{bstTheory} and \texttt{sampleTheory} both (because the latter is an ancestor of the former, and it's impossible to have a child theory in context without also having its parent). |
| 48 | +\end{description} |
| 49 | + |
| 50 | +After a call to \texttt{Holmake}, the required theories (\texttt{bst} and its ancestors) in \texttt{theories} will be rebuilt, and the following files will be generated in the \texttt{papers} directory: |
| 51 | +\begin{description} |
| 52 | +\item[\texttt{.hol}] The usual output directory containing HOL object files, logs and the like. |
| 53 | +\item[\texttt{holtexbasic.sty}] A file specifying the standard HOL \LaTeX{} macros, copied across into the working directory from the HOL source tree. |
| 54 | +\item[\texttt{munge}] The munging executable responsible for turning \texttt{paper.htex} into \texttt{paper.tex}. |
| 55 | +This program is a Unix filter, reading from \texttt{stdin} and writing to \texttt{stdout}. |
| 56 | +\item[\texttt{paper.pdf}] The PDF of this document. |
| 57 | +\item[\texttt{paper.tex}] The translated paper file, containing \LaTeX{} replacements for all of the special HOL-macros. |
| 58 | +\item[\texttt{paper.*}] A slew of the usual auxiliary files generated by \LaTeX{} and \texttt{latexmk} as the PDF is generated. |
| 59 | +\end{description} |
| 60 | + |
| 61 | +\subsection{Sample Usages} |
| 62 | + |
| 63 | +\noindent The output on the right is generated by writing what appears in the left column: |
| 64 | + |
| 65 | +\begin{center} |
| 66 | +\begin{minipage}[t]{0.35\textwidth} |
| 67 | +\begin{alltt} |
| 68 | +Lead-in text: |
| 69 | +\bs{}begin\lb{}alltt\rb{} |
| 70 | +Alltt text: |
| 71 | +\bs{}HOLthm\lb{}bst.keys_elems\rb{} |
| 72 | +\bs{}end\lb{}alltt\rb{} |
| 73 | +The constant \bs{}HOLtm\lb{}keys\rb{} |
| 74 | +returns the set of a |
| 75 | +binary search tree's keys. |
| 76 | +\end{alltt} |
| 77 | +\end{minipage}\hfill{} |
| 78 | +\begin{minipage}[t]{0.55\textwidth} |
| 79 | +Lead-in text: |
| 80 | +\begin{alltt} |
| 81 | +Alltt text: |
| 82 | +\HOLthm{bst.keys_elems} |
| 83 | +\end{alltt} |
| 84 | +The constant \HOLtm{keys} returns the set of a binary search tree's keys. |
| 85 | +\end{minipage} |
| 86 | +\end{center} |
| 87 | + |
| 88 | +\end{document} |
0 commit comments