3188
|
1 |
|
|
2 |
\chapter{Presenting theories}
|
|
3 |
|
|
4 |
\section{Generating HTML documents} \label{sec:html}
|
|
5 |
\index{HTML|bold}
|
|
6 |
|
|
7 |
Isabelle is able to make HTML documents that show a theory's
|
|
8 |
definition, the theorems proved in its ML file and the relationship
|
3217
|
9 |
with its ancestors and descendants. HTML is the hypertext markup
|
|
10 |
language used on the World Wide Web to represent text containing
|
|
11 |
images and links to other documents. These documents may be viewed
|
|
12 |
using Web browsers like Netscape or Lynx.
|
3188
|
13 |
|
|
14 |
Besides the three HTML files that are made for every theory
|
|
15 |
(definition and theorems, ancestors, descendants), Isabelle stores
|
|
16 |
links to all theories in an index file. These indexes are themself
|
|
17 |
linked with other indexes to represent the hierarchic structure of
|
|
18 |
Isabelle's logics.
|
|
19 |
|
3217
|
20 |
\medskip To make HTML files for logics that are part of the Isabelle
|
|
21 |
distribution, simply append ``\texttt{-h true}'' to the
|
|
22 |
\texttt{ISABELLE_USEDIR_OPTIONS} setting before making a logic. For
|
|
23 |
example, to generate HTML files for {\FOL}, first add something like
|
|
24 |
this to your \texttt{\~\relax/isabelle/etc/settings} file:
|
3188
|
25 |
\begin{ttbox}
|
3217
|
26 |
ISABELLE_USEDIR_OPTIONS="-h true"
|
3188
|
27 |
\end{ttbox}
|
3217
|
28 |
Then \texttt{cd} into the \texttt{src/FOL} directory of the Isabelle
|
|
29 |
distribution and do an \texttt{isatool make} (or even \texttt{isatool
|
|
30 |
make test}).
|
3188
|
31 |
|
3217
|
32 |
\medskip As some of Isabelle's logics are based on others (e.g. {\tt
|
|
33 |
ZF} on {\tt FOL}) and because the HTML files list a theory's
|
|
34 |
ancestors, you should not make HTML files for a logic if the HTML
|
|
35 |
files for the base logic do not exist. Otherwise some of the hypertext
|
|
36 |
links might point to non-existing documents.
|
3188
|
37 |
|
|
38 |
The entry point to all logics is the {\tt index.html} file located in
|
3217
|
39 |
Isabelle's main directory.
|
3188
|
40 |
|
3217
|
41 |
A complete HTML version of all distributed Isabelle object-logics and
|
|
42 |
examples may be accessed on the WWW at:
|
3188
|
43 |
\begin{ttbox}
|
|
44 |
http://www4.informatik.tu-muenchen.de/~nipkow/isabelle/
|
|
45 |
\end{ttbox}
|
3217
|
46 |
Note that this is not necessarily consistent with your local sources!
|
3188
|
47 |
|
|
48 |
|
3217
|
49 |
\section*{*HTML generation internals}
|
3188
|
50 |
|
3217
|
51 |
The generation of HTML files is controlled by the following {\ML}
|
|
52 |
commands and reference variables:
|
3188
|
53 |
\begin{ttbox}
|
|
54 |
init_html : unit -> unit
|
|
55 |
make_html : bool ref
|
|
56 |
finish_html : unit -> unit
|
|
57 |
\end{ttbox}
|
|
58 |
|
|
59 |
\begin{ttdescription}
|
|
60 |
\item[\ttindexbold{init_html}]
|
|
61 |
activates the HTML facility. It stores the current working directory
|
|
62 |
as the place where the {\tt index.html} file for all theories loaded
|
|
63 |
afterwards will be stored.
|
|
64 |
|
|
65 |
\item[\ttindexbold{make_html}]
|
|
66 |
is a boolean reference variable read by {\tt use_thy} and other
|
|
67 |
functions to decide whether HTML files should be made. After you have
|
|
68 |
used {\tt init_html} you can manually change {\tt make_html}'s value
|
|
69 |
to temporarily disable HTML generation.
|
|
70 |
|
|
71 |
\item[\ttindexbold{finish_html}]
|
|
72 |
has to be called after all theories have been read that should be
|
|
73 |
listed in the current {\tt index.html} file. It reads a temporary
|
|
74 |
file with information about the theories read since the last use of
|
|
75 |
{\tt init_html} and makes the {\tt index.html} file. If {\tt
|
|
76 |
make_html} is {\tt false} nothing is done.
|
|
77 |
|
3217
|
78 |
The indexes made by this function also contain a link to the
|
|
79 |
\texttt{README.html} or \texttt{README} file if there exists one in
|
|
80 |
the directory where the index is stored. If there's a {\tt
|
|
81 |
README.html} file it is used instead of {\tt README}.
|
3188
|
82 |
|
|
83 |
\end{ttdescription}
|
|
84 |
|
|
85 |
The above functions could be used in the following way:
|
|
86 |
|
|
87 |
\begin{ttbox}
|
|
88 |
init_html();
|
3217
|
89 |
{\out Setting path for index.html to "/home/me/Isabelle-dist/src/HOL"}
|
3188
|
90 |
use_thy "List";
|
|
91 |
\dots
|
|
92 |
finish_html();
|
|
93 |
\end{ttbox}
|
|
94 |
|
|
95 |
Please note that HTML files are made only for those theories that are
|
3217
|
96 |
read while \texttt{make_html} is \texttt{true}. These files may
|
|
97 |
contain links to theories that were read with a \texttt{make_html} set
|
|
98 |
to \texttt{false} and therefore point to non-existing files.
|
3188
|
99 |
|
|
100 |
|
|
101 |
\section*{Extending or adding a logic}
|
|
102 |
|
3217
|
103 |
If you add a new subdirectory to Isabelle's logics (or add a
|
|
104 |
completely new logic), you would have to call {\tt init_html} at the
|
|
105 |
start of every directory's {\tt ROOT.ML} file and {\tt finish_html} at
|
|
106 |
the end of it. This is automatically done if you use
|
3188
|
107 |
|
|
108 |
\begin{ttbox}\index{*use_dir}
|
|
109 |
use_dir : string -> unit
|
|
110 |
\end{ttbox}
|
|
111 |
|
|
112 |
This function takes a path as its parameter, changes the working
|
|
113 |
directory, calls {\tt init_html} if {\tt make_html} is {\tt true},
|
|
114 |
executes {\tt ROOT.ML}, and calls {\tt finish_html}. The {\tt
|
|
115 |
index.html} file written in this directory will be automatically
|
|
116 |
linked to the first index found in the (recursively searched)
|
3217
|
117 |
super directories.
|
3188
|
118 |
|
3217
|
119 |
The \texttt{usedir} utility (see also \S\ref{sec:tool-usedir}) will
|
|
120 |
automatically take care of this.
|
3188
|
121 |
|
3217
|
122 |
\medskip The generated HTML files contain all theorems that were
|
|
123 |
proved in the theory's \ML{} file with {\tt qed}, {\tt qed_goal} and
|
|
124 |
{\tt qed_goalw}, or stored with {\tt bind_thm} and {\tt store_thm}.
|
|
125 |
Additionally, there is a hypertext link to the whole \ML{} file.
|
3188
|
126 |
|
|
127 |
You can add section headings to the list of theorems by using
|
|
128 |
|
|
129 |
\begin{ttbox}\index{*use_dir}
|
|
130 |
section: string -> unit
|
|
131 |
\end{ttbox}
|
|
132 |
|
|
133 |
in a theory's ML file, which converts a plain string to a HTML
|
|
134 |
heading and inserts it before the next theorem proved or stored with
|
3217
|
135 |
one of the above functions.
|
3188
|
136 |
|
|
137 |
|
3217
|
138 |
\section*{*Using someone else's database}
|
3188
|
139 |
|
|
140 |
To make them independent from their storage place, the HTML files only
|
|
141 |
contain relative paths which are derived from absolute ones like the
|
|
142 |
current working directory, {\tt gif_path} or {\tt base_path}. The
|
|
143 |
latter two are reference variables which are initialized at the time
|
|
144 |
when the {\tt Pure} database is made. Because you need write access
|
|
145 |
for the current directory to make HTML files and therefore (probably)
|
|
146 |
generate them in your home directory, the absolute {\tt base_path} is
|
|
147 |
not correct if you use someone else's database or a database derived
|
|
148 |
from it.
|
|
149 |
|
|
150 |
In that case you first should set {\tt base_path} to the value of {\em
|
|
151 |
your} Isabelle main directory, i.e. the directory that contains the
|
|
152 |
subdirectories where standard logics like {\tt FOL} and {\tt HOL} or
|
|
153 |
your own logics are stored. If you do not do this, the generated HTML
|
|
154 |
files will still be usable but may contain incomplete titles and lack
|
|
155 |
some hypertext links.
|
|
156 |
|
|
157 |
It's also a good idea to set {\tt gif_path} which points to the
|
3217
|
158 |
directory containing two GIF images used in the HTML documents.
|
|
159 |
Normally this is the \texttt{src/Tools} subdirectory of Isabelle's
|
3188
|
160 |
main directory. While its value in general is still valid, your HTML
|
|
161 |
files would depend on files not owned by you. This prevents you from
|
|
162 |
changing the location of the HTML files (as they contain relative
|
|
163 |
paths) and also causes trouble if the database's maker (re)moves the
|
|
164 |
GIFs.
|
|
165 |
|
|
166 |
Here's what you should do before invoking {\tt init_html} using
|
|
167 |
someone else's \ML{} database:
|
|
168 |
|
|
169 |
\begin{ttbox}
|
3217
|
170 |
base_path := "/home/someone/Isabelle-dist/src";
|
|
171 |
gif_path := "/home/someone/Isabelle-dist/src/Tools";
|
3188
|
172 |
init_html();
|
|
173 |
\dots
|
|
174 |
\end{ttbox}
|