doc-src/Ref/introduction.tex
changeset 322 bacfaeeea007
parent 286 e7efbf03562b
child 332 01b87a921967
equal deleted inserted replaced
321:998f1c5adafb 322:bacfaeeea007
     7 
     7 
     8 When you are looking for a way of performing some task, scan the Table of
     8 When you are looking for a way of performing some task, scan the Table of
     9 Contents for a relevant heading.  Functions are organized by their purpose,
     9 Contents for a relevant heading.  Functions are organized by their purpose,
    10 by their operands (subgoals, tactics, theorems), and by their usefulness.
    10 by their operands (subgoals, tactics, theorems), and by their usefulness.
    11 In each section, basic functions appear first, then advanced functions, and
    11 In each section, basic functions appear first, then advanced functions, and
    12 finally esoteric functions.
    12 finally esoteric functions.  Use the Index when you are looking for the
    13 
    13 definition of a particular Isabelle function.
    14 The Index provides an alphabetical listing.  Page numbers of definitions
       
    15 are printed in {\bf bold}, passing references in Roman type.  Use the Index
       
    16 when you are looking for the definition of a particular Isabelle function.
       
    17 
    14 
    18 A few examples are presented.  Many examples files are distributed with
    15 A few examples are presented.  Many examples files are distributed with
    19 Isabelle, however; please experiment interactively.
    16 Isabelle, however; please experiment interactively.
    20 
    17 
    21 
    18 
    22 \section{Basic interaction with Isabelle}
    19 \section{Basic interaction with Isabelle}
    23 \index{sessions!saving|bold}\index{saving your work|bold}
    20 \index{saving your work|bold}
    24 Isabelle provides no means of storing theorems or proofs on files.
    21 Isabelle provides no means of storing theorems or proofs on files.
    25 Theorems are simply part of the \ML{} state and are named by \ML{}
    22 Theorems are simply part of the \ML{} state and are named by \ML{}
    26 identifiers.  To save your work between sessions, you must save a copy of
    23 identifiers.  To save your work between sessions, you must save a copy of
    27 the \ML{} image.  The procedure for doing so is compiler-dependent:
    24 the \ML{} image.  The procedure for doing so is compiler-dependent:
    28 \begin{itemize}\index{Poly/\ML}
    25 \begin{itemize}\index{Poly/{\ML} compiler}
    29 \item At the end of a session, Poly/\ML{} saves the state, provided you have
    26 \item At the end of a session, Poly/\ML{} saves the state, provided you
    30 created a database for your own use.  You can create a database by copying
    27   have created a database for your own use.  You can create a database by
    31 an existing one, or by calling the Poly/\ML{} function {\tt make_database};
    28   copying an existing one, or by calling the Poly/\ML{} function {\tt
    32 the latter course uses much less disc space.  Note that a Poly/\ML{}
    29     make_database}; the latter course uses much less disc space.  A
    33 database {\bf does not} save the contents of references, such as the
    30   Poly/\ML{} database {\em does not\/} save the contents of references,
    34 current state of a backward proof.
    31   such as the current state of a backward proof.
    35 
    32 
    36 \item With New Jersey \ML{} you must save the state explicitly before
    33 \item With New Jersey \ML{} you must save the state explicitly before
    37 ending the session.  While a Poly/\ML{} database can be small, a New Jersey
    34 ending the session.  While a Poly/\ML{} database can be small, a New Jersey
    38 image occupies several megabytes.
    35 image occupies several megabytes.
    39 \end{itemize}
    36 \end{itemize}
    46 the axioms.  Ideally, your record will be intelligible to others as a
    43 the axioms.  Ideally, your record will be intelligible to others as a
    47 formal description of your work.
    44 formal description of your work.
    48 
    45 
    49 Since Isabelle's user interface is the \ML{} top level, some kind of window
    46 Since Isabelle's user interface is the \ML{} top level, some kind of window
    50 support is essential.  One window displays the Isabelle session, while the
    47 support is essential.  One window displays the Isabelle session, while the
    51 other displays a file --- your proof record --- being edited.  Some people
    48 other displays a file --- your proof record --- being edited.  The Emacs
    52 use a screen editor such as Emacs, which supports windows and can manage
    49 editor supports windows and can manage interactive sessions.
    53 interactive sessions.  Others prefer to use a workstation running the X Window
       
    54 System.
       
    55 
    50 
    56 
    51 
    57 \section{Ending a session}
    52 \section{Ending a session}
    58 \index{sessions!ending|bold}
       
    59 \begin{ttbox} 
    53 \begin{ttbox} 
    60 quit     : unit -> unit
    54 quit     : unit -> unit
    61 commit   : unit -> unit \hfill{\bf Poly/ML only}
    55 commit   : unit -> unit \hfill{\bf Poly/ML only}
    62 exportML : string -> bool \hfill{\bf New Jersey ML only}
    56 exportML : string -> bool \hfill{\bf New Jersey ML only}
    63 \end{ttbox}
    57 \end{ttbox}
    64 \begin{description}
    58 \begin{ttdescription}
    65 \item[\ttindexbold{quit}();]  
    59 \item[\ttindexbold{quit}();]  
    66 aborts the Isabelle session, without saving the state.
    60 aborts the Isabelle session, without saving the state.
    67 
    61 
    68 \item[\ttindexbold{commit}();]  saves the current state in your
    62 \item[\ttindexbold{commit}();] 
    69 Poly/\ML{} database without finishing the session.  Values of reference
    63   saves the current state in your Poly/\ML{} database without ending the
    70 variables are lost, so never do this during an interactive
    64   session.  The contents of references are lost, so never do this during an
    71 proof!\index{Poly/\ML} 
    65   interactive proof!\index{Poly/{\ML} compiler}
    72 
    66 
    73 \item[\ttindexbold{exportML} \tt"{\it file}";]  saves an
    67 \item[\ttindexbold{exportML} "{\it file}";]  saves an
    74 image of your session to the given {\it file}.
    68 image of your session to the given {\it file}.
    75 \end{description}
    69 \end{ttdescription}
    76 
    70 
    77 \begin{warn}
    71 \begin{warn}
    78 Typing control-D also finishes the session, but its effect is
    72 Typing control-D also finishes the session, but its effect is
    79 compiler-dependent.  Poly/\ML{} will then save the state, if you have a
    73 compiler-dependent.  Poly/\ML{} will then save the state, if you have a
    80 private database.  New Jersey \ML{} will discard the state!
    74 private database.  New Jersey \ML{} will discard the state!
    81 \end{warn}
    75 \end{warn}
    82 
    76 
    83 
    77 
    84 \section{Reading files of proofs and theories}
    78 \section{Reading ML files}
    85 \index{files!reading|bold}
    79 \index{files!reading}
    86 \begin{ttbox} 
    80 \begin{ttbox} 
    87 cd              : string -> unit
    81 cd              : string -> unit
    88 use             : string -> unit
    82 use             : string -> unit
    89 use_thy         : string -> unit
       
    90 time_use        : string -> unit
    83 time_use        : string -> unit
    91 time_use_thy    : string -> unit
    84 \end{ttbox}
    92 update          : unit -> unit
    85 Section~\ref{LoadingTheories} describes commands for loading theory files.
    93 loadpath        : string list ref
    86 \begin{ttdescription}
    94 \end{ttbox}
    87 \item[\ttindexbold{cd} "{\it dir}";]
    95 \begin{description}
    88   changes the current directory to {\it dir}.  This is the default directory
    96 \item[\ttindexbold{cd} \tt"{\it dir}";]  changes to {\it dir\/} the default
    89   for reading files and for writing temporary files.
    97 directory for reading files.
    90 
    98 
    91 \item[\ttindexbold{use} "$file$";]  
    99 \item[\ttindexbold{use} \tt"$file$";]  
       
   100 reads the given {\it file} as input to the \ML{} session.  Reading a file
    92 reads the given {\it file} as input to the \ML{} session.  Reading a file
   101 of Isabelle commands is the usual way of replaying a proof.
    93 of Isabelle commands is the usual way of replaying a proof.
   102 
    94 
   103 \item[\ttindexbold{use_thy} \tt"$tname$";] 
    95 \item[\ttindexbold{time_use} "$file$";]  
   104   reads a theory definition from file {\it tname}{\tt.thy} and also reads
       
   105   {\ML} commands from the file {\it tname}{\tt.ML}, if it exists.  If
       
   106   theory {\it tname} depends on theories that have not been read already,
       
   107   then it loads these beforehand.  See Chapter~\ref{theories} for
       
   108   details.
       
   109 
       
   110 \item[\ttindexbold{time_use} \tt"$file$";]  
       
   111 performs {\tt use~"$file$"} and prints the total execution time.
    96 performs {\tt use~"$file$"} and prints the total execution time.
   112 
    97 \end{ttdescription}
   113 \item[\ttindexbold{time_use_thy} \tt"$tname$";]  
       
   114 performs {\tt use_thy "$tname$"} and prints the total execution time.
       
   115 
       
   116 \item[\ttindexbold{update} \tt();]  
       
   117 reads all theories that have changed since the last time they have been read.
       
   118 See Chapter~\ref{theories} for details.
       
   119 
       
   120 \item[\ttindexbold{loadpath}] 
       
   121   contains a list of paths that is used by {\tt use_thy} and {\tt update}
       
   122   to find {\it tname}{\tt.ML} and {\it tname}{\tt.thy}.  See
       
   123   Chapter~\ref{theories} for details.
       
   124 \end{description}
       
   125 
    98 
   126 
    99 
   127 \section{Printing of terms and theorems}
   100 \section{Printing of terms and theorems}
   128 \index{printing!flags|bold}
   101 \index{printing control|(}
   129 Isabelle's pretty printer is controlled by a number of parameters.
   102 Isabelle's pretty printer is controlled by a number of parameters.
   130 
   103 
   131 \subsection{Printing limits}
   104 \subsection{Printing limits}
   132 \begin{ttbox} 
   105 \begin{ttbox} 
   133 Pretty.setdepth  : int -> unit
   106 Pretty.setdepth  : int -> unit
   134 Pretty.setmargin : int -> unit
   107 Pretty.setmargin : int -> unit
   135 print_depth      : int -> unit
   108 print_depth      : int -> unit
   136 \end{ttbox}
   109 \end{ttbox}
   137 These set limits for terminal output.
   110 These set limits for terminal output.
   138 
   111 
   139 \begin{description}
   112 \begin{ttdescription}
   140 \item[\ttindexbold{Pretty.setdepth} \(d\);]  tells
   113 \item[\ttindexbold{Pretty.setdepth} \(d\);]  
   141 Isabelle's pretty printer to limit the printing depth to~$d$.  This affects
   114   tells Isabelle's pretty printer to limit the printing depth to~$d$.  This
   142 Isabelle's display of theorems and terms.  The default value is~0, which
   115   affects Isabelle's display of theorems and terms.  The default value
   143 permits printing to an arbitrary depth.  Useful values for $d$ are~10 and~20.
   116   is~0, which permits printing to an arbitrary depth.  Useful values for
   144 
   117   $d$ are~10 and~20.
   145 \item[\ttindexbold{Pretty.setmargin} \(m\);]  tells
   118 
   146 Isabelle's pretty printer to assume a right margin (page width) of~$m$.
   119 \item[\ttindexbold{Pretty.setmargin} \(m\);]  
   147 The initial margin is~80.
   120   tells Isabelle's pretty printer to assume a right margin (page width)
   148 
   121   of~$m$.  The initial margin is~80.
   149 \item[\ttindexbold{print_depth} \(n\);]  limits
   122 
   150 the printing depth of complex \ML{} values, such as theorems and terms.
   123 \item[\ttindexbold{print_depth} \(n\);]  
   151 This command affects the \ML{} top level and its effect is
   124   limits the printing depth of complex \ML{} values, such as theorems and
   152 compiler-dependent.  Typically $n$ should be less than~10.
   125   terms.  This command affects the \ML{} top level and its effect is
   153 \end{description}
   126   compiler-dependent.  Typically $n$ should be less than~10.
   154 
   127 \end{ttdescription}
   155 
   128 
   156 \subsection{Printing of meta-level hypotheses}
   129 
   157 \index{hypotheses!meta-level!printing of|bold}
   130 \subsection{Printing of hypotheses, types and sorts}
   158 \begin{ttbox} 
   131 \index{meta-assumptions!printing of}
   159 show_hyps: bool ref \hfill{\bf initially true}
   132 \index{types!printing of}\index{sorts!printing of}
   160 \end{ttbox}
   133 \begin{ttbox} 
   161 A theorem's hypotheses are normally displayed, since such dependence is
   134 show_hyps  : bool ref \hfill{\bf initially true}
   162 important.  If this information becomes too verbose, however, it can be
   135 show_types : bool ref \hfill{\bf initially false}
   163 switched off;  each hypothesis is then displayed as a dot.
   136 show_sorts : bool ref \hfill{\bf initially false}
   164 \begin{description}
   137 \end{ttbox}
   165 \item[\ttindexbold{show_hyps} \tt:= true;]   
   138 These flags allow you to control how much information is displayed for
   166 makes Isabelle show meta-level hypotheses when printing a theorem; setting
   139 terms and theorems.  The hypotheses are normally shown; types and sorts are
   167 it to {\tt false} suppresses them.
   140 not.  Displaying types and sorts may explain why a polymorphic inference
   168 \end{description}
   141 rule fails to resolve with some goal.
   169 
   142 
   170 
   143 \begin{ttdescription}
   171 \subsection{Printing of types and sorts}
   144 \item[\ttindexbold{show_hyps} := false;]   
   172 \begin{ttbox} 
   145 makes Isabelle show each meta-level hypotheses as a dot.
   173 show_types: bool ref \hfill{\bf initially false}
   146 
   174 show_sorts: bool ref \hfill{\bf initially false}
   147 \item[\ttindexbold{show_types} := true;]
   175 \end{ttbox}
       
   176 These control Isabelle's display of types and sorts.  Normally terms are
       
   177 printed without type and sorts because they are verbose.  Occasionally you
       
   178 may require this information, say to discover why a polymorphic inference rule
       
   179 fails to resolve with some goal.
       
   180 
       
   181 \begin{description}
       
   182 \item[\ttindexbold{show_types} \tt:= true;]\index{types}
       
   183 makes Isabelle show types when printing a term or theorem.
   148 makes Isabelle show types when printing a term or theorem.
   184 
   149 
   185 \item[\ttindexbold{show_sorts} \tt:= true;]\index{sorts}
   150 \item[\ttindexbold{show_sorts} := true;]
   186 makes Isabelle show the sorts of type variables.  It has no effect unless
   151 makes Isabelle show the sorts of type variables.  It has no effect unless
   187 {\tt show_types} is~{\tt true}. 
   152 {\tt show_types} is~{\tt true}. 
   188 \end{description}
   153 \end{ttdescription}
   189 
   154 
   190 
   155 
   191 \subsection{$\eta$-contraction before printing}
   156 \subsection{$\eta$-contraction before printing}
   192 \begin{ttbox} 
   157 \begin{ttbox} 
   193 eta_contract: bool ref \hfill{\bf initially false}
   158 eta_contract: bool ref \hfill{\bf initially false}
   198 unification occasionally puts terms into a fully $\eta$-expanded form.  For
   163 unification occasionally puts terms into a fully $\eta$-expanded form.  For
   199 example, if $F$ has type $(\tau\To\tau)\To\tau$ then its expanded form is
   164 example, if $F$ has type $(\tau\To\tau)\To\tau$ then its expanded form is
   200 $\lambda h.F(\lambda x.h(x))$.  By default, the user sees this expanded
   165 $\lambda h.F(\lambda x.h(x))$.  By default, the user sees this expanded
   201 form.
   166 form.
   202 
   167 
   203 \begin{description}
   168 \begin{ttdescription}
   204 \item[\ttindexbold{eta_contract} \tt:= true;]
   169 \item[\ttindexbold{eta_contract} := true;]
   205 makes Isabelle perform $\eta$-contractions before printing, so that
   170 makes Isabelle perform $\eta$-contractions before printing, so that
   206 $\lambda h.F(\lambda x.h(x))$ appears simply as~$F$.  The
   171 $\lambda h.F(\lambda x.h(x))$ appears simply as~$F$.  The
   207 distinction between a term and its $\eta$-expanded form occasionally
   172 distinction between a term and its $\eta$-expanded form occasionally
   208 matters.
   173 matters.
   209 \end{description}
   174 \end{ttdescription}
       
   175 \index{printing control|)}
   210 
   176 
   211 
   177 
   212 \section{Displaying exceptions as error messages}
   178 \section{Displaying exceptions as error messages}
   213 \index{printing!exceptions|bold}\index{exceptions|bold}
   179 \index{exceptions!printing of}
   214 \begin{ttbox} 
   180 \begin{ttbox} 
   215 print_exn: exn -> 'a
   181 print_exn: exn -> 'a
   216 \end{ttbox}
   182 \end{ttbox}
   217 Certain Isabelle primitives, such as the forward proof functions {\tt RS}
   183 Certain Isabelle primitives, such as the forward proof functions {\tt RS}
   218 and {\tt RSN}, are called both interactively and from programs.  They
   184 and {\tt RSN}, are called both interactively and from programs.  They
   219 indicate errors not by printing messages, but by raising exceptions.  For
   185 indicate errors not by printing messages, but by raising exceptions.  For
   220 interactive use, \ML's reporting of an uncaught exception is most
   186 interactive use, \ML's reporting of an uncaught exception is 
   221 uninformative.
   187 uninformative.  The Poly/ML function {\tt exception_trace} can generate a
   222 
   188 backtrace.\index{Poly/{\ML} compiler}
   223 \begin{description}
   189 
       
   190 \begin{ttdescription}
   224 \item[\ttindexbold{print_exn} $e$] 
   191 \item[\ttindexbold{print_exn} $e$] 
   225 displays the exception~$e$ in a readable manner, and then re-raises~$e$.
   192 displays the exception~$e$ in a readable manner, and then re-raises~$e$.
   226 Typical usage is~\hbox{\tt \ldots{} handle e => print_exn e;}, where
   193 Typical usage is~\hbox{\tt $EXP$ handle e => print_exn e;}, where
   227 \ldots{} is an expression that may raise an exception.
   194 $EXP$ is an expression that may raise an exception.
   228 
   195 
   229 {\tt print_exn} can display the following common exceptions, which concern
   196 {\tt print_exn} can display the following common exceptions, which concern
   230 types, terms, theorems and theories, respectively.  Each carries a message
   197 types, terms, theorems and theories, respectively.  Each carries a message
   231 and related information.
   198 and related information.
   232 \begin{ttbox} 
   199 \begin{ttbox} 
   233 exception TYPE   of string * typ list * term list
   200 exception TYPE   of string * typ list * term list
   234 exception TERM   of string * term list
   201 exception TERM   of string * term list
   235 exception THM    of string * int * thm list
   202 exception THM    of string * int * thm list
   236 exception THEORY of string * theory list
   203 exception THEORY of string * theory list
   237 \end{ttbox}
   204 \end{ttbox}
   238 {\tt print_exn} calls \ttindex{prin} to print terms.  This obtains pretty
   205 \end{ttdescription}
   239 printing information from the proof state last stored in the subgoal
   206 \begin{warn}
   240 module, and will fail if no interactive proof has begun in the current
   207   {\tt print_exn} prints terms by calling \ttindex{prin}, which obtains
   241 session.
   208   pretty printing information from the proof state last stored in the
   242 \end{description}
   209   subgoal module.  The appearance of the output thus depends upon the
   243 
   210   theory used in the last interactive proof.
       
   211 \end{warn}
   244 
   212 
   245 \section{Shell scripts}
   213 \section{Shell scripts}
   246 \index{shell scripts|bold}
   214 \index{shell scripts|bold} The following files are distributed with
   247 The following files are distributed with Isabelle, and work under
   215 Isabelle, and work under Unix$^{\rm TM}$.  They can be executed as commands
   248 Unix$^{\rm TM}$.  They can be executed as commands to the Unix shell.  Some
   216 to the Unix shell.  Some of them depend upon shell environment variables.
   249 of them depend upon shell environment variables.
   217 \begin{ttdescription}
   250 \begin{description}
   218 \item[make-all $switches$] \index{*make-all shell script}
   251 \item[\ttindexbold{make-all} $switches$] 
       
   252   compiles the Isabelle system, when executed on the source directory.
   219   compiles the Isabelle system, when executed on the source directory.
   253   Environment variables specify which \ML{} compiler to use.  These
   220   Environment variables specify which \ML{} compiler to use.  These
   254   variables, and the {\it switches}, are documented on the file itself.
   221   variables, and the {\it switches}, are documented on the file itself.
   255 
   222 
   256 \item[\ttindexbold{teeinput} $program$] 
   223 \item[teeinput $program$] \index{*teeinput shell script}
   257 executes the {\it program}, while piping the standard input to a log file
   224   executes the {\it program}, while piping the standard input to a log file
   258 designated by the \verb|$LISTEN| environment variable.  Normally the
   225   designated by the \verb|$LISTEN| environment variable.  Normally the
   259 program is Isabelle, and the log file receives a copy of all the Isabelle
   226   program is Isabelle, and the log file receives a copy of all the Isabelle
   260 commands.
   227   commands.
   261 
   228 
   262 \item[\ttindexbold{xlisten} $program$] 
   229 \item[xlisten $program$] \index{*xlisten shell script}
   263   is a trivial `user interface' for the X Window System.  It creates two
   230   is a trivial `user interface' for the X Window System.  It creates two
   264   windows using {\tt xterm}.  One executes an interactive session via
   231   windows using {\tt xterm}.  One executes an interactive session via
   265   \hbox{\tt teeinput $program$}, while the other displays the log file.  To
   232   \hbox{\tt teeinput $program$}, while the other displays the log file.  To
   266   make a proof record, simply paste lines from the log file into an editor
   233   make a proof record, simply paste lines from the log file into an editor
   267   window.
   234   window.
   268 
   235 
   269 \item[\ttindexbold{expandshort} $files$] 
   236 \item[expandshort $files$]  \index{*expandshort shell script}
   270   reads the {\it files\/} and replaces all occurrences of the shorthand
   237   reads the {\it files\/} and replaces all occurrences of the shorthand
   271   commands {\tt br}, {\tt be}, {\tt brs}, {\tt bes}, etc., with the
   238   commands {\tt br}, {\tt be}, {\tt brs}, {\tt bes}, etc., with the
   272   corresponding full commands.  Shorthand commands should appear one
   239   corresponding full commands.  Shorthand commands should appear one
   273   per line.  The old versions of the files
   240   per line.  The old versions of the files
   274   are renamed to have the suffix~\verb'~~'.
   241   are renamed to have the suffix~\verb'~~'.
   275 \end{description}
   242 \end{ttdescription}
   276 
   243 
   277 \index{sessions|)}
   244 \index{sessions|)}