doc-src/IsarImplementation/Thy/document/prelim.tex
author wenzelm
Tue, 29 Aug 2006 18:49:33 +0200
changeset 20429 116255c9209b
parent 20215 96a4b3b7a6aa
child 20430 fd646e926983
permissions -rw-r--r--
more on contexts;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     1
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     2
\begin{isabellebody}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     3
\def\isabellecontext{prelim}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     4
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     5
\isadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     6
\isanewline
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     7
\isanewline
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     8
\isanewline
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
     9
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    10
\endisadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    11
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    12
\isatagtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    13
\isacommand{theory}\isamarkupfalse%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    14
\ prelim\ \isakeyword{imports}\ base\ \isakeyword{begin}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    15
\endisatagtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    16
{\isafoldtheory}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    17
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    18
\isadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    19
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    20
\endisadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    21
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    22
\isamarkupchapter{Preliminaries%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    23
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    24
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    25
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    26
\isamarkupsection{Named entities%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    27
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    28
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    29
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    30
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    31
Named entities of different kinds (logical constant, type,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    32
type class, theorem, method etc.) live in separate name spaces.  It is
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    33
usually clear from the occurrence of a name which kind of entity it
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    34
refers to.  For example, proof method \isa{foo} vs.\ theorem
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    35
\isa{foo} vs.\ logical constant \isa{foo} are easily
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    36
distinguished by means of the syntactic context.  A notable exception
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    37
are logical identifiers within a term (\secref{sec:terms}): constants,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    38
fixed variables, and bound variables all share the same identifier
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    39
syntax, but are distinguished by their scope.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    40
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    41
Each name space is organized as a collection of \emph{qualified
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    42
names}, which consist of a sequence of basic name components separated
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    43
by dots: \isa{Bar{\isachardot}bar{\isachardot}foo}, \isa{Bar{\isachardot}foo}, and \isa{foo}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    44
are examples for valid qualified names.  Name components are
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    45
subdivided into \emph{symbols}, which constitute the smallest textual
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    46
unit in Isabelle --- raw characters are normally not encountered
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    47
directly.%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    48
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    49
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    50
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    51
\isamarkupsubsection{Strings of symbols%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    52
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    53
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    54
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    55
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    56
Isabelle strings consist of a sequence of
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    57
symbols\glossary{Symbol}{The smalles unit of text in Isabelle,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    58
subsumes plain ASCII characters as well as an infinite collection of
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    59
named symbols (for greek, math etc.).}, which are either packed as an
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    60
actual \isa{string}, or represented as a list.  Each symbol is in
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    61
itself a small string of the following form:
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    62
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    63
\begin{enumerate}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    64
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    65
\item either a singleton ASCII character ``\isa{c}'' (with
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    66
character code 0--127), for example ``\verb,a,'',
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    67
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    68
\item or a regular symbol ``\verb,\,\verb,<,\isa{ident}\verb,>,'',
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    69
for example ``\verb,\,\verb,<alpha>,'',
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    70
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    71
\item or a control symbol ``\verb,\,\verb,<^,\isa{ident}\verb,>,'', for example ``\verb,\,\verb,<^bold>,'',
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    72
20206
eb529c6883ec updated;
wenzelm
parents: 18554
diff changeset
    73
\item or a raw control symbol ``\verb,\,\verb,<^raw:,\isa{{\isasymdots}}\verb,>,'' where ``\isa{{\isasymdots}}'' refers to any
eb529c6883ec updated;
wenzelm
parents: 18554
diff changeset
    74
printable ASCII character (excluding ``\verb,.,'' and ``\verb,>,'') or
20215
96a4b3b7a6aa updated;
wenzelm
parents: 20206
diff changeset
    75
non-ASCII character, for example ``\verb,\,\verb,<^raw:$\sum_{i = 1}^n$>,'',
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    76
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    77
\item or a numbered raw control symbol ``\verb,\,\verb,<^raw,\isa{nnn}\verb,>, where \isa{nnn} are digits, for example
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    78
``\verb,\,\verb,<^raw42>,''.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    79
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    80
\end{enumerate}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    81
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    82
The \isa{ident} syntax for symbol names is \isa{letter\ {\isacharparenleft}letter\ {\isacharbar}\ digit{\isacharparenright}\isactrlsup {\isacharasterisk}}, where \isa{letter\ {\isacharequal}\ A{\isachardot}{\isachardot}Za{\isachardot}{\isachardot}Z} and \isa{digit\ {\isacharequal}\ {\isadigit{0}}{\isachardot}{\isachardot}{\isadigit{9}}}.  There are infinitely many regular symbols and
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    83
control symbols available, but a certain collection of standard
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    84
symbols is treated specifically.  For example,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    85
``\verb,\,\verb,<alpha>,'' is classified as a (non-ASCII) letter,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    86
which means it may occur within regular Isabelle identifier syntax.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    87
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    88
Output of symbols depends on the print mode (\secref{sec:print-mode}).
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    89
For example, the standard {\LaTeX} setup of the Isabelle document
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    90
preparation system would present ``\verb,\,\verb,<alpha>,'' as \isa{{\isasymalpha}}, and ``\verb,\,\verb,<^bold>,\verb,\,\verb,<alpha>,'' as \isa{\isactrlbold {\isasymalpha}}.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    91
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    92
\medskip It is important to note that the character set underlying
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    93
Isabelle symbols is plain 7-bit ASCII.  Since 8-bit characters are
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    94
passed through transparently, Isabelle may easily process actual
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    95
Unicode/UCS data (using the well-known UTF-8 encoding, for example).
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    96
Unicode provides its own collection of mathematical symbols, but there
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    97
is presently no link to Isabelle's named ones; both kinds of symbols
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    98
coexist independently.%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
    99
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   100
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   101
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   102
\isadelimmlref
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   103
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   104
\endisadelimmlref
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   105
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   106
\isatagmlref
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   107
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   108
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   109
\begin{mldecls}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   110
  \indexmltype{Symbol.symbol}\verb|type Symbol.symbol| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   111
  \indexml{Symbol.explode}\verb|Symbol.explode: string -> Symbol.symbol list| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   112
  \indexml{Symbol.is-letter}\verb|Symbol.is_letter: Symbol.symbol -> bool| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   113
  \indexml{Symbol.is-digit}\verb|Symbol.is_digit: Symbol.symbol -> bool| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   114
  \indexml{Symbol.is-quasi}\verb|Symbol.is_quasi: Symbol.symbol -> bool| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   115
  \indexml{Symbol.is-blank}\verb|Symbol.is_blank: Symbol.symbol -> bool| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   116
  \indexmltype{Symbol.sym}\verb|type Symbol.sym| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   117
  \indexml{Symbol.decode}\verb|Symbol.decode: Symbol.symbol -> Symbol.sym| \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   118
  \end{mldecls}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   119
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   120
  \begin{description}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   121
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   122
  \item \verb|Symbol.symbol| represents Isabelle symbols; this type
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   123
  is merely an alias for \verb|string|, but emphasizes the
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   124
  specific format encountered here.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   125
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   126
  \item \verb|Symbol.explode|~\isa{s} produces an actual symbol
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   127
  list from the packed form usually encountered as user input.  This
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   128
  function replaces \verb|String.explode| for virtually all purposes
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   129
  of manipulating text in Isabelle!  Plain \isa{implode} may be
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   130
  used for the reverse operation.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   131
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   132
  \item \verb|Symbol.is_letter|, \verb|Symbol.is_digit|, \verb|Symbol.is_quasi|, \verb|Symbol.is_blank| classify certain symbols
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   133
  (both ASCII and several named ones) according to fixed syntactic
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   134
  convections of Isabelle, e.g.\ see \cite{isabelle-isar-ref}.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   135
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   136
  \item \verb|Symbol.sym| is a concrete datatype that represents
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   137
  the different kinds of symbols explicitly as \verb|Symbol.Char|,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   138
  \verb|Symbol.Sym|, \verb|Symbol.Ctrl|, or \verb|Symbol.Raw|.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   139
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   140
  \item \verb|Symbol.decode| converts the string representation of a
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   141
  symbol into the explicit datatype version.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   142
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   143
  \end{description}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   144
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   145
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   146
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   147
\endisatagmlref
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   148
{\isafoldmlref}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   149
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   150
\isadelimmlref
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   151
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   152
\endisadelimmlref
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   153
%
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   154
\isamarkupsubsection{Simple names%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   155
}
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   156
\isamarkuptrue%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   157
%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   158
\begin{isamarkuptext}%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   159
FIXME%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   160
\end{isamarkuptext}%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   161
\isamarkuptrue%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   162
%
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   163
\isamarkupsubsection{Qualified names and name spaces%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   164
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   165
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   166
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   167
\isadelimFIXME
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   168
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   169
\endisadelimFIXME
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   170
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   171
\isatagFIXME
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   172
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   173
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   174
Qualified names are constructed according to implicit naming
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   175
principles of the present context.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   176
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   177
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   178
The last component is called \emph{base name}; the remaining prefix of
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   179
qualification may be empty.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   180
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   181
Some practical conventions help to organize named entities more
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   182
systematically:
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   183
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   184
\begin{itemize}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   185
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   186
\item Names are qualified first by the theory name, second by an
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   187
optional ``structure''.  For example, a constant \isa{c} declared
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   188
as part of a certain structure \isa{b} (say a type definition) in
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   189
theory \isa{A} will be named \isa{A{\isachardot}b{\isachardot}c} internally.
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   190
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   191
\item
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   192
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   193
\item
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   194
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   195
\item
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   196
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   197
\item
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   198
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   199
\end{itemize}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   200
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   201
Names of different kinds of entities are basically independent, but
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   202
some practical naming conventions relate them to each other.  For
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   203
example, a constant \isa{foo} may be accompanied with theorems
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   204
\isa{foo{\isachardot}intro}, \isa{foo{\isachardot}elim}, \isa{foo{\isachardot}simps} etc.  The
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   205
same may happen for a type \isa{foo}, which is then apt to cause
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   206
clashes in the theorem name space!  To avoid this, we occasionally
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   207
follow an additional convention of suffixes that determine the
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   208
original kind of entity that a name has been derived.  For example,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   209
constant \isa{foo} is associated with theorem \isa{foo{\isachardot}intro},
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   210
type \isa{foo} with theorem \isa{foo{\isacharunderscore}type{\isachardot}intro}, and type
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   211
class \isa{foo} with \isa{foo{\isacharunderscore}class{\isachardot}intro}.%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   212
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   213
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   214
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   215
\endisatagFIXME
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   216
{\isafoldFIXME}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   217
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   218
\isadelimFIXME
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   219
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   220
\endisadelimFIXME
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   221
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   222
\isamarkupsection{Structured output%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   223
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   224
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   225
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   226
\isamarkupsubsection{Pretty printing%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   227
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   228
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   229
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   230
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   231
FIXME%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   232
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   233
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   234
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   235
\isamarkupsubsection{Output channels%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   236
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   237
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   238
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   239
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   240
FIXME%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   241
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   242
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   243
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   244
\isamarkupsubsection{Print modes%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   245
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   246
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   247
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   248
\begin{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   249
FIXME%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   250
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   251
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   252
%
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   253
\isamarkupsection{Contexts \label{sec:context}%
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   254
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   255
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   256
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   257
\begin{isamarkuptext}%
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   258
A logical context represents the background that is taken for
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   259
  granted when formulating statements and composing proofs.  It acts
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   260
  as a medium to produce formal content, depending on earlier material
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   261
  (declarations, results etc.).
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   262
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   263
  In particular, derivations within the primitive Pure logic can be
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   264
  described as a judgment \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}}, meaning that a
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   265
  proposition \isa{{\isasymphi}} is derivable from hypotheses \isa{{\isasymGamma}}
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   266
  within the theory \isa{{\isasymTheta}}.  There are logical reasons for
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   267
  keeping \isa{{\isasymTheta}} and \isa{{\isasymGamma}} separate: theories support type
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   268
  constructors and schematic polymorphism of constants and axioms,
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   269
  while the inner calculus of \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}} is limited to Simple
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   270
  Type Theory (with fixed type variables in the assumptions).
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   271
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   272
  \medskip Contexts and derivations are linked by the following key
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   273
  principles:
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   274
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   275
  \begin{itemize}
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   276
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   277
  \item Transfer: monotonicity of derivations admits results to be
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   278
  transferred into a larger context, i.e.\ \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}}
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   279
  implies \isa{{\isasymGamma}{\isacharprime}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\isactrlsub {\isacharprime}\ {\isasymphi}} for contexts \isa{{\isasymTheta}{\isacharprime}\ {\isasymsupseteq}\ {\isasymTheta}} and \isa{{\isasymGamma}{\isacharprime}\ {\isasymsupseteq}\ {\isasymGamma}}.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   280
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   281
  \item Export: discharge of hypotheses admits results to be exported
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   282
  into a smaller context, i.e.\ \isa{{\isasymGamma}{\isacharprime}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymphi}} implies
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   283
  \isa{{\isasymGamma}\ {\isasymturnstile}\isactrlsub {\isasymTheta}\ {\isasymDelta}\ {\isasymLongrightarrow}\ {\isasymphi}} where \isa{{\isasymGamma}{\isacharprime}\ {\isasymsupseteq}\ {\isasymGamma}} and \isa{{\isasymDelta}\ {\isacharequal}\ {\isasymGamma}{\isacharprime}\ {\isacharminus}\ {\isasymGamma}}.  Note that \isa{{\isasymTheta}} remains unchanged here, only the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   284
  \isa{{\isasymGamma}} part is affected.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   285
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   286
  \end{itemize}
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   287
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   288
  \medskip Isabelle/Isar provides two different notions of abstract
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   289
  containers called \emph{theory context} and \emph{proof context},
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   290
  respectively.  These model the main characteristics of the primitive
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   291
  \isa{{\isasymTheta}} and \isa{{\isasymGamma}} above, without subscribing to any
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   292
  particular kind of content yet.  Instead, contexts merely impose a
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   293
  certain policy of managing arbitrary \emph{context data}.  The
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   294
  system provides strongly typed mechanisms to declare new kinds of
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   295
  data at compile time.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   296
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   297
  Thus the internal bootstrap process of Isabelle/Pure eventually
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   298
  reaches a stage where certain data slots provide the logical content
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   299
  of \isa{{\isasymTheta}} and \isa{{\isasymGamma}} sketched above, but this does not
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   300
  stop there!  Various additional data slots support all kinds of
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   301
  mechanisms that are not necessarily part of the core logic.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   302
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   303
  For example, there would be data for canonical introduction and
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   304
  elimination rules for arbitrary operators (depending on the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   305
  object-logic and application), which enables users to perform
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   306
  standard proof steps implicitly (cf.\ the \isa{rule} method).
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   307
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   308
  Isabelle is able to bring forth more and more concepts successively.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   309
  In particular, an object-logic like Isabelle/HOL continues the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   310
  Isabelle/Pure setup by adding specific components for automated
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   311
  reasoning (classical reasoner, tableau prover, structured induction
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   312
  etc.) and derived specification mechanisms (inductive predicates,
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   313
  recursive functions etc.).  All of this is based on the generic data
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   314
  management by theory and proof contexts.%
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   315
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   316
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   317
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   318
\isamarkupsubsection{Theory context \label{sec:context-theory}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   319
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   320
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   321
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   322
\begin{isamarkuptext}%
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   323
Each theory is explicitly named and holds a unique identifier.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   324
  There is a separate \emph{theory reference} for pointing backwards
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   325
  to the enclosing theory context of derived entities.  Theories are
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   326
  related by a (nominal) sub-theory relation, which corresponds to the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   327
  canonical dependency graph: each theory is derived from a certain
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   328
  sub-graph of ancestor theories.  The \isa{merge} of two theories
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   329
  refers to the least upper bound, which actually degenerates into
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   330
  absorption of one theory into the other, due to the nominal
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   331
  sub-theory relation this.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   332
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   333
  The \isa{begin} operation starts a new theory by importing
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   334
  several parent theories and entering a special \isa{draft} mode,
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   335
  which is sustained until the final \isa{end} operation.  A draft
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   336
  mode theory acts like a linear type, where updates invalidate
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   337
  earlier drafts, but theory reference values will be propagated
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   338
  automatically.  Thus derived entities that ``belong'' to a draft
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   339
  might be transferred spontaneously to a larger context.  An
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   340
  invalidated draft is called ``stale''.  The \isa{copy} operation
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   341
  produces an auxiliary version with the same data content, but is
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   342
  unrelated to the original: updates of the copy do not affect the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   343
  original, neither does the sub-theory relation hold.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   344
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   345
  The example below shows a theory graph derived from \isa{Pure}.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   346
  Theory \isa{Length} imports \isa{Nat} and \isa{List}.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   347
  The linear draft mode is enabled during the ``\isa{{\isasymdots}}'' stage of
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   348
  the theory body.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   349
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   350
  \bigskip
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   351
  \begin{tabular}{rcccl}
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   352
        &            & $Pure$ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   353
        &            & $\downarrow$ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   354
        &            & $FOL$ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   355
        & $\swarrow$ &              & $\searrow$ & \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   356
  $Nat$ &            &              &            & $List$ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   357
        & $\searrow$ &              & $\swarrow$ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   358
        &            & $Length$ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   359
        &            & \multicolumn{3}{l}{~~$\isarkeyword{imports}$} \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   360
        &            & \multicolumn{3}{l}{~~$\isarkeyword{begin}$} \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   361
        &            & $\vdots$~~ \\
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   362
        &            & \multicolumn{3}{l}{~~$\isarkeyword{end}$} \\
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   363
  \end{tabular}
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   364
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   365
  \medskip In practice, derived theory operations mostly operate
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   366
  drafts, namely the body of the current portion of theory that the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   367
  user happens to be composing.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   368
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   369
 \medskip There is also a builtin theory history mechanism that amends for
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   370
  the destructive behaviour of theory drafts.  The \isa{checkpoint} operation produces an intermediate stepping stone that
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   371
  survives the next update unscathed: both the original and the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   372
  changed theory remain valid and are related by the sub-theory
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   373
  relation.  This recovering of pure theory values comes at the cost
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   374
  of extra internal bookeeping.  The cumulative effect of
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   375
  checkpointing is purged by the \isa{finish} operation.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   376
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   377
  History operations are usually managed by the system, e.g.\ notably
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   378
  in the Isar transaction loop.
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   379
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   380
  \medskip
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   381
  FIXME theory data%
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   382
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   383
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   384
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   385
\isamarkupsubsection{Proof context \label{sec:context-proof}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   386
}
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   387
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   388
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   389
\begin{isamarkuptext}%
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   390
A proof context is an arbitrary container that is initialized from a
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   391
  given theory.  The result contains a back-reference to the theory it
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   392
  belongs to, together with pure data.  No further bookkeeping is
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   393
  required here, thanks to the lack of destructive features.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   394
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   395
  There is no restriction on producing proof contexts, although the
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   396
  usual discipline is to follow block structure as a mental model: a
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   397
  given context is extended consecutively, results are exported back
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   398
  into the original context.  In particular, the concept of Isar proof
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   399
  state models block-structured reasoning explicitly, using a stack of
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   400
  proof contexts.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   401
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   402
  Due to the lack of identification and back-referencing, entities
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   403
  derived in a proof context need to record inherent logical
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   404
  requirements explicitly.  For example, hypotheses used in a
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   405
  derivation will be recorded separately within the sequent \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}}, just to make double sure.  Results could leak into an alien
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   406
  proof context do to programming errors, but Isabelle/Isar
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   407
  occasionally includes extra validity checks at the end of a
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   408
  sub-proof.
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   409
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   410
  \medskip
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   411
  FIXME proof data
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   412
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   413
\glossary{Proof context}{The static context of a structured proof,
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   414
acts like a local ``theory'' of the current portion of Isar proof
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   415
text, generalizes the idea of local hypotheses \isa{{\isasymGamma}} in
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   416
judgments \isa{{\isasymGamma}\ {\isasymturnstile}\ {\isasymphi}} of natural deduction calculi.  There is a
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   417
generic notion of introducing and discharging hypotheses.  Arbritrary
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   418
auxiliary context data may be adjoined.}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   419
\end{isamarkuptext}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   420
\isamarkuptrue%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   421
%
20429
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   422
\isamarkupsubsection{Generic contexts%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   423
}
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   424
\isamarkuptrue%
116255c9209b more on contexts;
wenzelm
parents: 20215
diff changeset
   425
%
18537
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   426
\isadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   427
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   428
\endisadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   429
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   430
\isatagtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   431
\isacommand{end}\isamarkupfalse%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   432
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   433
\endisatagtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   434
{\isafoldtheory}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   435
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   436
\isadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   437
%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   438
\endisadelimtheory
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   439
\isanewline
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   440
\end{isabellebody}%
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   441
%%% Local Variables:
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   442
%%% mode: latex
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   443
%%% TeX-master: "root"
2681f9e34390 "The Isabelle/Isar Implementation" manual;
wenzelm
parents:
diff changeset
   444
%%% End: