doc-src/Ref/introduction.tex
author wenzelm
Sun, 10 Oct 2010 20:12:10 +0100
changeset 39836 a194f39cfcb4
parent 39835 6cefd96bb71d
child 39838 eb47307ab930
permissions -rw-r--r--
note on Isabelle file specifications; removed junk;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     1
286
e7efbf03562b first draft of Springer book
lcp
parents: 159
diff changeset
     2
\chapter{Basic Use of Isabelle}\index{sessions|(} 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     3
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     4
\section{Ending a session}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     5
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     6
quit    : unit -> unit
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
     7
exit    : int -> unit
6067
0f8ab32093ae fixed commit spec;
wenzelm
parents: 5371
diff changeset
     8
commit  : unit -> bool
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     9
\end{ttbox}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    10
\begin{ttdescription}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    11
\item[\ttindexbold{quit}();] ends the Isabelle session, without saving
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    12
  the state.
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    13
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    14
\item[\ttindexbold{exit} \(i\);] similar to {\tt quit}, passing return
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    15
  code \(i\) to the operating system.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    16
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    17
\item[\ttindexbold{commit}();] saves the current state without ending
6067
0f8ab32093ae fixed commit spec;
wenzelm
parents: 5371
diff changeset
    18
  the session, provided that the logic image is opened read-write;
0f8ab32093ae fixed commit spec;
wenzelm
parents: 5371
diff changeset
    19
  return value {\tt false} indicates an error.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    20
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    21
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    22
Typing control-D also finishes the session in essentially the same way
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2225
diff changeset
    23
as the sequence {\tt commit(); quit();} would.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    24
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    25
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    26
\section{Reading ML files}
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    27
\index{files!reading}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    28
\begin{ttbox} 
138
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
    29
cd              : string -> unit
884
35c836adf48f added documentation of pwd
clasohm
parents: 508
diff changeset
    30
pwd             : unit -> string
138
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
    31
use             : string -> unit
9ba8bff1addc added chapter "Defining Theories" and made changes for new Readthy functions
clasohm
parents: 104
diff changeset
    32
time_use        : string -> unit
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    33
\end{ttbox}
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    34
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    35
\item[\ttindexbold{cd} "{\it dir}";] changes the current directory to
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    36
  {\it dir}.  This is the default directory for reading files.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    37
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    38
\item[\ttindexbold{pwd}();] returns the full path of the current
7264fa2ff2ec several minor updates;
wenzelm
parents: 4274
diff changeset
    39
  directory.
884
35c836adf48f added documentation of pwd
clasohm
parents: 508
diff changeset
    40
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    41
\item[\ttindexbold{use} "$file$";]  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    42
reads the given {\it file} as input to the \ML{} session.  Reading a file
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    43
of Isabelle commands is the usual way of replaying a proof.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    44
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    45
\item[\ttindexbold{time_use} "$file$";]  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    46
performs {\tt use~"$file$"} and prints the total execution time.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
    47
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    48
6343
97c697a32b73 updated;
wenzelm
parents: 6067
diff changeset
    49
The $dir$ and $file$ specifications of the \texttt{cd} and \texttt{use}
97c697a32b73 updated;
wenzelm
parents: 6067
diff changeset
    50
commands may contain path variables (e.g.\ \texttt{\$ISABELLE_HOME}) that are
97c697a32b73 updated;
wenzelm
parents: 6067
diff changeset
    51
expanded appropriately.  Note that \texttt{\~\relax} abbreviates
97c697a32b73 updated;
wenzelm
parents: 6067
diff changeset
    52
\texttt{\$HOME}, and \texttt{\~\relax\~\relax} abbreviates
6571
wenzelm
parents: 6569
diff changeset
    53
\texttt{\$ISABELLE_HOME}\index{*\$ISABELLE_HOME}.  The syntax for path
wenzelm
parents: 6569
diff changeset
    54
specifications follows Unix conventions.
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    55
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    56
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    57
\section{Reading theories}\label{sec:intro-theories}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    58
\index{theories!reading}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    59
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    60
In Isabelle, any kind of declarations, definitions, etc.\ are organized around
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    61
named \emph{theory} objects.  Logical reasoning always takes place within a
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    62
certain theory context, which may be switched at any time.  Theory $name$ is
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    63
defined by a theory file $name$\texttt{.thy}, containing declarations of
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    64
\texttt{consts}, \texttt{types}, \texttt{defs}, etc.\ (see
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    65
\S\ref{sec:ref-defining-theories} for more details on concrete syntax).
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    66
Furthermore, there may be an associated {\ML} file $name$\texttt{.ML} with
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    67
proof scripts that are to be run in the context of the theory.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    68
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    69
\begin{ttbox}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    70
context      : theory -> unit
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    71
the_context  : unit -> theory
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    72
theory       : string -> theory
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    73
use_thy      : string -> unit
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    74
time_use_thy : string -> unit
7136
71f6eef45713 added update_thy_only;
wenzelm
parents: 6618
diff changeset
    75
update_thy   : string -> unit
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    76
\end{ttbox}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    77
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    78
\begin{ttdescription}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    79
  
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    80
\item[\ttindexbold{context} $thy$;] switches the current theory context.  Any
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    81
  subsequent command with ``implicit theory argument'' (e.g.\ \texttt{Goal})
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    82
  will refer to $thy$ as its theory.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    83
  
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    84
\item[\ttindexbold{the_context}();] obtains the current theory context, or
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    85
  raises an error if absent.
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    86
  
6569
wenzelm
parents: 6568
diff changeset
    87
\item[\ttindexbold{theory} "$name$";] retrieves the theory called $name$ from
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7990
diff changeset
    88
  the internal data\-base of loaded theories, raising an error if absent.
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    89
  
6569
wenzelm
parents: 6568
diff changeset
    90
\item[\ttindexbold{use_thy} "$name$";] reads theory $name$ from the file
6571
wenzelm
parents: 6569
diff changeset
    91
  system, looking for $name$\texttt{.thy} and $name$\texttt{.ML} (the latter
wenzelm
parents: 6569
diff changeset
    92
  being optional).  It also ensures that all parent theories are loaded as
wenzelm
parents: 6569
diff changeset
    93
  well.  In case some older versions have already been present,
wenzelm
parents: 6569
diff changeset
    94
  \texttt{use_thy} only tries to reload $name$ itself, but is content with any
wenzelm
parents: 6569
diff changeset
    95
  version of its ancestors.
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    96
  
6569
wenzelm
parents: 6568
diff changeset
    97
\item[\ttindexbold{time_use_thy} "$name$";] same as \texttt{use_thy}, but
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    98
  reports the time taken to process the actual theory parts and {\ML} files
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
    99
  separately.
7592
wenzelm
parents: 7282
diff changeset
   100
  
7136
71f6eef45713 added update_thy_only;
wenzelm
parents: 6618
diff changeset
   101
\item[\ttindexbold{update_thy} "$name$";] is similar to \texttt{use_thy}, but
71f6eef45713 added update_thy_only;
wenzelm
parents: 6618
diff changeset
   102
  ensures that theory $name$ is fully up-to-date with respect to the file
7592
wenzelm
parents: 7282
diff changeset
   103
  system --- apart from theory $name$ itself, any of its ancestors may be
wenzelm
parents: 7282
diff changeset
   104
  reloaded as well.
6568
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
   105
  
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
   106
\end{ttdescription}
b38bc78d9a9d theory loader stuff updated and improved;
wenzelm
parents: 6343
diff changeset
   107
9695
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 9231
diff changeset
   108
Note that theories of pre-built logic images (e.g.\ HOL) are marked as
7282
69d601df351c finished theories;
wenzelm
parents: 7136
diff changeset
   109
\emph{finished} and cannot be updated any more.  See \S\ref{sec:more-theories}
69d601df351c finished theories;
wenzelm
parents: 7136
diff changeset
   110
for further information on Isabelle's theory loader.
4274
2048e7a79d09 cd, use: path variables;
wenzelm
parents: 3485
diff changeset
   111
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   112
30184
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 28504
diff changeset
   113
\section{Timing}
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 28504
diff changeset
   114
\index{timing statistics}\index{proofs!timing}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
\begin{ttbox} 
30184
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 28504
diff changeset
   116
timing: bool ref \hfill{\bf initially false}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   117
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   118
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   119
\begin{ttdescription}
30184
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 28504
diff changeset
   120
\item[set \ttindexbold{timing};] enables global timing in Isabelle.
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 28504
diff changeset
   121
  This information is compiler-dependent.
322
bacfaeeea007 penultimate Springer draft
lcp
parents: 286
diff changeset
   122
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   123
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   124
\index{sessions|)}
5371
e27558a68b8d emacs local vars;
wenzelm
parents: 4543
diff changeset
   125
e27558a68b8d emacs local vars;
wenzelm
parents: 4543
diff changeset
   126
e27558a68b8d emacs local vars;
wenzelm
parents: 4543
diff changeset
   127
%%% Local Variables: 
e27558a68b8d emacs local vars;
wenzelm
parents: 4543
diff changeset
   128
%%% mode: latex
e27558a68b8d emacs local vars;
wenzelm
parents: 4543
diff changeset
   129
%%% TeX-master: "ref"
e27558a68b8d emacs local vars;
wenzelm
parents: 4543
diff changeset
   130
%%% End: