doc-src/Ref/theories.tex
changeset 1380 2f8055af9c04
parent 1369 b82815e61b30
child 1387 9bcad9c22fd4
equal deleted inserted replaced
1379:8f693d2ffb59 1380:2f8055af9c04
    82   constructors.  The $name$ must be an existing type constructor, which is
    82   constructors.  The $name$ must be an existing type constructor, which is
    83   given the additional arity $arity$.
    83   given the additional arity $arity$.
    84 
    84 
    85 \item[$constDecl$]
    85 \item[$constDecl$]
    86   is a series of constant declarations.  Each new constant $name$ is given
    86   is a series of constant declarations.  Each new constant $name$ is given
    87   the type specified by the $string$.  The optional $mixfix$ annotations may
    87   the specified type.  The optional $mixfix$ annotations may
    88   attach concrete syntax to the constant. A variant of {\tt consts} is the
    88   attach concrete syntax to the constant. A variant of {\tt consts} is the
    89   {\tt syntax} section\index{*syntax section}, which adds just syntax without
    89   {\tt syntax} section\index{*syntax section}, which adds just syntax without
    90   declaring logical constants.
    90   declaring logical constants.
    91 
    91 
    92 \item[$mixfix$] \index{mixfix declarations}
    92 \item[$mixfix$] \index{mixfix declarations}
   453 returns the identification \rmindex{stamps} of the signature associated
   453 returns the identification \rmindex{stamps} of the signature associated
   454 with~$thy$.
   454 with~$thy$.
   455 \end{ttdescription}
   455 \end{ttdescription}
   456 
   456 
   457 
   457 
   458 \section{Viewing theories as HTML documents}
   458 \section{Generating HTML documents}
   459 \index{HTML|bold} 
   459 \index{HTML|bold} 
   460 
   460 
   461 Isabelle is able to make HTML documents that show a theory's
   461 Isabelle is able to make HTML documents that show a theory's
   462 definition, the theorems proved in its ML file and the relationship
   462 definition, the theorems proved in its ML file and the relationship
   463 with its ancestors and descendants. HTML stands for Hypertext Markup
   463 with its ancestors and descendants. HTML stands for Hypertext Markup
   464 Language and is used in the World Wide Web to represent text
   464 Language and is used in the World Wide Web to represent text
   465 containing images and links to other documents. Web browsers like the
   465 containing images and links to other documents. Web browsers like
   466 ones from Mosaic or Netscape are used to view these documents.
   466 {\tt xmosaic} or {\tt netscape} are used to view these documents.
   467 
   467 
   468 Besides the three HTML files that are made for every theory
   468 Besides the three HTML files that are made for every theory
   469 (definition and theorems, ancestors, descendants), Isabelle stores
   469 (definition and theorems, ancestors, descendants), Isabelle stores
   470 links to all theories in an index file. These indexes are themself
   470 links to all theories in an index file. These indexes are themself
   471 linked with other indexes.
   471 linked with other indexes to represent the hierarchic structure of
       
   472 Isabelle's logics.
   472 
   473 
   473 To make HTML files for logics that are part of the Isabelle
   474 To make HTML files for logics that are part of the Isabelle
   474 distribution, simply set the environment variable {\tt MAKE_HTML}
   475 distribution, simply set the shell environment variable {\tt
   475 before compiling a logic. The entry point to all logics is the {\tt
   476 MAKE_HTML} before compiling a logic. This works for single logics as
   476 index.html} file located in Isabelle's main directory. You also can
   477 well as for the shell script {\tt make-all} (see
   477 access a HTML version of the Isabelle distribution package at
   478 \ref{sec:shell-scripts}). To make HTML files for {\tt FOL} using a
       
   479 {\tt csh} style shell, the following commands can be used:
       
   480 
       
   481 \begin{ttbox}
       
   482 cd FOL
       
   483 setenv MAKE_HTML
       
   484 make
       
   485 \end{ttbox}
       
   486 
       
   487 As some of Isabelle's logics are based on others (e.g. {\tt ZF} on
       
   488 {\tt FOL}) and because the HTML files list a theory's ancestors, you
       
   489 should not make HTML files for a logic if the HTML files for the base
       
   490 logic do not exist. Otherwise some of the hypertext links might point
       
   491 to non-existing documents.
       
   492 
       
   493 The entry point to all logics is the {\tt index.html} file located in
       
   494 Isabelle's main directory. You can also access a HTML version of the
       
   495 distribution package at
   478 
   496 
   479 \begin{ttbox}
   497 \begin{ttbox}
   480 http://www4.informatik.tu-muenchen.de/~nipkow/isabelle
   498 http://www4.informatik.tu-muenchen.de/~nipkow/isabelle
   481 \end{ttbox}
   499 \end{ttbox}
   482 
   500 
   483 Internally the HTML generation is controlled by
   501 
   484 
   502 \subsection*{Manual HTML generation}
   485 \begin{ttbox}
   503 
   486 index_path  : string ref
   504 To manually activate and deactivate the generation of HTML files the
   487 gif_path    : string ref
   505 following commands and reference variables are used:
   488 base_path   : string ref
   506 
       
   507 \begin{ttbox}
   489 init_html   : unit -> unit
   508 init_html   : unit -> unit
   490 make_html   : bool ref
   509 make_html   : bool ref
   491 finish_html : unit -> unit
   510 finish_html : unit -> unit
   492 \end{ttbox}
   511 \end{ttbox}
   493 
   512 
   494 \begin{ttdescription}
   513 \begin{ttdescription}
   495 \item[\ttindexbold{base_path}]
       
   496 contains the absolute path of Isabelle's main directory. To make them
       
   497 independent from their storage place, the HTML files only contain
       
   498 relative paths which are derived from absolute ones like the current
       
   499 working directory, {\tt index_path} or {\tt base_path}.
       
   500 
       
   501 As {\tt base_path} and {\tt gif_path} are set at the time when the
       
   502 {\tt Pure} database is made, they are not valid if you use someone
       
   503 else's database to read theories stored in your private directory. In
       
   504 that case you first have to set {\tt base_path} to the value of {\em
       
   505 your} Isabelle main directory, i.e. the directory that contains the
       
   506 subdirectories where logics like {\tt FOL}, {\tt HOL} etc. are
       
   507 stored. Besides you have to set the next variable:
       
   508 
       
   509 \item[\ttindexbold{gif_path}]
       
   510 contains the absolute path of two GIF images used in the HTML
       
   511 documents. Normally it points to the {\tt Tools} subdirectory of
       
   512 Isabelle's main directory. As with {\tt base_path} you have to set it
       
   513 manually if you use someone else's database.
       
   514 
       
   515 \item[\ttindexbold{init_html}]
   514 \item[\ttindexbold{init_html}]
   516 activates the HTML facility. It stores the current working directory
   515 activates the HTML facility. It stores the current working directory
   517 in {\tt index_path} which is were the {\tt index.html} file for all
   516 as the place where the {\tt index.html} file for all theories loaded
   518 theories loaded afterwards will be placed.
   517 afterwards will be stored.
   519 
   518 
   520 \item[\ttindexbold{make_html}]
   519 \item[\ttindexbold{make_html}]
   521 is a variable read by {\tt use_thy} to decide whether HTML files
   520 is a boolean reference variable read by {\tt use_thy} and other
   522 should be made or not. After you have used {\tt init_html} you can
   521 functions to decide whether HTML files should be made. After you have
   523 manually change {\tt make_html}'s value to temporarily disable HTML
   522 used {\tt init_html} you can manually change {\tt make_html}'s value
   524 generation.
   523 to temporarily disable HTML generation.
   525 
   524 
   526 \item[\ttindexbold{finish_html}]
   525 \item[\ttindexbold{finish_html}]
   527 has to be called after all theories have been read that should be
   526 has to be called after all theories have been read that should be
   528 contained in the current {\tt index.html} file. It reads a temporary
   527 listed in the current {\tt index.html} file. It reads a temporary
   529 file with information about the theories read since the last use of
   528 file with information about the theories read since the last use of
   530 {\tt init_html} and makes the {\tt index.html} file. If {\tt
   529 {\tt init_html} and makes the {\tt index.html} file. If {\tt
   531 make_html} is {\tt false} nothing is done.
   530 make_html} is {\tt false} nothing is done.
   532 
   531 
   533 The indexes made by this function also contain a link to the {\tt
   532 The indexes made by this function also contain a link to the {\tt
   534 README} file if there exists one in the directory were the index is
   533 README} file if there exists one in the directory were the index is
   535 stored. If there's a {\tt README.html} file it's used instead of the
   534 stored. If there's a {\tt README.html} file it is used instead of
   536 {\tt README} file.
   535 {\tt README}.
   537 
   536 
   538 \end{ttdescription}
   537 \end{ttdescription}
   539 
   538 
   540 Please note that the HTML facility was developed to make HTML
   539 The above functions could be used in the following way:
   541 documents for a stable version of a logic. It is not intended to make
   540 
   542 these documents for a logic were theories are changed and only a part
   541 \begin{ttbox}
   543 of the logic is reread.
   542 init_html();
   544 
   543 {\out Setting path for index.html to "/home/stud/clasohm/isabelle/HOL"}
   545 If you add new subdirectories to Isabelle's logics (or add a completly
   544 use_thy "List";
   546 new logic), you would have to call {\tt init_html} at the start of the
   545 \dots
       
   546 finish_html();
       
   547 \end{ttbox}
       
   548 
       
   549 Please note that HTML files are made only for those theories that are
       
   550 read while {\tt make_html} is {\tt true}. These files may contain
       
   551 links to theories that were read with a {\tt false} {\tt make_html}
       
   552 and therefore point to non-existing files.
       
   553 
       
   554 
       
   555 \subsection*{Extending or adding a logic}
       
   556 
       
   557 If you add a new subdirectory to Isabelle's logics (or add a completly
       
   558 new logic), you would have to call {\tt init_html} at the start of every
   547 directory's {\tt ROOT.ML} file and {\tt finish_html} at the end of
   559 directory's {\tt ROOT.ML} file and {\tt finish_html} at the end of
   548 it. This is automatically done if you use
   560 it. This is automatically done if you use
   549 
   561 
   550 \begin{ttbox}
   562 \begin{ttbox}\index{use_dir}
   551 use_dir : string -> unit
   563 use_dir : string -> unit
   552 \end{ttbox}
   564 \end{ttbox}
   553 
   565 
   554 This function takes a path as its parameter, changes the working
   566 This function takes a path as its parameter, changes the working
   555 directory, calls {\tt init_html} if {\tt make_html} is {\tt true},
   567 directory, calls {\tt init_html} if {\tt make_html} is {\tt true},
   556 executes {\tt ROOT.ML}, and calls {\tt finish_html}. The {\tt
   568 executes {\tt ROOT.ML}, and calls {\tt finish_html}. The {\tt
   557 index.html} file written in this directory will be automatically
   569 index.html} file written in this directory will be automatically
   558 linked to the first index found in the (recursively searched)
   570 linked to the first index found in the (recursively searched)
   559 superdirectories.
   571 superdirectories.
   560 
   572 
       
   573 Instead of adding something like
       
   574 
       
   575 \begin{ttbox}
       
   576 use"ex/ROOT.ML";
       
   577 \end{ttbox}
       
   578 
       
   579 to the logic's makefile you have to use this:
       
   580 
       
   581 \begin{ttbox}
       
   582 use_dir"ex";
       
   583 \end{ttbox}
       
   584 
       
   585 Since {\tt use_dir} calls {\tt init_html} only if {\tt make_html} is
       
   586 {\tt true} the generation of HTML files depends on the value this
       
   587 reference variable has. It can either be inherited from the used \ML{}
       
   588 database or set in the makefile before {\tt use_dir} is invoked,
       
   589 e.g. to set it's value according to the environment variable {\tt
       
   590 MAKE_HTML}.
       
   591 
       
   592 The generated HTML files contain all theorems that were proved in the
       
   593 theory's \ML{} file with {\tt qed}, {\tt qed_goal} and {\tt qed_goalw},
       
   594 or stored with {\tt bind_thm} and {\tt store_thm}. Additionally there
       
   595 is a hypertext link to the whole \ML{} file.
       
   596 
       
   597 
       
   598 \subsection*{Using someone else's database}
       
   599 
       
   600 To make them independent from their storage place, the HTML files only
       
   601 contain relative paths which are derived from absolute ones like the
       
   602 current working directory, {\tt gif_path} or {\tt base_path}. The
       
   603 latter two are reference variables which are initialized at the time
       
   604 when the {\tt Pure} database is made. Because you need write access
       
   605 for the current directory to make HTML files and therefore (probably)
       
   606 generate them in your home directory, the absolute {\tt base_path} is
       
   607 not correct if you use someone else's database or a database derived
       
   608 from it.
       
   609 
       
   610 In that case you first have to set {\tt base_path} to the value of
       
   611 {\em your} Isabelle main directory, i.e. the directory that contains
       
   612 the subdirectories where standard logics like {\tt FOL} and {\tt HOL}
       
   613 or your own logics are stored.
       
   614 
       
   615 It's also a good idea to set {\tt gif_path} which points to the
       
   616 directory containing two GIF images used in the HTML
       
   617 documents. Normally this is the {\tt Tools} subdirectory of Isabelle's
       
   618 main directory. While its value in general is still valid, your HTML
       
   619 files would depend on files not owned by you. This prevents you from
       
   620 changing the location of the HTML files (as they contain relative
       
   621 paths) and also causes trouble if the database's maker (re)moves the
       
   622 GIFs.
       
   623 
       
   624 Here's what you have to do before invoking {\tt init_html} using
       
   625 someone else's \ML{} database:
       
   626 
       
   627 \begin{ttbox}
       
   628 base_path := "/home/smith/isabelle";
       
   629 gif_path := "/home/smith/isabelle/Tools";
       
   630 init_html();
       
   631 \dots
       
   632 \end{ttbox}
   561 
   633 
   562 \section{Terms}
   634 \section{Terms}
   563 \index{terms|bold}
   635 \index{terms|bold}
   564 Terms belong to the \ML\ type \mltydx{term}, which is a concrete datatype
   636 Terms belong to the \ML\ type \mltydx{term}, which is a concrete datatype
   565 with six constructors: there are six kinds of term.
   637 with six constructors: there are six kinds of term.