| 1 |
% STOLEN VERSION of ``zguide.tex'' 11th December 1990 |
| 2 |
% Copyright (C) J. M. Spivey 1990 |
| 3 |
|
| 4 |
% The zed style option and its documentation may be freely copied, |
| 5 |
% distributed and used for any purpose except direct commercial gain, |
| 6 |
% provided that they are copied and distributed as a whole and without |
| 7 |
% modification. The author accepts no liablility for their accuracy or |
| 8 |
% fitness for any purpose. |
| 9 |
|
| 10 |
\documentclass{article} |
| 11 |
|
| 12 |
\usepackage{zed-csp} |
| 13 |
|
| 14 |
\def\fuzz{{\large\it f\kern0.1em}{\normalsize\sc uzz}} |
| 15 |
\let\Fuzz=\fuzz |
| 16 |
\def\ZRM{{\rm ZRM}} |
| 17 |
|
| 18 |
\makeatletter % Oh-ho: here comes some more lark's vomit ... |
| 19 |
|
| 20 |
\def\demo{\par\vbox\bgroup\begingroup\quote} |
| 21 |
\def\gives{\endquote\endgroup\egroup} |
| 22 |
\def\enddemo{\global\@ignoretrue} |
| 23 |
|
| 24 |
% Try doing this in pure LaTeX without `visual formatting'! |
| 25 |
\def\symtab{\setbox0=\vbox\bgroup \def\\{\cr} |
| 26 |
\halign\bgroup\strut$##$\hfil&\quad##\hfil\cr} |
| 27 |
\def\endsymtab{\crcr\egroup\egroup |
| 28 |
\dimen0=\ht0 \divide\dimen0 by2 \advance\dimen0 by\ht\strutbox |
| 29 |
\splittopskip=\ht\strutbox \vbadness=10000 |
| 30 |
\predisplaypenalty=0 |
| 31 |
$$\halign{##\cr\hbox to\linewidth{% |
| 32 |
\valign{##\vfil\cr |
| 33 |
\setbox1=\vsplit0 to\dimen0 \unvbox1\cr |
| 34 |
\noalign{\hfil}\unvbox0\cr |
| 35 |
\noalign{\hfil}}}\cr |
| 36 |
\noalign{\prevdepth=\dp\strutbox}}$$ |
| 37 |
\global\@ignoretrue} |
| 38 |
|
| 39 |
\makeatother % Sanity is restored |
| 40 |
|
| 41 |
\begin{document} |
| 42 |
|
| 43 |
\title{A guide to the {\tt zed} style option} |
| 44 |
\author{Mike Spivey} |
| 45 |
\date{December 1990} |
| 46 |
\maketitle |
| 47 |
|
| 48 |
\section{Introduction} |
| 49 |
|
| 50 |
This document is a guide to the version of the {\tt zed} style option |
| 51 |
for \LaTeX\ dated 11th December 1990. This new version of the style |
| 52 |
option is fully compatible with the {\tt fuzz} style option |
| 53 |
distributed with the my \fuzz\ type-checker for Z, but uses two fonts |
| 54 |
from the AMS in place of the special Z font distributed with |
| 55 |
\fuzz. Some of the symbols have been cobbled together by combining |
| 56 |
two or more characters, but the results are good enough for rough |
| 57 |
drafts. The style option requires the `old' AMS fonts, and will not at |
| 58 |
present work with Sli\TeX\ or the Sch\"opf-Mittelbach font selection |
| 59 |
scheme. |
| 60 |
|
| 61 |
The rest of this guide is mostly extracted from the manual for \fuzz, |
| 62 |
and it assumes a basic knowledge of \LaTeX. I have not removed some |
| 63 |
information about how the \fuzz\ type-checker treats various |
| 64 |
constructs, in case you later want to type-check a document you have |
| 65 |
formatted with the {\tt zed} style option. For information about the |
| 66 |
\fuzz\ package and how to order it, see the end of this guide. |
| 67 |
|
| 68 |
This guide and the {\tt zed} style option itself may be freely copied, |
| 69 |
distributed and used for any purpose except direct commercial gain, |
| 70 |
provided that they are copied and distributed as a whole and without |
| 71 |
modification. The author accepts no liablility for their accuracy or |
| 72 |
fitness for any purpose. |
| 73 |
|
| 74 |
\section{Loading the {\tt zed} style option} |
| 75 |
|
| 76 |
Every \LaTeX\ document should begin with a \verb/\documentstyle/ |
| 77 |
command. If the document contains a Z specification, this command |
| 78 |
should include the style option \verb/zed/. For example: |
| 79 |
\begin{quote} |
| 80 |
\verb/\documentstyle[12pt,zed]{article}/ |
| 81 |
\end{quote} |
| 82 |
Including \verb/zed/ as a style option loads macros from the file |
| 83 |
\verb/zed.sty/ and also loads four fonts of extra mathematical symbols |
| 84 |
called \verb/msxm9/, \verb/msym9/, \verb/msxm10/, and \verb/msym10/. |
| 85 |
Your \LaTeX\ installation must have these fonts for the \verb/zed/ |
| 86 |
style option to work; if it doesn't, or they are in the wrong place to |
| 87 |
be found by \TeX, then you will get an error message like this: |
| 88 |
\begin{quote} |
| 89 |
\verb/! Font \ninsxm=msxm9 not loadable .../ |
| 90 |
\end{quote} |
| 91 |
The \verb/zed/ style option can be used with any of the standard |
| 92 |
\LaTeX\ styles, and it can appear either before or after the type-size |
| 93 |
option if one is used. It can be combined with most of the standard |
| 94 |
style options, but it should not be combined with \verb/fleqn/, |
| 95 |
because {\tt zed} already makes provision for setting mathematics |
| 96 |
flush left. At present, \verb/zed/ does not work with Sli\TeX. |
| 97 |
|
| 98 |
\section{Making boxes} |
| 99 |
|
| 100 |
To print a schema, use the \verb/schema/ environment. Here is an |
| 101 |
example, showing first the input, then the output from \LaTeX: |
| 102 |
\begin{demo} |
| 103 |
\begin{verbatim} |
| 104 |
\begin{schema}{PhoneDB} |
| 105 |
known: \power NAME \\ phone: NAME \pfun PHONE |
| 106 |
\where |
| 107 |
known = \dom phone |
| 108 |
\end{schema} |
| 109 |
\end{verbatim} |
| 110 |
\gives |
| 111 |
\begin{schema}{PhoneDB} |
| 112 |
known: \power NAME \\ phone: NAME \pfun PHONE |
| 113 |
\where |
| 114 |
known = \dom phone |
| 115 |
\end{schema} |
| 116 |
\end{demo} |
| 117 |
The name of the schema appears as an argument to the environment, and |
| 118 |
the horizontal dividing line between declarations and predicates is |
| 119 |
indicated by \verb/\where/. Successive lines in the declaration and |
| 120 |
predicate parts are separated by the command \verb/\\/. In this |
| 121 |
example, the Z symbols `$\power$', `$\pfun$' and `$\dom$' have been |
| 122 |
entered as the commands \verb/\power/, \verb/\pfun/ and \verb/\dom/: |
| 123 |
for a complete list of these commands, see Section~\ref{s:symtabs} |
| 124 |
below. |
| 125 |
|
| 126 |
Like the \verb/displaymath/ environment of \LaTeX, the \verb/schema/ |
| 127 |
environment (and the others we shall come to in a moment) can appear |
| 128 |
in the middle of a paragraph, and ordinarily should have no blank |
| 129 |
lines either before or after it. Blank lines before the environment |
| 130 |
are ignored, but blank lines afterwards cause the following text to |
| 131 |
begin a new paragraph. |
| 132 |
|
| 133 |
For a schema without a predicate part, the command \verb/\where/ is |
| 134 |
simply omitted, as in the following example: |
| 135 |
\begin{demo} |
| 136 |
\begin{verbatim} |
| 137 |
\begin{schema}{Document[CHAR]} |
| 138 |
left, right: \seq CHAR |
| 139 |
\end{schema} |
| 140 |
\end{verbatim} |
| 141 |
\gives |
| 142 |
\begin{schema}{Document[CHAR]} |
| 143 |
left, right: \seq CHAR |
| 144 |
\end{schema} |
| 145 |
\end{demo} |
| 146 |
This example also shows how to set schemas with generic parameters. |
| 147 |
|
| 148 |
For axiomatic descriptions, the \verb/axdef/ environment is used. |
| 149 |
Here is an example: |
| 150 |
\begin{demo} |
| 151 |
\begin{verbatim} |
| 152 |
\begin{axdef} |
| 153 |
limit: \nat |
| 154 |
\where |
| 155 |
limit \leq 65535 |
| 156 |
\end{axdef} |
| 157 |
\end{verbatim} |
| 158 |
\gives |
| 159 |
\begin{axdef} |
| 160 |
limit: \nat |
| 161 |
\where |
| 162 |
limit \leq 65535 |
| 163 |
\end{axdef} |
| 164 |
\end{demo} |
| 165 |
In both kinds of box, predicates and declarations can be split between |
| 166 |
lines before or after infixed symbols, as shown in the following |
| 167 |
example: |
| 168 |
\begin{demo} |
| 169 |
\begin{verbatim} |
| 170 |
\begin{axdef} |
| 171 |
policy: \power_1 RESOURCE \fun RESOURCE |
| 172 |
\where |
| 173 |
\forall S: \power_1 RESOURCE @ \\ |
| 174 |
\t1 policy(S) \in S |
| 175 |
\end{axdef} |
| 176 |
\end{verbatim} |
| 177 |
\gives |
| 178 |
\begin{axdef} |
| 179 |
policy: \power_1 RESOURCE \fun RESOURCE |
| 180 |
\where |
| 181 |
\forall S: \power_1 RESOURCE @ \\ |
| 182 |
\t1 policy(S) \in S |
| 183 |
\end{axdef} |
| 184 |
\end{demo} |
| 185 |
The strange hint \verb/\t1/ in this example makes the corresponding |
| 186 |
line in the output have one helping of indentation. As things get |
| 187 |
more nested, you can say \verb/\t2/, \verb/\t3/, and so on. But if |
| 188 |
you should ever get beyond \verb/t9/, you'll need to use braces around |
| 189 |
the argument: \verb/\t{10}/, and you'd better look for some way to |
| 190 |
simplify your specification! |
| 191 |
|
| 192 |
This system of tab stops is a little crude, but it is easier to use |
| 193 |
than the alternatives, and usually gives acceptable results. The |
| 194 |
\verb/\t/$n$ commands are completely ignored by the type-checker, |
| 195 |
so you are free to use them as you like to improve the look of your |
| 196 |
specification. The size of `helping' you get with |
| 197 |
\verb/\t/$n$ is a style parameter \verb/\zedindent/, and the default |
| 198 |
is 2em. |
| 199 |
|
| 200 |
For generic definitions, there's the \verb/gendef/ environment: for |
| 201 |
example, |
| 202 |
\begin{demo} |
| 203 |
\begin{verbatim} |
| 204 |
\begin{gendef}[X,Y] |
| 205 |
first: X \cross Y \fun X |
| 206 |
\where |
| 207 |
\forall x: X; y: Y @ \\ |
| 208 |
\t1 first(x,y) = x |
| 209 |
\end{gendef} |
| 210 |
\end{verbatim} |
| 211 |
\gives |
| 212 |
\begin{gendef}[X,Y] |
| 213 |
first: X \cross Y \fun X |
| 214 |
\where |
| 215 |
\forall x: X; y: Y @ \\ |
| 216 |
\t1 first(x,y) = x |
| 217 |
\end{gendef} |
| 218 |
\end{demo} |
| 219 |
In this environment, the formal generic parmeters are an optional |
| 220 |
argument. Omitting this argument results in a box with a solid double |
| 221 |
bar at the top, which can be used for uniquely defining non-generic |
| 222 |
constants. |
| 223 |
|
| 224 |
If a schema or other box contains more than one predicate below the |
| 225 |
line, it often looks better to add a small vertical space between |
| 226 |
them. This can be done with the command \verb/\also/: |
| 227 |
\begin{demo} |
| 228 |
\begin{verbatim} |
| 229 |
\begin{schema}{AddPhone} |
| 230 |
\Delta PhoneDB \\ name?: NAME \\ number?: PHONE |
| 231 |
\where |
| 232 |
name? \notin known |
| 233 |
\also |
| 234 |
phone' = phone \oplus \{name? \mapsto number?\} |
| 235 |
\end{schema} |
| 236 |
\end{verbatim} |
| 237 |
\gives |
| 238 |
\begin{schema}{AddPhone} |
| 239 |
\Delta PhoneDB \\ name?: NAME \\ number?: PHONE |
| 240 |
\where |
| 241 |
name? \notin known |
| 242 |
\also |
| 243 |
phone' = phone \oplus \{name? \mapsto number?\} |
| 244 |
\end{schema} |
| 245 |
\end{demo} |
| 246 |
|
| 247 |
Some Z paragraphs do not appear in boxes, and for these the \verb/zed/ |
| 248 |
environment is used: |
| 249 |
\begin{demo} |
| 250 |
\begin{verbatim} |
| 251 |
\begin{zed} |
| 252 |
[NAME, DATE] |
| 253 |
\also |
| 254 |
REPORT ::= ok | unknown \ldata NAME \rdata |
| 255 |
\also |
| 256 |
\exists n: NAME @ \\ |
| 257 |
\t1 birthday(n) \in December. |
| 258 |
\end{zed} |
| 259 |
\end{verbatim} |
| 260 |
\gives |
| 261 |
\begin{zed} |
| 262 |
[NAME, DATE] |
| 263 |
\also |
| 264 |
REPORT ::= ok | unknown \ldata NAME \rdata |
| 265 |
\also |
| 266 |
\exists n: NAME @ \\ |
| 267 |
\t1 birthday(n) \in December. |
| 268 |
\end{zed} |
| 269 |
\end{demo} |
| 270 |
This environment should be used for basic type definitions, |
| 271 |
constraints, abbreviation definitions, free type definitions, and the |
| 272 |
horizontal form of schema definitions. As the example illustrates, a |
| 273 |
full stop or comma is allowed just before the closing \verb/\end/ |
| 274 |
command of any of the Z environments, if that suits your taste (or is |
| 275 |
forced on you by a publisher's house rules). This punctuation is |
| 276 |
ignored by the type-checker. |
| 277 |
|
| 278 |
For large free type definitions, the \verb/syntax/ environment |
| 279 |
provides a useful alternative to the \verb/zed/ environment, as the |
| 280 |
following example suggests: |
| 281 |
\begin{demo} |
| 282 |
\begin{verbatim} |
| 283 |
\begin{syntax} |
| 284 |
OP & ::= & plus | minus | times | divide |
| 285 |
\also |
| 286 |
EXP & ::= & const \ldata \nat \rdata \\ |
| 287 |
& | & binop \ldata OP \cross EXP \cross EXP \rdata |
| 288 |
\end{syntax} |
| 289 |
\end{verbatim} |
| 290 |
\gives |
| 291 |
\begin{syntax} |
| 292 |
OP & ::= & plus | minus | times | divide |
| 293 |
\also |
| 294 |
EXP & ::= & const \ldata \nat \rdata \\ & | & binop \ldata OP |
| 295 |
\cross EXP \cross EXP \rdata |
| 296 |
\end{syntax} |
| 297 |
\end{demo} |
| 298 |
Just as in the \verb/eqnarray/ environment of \LaTeX, the fields are |
| 299 |
separated by \verb/&/ characters, and these are ignored by the |
| 300 |
type-checker. |
| 301 |
|
| 302 |
\section{Inside the boxes}\label{s:symtabs} |
| 303 |
|
| 304 |
The first thing to notice about the text inside the boxes is that |
| 305 |
multi-character identifiers look better than they do with ordinary |
| 306 |
\LaTeX: instead of $\mit specifications$, you get $specifications$. |
| 307 |
The letters are not spread apart, and ligatures like $fi$ are used. |
| 308 |
This is achieved by an adjustment to the way \TeX\ treats letters in |
| 309 |
mathematical formulas, and no special commands are needed in the input |
| 310 |
file. Embedded underline characters can be set with the \verb/\_/ |
| 311 |
command, which is also used for dummy arguments of operators: |
| 312 |
\verb/not\_known/ gives $not\_known$, and \verb/\_ + \_/ gives |
| 313 |
$\_ + \_$~. |
| 314 |
|
| 315 |
The various special symbols of the Z language and library have |
| 316 |
mnemonic names. Some of these names are the same as in ordinary |
| 317 |
\LaTeX, and some symbols have new names more suggestive of their |
| 318 |
meaning in Z. The spaces inserted around the symbols have been |
| 319 |
adjusted to make them look better in Z specifications. |
| 320 |
|
| 321 |
A few symbols have two names, reflecting two different uses for the |
| 322 |
symbol in Z. The symbol $\semi$ is called \verb/\semi/ when it is used |
| 323 |
as an operation on schemas, and \verb/\comp/ when it is used for |
| 324 |
composition of relations. The symbol $\hide$ is called \verb/\hide/ as |
| 325 |
the hiding operator of the schema calculus, and \verb/\setminus/ for |
| 326 |
the set difference operator. The symbol $\project$ is called |
| 327 |
\verb/project/ as the schema projection operator, and \verb/\filter/ |
| 328 |
for filtering of sequences. The spaces around the schema operations |
| 329 |
are a little larger, and the type-checker recognizes each name only in |
| 330 |
the appropriate context. |
| 331 |
|
| 332 |
For most symbols, two attributes are of interest: the syntactic class |
| 333 |
({\sf In-Fun}, \dots) assigned to it by the type-checker, and the kind |
| 334 |
of symbol \LaTeX\ generates from it. The first of these affects the |
| 335 |
parsing of an expression containing the symbol, and the second affects |
| 336 |
the way spaces will be inserted when the expression is printed. In the |
| 337 |
description below, `thin', `medium' and `thick' spaces are the same as |
| 338 |
those produced by the \LaTeX\ commands \verb/\,/ and \verb/\:/ and |
| 339 |
\verb/\;/ respectively. |
| 340 |
|
| 341 |
Here are the mnemonics for the basic elements of the Z language: |
| 342 |
\begin{symtab} |
| 343 |
\power & \verb/\power/ \\ |
| 344 |
\cross & \verb/\cross/ \\ |
| 345 |
\in & \verb/\in/ \\ |
| 346 |
| & \verb/|/ or \verb/\mid/ \\ |
| 347 |
@ & \verb/@/ or \verb/\spot/ \\ |
| 348 |
\theta & \verb/\theta/ \\ |
| 349 |
\lambda & \verb/\lambda/ \\ |
| 350 |
\mu & \verb/\mu/ \\ |
| 351 |
\Delta & \verb/\Delta/ \\ |
| 352 |
\Xi & \verb/\Xi/ \\ |
| 353 |
\defs & \verb/\defs/ |
| 354 |
\end{symtab} |
| 355 |
The operators of propositional logic and the schema calculus are as |
| 356 |
follows. Many of these names are already defined by \LaTeX, but the |
| 357 |
spacing is often adjusted to make them look better in Z |
| 358 |
specifications. |
| 359 |
\begin{symtab} |
| 360 |
\lnot & \verb/\lnot/ \\ |
| 361 |
\land & \verb/\land/ \\ |
| 362 |
\lor & \verb/\lor/ \\ |
| 363 |
\implies & \verb/\implies/ \\ |
| 364 |
\iff & \verb/\iff/ \\ |
| 365 |
\forall & \verb/\forall/ \\ |
| 366 |
\exists & \verb/\exists/ \\ |
| 367 |
\exists_1 & \verb/\exists_1/ \\ |
| 368 |
\hide & \verb/\hide/ \\ |
| 369 |
\project & \verb/\project/ \\ |
| 370 |
\pre & \verb/\pre/ \\ |
| 371 |
\semi & \verb/\semi/ |
| 372 |
\end{symtab} |
| 373 |
Here are the various sorts of fancy brackets: |
| 374 |
\begin{symtab} |
| 375 |
\{\ldots\} & \verb/\{ ... \}/ \\ |
| 376 |
\langle\ldots\rangle & \verb/\langle ... \rangle/ \\ |
| 377 |
\lbag\ldots\rbag & \verb/\lbag ... \rbag/ \\ |
| 378 |
\ldata\ldots\rdata & \verb/\ldata ... \rdata/ \\ |
| 379 |
\ldots\limg\ldots\rimg & \verb/... \limg ... \rimg/ |
| 380 |
\end{symtab} |
| 381 |
Those are all the symbols `built-in' to the Z language; now for the |
| 382 |
symbols defined as part of the mathematical tool-kit. First come the |
| 383 |
symbols which are not defined as infix operators, etc.: |
| 384 |
\begin{symtab} |
| 385 |
\empty & \verb/\empty/ \\ |
| 386 |
\bigcup & \verb/\bigcup/ \\ |
| 387 |
\bigcap & \verb/\bigcap/ \\ |
| 388 |
\dom & \verb/\dom/ \\ |
| 389 |
\ran & \verb/\ran/ \\ |
| 390 |
\nat & \verb/\nat/ \\ |
| 391 |
\num & \verb/\num/ \\ |
| 392 |
\nat_1 & \verb/\nat_1/ \\ |
| 393 |
\# & \verb/\#/ \\ |
| 394 |
\dcat & \verb/\dcat/ |
| 395 |
\end{symtab} |
| 396 |
Here are the infix function symbols; they are defined in \LaTeX\ as |
| 397 |
binary operators, so medium spaces are inserted automatically. The |
| 398 |
type-checker recognizes them as of class {\sf In-Fun}. Each symbol is |
| 399 |
shown with its priority: |
| 400 |
\begin{symtab} |
| 401 |
\mapsto & \verb/\mapsto/\quad\hfill 1 \\ |
| 402 |
\upto & \verb/\upto/\quad\hfill 2 \\ |
| 403 |
+ & \verb/+/\quad\hfill 3 \\ |
| 404 |
- & \verb/-/\quad\hfill 3 \\ |
| 405 |
\cup & \verb/\cup/\quad\hfill 3 \\ |
| 406 |
\setminus & \verb/\setminus/\quad\hfill 3 \\ |
| 407 |
\cat & \verb/\cat/\quad\hfill 3 \\ |
| 408 |
\uplus & \verb/\uplus/\quad\hfill 3 \\ |
| 409 |
* & \verb/*/\quad\hfill 4 \\ |
| 410 |
\div & \verb/\div/\quad\hfill 4 \\ |
| 411 |
\mod & \verb/\mod/\quad\hfill 4 \\ |
| 412 |
\cap & \verb/\cap/\quad\hfill 4 \\ |
| 413 |
\comp & \verb/\comp/\quad\hfill 4 \\ |
| 414 |
\circ & \verb/\circ/\quad\hfill 4 \\ |
| 415 |
\filter & \verb/\filter/\quad\hfill 4 \\ |
| 416 |
\oplus & \verb/\oplus/\quad\hfill 5 \\ |
| 417 |
\dres & \verb/\dres/\quad\hfill 6 \\ |
| 418 |
\rres & \verb/\rres/\quad\hfill 6 \\ |
| 419 |
\ndres & \verb/\ndres/\quad\hfill 6 \\ |
| 420 |
\nrres & \verb/\nrres/\quad\hfill 6 |
| 421 |
\end{symtab} |
| 422 |
The postfix function symbols (class {\sf Post-Fun}) all produce |
| 423 |
superscripts: |
| 424 |
\begin{symtab} |
| 425 |
\inv & \verb/\inv/ \\ |
| 426 |
\plus & \verb/\plus/ \\ |
| 427 |
\star & \verb/\star/ \\ |
| 428 |
\bsup n \esup & \verb/\bsup n \esup/ |
| 429 |
\end{symtab} |
| 430 |
As an example, \verb/R \star/ is printed as $R \star$. For iteration, |
| 431 |
the commands \verb/\bsup ... \esup/ should be used: for example, |
| 432 |
\verb/R \bsup n \esup/ is printed as $R \bsup n \esup$. The |
| 433 |
type-checker regards this formula as equivalent to $iter~n~R$, as |
| 434 |
explained on page 112 of the \ZRM. |
| 435 |
|
| 436 |
The infix relation symbols (class {\sf In-Rel}) are defined in |
| 437 |
\LaTeX\ as relations, so thick spaces are inserted around them |
| 438 |
automatically: |
| 439 |
\begin{symtab} |
| 440 |
\neq & \verb/\neq/ \\ |
| 441 |
\notin & \verb/\notin/ \\ |
| 442 |
\subseteq & \verb/\subseteq/ \\ |
| 443 |
\subset & \verb/\subset/ \\ |
| 444 |
< & \verb/</ \\ |
| 445 |
> & \verb/>/ \\ |
| 446 |
\leq & \verb/\leq/ \\ |
| 447 |
\geq & \verb/\geq/ \\ |
| 448 |
\partition & \verb/\partition/ \\ |
| 449 |
\inbag & \verb/\inbag/ \\ |
| 450 |
\end{symtab} |
| 451 |
There is only one prefix relation symbol (class {\sf Pre-Rel}). It |
| 452 |
separates itself from an argument with a thick space: |
| 453 |
\begin{symtab} |
| 454 |
\disjoint & \verb/\disjoint/ |
| 455 |
\end{symtab} |
| 456 |
The infix generic symbols are seen by \LaTeX\ as relation symbols, so |
| 457 |
they are surrounded by thick spaces. Of course, the type-checker |
| 458 |
itself assigns them class {\sf In-Gen}: |
| 459 |
\begin{symtab} |
| 460 |
\rel & \verb/\rel/ \\ |
| 461 |
\pfun & \verb/\pfun/ \\ |
| 462 |
\fun & \verb/\fun/ \\ |
| 463 |
\pinj & \verb/\pinj/ \\ |
| 464 |
\inj & \verb/\inj/ \\ |
| 465 |
\psurj & \verb/\psurj/ \\ |
| 466 |
\surj & \verb/\surj/ \\ |
| 467 |
\bij & \verb/\bij/ \\ |
| 468 |
\ffun & \verb/\ffun/ \\ |
| 469 |
\finj & \verb/\finj/ |
| 470 |
\end{symtab} |
| 471 |
Prefix generic symbols are assigned class {\sf Pre-Gen} by the |
| 472 |
type-checker; in \LaTeX, they are defined as operator symbols, so that |
| 473 |
a thin space is inserted between the symbol and a following generic |
| 474 |
parameter: |
| 475 |
\begin{symtab} |
| 476 |
\power_1 & \verb/\power_1/ \\ |
| 477 |
\id & \verb/\id/ \\ |
| 478 |
\finset & \verb/\finset/ \\ |
| 479 |
\finset_1 & \verb/\finset_1/ \\ |
| 480 |
\seq & \verb/\seq/ \\ |
| 481 |
\seq_1 & \verb/\seq_1/ \\ |
| 482 |
\iseq & \verb/\iseq/ \\ |
| 483 |
\bag & |
| 484 |
\verb/\bag/ |
| 485 |
\end{symtab} |
| 486 |
|
| 487 |
\section{Fine points} |
| 488 |
|
| 489 |
In math mode, which is used for type-setting the contents of Z boxes, |
| 490 |
\TeX\ ignores all space characters in the input file. The spaces which |
| 491 |
appear between elements of a mathematical formula are determined by |
| 492 |
\TeX\ itself, working from information about the symbols in the |
| 493 |
formula. Although this information has been adjusted in the {\tt zed} |
| 494 |
style option to make Z texts look as balanced as possible, there are |
| 495 |
one or two situations in which \TeX\ needs a little help. |
| 496 |
|
| 497 |
Special care is needed when function application is indicated by |
| 498 |
juxtaposing two identifiers, as in the expression $rev~words$. This |
| 499 |
expression should be typed as % |
| 500 |
\verb/rev~words/. Typing just % |
| 501 |
\verb/rev words/ results in the output $rev words$, since \TeX\ ignores the |
| 502 |
space separating the two identifiers. In a formula, the character |
| 503 |
% |
| 504 |
\verb/~/ inserts the same amount of space as the \LaTeX\ % |
| 505 |
\verb/\,/ |
| 506 |
command, but it looks better in the input file. The type-checker |
| 507 |
completely ignores both the % |
| 508 |
\verb/~/ character and the \LaTeX\ spacing |
| 509 |
commands, except that it issues a warning if it finds that a needed |
| 510 |
one is missing, for example, between two identifiers. It is not |
| 511 |
necessary to separate symbols like % |
| 512 |
\verb/\dom/ and % |
| 513 |
\verb/\ran/ from |
| 514 |
their arguments with a % |
| 515 |
\verb/~/, because \TeX\ inserts the right |
| 516 |
amount of space automatically. For example, the input % |
| 517 |
\verb/\dom f/ |
| 518 |
produces $\dom f$. |
| 519 |
|
| 520 |
It is good style also to insert small spaces inside the braces of a |
| 521 |
set comprehension, as in this example: |
| 522 |
\begin{demo} |
| 523 |
% |
| 524 |
\verb/\{~x: \nat | x \leq 10 @ x * x~\}/ |
| 525 |
\gives |
| 526 |
\[\{~x: \nat | x \leq 10 @ x * x~\}\] |
| 527 |
\end{demo} |
| 528 |
This helps to distinguish it visually from a set display, which should |
| 529 |
not have the space: |
| 530 |
\begin{demo} |
| 531 |
% |
| 532 |
\verb/\{1, 2, 3\}/ |
| 533 |
\gives |
| 534 |
\[\{1, 2, 3\}\] |
| 535 |
\end{demo} |
| 536 |
The space symbol % |
| 537 |
\verb/~/ is ignored by the type-checker, so this is |
| 538 |
purely a matter of appearance. It also looks better if you add small |
| 539 |
spaces inside the square brackets of `horizontal' schema texts. |
| 540 |
|
| 541 |
\TeX\ also needs help when a binary operator appears at the end of a |
| 542 |
line, as in the following example: |
| 543 |
\begin{demo} |
| 544 |
\begin{verbatim} |
| 545 |
\begin{zed} |
| 546 |
directory' = directory \cup {} \\ |
| 547 |
\t3 \{new\_name? \mapsto new\_number?\} |
| 548 |
\end{zed} |
| 549 |
\end{verbatim} |
| 550 |
\gives |
| 551 |
\begin{zed} |
| 552 |
directory' = directory \cup {} \\ |
| 553 |
\t3 \{new\_name? \mapsto new\_number?\} |
| 554 |
\end{zed} |
| 555 |
\end{demo} |
| 556 |
\TeX\ will not recognize % |
| 557 |
\verb/\cup/ as a binary operator and insert |
| 558 |
the correct space unless it is surrounded by two operands, so the |
| 559 |
dummy operand % |
| 560 |
\verb/{}/ has been inserted: this is ignored by the |
| 561 |
type-checker. This problem affects only binary operators; relation |
| 562 |
signs do not need to be surrounded by arguments to be recognized by |
| 563 |
\TeX. |
| 564 |
|
| 565 |
\section{Bits and pieces} |
| 566 |
|
| 567 |
Specification documents often contain mathematical text which does not |
| 568 |
form part of the specification proper. This section describes some |
| 569 |
environments for setting various kinds of mathematics; they are |
| 570 |
provided for convenience, and they are all ignored by the |
| 571 |
type-checker. Besides these environments for making displays, run-in |
| 572 |
mathematics can be set with the usual % |
| 573 |
\verb/math/ environment, or with |
| 574 |
the commands % |
| 575 |
\verb/$ ... $/ or \hbox{% |
| 576 |
\verb/\( ... \)/}. All the Z |
| 577 |
symbols listed in Section~\ref{s:symtabs} can be used with these |
| 578 |
commands. |
| 579 |
|
| 580 |
The simplest display environment is provided by the commands |
| 581 |
% |
| 582 |
\verb/\[ ... \]/. This form acts just like % |
| 583 |
\verb/\begin{zed} ... \end{zed}/, except that the contents are ignored by the |
| 584 |
type-checker. Here is an example: |
| 585 |
\begin{demo} |
| 586 |
\begin{verbatim} |
| 587 |
\[ |
| 588 |
\exists PhoneDB @ \\ |
| 589 |
\t1 known = \empty |
| 590 |
\] |
| 591 |
\end{verbatim} |
| 592 |
\gives |
| 593 |
\[ |
| 594 |
\exists PhoneDB @ \\ |
| 595 |
\t1 known = \empty |
| 596 |
\] |
| 597 |
\end{demo} |
| 598 |
These commands generalize the standard \LaTeX\ commands with the same |
| 599 |
name, because the displayed material can be several lines. Note, |
| 600 |
however, that the contents are set as text style rather than display |
| 601 |
style mathematics. |
| 602 |
|
| 603 |
A schema box with no name is generated by the % |
| 604 |
\verb/schema*/ |
| 605 |
environment: |
| 606 |
\begin{demo} |
| 607 |
\begin{verbatim} |
| 608 |
\begin{schema*} |
| 609 |
x, y: \nat |
| 610 |
\where |
| 611 |
x > y |
| 612 |
\end{schema*} |
| 613 |
\end{verbatim} |
| 614 |
\gives |
| 615 |
\begin{schema*} |
| 616 |
x, y: \nat |
| 617 |
\where |
| 618 |
x > y |
| 619 |
\end{schema*} |
| 620 |
\end{demo} |
| 621 |
This form is often useful for showing the result of expanding a |
| 622 |
complex schema-expression. |
| 623 |
|
| 624 |
Another kind of mathematical display is provided by the % |
| 625 |
\verb/argue/ |
| 626 |
environment. This is like the % |
| 627 |
\verb/zed/ environment, but the |
| 628 |
separation between lines is increased a little, and page breaks may |
| 629 |
occur between lines. The intended use is for arguments like this: |
| 630 |
\begin{demo} |
| 631 |
\begin{verbatim} |
| 632 |
\begin{argue} |
| 633 |
S \dres (T \dres R) \\ |
| 634 |
\t1 = \id S \comp \id T \comp R \\ |
| 635 |
\t1 = \id (S \cap T) \comp R & law about $\id$ \\ |
| 636 |
\t1 = (S \cap T) \dres R. |
| 637 |
\end{argue} |
| 638 |
\end{verbatim} |
| 639 |
\gives |
| 640 |
\begin{argue} |
| 641 |
S \dres (T \dres R) \\ |
| 642 |
\t1 = \id S \comp \id T \comp R \\ |
| 643 |
\t1 = \id (S \cap T) \comp R & law about $\id$ \\ |
| 644 |
\t1 = (S \cap T) \dres R. |
| 645 |
\end{argue} |
| 646 |
\end{demo} |
| 647 |
When the left-hand side is long, I find this style better than the |
| 648 |
\LaTeX\ % |
| 649 |
\verb/eqnarray/ style, which wastes a lot of space. The second |
| 650 |
field on each line is optional. Again, the % |
| 651 |
\verb/argue/ environment is |
| 652 |
ignored by the type-checker. |
| 653 |
|
| 654 |
Finally, there is the % |
| 655 |
\verb/infrule/ environment, used for inference |
| 656 |
rules: |
| 657 |
\begin{demo} |
| 658 |
\begin{verbatim} |
| 659 |
\begin{infrule} |
| 660 |
\Gamma \shows P |
| 661 |
\derive[x \notin freevars(\Gamma)] |
| 662 |
\Gamma \shows \forall x @ P |
| 663 |
\end{infrule} |
| 664 |
\end{verbatim} |
| 665 |
\gives |
| 666 |
\begin{infrule} |
| 667 |
\Gamma \shows P |
| 668 |
\derive[x \notin freevars(\Gamma)] |
| 669 |
\Gamma \shows \forall x \spot P |
| 670 |
\end{infrule} |
| 671 |
\end{demo} |
| 672 |
The horizontal line is generated by % |
| 673 |
\verb/\derive/; the optional |
| 674 |
argument is a side-condition of the rule. |
| 675 |
|
| 676 |
\section{Style parameters} |
| 677 |
|
| 678 |
A few style parameters affect the way Z text is set out; they can be |
| 679 |
changed at any time if your taste doesn't match mine. |
| 680 |
|
| 681 |
\begin{description} |
| 682 |
\item[\tt\string\zedindent] The indentation for mathematical text. |
| 683 |
By default, this is the same as % |
| 684 |
\verb|\leftmargini|, the indentation |
| 685 |
used for list environments. |
| 686 |
\item[\tt\string\zedleftsep] The space between the vertical line on the left |
| 687 |
of schemas, etc., and the maths inside. The default is 1em. |
| 688 |
\item[\tt\string\zedtab] The unit of indentation used by % |
| 689 |
\verb|\t|. The default |
| 690 |
is 2em. |
| 691 |
\item[\tt\string\zedbar] The length of the horizontal bar in the middle of a |
| 692 |
schema. The default is 6em. |
| 693 |
\item[\tt\string\zedskip] The vertical space inserted by |
| 694 |
% |
| 695 |
\verb/\also/. By default, this is the same as that inserted by |
| 696 |
% |
| 697 |
\verb/\medskip/. |
| 698 |
\end{description} |
| 699 |
|
| 700 |
\newpage |
| 701 |
\section{The fuzz package} |
| 702 |
|
| 703 |
The \fuzz\ package consists of two parts -- a style option compatible |
| 704 |
with the {\tt zed} style option described here, and an analysis and |
| 705 |
checking program. Using \fuzz\ together with \LaTeX, you can: |
| 706 |
\begin{itemize} |
| 707 |
\item Input Z specifications as ordinary ASCII files. |
| 708 |
\item Process them for laser printing or photo-typesetting. |
| 709 |
\item Check them for conformance with the Z language rules. |
| 710 |
\item Produce a listing showing the schemas in the specification with |
| 711 |
components and their types. |
| 712 |
\end{itemize} |
| 713 |
The \fuzz\ analysis program works on the same ASCII file as \LaTeX; it |
| 714 |
extracts the formal text and checks it for conformance with the rules |
| 715 |
of the Z language, producing clear error messages. Analysis of a |
| 716 |
1300-line specification takes about 7 seconds on a SUN 3/75. |
| 717 |
|
| 718 |
The \fuzz\ distribution contains the \LaTeX\ style option, a special |
| 719 |
font of Z symbols, object code for the analysis program, a library |
| 720 |
containing the standard mathematical tool-kit, and some example |
| 721 |
specifications. To use \fuzz, you will need to have \LaTeX\ installed |
| 722 |
on your machine, but everything else you need is included. \fuzz\ is |
| 723 |
currently available under `no-nonsense' licence conditions for the IBM |
| 724 |
PC and other DOS machines, and for the SUN 3 and SUN 4 under SUN UNIX. |
| 725 |
The PC version can also be used on the PS/2. We are willing to |
| 726 |
produce versions for other machines according to demand. |
| 727 |
|
| 728 |
\newpage |
| 729 |
\thispagestyle{empty} |
| 730 |
\section*{Ordering information} |
| 731 |
|
| 732 |
You can order the \fuzz\ package either by cutting out the coupon |
| 733 |
below and sending it with your payment, or by sending an official |
| 734 |
order -- we will send an invoice. Please send all orders to the |
| 735 |
address below. Technical enquiries can be sent to Mike Spivey at the |
| 736 |
same address, or by E-mail to {\tt [email protected]} . |
| 737 |
|
| 738 |
\vfill |
| 739 |
{\center\large\bf \Fuzz\ package: order form\par} |
| 740 |
\bigskip |
| 741 |
\noindent To: Mrs.\ A. Spivey, 34, Westlands Grove, Stockton Lane, |
| 742 |
\hfil\break\hphantom{To: }York, YO3 0EF, England. |
| 743 |
\par\bigskip |
| 744 |
\newdimen\x \setbox0=\hbox{Telephone:} \x=\wd0 |
| 745 |
\begingroup |
| 746 |
\baselineskip=24pt |
| 747 |
\def\addrline#1{\hbox to\linewidth{\hbox to\x{#1\hfil}\qquad\hrulefill}} |
| 748 |
\addrline{Name:} |
| 749 |
\addrline{Address:} |
| 750 |
\addrline{} |
| 751 |
\addrline{} |
| 752 |
\addrline{Telephone:} |
| 753 |
\endgroup |
| 754 |
\bigskip |
| 755 |
\noindent Please send [\qquad] copies of the \fuzz\ package for the |
| 756 |
following machines: |
| 757 |
\par\bigskip |
| 758 |
\halign{\hskip\x\qquad#\hfil\qquad&#\qquad\hfil&#\hfil\cr |
| 759 |
[\quad]& SUN 3 version: Cartridge tape& \pounds 300\cr |
| 760 |
\noalign{\medskip} |
| 761 |
[\quad]& SUN 4 version: 3.5in disk& \pounds 275\cr |
| 762 |
\noalign{\medskip} |
| 763 |
[\quad]& SUN 4 version: Cartridge tape& \pounds 300\cr |
| 764 |
\noalign{\medskip} |
| 765 |
[\quad]& IBM PC version: 5.25in disk& \pounds 200\cr |
| 766 |
\noalign{\medskip} |
| 767 |
[\quad]& IBM PC version: 3.5in disk& \pounds 200\cr} |
| 768 |
\bigskip |
| 769 |
\noindent I enclose a cheque for \pounds [\qquad], payable to |
| 770 |
Dr.\ J. M.~Spivey. |
| 771 |
\par\bigskip\noindent |
| 772 |
Signed: |
| 773 |
\par\bigskip |
| 774 |
\end{document} |