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