doc-src/Ref/introduction.tex
changeset 6568 b38bc78d9a9d
parent 6343 97c697a32b73
child 6569 66c941ea1f01
equal deleted inserted replaced
6567:8338dd394144 6568:b38bc78d9a9d
    13 by their operands (subgoals, tactics, theorems), and by their usefulness.
    13 by their operands (subgoals, tactics, theorems), and by their usefulness.
    14 In each section, basic functions appear first, then advanced functions, and
    14 In each section, basic functions appear first, then advanced functions, and
    15 finally esoteric functions.  Use the Index when you are looking for the
    15 finally esoteric functions.  Use the Index when you are looking for the
    16 definition of a particular Isabelle function.
    16 definition of a particular Isabelle function.
    17 
    17 
    18 A few examples are presented.  Many examples files are distributed with
    18 A few examples are presented.  Many example files are distributed with
    19 Isabelle, however; please experiment interactively.
    19 Isabelle, however; please experiment interactively.
    20 
    20 
    21 
    21 
    22 \section{Basic interaction with Isabelle}
    22 \section{Basic interaction with Isabelle}
    23 \index{starting up|bold}\nobreak
    23 \index{starting up|bold}\nobreak
    24 %
    24 %
    25 We assume that your local Isabelle administrator (this might be you!)
    25 We assume that your local Isabelle administrator (this might be you!) has
    26 has already installed the \Pure\ system and several object-logics
    26 already installed the Isabelle system together with appropriate object-logics
    27 properly --- otherwise see the {\tt INSTALL} file in the top-level
    27 --- otherwise see the \texttt{README} and \texttt{INSTALL} files in the
    28 directory of the distribution on how to build it.
    28 top-level directory of the distribution on how to do this.
    29 
    29 
    30 \medskip Let $\langle isabellehome \rangle$ denote the location where
    30 \medskip Let $\langle isabellehome \rangle$ denote the location where
    31 the distribution has been installed.  To run Isabelle from a the shell
    31 the distribution has been installed.  To run Isabelle from a the shell
    32 prompt within an ordinary text terminal session, simply type
    32 prompt within an ordinary text terminal session, simply type
    33 \begin{ttbox}
    33 \begin{ttbox}
    34 \({\langle}isabellehome{\rangle}\)/bin/isabelle
    34 \({\langle}isabellehome{\rangle}\)/bin/isabelle
    35 \end{ttbox}
    35 \end{ttbox}
    36 This should start an interactive \ML{} session with the default
    36 This should start an interactive \ML{} session with the default object-logic
    37 object-logic already preloaded.
    37 (usually {\HOL}) already pre-loaded.
    38 
    38 
    39 Subsequently we assume that {\tt \(\langle isabellehome \rangle\)/bin}
    39 Subsequently, we assume that the \texttt{isabelle} executable is determined
    40 has been added to your shell's search path, in order to avoid typing
    40 automatically by the shell, e.g.\ by adding {\tt \(\langle isabellehome
    41 full path specifications of the executable files.
    41   \rangle\)/bin} to your search path.\footnote{Depending on your installation,
    42 
    42   there might be also stand-alone binaries located in some global directory
    43 The object-logic image to load may be also specified explicitly as an
    43   such as \texttt{/usr/bin}.  Do not attempt to copy {\tt \(\langle
    44 argument to the {\tt isabelle} command, e.g.
    44     isabellehome \rangle\)/bin/isabelle}, though!  See \texttt{isatool
       
    45     install} in \emph{The Isabelle System Manual} of how to do this properly.}
       
    46 
       
    47 The object-logic image to load may be also specified explicitly as an argument
       
    48 to the {\tt isabelle} command, e.g.
    45 \begin{ttbox}
    49 \begin{ttbox}
    46 isabelle FOL
    50 isabelle FOL
    47 \end{ttbox}
    51 \end{ttbox}
    48 This should put you into the world of polymorphic first-order logic
    52 This should put you into the world of polymorphic first-order logic (assuming
    49 (assuming that {\FOL} has been pre-built).
    53 that an image of {\FOL} has been pre-built).
    50 
    54 
    51 \index{saving your work|bold} Isabelle provides no means of storing
    55 \index{saving your session|bold} Isabelle provides no means of storing
    52 theorems or internal proof objects on files.  Theorems are simply part
    56 theorems or internal proof objects on files.  Theorems are simply part of the
    53 of the \ML{} state.  To save your work between sessions, you must dump
    57 \ML{} state.  To save your work between sessions, you may dump the \ML{}
    54 the \ML{} system state to a file.  This is done automatically when
    58 system state to a file.  This is done automatically when ending the session
    55 ending the session normally (e.g.\ by typing control-D), provided that
    59 normally (e.g.\ by typing control-D), provided that the image has been opened
    56 the image has been opened \emph{writable} in the first place.  The
    60 \emph{writable} in the first place.  The standard object-logic images are
    57 standard object-logic images are usually read-only, so you probably
    61 usually read-only, so you have to create a private working copy first.  For
    58 have to create a private working copy first.  For example, the
    62 example, the following shell command puts you into a writable Isabelle session
    59 following shell command puts you into a writable Isabelle session of
    63 of name \texttt{Foo} that initially contains just plain \HOL:
    60 name \texttt{Foo} that initially contains just \FOL:
    64 \begin{ttbox}
    61 \begin{ttbox}
    65 isabelle HOL Foo
    62 isabelle FOL Foo
       
    63 \end{ttbox}
    66 \end{ttbox}
    64 Ending the \texttt{Foo} session with control-D will cause the complete
    67 Ending the \texttt{Foo} session with control-D will cause the complete
    65 \ML{} world to be saved somewhere in your home directory\footnote{The
    68 \ML-world to be saved somewhere in your home directory\footnote{The default
    66   default location is in \texttt{\~\relax/isabelle/heaps}, but this
    69   location is in \texttt{\~\relax/isabelle/heaps}, but this depends on your
    67   depends on your local configuration.}.  Make sure there is enough
    70   local configuration.}.  Make sure there is enough space available! Then one
    68 space available! Then one may later continue at exactly the same point
    71 may later continue at exactly the same point by running
    69 by running
       
    70 \begin{ttbox}
    72 \begin{ttbox}
    71 isabelle Foo  
    73 isabelle Foo  
    72 \end{ttbox}
    74 \end{ttbox}
    73 
    75 
    74 More details about the \texttt{isabelle} command may be found in \emph{The
    76 \medskip Saving the {\ML} state is not enough.  Record, on a file, the
    75   Isabelle System Manual}.
    77 top-level commands that generate your theories and proofs.  Such a record
    76 
    78 allows you to replay the proofs whenever required, for instance after making
    77 \medskip Saving the state is not enough.  Record, on a file, the
    79 minor changes to the axioms.  Ideally, your these sources will be somewhat
    78 top-level commands that generate your theories and proofs.  Such a
    80 intelligible to others as a formal description of your work.
    79 record allows you to replay the proofs whenever required, for instance
    81 
    80 after making minor changes to the axioms.  Ideally, your record will
    82 It is good practice to put all source files that constitute a separate
    81 be somewhat intelligible to others as a formal description of your
    83 Isabelle session into an individual directory, together with an {\ML} file
    82 work.
    84 called \texttt{ROOT.ML} that contains appropriate commands to load all other
    83 
    85 files required.  Running \texttt{isabelle} with option \texttt{-u}
    84 \medskip There are more comfortable user interfaces than the
    86 automatically loads \texttt{ROOT.ML} on entering the session.  The
    85 bare-bones \ML{} top-level run from a text terminal.  The
    87 \texttt{isatool usedir} utility provides some more options to manage your
    86 \texttt{Isabelle} executable (note the capital I) runs one such
    88 sessions, such as automatic generation of theory browsing information.
    87 interface, depending on your local configuration.  Furthermore there
    89 
    88 are a number of external utilities available.  These are started
    90 \medskip More details about the \texttt{isabelle} and \texttt{isatool}
    89 uniformly via the \texttt{isatool} wrapper.  See the \emph{System
    91 commands may be found in \emph{The Isabelle System Manual}.
    90   Manual} for more information user interfaces and utilities.
    92 
       
    93 \medskip There are more comfortable user interfaces than the bare-bones \ML{}
       
    94 top-level run from a text terminal.  The \texttt{Isabelle} executable (note
       
    95 the capital I) runs one such interface, depending on your local configuration.
       
    96 Again, see \emph{The Isabelle System Manual} for more information.
    91 
    97 
    92 
    98 
    93 \section{Ending a session}
    99 \section{Ending a session}
    94 \begin{ttbox} 
   100 \begin{ttbox} 
    95 quit    : unit -> unit
   101 quit    : unit -> unit
   137 
   143 
   138 The $dir$ and $file$ specifications of the \texttt{cd} and \texttt{use}
   144 The $dir$ and $file$ specifications of the \texttt{cd} and \texttt{use}
   139 commands may contain path variables (e.g.\ \texttt{\$ISABELLE_HOME}) that are
   145 commands may contain path variables (e.g.\ \texttt{\$ISABELLE_HOME}) that are
   140 expanded appropriately.  Note that \texttt{\~\relax} abbreviates
   146 expanded appropriately.  Note that \texttt{\~\relax} abbreviates
   141 \texttt{\$HOME}, and \texttt{\~\relax\~\relax} abbreviates
   147 \texttt{\$HOME}, and \texttt{\~\relax\~\relax} abbreviates
   142 \texttt{\$ISABELLE_HOME}.  Section~\ref{LoadingTheories} describes commands
   148 \texttt{\$ISABELLE_HOME}.
   143 for loading theory files.
   149 
       
   150 
       
   151 \section{Reading theories}\label{sec:intro-theories}
       
   152 \index{theories!reading}
       
   153 
       
   154 In Isabelle, any kind of declarations, definitions, etc.\ are organized around
       
   155 named \emph{theory} objects.  Logical reasoning always takes place within a
       
   156 certain theory context, which may be switched at any time.  Theory $name$ is
       
   157 defined by a theory file $name$\texttt{.thy}, containing declarations of
       
   158 \texttt{consts}, \texttt{types}, \texttt{defs}, etc.\ (see
       
   159 \S\ref{sec:ref-defining-theories} for more details on concrete syntax).
       
   160 Furthermore, there may be an associated {\ML} file $name$\texttt{.ML} with
       
   161 proof scripts that are to be run in the context of the theory.
       
   162 
       
   163 \begin{ttbox}
       
   164 context      : theory -> unit
       
   165 the_context  : unit -> theory
       
   166 theory       : string -> theory
       
   167 use_thy      : string -> unit
       
   168 time_use_thy : string -> unit
       
   169 \end{ttbox}
       
   170 
       
   171 \begin{ttdescription}
       
   172   
       
   173 \item[\ttindexbold{context} $thy$;] switches the current theory context.  Any
       
   174   subsequent command with ``implicit theory argument'' (e.g.\ \texttt{Goal})
       
   175   will refer to $thy$ as its theory.
       
   176   
       
   177 \item[\ttindexbold{the_context}();] obtains the current theory context, or
       
   178   raises an error if absent.
       
   179   
       
   180 \item[\ttindexbold{theory} $name$;] retrieves the theory called $name$ from
       
   181   the internal database of loaded theories, raising an error if absent.
       
   182   
       
   183 \item[\ttindexbold{use_thy} $name$;] reads theory $name$ from the file system,
       
   184   looking for $name$\texttt{.thy} and (optionally) $name$\texttt{.ML}; also
       
   185   makes sure that all parent theories are loaded as well.  In case some older
       
   186   versions have already been present, \texttt{use_thy} only tries to reload
       
   187   $name$ itself, but is content with any version of its parents.
       
   188   
       
   189 \item[\ttindexbold{time_use_thy} $name$;] same as \texttt{use_thy}, but
       
   190   reports the time taken to process the actual theory parts and {\ML} files
       
   191   separately.
       
   192   
       
   193 \end{ttdescription}
       
   194 
       
   195 See \S\ref{sec:more-theories} for further information on Isabelle's theory
       
   196 loader.
   144 
   197 
   145 
   198 
   146 \section{Setting flags}
   199 \section{Setting flags}
   147 \begin{ttbox}
   200 \begin{ttbox}
   148 set     : bool ref -> bool
   201 set     : bool ref -> bool
   261 
   314 
   262 \section{Diagnostic messages}
   315 \section{Diagnostic messages}
   263 \index{error messages}
   316 \index{error messages}
   264 \index{warnings}
   317 \index{warnings}
   265 
   318 
   266 Isabelle conceptually provides three output channels for different
   319 Isabelle conceptually provides three output channels for different kinds of
   267 kinds of messages: ordinary text, warnings, errors.  Depending on the
   320 messages: ordinary text, warnings, errors.  Depending on the user interface
   268 user interface involved, these messages may appear in different text
   321 involved, these messages may appear in different text styles or colours.
   269 styles or colours, even within separate windows.
       
   270 
   322 
   271 The default setup of an \texttt{isabelle} terminal session is as
   323 The default setup of an \texttt{isabelle} terminal session is as
   272 follows: plain output of ordinary text, warnings prefixed by
   324 follows: plain output of ordinary text, warnings prefixed by
   273 \texttt{\#\#\#}'s, errors prefixed by \texttt{***}'s.  For example, a
   325 \texttt{\#\#\#}'s, errors prefixed by \texttt{***}'s.  For example, a
   274 typical warning would look like this:
   326 typical warning would look like this: