author wenzelm
Fri May 17 19:04:52 2013 +0200 (2013-05-17)
changeset 52056 fc458f304f93
parent 52054 eaf17514aabd
child 52061 1a52aa84e411
permissions -rw-r--r--
added isabelle-process option -o;
     1 theory Basics
     2 imports Base
     3 begin
     5 chapter {* The Isabelle system environment *}
     7 text {* This manual describes Isabelle together with related tools and
     8   user interfaces as seen from a system oriented view.  See also the
     9   \emph{Isabelle/Isar Reference Manual}~\cite{isabelle-isar-ref} for
    10   the actual Isabelle input language and related concepts, and
    11   \emph{The Isabelle/Isar Implementation
    12   Manual}~\cite{isabelle-implementation} for the main concepts of the
    13   underlying implementation in Isabelle/ML.
    15   \medskip The Isabelle system environment provides the following
    16   basic infrastructure to integrate tools smoothly.
    18   \begin{enumerate}
    20   \item The \emph{Isabelle settings} mechanism provides process
    21   environment variables to all Isabelle executables (including tools
    22   and user interfaces).
    24   \item The raw \emph{Isabelle process} (@{executable_ref
    25   "isabelle-process"}) runs logic sessions either interactively or in
    26   batch mode.  In particular, this view abstracts over the invocation
    27   of the actual ML system to be used.  Regular users rarely need to
    28   care about the low-level process.
    30   \item The main \emph{Isabelle tool wrapper} (@{executable_ref
    31   isabelle}) provides a generic startup environment Isabelle related
    32   utilities, user interfaces etc.  Such tools automatically benefit
    33   from the settings mechanism.
    35   \end{enumerate}
    36 *}
    39 section {* Isabelle settings \label{sec:settings} *}
    41 text {*
    42   The Isabelle system heavily depends on the \emph{settings
    43   mechanism}\indexbold{settings}.  Essentially, this is a statically
    44   scoped collection of environment variables, such as @{setting
    45   ISABELLE_HOME}, @{setting ML_SYSTEM}, @{setting ML_HOME}.  These
    46   variables are \emph{not} intended to be set directly from the shell,
    47   though.  Isabelle employs a somewhat more sophisticated scheme of
    48   \emph{settings files} --- one for site-wide defaults, another for
    49   additional user-specific modifications.  With all configuration
    50   variables in clearly defined places, this scheme is more
    51   maintainable and user-friendly than global shell environment
    52   variables.
    54   In particular, we avoid the typical situation where prospective
    55   users of a software package are told to put several things into
    56   their shell startup scripts, before being able to actually run the
    57   program. Isabelle requires none such administrative chores of its
    58   end-users --- the executables can be invoked straight away.
    59   Occasionally, users would still want to put the @{file
    60   "$ISABELLE_HOME/bin"} directory into their shell's search path, but
    61   this is not required.
    62 *}
    65 subsection {* Bootstrapping the environment \label{sec:boot} *}
    67 text {* Isabelle executables need to be run within a proper settings
    68   environment.  This is bootstrapped as described below, on the first
    69   invocation of one of the outer wrapper scripts (such as
    70   @{executable_ref isabelle}).  This happens only once for each
    71   process tree, i.e.\ the environment is passed to subprocesses
    72   according to regular Unix conventions.
    74   \begin{enumerate}
    76   \item The special variable @{setting_def ISABELLE_HOME} is
    77   determined automatically from the location of the binary that has
    78   been run.
    80   You should not try to set @{setting ISABELLE_HOME} manually. Also
    81   note that the Isabelle executables either have to be run from their
    82   original location in the distribution directory, or via the
    83   executable objects created by the @{tool install} tool.  Symbolic
    84   links are admissible, but a plain copy of the @{file
    85   "$ISABELLE_HOME/bin"} files will not work!
    87   \item The file @{file "$ISABELLE_HOME/etc/settings"} is run as a
    88   @{executable_ref bash} shell script with the auto-export option for
    89   variables enabled.
    91   This file holds a rather long list of shell variable assigments,
    92   thus providing the site-wide default settings.  The Isabelle
    93   distribution already contains a global settings file with sensible
    94   defaults for most variables.  When installing the system, only a few
    95   of these may have to be adapted (probably @{setting ML_SYSTEM}
    96   etc.).
    98   \item The file @{verbatim "$ISABELLE_HOME_USER/etc/settings"} (if it
    99   exists) is run in the same way as the site default settings. Note
   100   that the variable @{setting ISABELLE_HOME_USER} has already been set
   101   before --- usually to something like @{verbatim
   102   "$USER_HOME/.isabelle/IsabelleXXXX"}.
   104   Thus individual users may override the site-wide defaults.  See also
   105   file @{file "$ISABELLE_HOME/etc/user-settings.sample"} in the
   106   distribution.  Typically, a user settings file would contain only a
   107   few lines, just the assigments that are really changed.  One should
   108   definitely \emph{not} start with a full copy the basic @{file
   109   "$ISABELLE_HOME/etc/settings"}. This could cause very annoying
   110   maintainance problems later, when the Isabelle installation is
   111   updated or changed otherwise.
   113   \end{enumerate}
   115   Since settings files are regular GNU @{executable_def bash} scripts,
   116   one may use complex shell commands, such as @{verbatim "if"} or
   117   @{verbatim "case"} statements to set variables depending on the
   118   system architecture or other environment variables.  Such advanced
   119   features should be added only with great care, though. In
   120   particular, external environment references should be kept at a
   121   minimum.
   123   \medskip A few variables are somewhat special:
   125   \begin{itemize}
   127   \item @{setting_def ISABELLE_PROCESS} and @{setting_def ISABELLE_TOOL} are set
   128   automatically to the absolute path names of the @{executable
   129   "isabelle-process"} and @{executable isabelle} executables,
   130   respectively.
   132   \item @{setting_ref ISABELLE_OUTPUT} will have the identifiers of
   133   the Isabelle distribution (cf.\ @{setting ISABELLE_IDENTIFIER}) and
   134   the ML system (cf.\ @{setting ML_IDENTIFIER}) appended automatically
   135   to its value.
   137   \end{itemize}
   139   \medskip Note that the settings environment may be inspected with
   140   the @{tool getenv} tool.  This might help to figure out the effect
   141   of complex settings scripts.  *}
   144 subsection {* Common variables *}
   146 text {*
   147   This is a reference of common Isabelle settings variables. Note that
   148   the list is somewhat open-ended. Third-party utilities or interfaces
   149   may add their own selection. Variables that are special in some
   150   sense are marked with @{text "\<^sup>*"}.
   152   \begin{description}
   154   \item[@{setting_def USER_HOME}@{text "\<^sup>*"}] Is the cross-platform
   155   user home directory.  On Unix systems this is usually the same as
   156   @{setting HOME}, but on Windows it is the regular home directory of
   157   the user, not the one of within the Cygwin root
   158   file-system.\footnote{Cygwin itself offers another choice whether
   159   its HOME should point to the \texttt{/home} directory tree or the
   160   Windows user home.}
   162  \item[@{setting_def ISABELLE_HOME}@{text "\<^sup>*"}] is the location of the
   163   top-level Isabelle distribution directory. This is automatically
   164   determined from the Isabelle executable that has been invoked.  Do
   165   not attempt to set @{setting ISABELLE_HOME} yourself from the shell!
   167   \item[@{setting_def ISABELLE_HOME_USER}] is the user-specific
   168   counterpart of @{setting ISABELLE_HOME}. The default value is
   169   relative to @{verbatim "$USER_HOME/.isabelle"}, under rare
   170   circumstances this may be changed in the global setting file.
   171   Typically, the @{setting ISABELLE_HOME_USER} directory mimics
   172   @{setting ISABELLE_HOME} to some extend. In particular, site-wide
   173   defaults may be overridden by a private @{verbatim
   174   "$ISABELLE_HOME_USER/etc/settings"}.
   176   \item[@{setting_def ISABELLE_PLATFORM_FAMILY}@{text "\<^sup>*"}] is
   177   automatically set to the general platform family: @{verbatim linux},
   178   @{verbatim macos}, @{verbatim windows}.  Note that
   179   platform-dependent tools usually need to refer to the more specific
   180   identification according to @{setting ISABELLE_PLATFORM}, @{setting
   183   \item[@{setting_def ISABELLE_PLATFORM}@{text "\<^sup>*"}] is automatically
   184   set to a symbolic identifier for the underlying hardware and
   185   operating system.  The Isabelle platform identification always
   186   refers to the 32 bit variant, even this is a 64 bit machine.  Note
   187   that the ML or Java runtime may have a different idea, depending on
   188   which binaries are actually run.
   190   \item[@{setting_def ISABELLE_PLATFORM64}@{text "\<^sup>*"}] is similar to
   191   @{setting ISABELLE_PLATFORM} but refers to the proper 64 bit variant
   192   on a platform that supports this; the value is empty for 32 bit.
   193   Note that the following bash expression (including the quotes)
   194   prefers the 64 bit platform, if that is available:
   196   @{verbatim [display] "\"${ISABELLE_PLATFORM64:-$ISABELLE_PLATFORM}\""}
   198   \item[@{setting_def ISABELLE_PROCESS}@{text "\<^sup>*"}, @{setting
   199   ISABELLE_TOOL}@{text "\<^sup>*"}] are automatically set to the full path
   200   names of the @{executable "isabelle-process"} and @{executable
   201   isabelle} executables, respectively.  Thus other tools and scripts
   202   need not assume that the @{file "$ISABELLE_HOME/bin"} directory is
   203   on the current search path of the shell.
   205   \item[@{setting_def ISABELLE_IDENTIFIER}@{text "\<^sup>*"}] refers
   206   to the name of this Isabelle distribution, e.g.\ ``@{verbatim
   207   Isabelle2012}''.
   209   \item[@{setting_def ML_SYSTEM}, @{setting_def ML_HOME},
   210   @{setting_def ML_OPTIONS}, @{setting_def ML_PLATFORM}, @{setting_def
   211   ML_IDENTIFIER}@{text "\<^sup>*"}] specify the underlying ML system
   212   to be used for Isabelle.  There is only a fixed set of admissable
   213   @{setting ML_SYSTEM} names (see the @{file
   214   "$ISABELLE_HOME/etc/settings"} file of the distribution).
   216   The actual compiler binary will be run from the directory @{setting
   217   ML_HOME}, with @{setting ML_OPTIONS} as first arguments on the
   218   command line.  The optional @{setting ML_PLATFORM} may specify the
   219   binary format of ML heap images, which is useful for cross-platform
   220   installations.  The value of @{setting ML_IDENTIFIER} is
   221   automatically obtained by composing the values of @{setting
   222   ML_SYSTEM}, @{setting ML_PLATFORM} and the Isabelle version values.
   224   \item[@{setting_def ISABELLE_POLYML}@{text "\<^sup>*"}] is @{verbatim true}
   225   for @{setting ML_SYSTEM} values derived from Poly/ML, as opposed to
   226   SML/NJ where it is empty.  This is particularly useful with the
   227   build option @{system_option condition}
   228   (\secref{sec:system-options}) to restrict big sessions to something
   229   that SML/NJ can still handle.
   231   \item[@{setting_def ISABELLE_JDK_HOME}] needs to point to a full JDK
   232   (Java Development Kit) installation with @{verbatim javac} and
   233   @{verbatim jar} executables.  This is essential for Isabelle/Scala
   234   and other JVM-based tools to work properly.  Note that conventional
   235   @{verbatim JAVA_HOME} usually points to the JRE (Java Runtime
   236   Environment), not JDK.
   238   \item[@{setting_def ISABELLE_PATH}] is a list of directories
   239   (separated by colons) where Isabelle logic images may reside.  When
   240   looking up heaps files, the value of @{setting ML_IDENTIFIER} is
   241   appended to each component internally.
   243   \item[@{setting_def ISABELLE_OUTPUT}@{text "\<^sup>*"}] is a
   244   directory where output heap files should be stored by default. The
   245   ML system and Isabelle version identifier is appended here, too.
   247   \item[@{setting_def ISABELLE_BROWSER_INFO}] is the directory where
   248   theory browser information (HTML text, graph data, and printable
   249   documents) is stored (see also \secref{sec:info}).  The default
   250   value is @{verbatim "$ISABELLE_HOME_USER/browser_info"}.
   252   \item[@{setting_def ISABELLE_LOGIC}] specifies the default logic to
   253   load if none is given explicitely by the user.  The default value is
   254   @{verbatim HOL}.
   256   \item[@{setting_def ISABELLE_LINE_EDITOR}] specifies the default
   257   line editor for the @{tool_ref tty} interface.
   259   \item[@{setting_def ISABELLE_LATEX}, @{setting_def
   260   ISABELLE_PDFLATEX}, @{setting_def ISABELLE_BIBTEX}, @{setting_def
   261   ISABELLE_DVIPS}] refer to {\LaTeX} related tools for Isabelle
   262   document preparation (see also \secref{sec:tool-latex}).
   264   \item[@{setting_def ISABELLE_TOOLS}] is a colon separated list of
   265   directories that are scanned by @{executable isabelle} for external
   266   utility programs (see also \secref{sec:isabelle-tool}).
   268   \item[@{setting_def ISABELLE_DOCS}] is a colon separated list of
   269   directories with documentation files.
   271   \item[@{setting_def ISABELLE_DOC_FORMAT}] specifies the preferred
   272   document format, typically @{verbatim pdf} or @{verbatim dvi}.
   274   \item[@{setting_def PDF_VIEWER}] specifies the command-line to be
   275   used for displaying @{verbatim pdf} files.
   277   \item[@{setting_def DVI_VIEWER}] specifies the command-line to be
   278   used for displaying @{verbatim dvi} files.
   280   \item[@{setting_def PRINT_COMMAND}] specifies the standard printer
   281   spool command, which is expected to accept @{verbatim ps} files.
   283   \item[@{setting_def ISABELLE_TMP_PREFIX}@{text "\<^sup>*"}] is the
   284   prefix from which any running @{executable "isabelle-process"}
   285   derives an individual directory for temporary files.  The default is
   286   somewhere in @{verbatim "/tmp"}.
   288   \end{description}
   289 *}
   292 subsection {* Additional components \label{sec:components} *}
   294 text {* Any directory may be registered as an explicit \emph{Isabelle
   295   component}.  The general layout conventions are that of the main
   296   Isabelle distribution itself, and the following two files (both
   297   optional) have a special meaning:
   299   \begin{itemize}
   301   \item @{verbatim "etc/settings"} holds additional settings that are
   302   initialized when bootstrapping the overall Isabelle environment,
   303   cf.\ \secref{sec:boot}.  As usual, the content is interpreted as a
   304   @{verbatim bash} script.  It may refer to the component's enclosing
   305   directory via the @{verbatim "COMPONENT"} shell variable.
   307   For example, the following setting allows to refer to files within
   308   the component later on, without having to hardwire absolute paths:
   310 \begin{ttbox}
   312 \end{ttbox}
   314   Components can also add to existing Isabelle settings such as
   315   @{setting_def ISABELLE_TOOLS}, in order to provide
   316   component-specific tools that can be invoked by end-users.  For
   317   example:
   319 \begin{ttbox}
   321 \end{ttbox}
   323   \item @{verbatim "etc/components"} holds a list of further
   324   sub-components of the same structure.  The directory specifications
   325   given here can be either absolute (with leading @{verbatim "/"}) or
   326   relative to the component's main directory.
   328   \end{itemize}
   330   The root of component initialization is @{setting ISABELLE_HOME}
   331   itself.  After initializing all of its sub-components recursively,
   332   @{setting ISABELLE_HOME_USER} is included in the same manner (if
   333   that directory exists).  This allows to install private components
   334   via @{verbatim "$ISABELLE_HOME_USER/etc/components"}, although it is
   335   often more convenient to do that programmatically via the
   336   \verb,init_component, shell function in the \verb,etc/settings,
   337   script of \verb,$ISABELLE_HOME_USER, (or any other component
   338   directory).  For example:
   339 \begin{ttbox}
   340 init_component "$HOME/screwdriver-2.0"
   341 \end{ttbox}
   343   This is tolerant wrt.\ missing component directories, but might
   344   produce a warning.
   346   \medskip More complex situations may be addressed by initializing
   347   components listed in a given catalog file, relatively to some base
   348   directory:
   350 \begin{ttbox}
   351 init_components "$HOME/my_component_store" "some_catalog_file"
   352 \end{ttbox}
   354   The component directories listed in the catalog file are treated as
   355   relative to the given base directory.
   357   See also \secref{sec:tool-components} for some tool-support for
   358   resolving components that are formally initialized but not installed
   359   yet.
   360 *}
   363 section {* The raw Isabelle process *}
   365 text {*
   366   The @{executable_def "isabelle-process"} executable runs bare-bones
   367   Isabelle logic sessions --- either interactively or in batch mode.
   368   It provides an abstraction over the underlying ML system, and over
   369   the actual heap file locations.  Its usage is:
   371 \begin{ttbox}
   372 Usage: isabelle-process [OPTIONS] [INPUT] [OUTPUT]
   374   Options are:
   375     -I           startup Isar interaction mode
   376     -P           startup Proof General interaction mode
   377     -S           secure mode -- disallow critical operations
   378     -T ADDR      startup process wrapper, with socket address
   379     -W IN:OUT    startup process wrapper, with input/output fifos
   380     -e MLTEXT    pass MLTEXT to the ML session
   381     -m MODE      add print mode for output
   382     -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
   383     -q           non-interactive session
   384     -r           open heap file read-only
   385     -w           reset write permissions on OUTPUT
   387   INPUT (default "\$ISABELLE_LOGIC") and OUTPUT specify in/out heaps.
   388   These are either names to be searched in the Isabelle path, or
   389   actual file names (containing at least one /).
   390   If INPUT is "RAW_ML_SYSTEM", just start the bare bones ML system.
   391 \end{ttbox}
   393   Input files without path specifications are looked up in the
   394   @{setting ISABELLE_PATH} setting, which may consist of multiple
   395   components separated by colons --- these are tried in the given
   396   order with the value of @{setting ML_IDENTIFIER} appended
   397   internally.  In a similar way, base names are relative to the
   398   directory specified by @{setting ISABELLE_OUTPUT}.  In any case,
   399   actual file locations may also be given by including at least one
   400   slash (@{verbatim "/"}) in the name (hint: use @{verbatim "./"} to
   401   refer to the current directory).
   402 *}
   405 subsubsection {* Options *}
   407 text {*
   408   If the input heap file does not have write permission bits set, or
   409   the @{verbatim "-r"} option is given explicitely, then the session
   410   started will be read-only.  That is, the ML world cannot be
   411   committed back into the image file.  Otherwise, a writable session
   412   enables commits into either the input file, or into another output
   413   heap file (if that is given as the second argument on the command
   414   line).
   416   The read-write state of sessions is determined at startup only, it
   417   cannot be changed intermediately. Also note that heap images may
   418   require considerable amounts of disk space (approximately
   419   50--200~MB). Users are responsible for themselves to dispose their
   420   heap files when they are no longer needed.
   422   \medskip The @{verbatim "-w"} option makes the output heap file
   423   read-only after terminating.  Thus subsequent invocations cause the
   424   logic image to be read-only automatically.
   426   \medskip Using the @{verbatim "-e"} option, arbitrary ML code may be
   427   passed to the Isabelle session from the command line. Multiple
   428   @{verbatim "-e"}'s are evaluated in the given order. Strange things
   429   may happen when errorneous ML code is provided. Also make sure that
   430   the ML commands are terminated properly by semicolon.
   432   \medskip The @{verbatim "-m"} option adds identifiers of print modes
   433   to be made active for this session. Typically, this is used by some
   434   user interface, e.g.\ to enable output of proper mathematical
   435   symbols.
   437   \medskip Isabelle normally enters an interactive top-level loop
   438   (after processing the @{verbatim "-e"} texts). The @{verbatim "-q"}
   439   option inhibits interaction, thus providing a pure batch mode
   440   facility.
   442   \medskip Option @{verbatim "-s"} allows to override Isabelle system
   443   options for this process, see also \secref{sec:system-options}.
   445   \medskip The @{verbatim "-I"} option makes Isabelle enter Isar
   446   interaction mode on startup, instead of the primitive ML top-level.
   447   The @{verbatim "-P"} option configures the top-level loop for
   448   interaction with the Proof General user interface.
   450   \medskip The @{verbatim "-T"} or @{verbatim "-W"} option makes
   451   Isabelle enter a special process wrapper for interaction via
   452   Isabelle/Scala, see also @{file
   453   "~~/src/Pure/System/isabelle_process.scala"}.  The protocol between
   454   the ML and JVM process is private to the implementation.
   456   \medskip The @{verbatim "-S"} option makes the Isabelle process more
   457   secure by disabling some critical operations, notably runtime
   458   compilation and evaluation of ML source code.
   459 *}
   462 subsubsection {* Examples *}
   464 text {*
   465   Run an interactive session of the default object-logic (as specified
   466   by the @{setting ISABELLE_LOGIC} setting) like this:
   467 \begin{ttbox}
   468 isabelle-process
   469 \end{ttbox}
   471   Usually @{setting ISABELLE_LOGIC} refers to one of the standard
   472   logic images, which are read-only by default.  A writable session
   473   --- based on @{verbatim HOL}, but output to @{verbatim Test} (in the
   474   directory specified by the @{setting ISABELLE_OUTPUT} setting) ---
   475   may be invoked as follows:
   476 \begin{ttbox}
   477 isabelle-process HOL Test
   478 \end{ttbox}
   479   Ending this session normally (e.g.\ by typing control-D) dumps the
   480   whole ML system state into @{verbatim Test} (be prepared for more
   481   than 100\,MB):
   483   The @{verbatim Test} session may be continued later (still in
   484   writable state) by:
   485 \begin{ttbox}
   486 isabelle-process Test
   487 \end{ttbox}
   488   A read-only @{verbatim Test} session may be started by:
   489 \begin{ttbox}
   490 isabelle-process -r Test
   491 \end{ttbox}
   493   \bigskip The next example demonstrates batch execution of Isabelle.
   494   We retrieve the @{verbatim Main} theory value from the theory loader
   495   within ML (observe the delicate quoting rules for the Bash shell
   496   vs.\ ML):
   497 \begin{ttbox}
   498 isabelle-process -e 'Thy_Info.get_theory "Main";' -q -r HOL
   499 \end{ttbox}
   500   Note that the output text will be interspersed with additional junk
   501   messages by the ML runtime environment.  The @{verbatim "-W"} option
   502   allows to communicate with the Isabelle process via an external
   503   program in a more robust fashion.
   504 *}
   507 section {* The Isabelle tool wrapper \label{sec:isabelle-tool} *}
   509 text {*
   510   All Isabelle related tools and interfaces are called via a common
   511   wrapper --- @{executable isabelle}:
   513 \begin{ttbox}
   514 Usage: isabelle TOOL [ARGS ...]
   516   Start Isabelle tool NAME with ARGS; pass "-?" for tool specific help.
   518 Available tools:
   519   \dots
   520 \end{ttbox}
   522   In principle, Isabelle tools are ordinary executable scripts that
   523   are run within the Isabelle settings environment, see
   524   \secref{sec:settings}.  The set of available tools is collected by
   525   @{executable isabelle} from the directories listed in the @{setting
   526   ISABELLE_TOOLS} setting.  Do not try to call the scripts directly
   527   from the shell.  Neither should you add the tool directories to your
   528   shell's search path!
   529 *}
   532 subsubsection {* Examples *}
   534 text {* Show the list of available documentation of the Isabelle
   535   distribution:
   537 \begin{ttbox}
   538   isabelle doc
   539 \end{ttbox}
   541   View a certain document as follows:
   542 \begin{ttbox}
   543   isabelle doc system
   544 \end{ttbox}
   546   Query the Isabelle settings environment:
   547 \begin{ttbox}
   548   isabelle getenv ISABELLE_HOME_USER
   549 \end{ttbox}
   550 *}
   552 end