doc-src/Ref/theories.tex
changeset 3201 7c3cbf675e85
parent 3108 335efc3f5632
child 3485 f27a30a18a17
equal deleted inserted replaced
3200:ea2310ba01da 3201:7c3cbf675e85
       
     1 
     1 %% $Id$
     2 %% $Id$
     2 
     3 
     3 \chapter{Theories, Terms and Types} \label{theories}
     4 \chapter{Theories, Terms and Types} \label{theories}
     4 \index{theories|(}\index{signatures|bold}
     5 \index{theories|(}\index{signatures|bold}
     5 \index{reading!axioms|see{{\tt assume_ax}}} Theories organize the
     6 \index{reading!axioms|see{{\tt assume_ax}}} Theories organize the
   296 \item[\ttindexbold{unlink_thy} $thyname$]\indexbold{theories!removing}
   297 \item[\ttindexbold{unlink_thy} $thyname$]\indexbold{theories!removing}
   297   informs Isabelle that theory $thyname$ no longer exists.  If you delete the
   298   informs Isabelle that theory $thyname$ no longer exists.  If you delete the
   298   theory files for $thyname$ then you must execute {\tt unlink_thy};
   299   theory files for $thyname$ then you must execute {\tt unlink_thy};
   299   otherwise {\tt update} will complain about a missing file.
   300   otherwise {\tt update} will complain about a missing file.
   300 \end{ttdescription}
   301 \end{ttdescription}
   301 
       
   302 
       
   303 %FIXME remove
       
   304 %\goodbreak
       
   305 %\subsection{Important note for Poly/ML users}\index{Poly/{\ML} compiler}
       
   306 %The theory mechanism depends upon reference variables.  At the end of a
       
   307 %Poly/\ML{} session, the contents of references are lost unless they are
       
   308 %declared in the current database.  In particular, assignments to references
       
   309 %of the {\tt Pure} database are lost, including all information about loaded
       
   310 %theories. To avoid losing this information simply call
       
   311 %\begin{ttbox}
       
   312 %init_thy_reader();
       
   313 %\end{ttbox}
       
   314 %when building the new database.
       
   315 
   302 
   316 
   303 
   317 \subsection{*Pseudo theories}\label{sec:pseudo-theories}
   304 \subsection{*Pseudo theories}\label{sec:pseudo-theories}
   318 \indexbold{theories!pseudo}%
   305 \indexbold{theories!pseudo}%
   319 Any automatic reloading facility requires complete knowledge of all
   306 Any automatic reloading facility requires complete knowledge of all
   510 \item[\ttindexbold{stamps_of_thy} $thy$]\index{signatures}
   497 \item[\ttindexbold{stamps_of_thy} $thy$]\index{signatures}
   511 returns the identification \rmindex{stamps} of the signature associated
   498 returns the identification \rmindex{stamps} of the signature associated
   512 with~$thy$.
   499 with~$thy$.
   513 \end{ttdescription}
   500 \end{ttdescription}
   514 
   501 
   515 %FIXME move to sysman!
       
   516 %\section{Generating HTML documents}
       
   517 %\index{HTML|bold} 
       
   518 %
       
   519 %Isabelle is able to make HTML documents that show a theory's
       
   520 %definition, the theorems proved in its ML file and the relationship
       
   521 %with its ancestors and descendants. HTML stands for Hypertext Markup
       
   522 %Language and is used in the World Wide Web to represent text
       
   523 %containing images and links to other documents. Web browsers like
       
   524 %{\tt xmosaic} or {\tt netscape} are used to view these documents.
       
   525 %
       
   526 %Besides the three HTML files that are made for every theory
       
   527 %(definition and theorems, ancestors, descendants), Isabelle stores
       
   528 %links to all theories in an index file. These indexes are themself
       
   529 %linked with other indexes to represent the hierarchic structure of
       
   530 %Isabelle's logics.
       
   531 %
       
   532 %To make HTML files for logics that are part of the Isabelle
       
   533 %distribution, simply set the shell environment variable {\tt
       
   534 %MAKE_HTML} before compiling a logic. This works for single logics as
       
   535 %well as for the shell script {\tt make-all} (see
       
   536 %\ref{sec:shell-scripts}). To make HTML files for {\tt FOL} using a
       
   537 %{\tt csh} style shell, the following commands can be used:
       
   538 %
       
   539 %\begin{ttbox}
       
   540 %cd FOL
       
   541 %setenv MAKE_HTML
       
   542 %make
       
   543 %\end{ttbox}
       
   544 %
       
   545 %The databases made this way do not differ from the ones made with an
       
   546 %unset {\tt MAKE_HTML}; in particular no HTML files are written if the
       
   547 %database is used to manually load a theory.
       
   548 %
       
   549 %As you will see below, the HTML generation is controlled by a boolean
       
   550 %reference variable. If you want to make databases which define this
       
   551 %variable's value as {\tt true} and where therefore HTML files are
       
   552 %written each time {\tt use_thy} is invoked, you have to set {\tt
       
   553 %MAKE_HTML} to ``{\tt true}'':
       
   554 %
       
   555 %\begin{ttbox}
       
   556 %cd FOL
       
   557 %setenv MAKE_HTML true
       
   558 %make
       
   559 %\end{ttbox}
       
   560 %
       
   561 %All theories loaded from within the {\tt FOL} database and all
       
   562 %databases derived from it will now cause HTML files to be written.
       
   563 %This behaviour can be changed by assigning a value of {\tt false} to
       
   564 %the boolean reference variable {\tt make_html}. Be careful when making
       
   565 %such databases publicly available since it means that your users will
       
   566 %generate HTML files though they might not intend to do so.
       
   567 %
       
   568 %As some of Isabelle's logics are based on others (e.g. {\tt ZF} on
       
   569 %{\tt FOL}) and because the HTML files list a theory's ancestors, you
       
   570 %should not make HTML files for a logic if the HTML files for the base
       
   571 %logic do not exist. Otherwise some of the hypertext links might point
       
   572 %to non-existing documents.
       
   573 %
       
   574 %The entry point to all logics is the {\tt index.html} file located in
       
   575 %Isabelle's main directory. You can also access a HTML version of the
       
   576 %distribution package at
       
   577 %
       
   578 %\begin{ttbox}
       
   579 %http://www4.informatik.tu-muenchen.de/~nipkow/isabelle/
       
   580 %\end{ttbox}
       
   581 %
       
   582 %
       
   583 %\subsection*{Manual HTML generation}
       
   584 %
       
   585 %To manually control the generation of HTML files the following
       
   586 %commands and reference variables are used:
       
   587 %
       
   588 %\begin{ttbox}
       
   589 %init_html   : unit -> unit
       
   590 %make_html   : bool ref
       
   591 %finish_html : unit -> unit
       
   592 %\end{ttbox}
       
   593 %
       
   594 %\begin{ttdescription}
       
   595 %\item[\ttindexbold{init_html}]
       
   596 %activates the HTML facility. It stores the current working directory
       
   597 %as the place where the {\tt index.html} file for all theories loaded
       
   598 %afterwards will be stored.
       
   599 %
       
   600 %\item[\ttindexbold{make_html}]
       
   601 %is a boolean reference variable read by {\tt use_thy} and other
       
   602 %functions to decide whether HTML files should be made. After you have
       
   603 %used {\tt init_html} you can manually change {\tt make_html}'s value
       
   604 %to temporarily disable HTML generation.
       
   605 %
       
   606 %\item[\ttindexbold{finish_html}]
       
   607 %has to be called after all theories have been read that should be
       
   608 %listed in the current {\tt index.html} file. It reads a temporary
       
   609 %file with information about the theories read since the last use of
       
   610 %{\tt init_html} and makes the {\tt index.html} file. If {\tt
       
   611 %make_html} is {\tt false} nothing is done.
       
   612 %
       
   613 %The indexes made by this function also contain a link to the {\tt
       
   614 %README} file if there exists one in the directory where the index is
       
   615 %stored. If there's a {\tt README.html} file it is used instead of
       
   616 %{\tt README}.
       
   617 %
       
   618 %\end{ttdescription}
       
   619 %
       
   620 %The above functions could be used in the following way:
       
   621 %
       
   622 %\begin{ttbox}
       
   623 %init_html();
       
   624 %{\out Setting path for index.html to "/home/clasohm/isabelle/HOL"}
       
   625 %use_thy "List";
       
   626 %\dots
       
   627 %finish_html();
       
   628 %\end{ttbox}
       
   629 %
       
   630 %Please note that HTML files are made only for those theories that are
       
   631 %read while {\tt make_html} is {\tt true}. These files may contain
       
   632 %links to theories that were read with a {\tt false} {\tt make_html}
       
   633 %and therefore point to non-existing files.
       
   634 %
       
   635 %
       
   636 %\subsection*{Extending or adding a logic}
       
   637 %
       
   638 %If you add a new subdirectory to Isabelle's logics (or add a completly
       
   639 %new logic), you would have to call {\tt init_html} at the start of every
       
   640 %directory's {\tt ROOT.ML} file and {\tt finish_html} at the end of
       
   641 %it. This is automatically done if you use
       
   642 %
       
   643 %\begin{ttbox}\index{use_dir}
       
   644 %use_dir : string -> unit
       
   645 %\end{ttbox}
       
   646 %
       
   647 %This function takes a path as its parameter, changes the working
       
   648 %directory, calls {\tt init_html} if {\tt make_html} is {\tt true},
       
   649 %executes {\tt ROOT.ML}, and calls {\tt finish_html}. The {\tt
       
   650 %index.html} file written in this directory will be automatically
       
   651 %linked to the first index found in the (recursively searched)
       
   652 %superdirectories.
       
   653 %
       
   654 %Instead of adding something like
       
   655 %
       
   656 %\begin{ttbox}
       
   657 %use"ex/ROOT.ML";
       
   658 %\end{ttbox}
       
   659 %
       
   660 %to the logic's makefile you have to use this:
       
   661 %
       
   662 %\begin{ttbox}
       
   663 %use_dir"ex";
       
   664 %\end{ttbox}
       
   665 %
       
   666 %Since {\tt use_dir} calls {\tt init_html} only if {\tt make_html} is
       
   667 %{\tt true} the generation of HTML files depends on the value this
       
   668 %reference variable has. It can either be inherited from the used \ML{}
       
   669 %database or set in the makefile before {\tt use_dir} is invoked,
       
   670 %e.g. to set it's value according to the environment variable {\tt
       
   671 %MAKE_HTML}.
       
   672 %
       
   673 %The generated HTML files contain all theorems that were proved in the
       
   674 %theory's \ML{} file with {\tt qed}, {\tt qed_goal} and {\tt qed_goalw},
       
   675 %or stored with {\tt bind_thm} and {\tt store_thm}. Additionally there
       
   676 %is a hypertext link to the whole \ML{} file.
       
   677 %
       
   678 %You can add section headings to the list of theorems by using
       
   679 %
       
   680 %\begin{ttbox}\index{use_dir}
       
   681 %section: string -> unit
       
   682 %\end{ttbox}
       
   683 %
       
   684 %in a theory's ML file, which converts a plain string to a HTML
       
   685 %heading and inserts it before the next theorem proved or stored with
       
   686 %one of the above functions. If {\tt make_html} is {\tt false} nothing
       
   687 %is done.
       
   688 %
       
   689 %
       
   690 %\subsection*{Using someone else's database}
       
   691 %
       
   692 %To make them independent from their storage place, the HTML files only
       
   693 %contain relative paths which are derived from absolute ones like the
       
   694 %current working directory, {\tt gif_path} or {\tt base_path}. The
       
   695 %latter two are reference variables which are initialized at the time
       
   696 %when the {\tt Pure} database is made. Because you need write access
       
   697 %for the current directory to make HTML files and therefore (probably)
       
   698 %generate them in your home directory, the absolute {\tt base_path} is
       
   699 %not correct if you use someone else's database or a database derived
       
   700 %from it.
       
   701 %
       
   702 %In that case you first should set {\tt base_path} to the value of {\em
       
   703 %your} Isabelle main directory, i.e. the directory that contains the
       
   704 %subdirectories where standard logics like {\tt FOL} and {\tt HOL} or
       
   705 %your own logics are stored. If you do not do this, the generated HTML
       
   706 %files will still be usable but may contain incomplete titles and lack
       
   707 %some hypertext links.
       
   708 %
       
   709 %It's also a good idea to set {\tt gif_path} which points to the
       
   710 %directory containing two GIF images used in the HTML
       
   711 %documents. Normally this is the {\tt Tools} subdirectory of Isabelle's
       
   712 %main directory. While its value in general is still valid, your HTML
       
   713 %files would depend on files not owned by you. This prevents you from
       
   714 %changing the location of the HTML files (as they contain relative
       
   715 %paths) and also causes trouble if the database's maker (re)moves the
       
   716 %GIFs.
       
   717 %
       
   718 %Here's what you should do before invoking {\tt init_html} using
       
   719 %someone else's \ML{} database:
       
   720 %
       
   721 %\begin{ttbox}
       
   722 %base_path := "/home/smith/isabelle";
       
   723 %gif_path := "/home/smith/isabelle/Tools";
       
   724 %init_html();
       
   725 %\dots
       
   726 %\end{ttbox}
       
   727 
       
   728 
   502 
   729 \section{Terms}
   503 \section{Terms}
   730 \index{terms|bold}
   504 \index{terms|bold}
   731 Terms belong to the \ML\ type \mltydx{term}, which is a concrete datatype
   505 Terms belong to the \ML\ type \mltydx{term}, which is a concrete datatype
   732 with six constructors:
   506 with six constructors: