doc-src/IsarRef/Thy/document/Spec.tex
author wenzelm
Mon, 26 Mar 2012 15:38:09 +0200
changeset 47985 7c9e31ffcd9e
parent 47870 1c3c185bab4e
child 48353 a83b25e5bad3
permissions -rw-r--r--
updated theory header syntax and related details;
wenzelm@26869
     1
%
wenzelm@26869
     2
\begin{isabellebody}%
wenzelm@26869
     3
\def\isabellecontext{Spec}%
wenzelm@26869
     4
%
wenzelm@26869
     5
\isadelimtheory
wenzelm@26869
     6
%
wenzelm@26869
     7
\endisadelimtheory
wenzelm@26869
     8
%
wenzelm@26869
     9
\isatagtheory
wenzelm@26869
    10
\isacommand{theory}\isamarkupfalse%
wenzelm@26869
    11
\ Spec\isanewline
wenzelm@43522
    12
\isakeyword{imports}\ Base\ Main\isanewline
wenzelm@26869
    13
\isakeyword{begin}%
wenzelm@26869
    14
\endisatagtheory
wenzelm@26869
    15
{\isafoldtheory}%
wenzelm@26869
    16
%
wenzelm@26869
    17
\isadelimtheory
wenzelm@26869
    18
%
wenzelm@26869
    19
\endisadelimtheory
wenzelm@26869
    20
%
wenzelm@44140
    21
\isamarkupchapter{Specifications%
wenzelm@26869
    22
}
wenzelm@26869
    23
\isamarkuptrue%
wenzelm@26869
    24
%
wenzelm@30072
    25
\begin{isamarkuptext}%
wenzelm@30072
    26
The Isabelle/Isar theory format integrates specifications and
wenzelm@30072
    27
  proofs, supporting interactive development with unlimited undo
wenzelm@30072
    28
  operation.  There is an integrated document preparation system (see
wenzelm@30072
    29
  \chref{ch:document-prep}), for typesetting formal developments
wenzelm@30072
    30
  together with informal text.  The resulting hyper-linked PDF
wenzelm@30072
    31
  documents can be used both for WWW presentation and printed copies.
wenzelm@30072
    32
wenzelm@30072
    33
  The Isar proof language (see \chref{ch:proofs}) is embedded into the
wenzelm@30072
    34
  theory language as a proper sub-language.  Proof mode is entered by
wenzelm@30072
    35
  stating some \hyperlink{command.theorem}{\mbox{\isa{\isacommand{theorem}}}} or \hyperlink{command.lemma}{\mbox{\isa{\isacommand{lemma}}}} at the theory
wenzelm@30072
    36
  level, and left again with the final conclusion (e.g.\ via \hyperlink{command.qed}{\mbox{\isa{\isacommand{qed}}}}).  Some theory specification mechanisms also require a proof,
wenzelm@30072
    37
  such as \hyperlink{command.typedef}{\mbox{\isa{\isacommand{typedef}}}} in HOL, which demands non-emptiness of
wenzelm@30072
    38
  the representing sets.%
wenzelm@30072
    39
\end{isamarkuptext}%
wenzelm@30072
    40
\isamarkuptrue%
wenzelm@30072
    41
%
wenzelm@26870
    42
\isamarkupsection{Defining theories \label{sec:begin-thy}%
wenzelm@26870
    43
}
wenzelm@26870
    44
\isamarkuptrue%
wenzelm@26870
    45
%
wenzelm@26870
    46
\begin{isamarkuptext}%
wenzelm@26870
    47
\begin{matharray}{rcl}
wenzelm@40685
    48
    \indexdef{}{command}{theory}\hypertarget{command.theory}{\hyperlink{command.theory}{\mbox{\isa{\isacommand{theory}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}toplevel\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
    49
    \indexdef{global}{command}{end}\hypertarget{command.global.end}{\hyperlink{command.global.end}{\mbox{\isa{\isacommand{end}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ toplevel{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@26870
    50
  \end{matharray}
wenzelm@26870
    51
wenzelm@28788
    52
  Isabelle/Isar theories are defined via theory files, which may
wenzelm@28788
    53
  contain both specifications and proofs; occasionally definitional
wenzelm@28788
    54
  mechanisms also require some explicit proof.  The theory body may be
wenzelm@28788
    55
  sub-structured by means of \emph{local theory targets}, such as
wenzelm@28788
    56
  \hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}} and \hyperlink{command.class}{\mbox{\isa{\isacommand{class}}}}.
wenzelm@26870
    57
wenzelm@28788
    58
  The first proper command of a theory is \hyperlink{command.theory}{\mbox{\isa{\isacommand{theory}}}}, which
wenzelm@28788
    59
  indicates imports of previous theories and optional dependencies on
wenzelm@28788
    60
  other source files (usually in ML).  Just preceding the initial
wenzelm@28788
    61
  \hyperlink{command.theory}{\mbox{\isa{\isacommand{theory}}}} command there may be an optional \hyperlink{command.header}{\mbox{\isa{\isacommand{header}}}} declaration, which is only relevant to document
wenzelm@28788
    62
  preparation: see also the other section markup commands in
wenzelm@28788
    63
  \secref{sec:markup}.
wenzelm@28788
    64
wenzelm@28788
    65
  A theory is concluded by a final \hyperlink{command.global.end}{\mbox{\isa{\isacommand{end}}}} command,
wenzelm@28788
    66
  one that does not belong to a local theory target.  No further
wenzelm@28788
    67
  commands may follow such a global \hyperlink{command.global.end}{\mbox{\isa{\isacommand{end}}}},
wenzelm@28788
    68
  although some user-interfaces might pretend that trailing input is
wenzelm@28788
    69
  admissible.
wenzelm@26870
    70
wenzelm@43467
    71
  \begin{railoutput}
wenzelm@43575
    72
\rail@begin{4}{}
wenzelm@43467
    73
\rail@term{\hyperlink{command.theory}{\mbox{\isa{\isacommand{theory}}}}}[]
wenzelm@43467
    74
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@47985
    75
\rail@nont{\isa{imports}}[]
wenzelm@43575
    76
\rail@cr{2}
wenzelm@47985
    77
\rail@bar
wenzelm@47985
    78
\rail@nextbar{3}
wenzelm@47985
    79
\rail@nont{\isa{keywords}}[]
wenzelm@47985
    80
\rail@endbar
wenzelm@43467
    81
\rail@bar
wenzelm@43575
    82
\rail@nextbar{3}
wenzelm@43467
    83
\rail@nont{\isa{uses}}[]
wenzelm@43467
    84
\rail@endbar
wenzelm@43467
    85
\rail@term{\isa{\isakeyword{begin}}}[]
wenzelm@43467
    86
\rail@end
wenzelm@47985
    87
\rail@begin{2}{\isa{imports}}
wenzelm@47985
    88
\rail@term{\isa{\isakeyword{imports}}}[]
wenzelm@47985
    89
\rail@plus
wenzelm@47985
    90
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@47985
    91
\rail@nextplus{1}
wenzelm@47985
    92
\rail@endplus
wenzelm@47985
    93
\rail@end
wenzelm@47985
    94
\rail@begin{3}{\isa{keywords}}
wenzelm@47985
    95
\rail@term{\isa{\isakeyword{keywords}}}[]
wenzelm@47985
    96
\rail@plus
wenzelm@47985
    97
\rail@plus
wenzelm@47985
    98
\rail@nont{\hyperlink{syntax.string}{\mbox{\isa{string}}}}[]
wenzelm@47985
    99
\rail@nextplus{1}
wenzelm@47985
   100
\rail@endplus
wenzelm@47985
   101
\rail@bar
wenzelm@47985
   102
\rail@nextbar{1}
wenzelm@47985
   103
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@47985
   104
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@47985
   105
\rail@nont{\hyperlink{syntax.tags}{\mbox{\isa{tags}}}}[]
wenzelm@47985
   106
\rail@endbar
wenzelm@47985
   107
\rail@nextplus{2}
wenzelm@47985
   108
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@47985
   109
\rail@endplus
wenzelm@47985
   110
\rail@end
wenzelm@43467
   111
\rail@begin{3}{\isa{uses}}
wenzelm@43467
   112
\rail@term{\isa{\isakeyword{uses}}}[]
wenzelm@43467
   113
\rail@plus
wenzelm@43467
   114
\rail@bar
wenzelm@43467
   115
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   116
\rail@nextbar{1}
wenzelm@43467
   117
\rail@nont{\hyperlink{syntax.parname}{\mbox{\isa{parname}}}}[]
wenzelm@43467
   118
\rail@endbar
wenzelm@43467
   119
\rail@nextplus{2}
wenzelm@43467
   120
\rail@endplus
wenzelm@43467
   121
\rail@end
wenzelm@43467
   122
\end{railoutput}
wenzelm@26870
   123
wenzelm@26870
   124
wenzelm@28788
   125
  \begin{description}
wenzelm@26870
   126
wenzelm@40685
   127
  \item \hyperlink{command.theory}{\mbox{\isa{\isacommand{theory}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}A\ {\isaliteral{5C3C494D504F5254533E}{\isasymIMPORTS}}\ B\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ B\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C424547494E3E}{\isasymBEGIN}}{\isaliteral{22}{\isachardoublequote}}}
wenzelm@28788
   128
  starts a new theory \isa{A} based on the merge of existing
wenzelm@47985
   129
  theories \isa{{\isaliteral{22}{\isachardoublequote}}B\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ B\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}.  Due to the possibility to import more
wenzelm@47985
   130
  than one ancestor, the resulting theory structure of an Isabelle
wenzelm@47985
   131
  session forms a directed acyclic graph (DAG).  Isabelle takes care
wenzelm@47985
   132
  that sources contributing to the development graph are always
wenzelm@47985
   133
  up-to-date: changed files are automatically rechecked whenever a
wenzelm@47985
   134
  theory header specification is processed.
wenzelm@47985
   135
wenzelm@47985
   136
  The optional \indexdef{}{keyword}{keywords}\hypertarget{keyword.keywords}{\hyperlink{keyword.keywords}{\mbox{\isa{\isakeyword{keywords}}}}} specification declares outer
wenzelm@47985
   137
  syntax (\chref{ch:outer-syntax}) that is introduced in this theory
wenzelm@47985
   138
  later on (rare in end-user applications).  Both minor keywords and
wenzelm@47985
   139
  major keywords of the Isar command language need to be specified, in
wenzelm@47985
   140
  order to make parsing of proof documents work properly.  Command
wenzelm@47985
   141
  keywords need to be classified according to their structural role in
wenzelm@47985
   142
  the formal text.  Examples may be seen in Isabelle/HOL sources
wenzelm@47985
   143
  itself, such as \hyperlink{keyword.keywords}{\mbox{\isa{\isakeyword{keywords}}}}~\verb|"typedef"|
wenzelm@47985
   144
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ thy{\isaliteral{5F}{\isacharunderscore}}goal{\isaliteral{22}{\isachardoublequote}}} or \hyperlink{keyword.keywords}{\mbox{\isa{\isakeyword{keywords}}}}~\verb|"datatype"| \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ thy{\isaliteral{5F}{\isacharunderscore}}decl{\isaliteral{22}{\isachardoublequote}}} for theory-level declarations
wenzelm@47985
   145
  with and without proof, respectively.  Additional \hyperlink{syntax.tags}{\mbox{\isa{tags}}}
wenzelm@47985
   146
  provide defaults for document preparation (\secref{sec:tags}).
wenzelm@26870
   147
  
wenzelm@26902
   148
  The optional \indexdef{}{keyword}{uses}\hypertarget{keyword.uses}{\hyperlink{keyword.uses}{\mbox{\isa{\isakeyword{uses}}}}} specification declares additional
wenzelm@47985
   149
  dependencies on external files (notably ML sources).  Files will be
wenzelm@28788
   150
  loaded immediately (as ML), unless the name is parenthesized.  The
wenzelm@28788
   151
  latter case records a dependency that needs to be resolved later in
wenzelm@28788
   152
  the text, usually via explicit \indexref{}{command}{use}\hyperlink{command.use}{\mbox{\isa{\isacommand{use}}}} for ML files;
wenzelm@28788
   153
  other file formats require specific load commands defined by the
wenzelm@28788
   154
  corresponding tools or packages.
wenzelm@26870
   155
  
wenzelm@28788
   156
  \item \hyperlink{command.global.end}{\mbox{\isa{\isacommand{end}}}} concludes the current theory
wenzelm@47985
   157
  definition.  Note that some other commands, e.g.\ local theory
wenzelm@47985
   158
  targets \hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}} or \hyperlink{command.class}{\mbox{\isa{\isacommand{class}}}} may involve a
wenzelm@47985
   159
  \hyperlink{keyword.begin}{\mbox{\isa{\isakeyword{begin}}}} that needs to be matched by \hyperlink{command.local.end}{\mbox{\isa{\isacommand{end}}}}, according to the usual rules for nested blocks.
wenzelm@26870
   160
wenzelm@28788
   161
  \end{description}%
wenzelm@26870
   162
\end{isamarkuptext}%
wenzelm@26870
   163
\isamarkuptrue%
wenzelm@26870
   164
%
wenzelm@27042
   165
\isamarkupsection{Local theory targets \label{sec:target}%
wenzelm@27042
   166
}
wenzelm@27042
   167
\isamarkuptrue%
wenzelm@27042
   168
%
wenzelm@27042
   169
\begin{isamarkuptext}%
wenzelm@27042
   170
A local theory target is a context managed separately within the
wenzelm@27042
   171
  enclosing theory.  Contexts may introduce parameters (fixed
wenzelm@27042
   172
  variables) and assumptions (hypotheses).  Definitions and theorems
wenzelm@27042
   173
  depending on the context may be added incrementally later on.  Named
wenzelm@27042
   174
  contexts refer to locales (cf.\ \secref{sec:locale}) or type classes
wenzelm@40685
   175
  (cf.\ \secref{sec:class}); the name ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{2D}{\isacharminus}}{\isaliteral{22}{\isachardoublequote}}}'' signifies the
wenzelm@27042
   176
  global theory context.
wenzelm@27042
   177
wenzelm@27042
   178
  \begin{matharray}{rcll}
wenzelm@40685
   179
    \indexdef{}{command}{context}\hypertarget{command.context}{\hyperlink{command.context}{\mbox{\isa{\isacommand{context}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   180
    \indexdef{local}{command}{end}\hypertarget{command.local.end}{\hyperlink{command.local.end}{\mbox{\isa{\isacommand{end}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
   181
  \end{matharray}
wenzelm@27042
   182
wenzelm@43467
   183
  \begin{railoutput}
wenzelm@43535
   184
\rail@begin{1}{}
wenzelm@43467
   185
\rail@term{\hyperlink{command.context}{\mbox{\isa{\isacommand{context}}}}}[]
wenzelm@47870
   186
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   187
\rail@term{\isa{\isakeyword{begin}}}[]
wenzelm@43467
   188
\rail@end
wenzelm@43467
   189
\rail@begin{1}{\indexdef{}{syntax}{target}\hypertarget{syntax.target}{\hyperlink{syntax.target}{\mbox{\isa{target}}}}}
wenzelm@43467
   190
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   191
\rail@term{\isa{\isakeyword{in}}}[]
wenzelm@47870
   192
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   193
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   194
\rail@end
wenzelm@43467
   195
\end{railoutput}
wenzelm@27042
   196
wenzelm@27042
   197
wenzelm@28788
   198
  \begin{description}
wenzelm@27042
   199
  
wenzelm@40685
   200
  \item \hyperlink{command.context}{\mbox{\isa{\isacommand{context}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C424547494E3E}{\isasymBEGIN}}{\isaliteral{22}{\isachardoublequote}}} recommences an
wenzelm@27042
   201
  existing locale or class context \isa{c}.  Note that locale and
wenzelm@27052
   202
  class definitions allow to include the \hyperlink{keyword.begin}{\mbox{\isa{\isakeyword{begin}}}} keyword as
wenzelm@27052
   203
  well, in order to continue the local theory immediately after the
wenzelm@27052
   204
  initial specification.
wenzelm@27042
   205
  
wenzelm@28788
   206
  \item \hyperlink{command.local.end}{\mbox{\isa{\isacommand{end}}}} concludes the current local theory
wenzelm@27042
   207
  and continues the enclosing global theory.  Note that a global
wenzelm@27042
   208
  \hyperlink{command.global.end}{\mbox{\isa{\isacommand{end}}}} has a different meaning: it concludes the
wenzelm@27042
   209
  theory itself (\secref{sec:begin-thy}).
wenzelm@27042
   210
  
wenzelm@40685
   211
  \item \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{22}{\isachardoublequote}}}\indexdef{}{keyword}{in}\hypertarget{keyword.in}{\hyperlink{keyword.in}{\mbox{\isa{\isakeyword{in}}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} given after any
wenzelm@30072
   212
  local theory command specifies an immediate target, e.g.\
wenzelm@40685
   213
  ``\hyperlink{command.definition}{\mbox{\isa{\isacommand{definition}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C494E3E}{\isasymIN}}\ c{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}'' or ``\hyperlink{command.theorem}{\mbox{\isa{\isacommand{theorem}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C494E3E}{\isasymIN}}\ c{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{22}{\isachardoublequote}}}''.  This works both in a local or
wenzelm@27042
   214
  global theory context; the current target context will be suspended
wenzelm@40685
   215
  for this command only.  Note that ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C494E3E}{\isasymIN}}\ {\isaliteral{2D}{\isacharminus}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}'' will
wenzelm@27042
   216
  always produce a global result independently of the current target
wenzelm@27042
   217
  context.
wenzelm@27042
   218
wenzelm@28788
   219
  \end{description}
wenzelm@27042
   220
wenzelm@27042
   221
  The exact meaning of results produced within a local theory context
wenzelm@27042
   222
  depends on the underlying target infrastructure (locale, type class
wenzelm@27042
   223
  etc.).  The general idea is as follows, considering a context named
wenzelm@40685
   224
  \isa{c} with parameter \isa{x} and assumption \isa{{\isaliteral{22}{\isachardoublequote}}A{\isaliteral{5B}{\isacharbrackleft}}x{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@27042
   225
  
wenzelm@27042
   226
  Definitions are exported by introducing a global version with
wenzelm@27042
   227
  additional arguments; a syntactic abbreviation links the long form
wenzelm@27042
   228
  with the abstract version of the target context.  For example,
wenzelm@40685
   229
  \isa{{\isaliteral{22}{\isachardoublequote}}a\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{5B}{\isacharbrackleft}}x{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} becomes \isa{{\isaliteral{22}{\isachardoublequote}}c{\isaliteral{2E}{\isachardot}}a\ {\isaliteral{3F}{\isacharquery}}x\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}x{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} at the theory
wenzelm@40685
   230
  level (for arbitrary \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}x{\isaliteral{22}{\isachardoublequote}}}), together with a local
wenzelm@40685
   231
  abbreviation \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ c{\isaliteral{2E}{\isachardot}}a\ x{\isaliteral{22}{\isachardoublequote}}} in the target context (for the
wenzelm@27042
   232
  fixed parameter \isa{x}).
wenzelm@27042
   233
wenzelm@27042
   234
  Theorems are exported by discharging the assumptions and
wenzelm@40685
   235
  generalizing the parameters of the context.  For example, \isa{{\isaliteral{22}{\isachardoublequote}}a{\isaliteral{3A}{\isacharcolon}}\ B{\isaliteral{5B}{\isacharbrackleft}}x{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} becomes \isa{{\isaliteral{22}{\isachardoublequote}}c{\isaliteral{2E}{\isachardot}}a{\isaliteral{3A}{\isacharcolon}}\ A{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}x{\isaliteral{5D}{\isacharbrackright}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ B{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}x{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}}, again for arbitrary
wenzelm@40685
   236
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}x{\isaliteral{22}{\isachardoublequote}}}.%
wenzelm@27042
   237
\end{isamarkuptext}%
wenzelm@27042
   238
\isamarkuptrue%
wenzelm@27042
   239
%
wenzelm@27042
   240
\isamarkupsection{Basic specification elements%
wenzelm@27042
   241
}
wenzelm@27042
   242
\isamarkuptrue%
wenzelm@27042
   243
%
wenzelm@27042
   244
\begin{isamarkuptext}%
wenzelm@27042
   245
\begin{matharray}{rcll}
wenzelm@40685
   246
    \indexdef{}{command}{axiomatization}\hypertarget{command.axiomatization}{\hyperlink{command.axiomatization}{\mbox{\isa{\isacommand{axiomatization}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} & (axiomatic!) \\
wenzelm@40685
   247
    \indexdef{}{command}{definition}\hypertarget{command.definition}{\hyperlink{command.definition}{\mbox{\isa{\isacommand{definition}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@28788
   248
    \indexdef{}{attribute}{defn}\hypertarget{attribute.defn}{\hyperlink{attribute.defn}{\mbox{\isa{defn}}}} & : & \isa{attribute} \\
wenzelm@40685
   249
    \indexdef{}{command}{abbreviation}\hypertarget{command.abbreviation}{\hyperlink{command.abbreviation}{\mbox{\isa{\isacommand{abbreviation}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   250
    \indexdef{}{command}{print\_abbrevs}\hypertarget{command.print-abbrevs}{\hyperlink{command.print-abbrevs}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}abbrevs}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ {\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
   251
  \end{matharray}
wenzelm@27042
   252
wenzelm@27042
   253
  These specification mechanisms provide a slightly more abstract view
wenzelm@27042
   254
  than the underlying primitives of \hyperlink{command.consts}{\mbox{\isa{\isacommand{consts}}}}, \hyperlink{command.defs}{\mbox{\isa{\isacommand{defs}}}} (see \secref{sec:consts}), and \hyperlink{command.axioms}{\mbox{\isa{\isacommand{axioms}}}} (see
wenzelm@27042
   255
  \secref{sec:axms-thms}).  In particular, type-inference is commonly
wenzelm@27042
   256
  available, and result names need not be given.
wenzelm@27042
   257
wenzelm@43467
   258
  \begin{railoutput}
wenzelm@43535
   259
\rail@begin{2}{}
wenzelm@43467
   260
\rail@term{\hyperlink{command.axiomatization}{\mbox{\isa{\isacommand{axiomatization}}}}}[]
wenzelm@43467
   261
\rail@bar
wenzelm@43467
   262
\rail@nextbar{1}
wenzelm@43467
   263
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
   264
\rail@endbar
wenzelm@43467
   265
\rail@bar
wenzelm@43467
   266
\rail@nextbar{1}
wenzelm@43467
   267
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   268
\rail@nont{\isa{specs}}[]
wenzelm@43467
   269
\rail@endbar
wenzelm@43467
   270
\rail@end
wenzelm@43575
   271
\rail@begin{5}{}
wenzelm@43467
   272
\rail@term{\hyperlink{command.definition}{\mbox{\isa{\isacommand{definition}}}}}[]
wenzelm@43467
   273
\rail@bar
wenzelm@43467
   274
\rail@nextbar{1}
wenzelm@43467
   275
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   276
\rail@endbar
wenzelm@43575
   277
\rail@cr{3}
wenzelm@43467
   278
\rail@bar
wenzelm@43575
   279
\rail@nextbar{4}
wenzelm@43467
   280
\rail@nont{\isa{decl}}[]
wenzelm@43467
   281
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   282
\rail@endbar
wenzelm@43467
   283
\rail@bar
wenzelm@43575
   284
\rail@nextbar{4}
wenzelm@43467
   285
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   286
\rail@endbar
wenzelm@43467
   287
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   288
\rail@end
wenzelm@43575
   289
\rail@begin{5}{}
wenzelm@43467
   290
\rail@term{\hyperlink{command.abbreviation}{\mbox{\isa{\isacommand{abbreviation}}}}}[]
wenzelm@43467
   291
\rail@bar
wenzelm@43467
   292
\rail@nextbar{1}
wenzelm@43467
   293
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   294
\rail@endbar
wenzelm@43467
   295
\rail@bar
wenzelm@43467
   296
\rail@nextbar{1}
wenzelm@43467
   297
\rail@nont{\hyperlink{syntax.mode}{\mbox{\isa{mode}}}}[]
wenzelm@43467
   298
\rail@endbar
wenzelm@43575
   299
\rail@cr{3}
wenzelm@43467
   300
\rail@bar
wenzelm@43575
   301
\rail@nextbar{4}
wenzelm@43467
   302
\rail@nont{\isa{decl}}[]
wenzelm@43467
   303
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   304
\rail@endbar
wenzelm@43467
   305
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   306
\rail@end
wenzelm@43467
   307
\rail@begin{4}{\indexdef{}{syntax}{fixes}\hypertarget{syntax.fixes}{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}}
wenzelm@43467
   308
\rail@plus
wenzelm@43467
   309
\rail@bar
wenzelm@43467
   310
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   311
\rail@bar
wenzelm@43467
   312
\rail@nextbar{1}
wenzelm@43467
   313
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
   314
\rail@nont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
   315
\rail@endbar
wenzelm@43467
   316
\rail@bar
wenzelm@43467
   317
\rail@nextbar{1}
wenzelm@43467
   318
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
   319
\rail@endbar
wenzelm@43467
   320
\rail@nextbar{2}
wenzelm@43467
   321
\rail@nont{\hyperlink{syntax.vars}{\mbox{\isa{vars}}}}[]
wenzelm@43467
   322
\rail@endbar
wenzelm@43467
   323
\rail@nextplus{3}
wenzelm@43467
   324
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   325
\rail@endplus
wenzelm@43467
   326
\rail@end
wenzelm@43467
   327
\rail@begin{3}{\isa{specs}}
wenzelm@43467
   328
\rail@plus
wenzelm@43467
   329
\rail@bar
wenzelm@43467
   330
\rail@nextbar{1}
wenzelm@43467
   331
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   332
\rail@endbar
wenzelm@43467
   333
\rail@nont{\hyperlink{syntax.props}{\mbox{\isa{props}}}}[]
wenzelm@43467
   334
\rail@nextplus{2}
wenzelm@43467
   335
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   336
\rail@endplus
wenzelm@43467
   337
\rail@end
wenzelm@43467
   338
\rail@begin{2}{\isa{decl}}
wenzelm@43467
   339
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   340
\rail@bar
wenzelm@43467
   341
\rail@nextbar{1}
wenzelm@43467
   342
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
   343
\rail@nont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
   344
\rail@endbar
wenzelm@43467
   345
\rail@bar
wenzelm@43467
   346
\rail@nextbar{1}
wenzelm@43467
   347
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
   348
\rail@endbar
wenzelm@43467
   349
\rail@end
wenzelm@43467
   350
\end{railoutput}
wenzelm@27042
   351
wenzelm@27042
   352
wenzelm@28788
   353
  \begin{description}
wenzelm@27042
   354
  
wenzelm@40685
   355
  \item \hyperlink{command.axiomatization}{\mbox{\isa{\isacommand{axiomatization}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub m\ {\isaliteral{5C3C57484552453E}{\isasymWHERE}}\ {\isaliteral{5C3C7068693E}{\isasymphi}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C7068693E}{\isasymphi}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}
wenzelm@28788
   356
  introduces several constants simultaneously and states axiomatic
wenzelm@28788
   357
  properties for these.  The constants are marked as being specified
wenzelm@28788
   358
  once and for all, which prevents additional specifications being
wenzelm@28788
   359
  issued later on.
wenzelm@27042
   360
  
wenzelm@27042
   361
  Note that axiomatic specifications are only appropriate when
wenzelm@28110
   362
  declaring a new logical system; axiomatic specifications are
wenzelm@28110
   363
  restricted to global theory contexts.  Normal applications should
wenzelm@28110
   364
  only use definitional mechanisms!
wenzelm@27042
   365
wenzelm@40685
   366
  \item \hyperlink{command.definition}{\mbox{\isa{\isacommand{definition}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C57484552453E}{\isasymWHERE}}\ eq{\isaliteral{22}{\isachardoublequote}}} produces an
wenzelm@40685
   367
  internal definition \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{22}{\isachardoublequote}}} according to the specification
wenzelm@27042
   368
  given as \isa{eq}, which is then turned into a proven fact.  The
wenzelm@27042
   369
  given proposition may deviate from internal meta-level equality
wenzelm@27042
   370
  according to the rewrite rules declared as \hyperlink{attribute.defn}{\mbox{\isa{defn}}} by the
wenzelm@40685
   371
  object-logic.  This usually covers object-level equality \isa{{\isaliteral{22}{\isachardoublequote}}x\ {\isaliteral{3D}{\isacharequal}}\ y{\isaliteral{22}{\isachardoublequote}}} and equivalence \isa{{\isaliteral{22}{\isachardoublequote}}A\ {\isaliteral{5C3C6C65667472696768746172726F773E}{\isasymleftrightarrow}}\ B{\isaliteral{22}{\isachardoublequote}}}.  End-users normally need not
wenzelm@27042
   372
  change the \hyperlink{attribute.defn}{\mbox{\isa{defn}}} setup.
wenzelm@27042
   373
  
wenzelm@27042
   374
  Definitions may be presented with explicit arguments on the LHS, as
wenzelm@40685
   375
  well as additional conditions, e.g.\ \isa{{\isaliteral{22}{\isachardoublequote}}f\ x\ y\ {\isaliteral{3D}{\isacharequal}}\ t{\isaliteral{22}{\isachardoublequote}}} instead of
wenzelm@40685
   376
  \isa{{\isaliteral{22}{\isachardoublequote}}f\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ {\isaliteral{5C3C6C616D6264613E}{\isasymlambda}}x\ y{\isaliteral{2E}{\isachardot}}\ t{\isaliteral{22}{\isachardoublequote}}} and \isa{{\isaliteral{22}{\isachardoublequote}}y\ {\isaliteral{5C3C6E6F7465713E}{\isasymnoteq}}\ {\isadigit{0}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ g\ x\ y\ {\isaliteral{3D}{\isacharequal}}\ u{\isaliteral{22}{\isachardoublequote}}} instead of an
wenzelm@40685
   377
  unrestricted \isa{{\isaliteral{22}{\isachardoublequote}}g\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ {\isaliteral{5C3C6C616D6264613E}{\isasymlambda}}x\ y{\isaliteral{2E}{\isachardot}}\ u{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@27042
   378
  
wenzelm@40685
   379
  \item \hyperlink{command.abbreviation}{\mbox{\isa{\isacommand{abbreviation}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C57484552453E}{\isasymWHERE}}\ eq{\isaliteral{22}{\isachardoublequote}}} introduces a
wenzelm@28788
   380
  syntactic constant which is associated with a certain term according
wenzelm@28788
   381
  to the meta-level equality \isa{eq}.
wenzelm@27042
   382
  
wenzelm@27042
   383
  Abbreviations participate in the usual type-inference process, but
wenzelm@27042
   384
  are expanded before the logic ever sees them.  Pretty printing of
wenzelm@27042
   385
  terms involves higher-order rewriting with rules stemming from
wenzelm@27042
   386
  reverted abbreviations.  This needs some care to avoid overlapping
wenzelm@27042
   387
  or looping syntactic replacements!
wenzelm@27042
   388
  
wenzelm@27042
   389
  The optional \isa{mode} specification restricts output to a
wenzelm@27042
   390
  particular print mode; using ``\isa{input}'' here achieves the
wenzelm@27042
   391
  effect of one-way abbreviations.  The mode may also include an
wenzelm@27042
   392
  ``\hyperlink{keyword.output}{\mbox{\isa{\isakeyword{output}}}}'' qualifier that affects the concrete syntax
wenzelm@27042
   393
  declared for abbreviations, cf.\ \hyperlink{command.syntax}{\mbox{\isa{\isacommand{syntax}}}} in
wenzelm@27042
   394
  \secref{sec:syn-trans}.
wenzelm@27042
   395
  
wenzelm@40685
   396
  \item \hyperlink{command.print-abbrevs}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}abbrevs}}}} prints all constant abbreviations
wenzelm@27042
   397
  of the current context.
wenzelm@27042
   398
  
wenzelm@28788
   399
  \end{description}%
wenzelm@27042
   400
\end{isamarkuptext}%
wenzelm@27042
   401
\isamarkuptrue%
wenzelm@27042
   402
%
wenzelm@27042
   403
\isamarkupsection{Generic declarations%
wenzelm@27042
   404
}
wenzelm@27042
   405
\isamarkuptrue%
wenzelm@27042
   406
%
wenzelm@27042
   407
\begin{isamarkuptext}%
wenzelm@27042
   408
Arbitrary operations on the background context may be wrapped-up as
wenzelm@27042
   409
  generic declaration elements.  Since the underlying concept of local
wenzelm@27042
   410
  theories may be subject to later re-interpretation, there is an
wenzelm@27042
   411
  additional dependency on a morphism that tells the difference of the
wenzelm@27042
   412
  original declaration context wrt.\ the application context
wenzelm@27042
   413
  encountered later on.  A fact declaration is an important special
wenzelm@27042
   414
  case: it consists of a theorem which is applied to the context by
wenzelm@27042
   415
  means of an attribute.
wenzelm@27042
   416
wenzelm@27042
   417
  \begin{matharray}{rcl}
wenzelm@40685
   418
    \indexdef{}{command}{declaration}\hypertarget{command.declaration}{\hyperlink{command.declaration}{\mbox{\isa{\isacommand{declaration}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@41034
   419
    \indexdef{}{command}{syntax\_declaration}\hypertarget{command.syntax-declaration}{\hyperlink{command.syntax-declaration}{\mbox{\isa{\isacommand{syntax{\isaliteral{5F}{\isacharunderscore}}declaration}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   420
    \indexdef{}{command}{declare}\hypertarget{command.declare}{\hyperlink{command.declare}{\mbox{\isa{\isacommand{declare}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
   421
  \end{matharray}
wenzelm@27042
   422
wenzelm@43467
   423
  \begin{railoutput}
wenzelm@43575
   424
\rail@begin{5}{}
wenzelm@43467
   425
\rail@bar
wenzelm@43467
   426
\rail@term{\hyperlink{command.declaration}{\mbox{\isa{\isacommand{declaration}}}}}[]
wenzelm@43467
   427
\rail@nextbar{1}
wenzelm@43467
   428
\rail@term{\hyperlink{command.syntax-declaration}{\mbox{\isa{\isacommand{syntax{\isaliteral{5F}{\isacharunderscore}}declaration}}}}}[]
wenzelm@43467
   429
\rail@endbar
wenzelm@43467
   430
\rail@bar
wenzelm@43467
   431
\rail@nextbar{1}
wenzelm@43467
   432
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
   433
\rail@term{\isa{\isakeyword{pervasive}}}[]
wenzelm@43467
   434
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
   435
\rail@endbar
wenzelm@43575
   436
\rail@cr{3}
wenzelm@43467
   437
\rail@bar
wenzelm@43575
   438
\rail@nextbar{4}
wenzelm@43467
   439
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   440
\rail@endbar
wenzelm@43467
   441
\rail@nont{\hyperlink{syntax.text}{\mbox{\isa{text}}}}[]
wenzelm@43467
   442
\rail@end
wenzelm@43535
   443
\rail@begin{2}{}
wenzelm@43467
   444
\rail@term{\hyperlink{command.declare}{\mbox{\isa{\isacommand{declare}}}}}[]
wenzelm@43467
   445
\rail@bar
wenzelm@43467
   446
\rail@nextbar{1}
wenzelm@43467
   447
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
   448
\rail@endbar
wenzelm@43467
   449
\rail@plus
wenzelm@43467
   450
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
   451
\rail@nextplus{1}
wenzelm@43467
   452
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   453
\rail@endplus
wenzelm@43467
   454
\rail@end
wenzelm@43467
   455
\end{railoutput}
wenzelm@43467
   456
wenzelm@27042
   457
wenzelm@28788
   458
  \begin{description}
wenzelm@27042
   459
wenzelm@28788
   460
  \item \hyperlink{command.declaration}{\mbox{\isa{\isacommand{declaration}}}}~\isa{d} adds the declaration
wenzelm@27042
   461
  function \isa{d} of ML type \verb|declaration|, to the current
wenzelm@27042
   462
  local theory under construction.  In later application contexts, the
wenzelm@27042
   463
  function is transformed according to the morphisms being involved in
wenzelm@27042
   464
  the interpretation hierarchy.
wenzelm@27042
   465
wenzelm@40685
   466
  If the \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}pervasive{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} option is given, the corresponding
wenzelm@33516
   467
  declaration is applied to all possible contexts involved, including
wenzelm@33516
   468
  the global background theory.
wenzelm@33516
   469
wenzelm@41034
   470
  \item \hyperlink{command.syntax-declaration}{\mbox{\isa{\isacommand{syntax{\isaliteral{5F}{\isacharunderscore}}declaration}}}} is similar to \hyperlink{command.declaration}{\mbox{\isa{\isacommand{declaration}}}}, but is meant to affect only ``syntactic'' tools by
wenzelm@41034
   471
  convention (such as notation and type-checking information).
wenzelm@41034
   472
wenzelm@28788
   473
  \item \hyperlink{command.declare}{\mbox{\isa{\isacommand{declare}}}}~\isa{thms} declares theorems to the
wenzelm@27042
   474
  current local theory context.  No theorem binding is involved here,
wenzelm@27042
   475
  unlike \hyperlink{command.theorems}{\mbox{\isa{\isacommand{theorems}}}} or \hyperlink{command.lemmas}{\mbox{\isa{\isacommand{lemmas}}}} (cf.\
wenzelm@27042
   476
  \secref{sec:axms-thms}), so \hyperlink{command.declare}{\mbox{\isa{\isacommand{declare}}}} only has the effect
wenzelm@27042
   477
  of applying attributes as included in the theorem specification.
wenzelm@27042
   478
wenzelm@28788
   479
  \end{description}%
wenzelm@27042
   480
\end{isamarkuptext}%
wenzelm@27042
   481
\isamarkuptrue%
wenzelm@27042
   482
%
wenzelm@27042
   483
\isamarkupsection{Locales \label{sec:locale}%
wenzelm@27042
   484
}
wenzelm@27042
   485
\isamarkuptrue%
wenzelm@27042
   486
%
wenzelm@27042
   487
\begin{isamarkuptext}%
ballarin@33846
   488
Locales are parametric named local contexts, consisting of a list of
wenzelm@27042
   489
  declaration elements that are modeled after the Isar proof context
wenzelm@27042
   490
  commands (cf.\ \secref{sec:proof-context}).%
wenzelm@27042
   491
\end{isamarkuptext}%
wenzelm@27042
   492
\isamarkuptrue%
wenzelm@27042
   493
%
ballarin@33846
   494
\isamarkupsubsection{Locale expressions \label{sec:locale-expr}%
ballarin@33846
   495
}
ballarin@33846
   496
\isamarkuptrue%
ballarin@33846
   497
%
ballarin@33846
   498
\begin{isamarkuptext}%
ballarin@33846
   499
A \emph{locale expression} denotes a structured context composed of
ballarin@33846
   500
  instances of existing locales.  The context consists of a list of
ballarin@33846
   501
  instances of declaration elements from the locales.  Two locale
ballarin@33846
   502
  instances are equal if they are of the same locale and the
ballarin@33846
   503
  parameters are instantiated with equivalent terms.  Declaration
ballarin@33846
   504
  elements from equal instances are never repeated, thus avoiding
ballarin@33846
   505
  duplicate declarations.
ballarin@33846
   506
wenzelm@43467
   507
  \begin{railoutput}
wenzelm@43488
   508
\rail@begin{3}{\indexdef{}{syntax}{locale\_expr}\hypertarget{syntax.locale-expr}{\hyperlink{syntax.locale-expr}{\mbox{\isa{locale{\isaliteral{5F}{\isacharunderscore}}expr}}}}}
wenzelm@43467
   509
\rail@plus
wenzelm@43467
   510
\rail@nont{\isa{instance}}[]
wenzelm@43467
   511
\rail@nextplus{1}
wenzelm@43467
   512
\rail@cterm{\isa{{\isaliteral{2B}{\isacharplus}}}}[]
wenzelm@43467
   513
\rail@endplus
wenzelm@43467
   514
\rail@bar
wenzelm@43467
   515
\rail@nextbar{1}
wenzelm@43467
   516
\rail@term{\isa{\isakeyword{for}}}[]
wenzelm@43467
   517
\rail@plus
wenzelm@43467
   518
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
   519
\rail@nextplus{2}
wenzelm@43467
   520
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   521
\rail@endplus
wenzelm@43467
   522
\rail@endbar
wenzelm@43467
   523
\rail@end
wenzelm@43467
   524
\rail@begin{2}{\isa{instance}}
wenzelm@43467
   525
\rail@bar
wenzelm@43467
   526
\rail@nextbar{1}
wenzelm@43467
   527
\rail@nont{\isa{qualifier}}[]
wenzelm@43467
   528
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
   529
\rail@endbar
wenzelm@43467
   530
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   531
\rail@bar
wenzelm@43488
   532
\rail@nont{\isa{pos{\isaliteral{5F}{\isacharunderscore}}insts}}[]
wenzelm@43467
   533
\rail@nextbar{1}
wenzelm@43488
   534
\rail@nont{\isa{named{\isaliteral{5F}{\isacharunderscore}}insts}}[]
wenzelm@43467
   535
\rail@endbar
wenzelm@43467
   536
\rail@end
wenzelm@43467
   537
\rail@begin{3}{\isa{qualifier}}
wenzelm@43467
   538
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   539
\rail@bar
wenzelm@43467
   540
\rail@nextbar{1}
wenzelm@43467
   541
\rail@bar
wenzelm@43467
   542
\rail@term{\isa{{\isaliteral{3F}{\isacharquery}}}}[]
wenzelm@43467
   543
\rail@nextbar{2}
wenzelm@43467
   544
\rail@term{\isa{{\isaliteral{21}{\isacharbang}}}}[]
wenzelm@43467
   545
\rail@endbar
wenzelm@43467
   546
\rail@endbar
wenzelm@43467
   547
\rail@end
wenzelm@43488
   548
\rail@begin{3}{\isa{pos{\isaliteral{5F}{\isacharunderscore}}insts}}
wenzelm@43467
   549
\rail@plus
wenzelm@43467
   550
\rail@nextplus{1}
wenzelm@43467
   551
\rail@bar
wenzelm@43467
   552
\rail@term{\isa{{\isaliteral{5F}{\isacharunderscore}}}}[]
wenzelm@43467
   553
\rail@nextbar{2}
wenzelm@43467
   554
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   555
\rail@endbar
wenzelm@43467
   556
\rail@endplus
wenzelm@43467
   557
\rail@end
wenzelm@43488
   558
\rail@begin{2}{\isa{named{\isaliteral{5F}{\isacharunderscore}}insts}}
wenzelm@43467
   559
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   560
\rail@plus
wenzelm@43467
   561
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   562
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
   563
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
   564
\rail@nextplus{1}
wenzelm@43467
   565
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   566
\rail@endplus
wenzelm@43467
   567
\rail@end
wenzelm@43467
   568
\end{railoutput}
wenzelm@43467
   569
ballarin@33846
   570
ballarin@33846
   571
  A locale instance consists of a reference to a locale and either
ballarin@33846
   572
  positional or named parameter instantiations.  Identical
ballarin@33846
   573
  instantiations (that is, those that instante a parameter by itself)
wenzelm@40685
   574
  may be omitted.  The notation `\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5F}{\isacharunderscore}}{\isaliteral{22}{\isachardoublequote}}}' enables to omit the
wenzelm@40517
   575
  instantiation for a parameter inside a positional instantiation.
ballarin@33846
   576
ballarin@33846
   577
  Terms in instantiations are from the context the locale expressions
ballarin@33846
   578
  is declared in.  Local names may be added to this context with the
ballarin@33846
   579
  optional for clause.  In addition, syntax declarations from one
ballarin@33846
   580
  instance are effective when parsing subsequent instances of the same
ballarin@33846
   581
  expression.
ballarin@33846
   582
ballarin@33846
   583
  Instances have an optional qualifier which applies to names in
ballarin@33846
   584
  declarations.  Names include local definitions and theorem names.
ballarin@33846
   585
  If present, the qualifier itself is either optional
ballarin@33846
   586
  (``\texttt{?}''), which means that it may be omitted on input of the
ballarin@33846
   587
  qualified name, or mandatory (``\texttt{!}'').  If neither
ballarin@33846
   588
  ``\texttt{?}'' nor ``\texttt{!}'' are present, the command's default
ballarin@33846
   589
  is used.  For \hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}} and \hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}}
ballarin@33846
   590
  the default is ``mandatory'', for \hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}} and \hyperlink{command.sublocale}{\mbox{\isa{\isacommand{sublocale}}}} the default is ``optional''.%
ballarin@33846
   591
\end{isamarkuptext}%
ballarin@33846
   592
\isamarkuptrue%
ballarin@33846
   593
%
ballarin@33846
   594
\isamarkupsubsection{Locale declarations%
wenzelm@27042
   595
}
wenzelm@27042
   596
\isamarkuptrue%
wenzelm@27042
   597
%
wenzelm@27042
   598
\begin{isamarkuptext}%
wenzelm@27042
   599
\begin{matharray}{rcl}
wenzelm@40685
   600
    \indexdef{}{command}{locale}\hypertarget{command.locale}{\hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   601
    \indexdef{}{command}{print\_locale}\hypertarget{command.print-locale}{\hyperlink{command.print-locale}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}locale}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   602
    \indexdef{}{command}{print\_locales}\hypertarget{command.print-locales}{\hyperlink{command.print-locales}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}locales}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   603
    \indexdef{}{method}{intro\_locales}\hypertarget{method.intro-locales}{\hyperlink{method.intro-locales}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}locales}}}} & : & \isa{method} \\
wenzelm@40685
   604
    \indexdef{}{method}{unfold\_locales}\hypertarget{method.unfold-locales}{\hyperlink{method.unfold-locales}{\mbox{\isa{unfold{\isaliteral{5F}{\isacharunderscore}}locales}}}} & : & \isa{method} \\
wenzelm@27042
   605
  \end{matharray}
wenzelm@27042
   606
wenzelm@27042
   607
  \indexisarelem{fixes}\indexisarelem{constrains}\indexisarelem{assumes}
wenzelm@28788
   608
  \indexisarelem{defines}\indexisarelem{notes}
wenzelm@43467
   609
  \begin{railoutput}
wenzelm@43535
   610
\rail@begin{2}{}
wenzelm@43467
   611
\rail@term{\hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}}}[]
wenzelm@43467
   612
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   613
\rail@bar
wenzelm@43467
   614
\rail@nextbar{1}
wenzelm@43467
   615
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
   616
\rail@nont{\hyperlink{syntax.locale}{\mbox{\isa{locale}}}}[]
wenzelm@43467
   617
\rail@endbar
wenzelm@43467
   618
\rail@bar
wenzelm@43467
   619
\rail@nextbar{1}
wenzelm@43467
   620
\rail@term{\isa{\isakeyword{begin}}}[]
wenzelm@43467
   621
\rail@endbar
wenzelm@43467
   622
\rail@end
wenzelm@43535
   623
\rail@begin{2}{}
wenzelm@43467
   624
\rail@term{\hyperlink{command.print-locale}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}locale}}}}}[]
wenzelm@43467
   625
\rail@bar
wenzelm@43467
   626
\rail@nextbar{1}
wenzelm@43467
   627
\rail@term{\isa{{\isaliteral{21}{\isacharbang}}}}[]
wenzelm@43467
   628
\rail@endbar
wenzelm@43467
   629
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   630
\rail@end
wenzelm@43467
   631
\rail@begin{5}{\indexdef{}{syntax}{locale}\hypertarget{syntax.locale}{\hyperlink{syntax.locale}{\mbox{\isa{locale}}}}}
wenzelm@43467
   632
\rail@bar
wenzelm@43467
   633
\rail@plus
wenzelm@43488
   634
\rail@nont{\hyperlink{syntax.context-elem}{\mbox{\isa{context{\isaliteral{5F}{\isacharunderscore}}elem}}}}[]
wenzelm@43467
   635
\rail@nextplus{1}
wenzelm@43467
   636
\rail@endplus
wenzelm@43467
   637
\rail@nextbar{2}
wenzelm@43488
   638
\rail@nont{\hyperlink{syntax.locale-expr}{\mbox{\isa{locale{\isaliteral{5F}{\isacharunderscore}}expr}}}}[]
wenzelm@43467
   639
\rail@bar
wenzelm@43467
   640
\rail@nextbar{3}
wenzelm@43467
   641
\rail@term{\isa{{\isaliteral{2B}{\isacharplus}}}}[]
wenzelm@43467
   642
\rail@plus
wenzelm@43488
   643
\rail@nont{\hyperlink{syntax.context-elem}{\mbox{\isa{context{\isaliteral{5F}{\isacharunderscore}}elem}}}}[]
wenzelm@43467
   644
\rail@nextplus{4}
wenzelm@43467
   645
\rail@endplus
wenzelm@43467
   646
\rail@endbar
wenzelm@43467
   647
\rail@endbar
wenzelm@43467
   648
\rail@end
wenzelm@43488
   649
\rail@begin{12}{\indexdef{}{syntax}{context\_elem}\hypertarget{syntax.context-elem}{\hyperlink{syntax.context-elem}{\mbox{\isa{context{\isaliteral{5F}{\isacharunderscore}}elem}}}}}
wenzelm@43467
   650
\rail@bar
wenzelm@43467
   651
\rail@term{\isa{\isakeyword{fixes}}}[]
wenzelm@43467
   652
\rail@plus
wenzelm@43467
   653
\rail@nont{\hyperlink{syntax.fixes}{\mbox{\isa{fixes}}}}[]
wenzelm@43467
   654
\rail@nextplus{1}
wenzelm@43467
   655
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   656
\rail@endplus
wenzelm@43467
   657
\rail@nextbar{2}
wenzelm@43467
   658
\rail@term{\isa{\isakeyword{constrains}}}[]
wenzelm@43467
   659
\rail@plus
wenzelm@43467
   660
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
   661
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
   662
\rail@nont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
   663
\rail@nextplus{3}
wenzelm@43467
   664
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   665
\rail@endplus
wenzelm@43467
   666
\rail@nextbar{4}
wenzelm@43467
   667
\rail@term{\isa{\isakeyword{assumes}}}[]
wenzelm@43467
   668
\rail@plus
wenzelm@43467
   669
\rail@nont{\hyperlink{syntax.props}{\mbox{\isa{props}}}}[]
wenzelm@43467
   670
\rail@nextplus{5}
wenzelm@43467
   671
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   672
\rail@endplus
wenzelm@43467
   673
\rail@nextbar{6}
wenzelm@43467
   674
\rail@term{\isa{\isakeyword{defines}}}[]
wenzelm@43467
   675
\rail@plus
wenzelm@43467
   676
\rail@bar
wenzelm@43467
   677
\rail@nextbar{7}
wenzelm@43467
   678
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   679
\rail@endbar
wenzelm@43467
   680
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   681
\rail@bar
wenzelm@43467
   682
\rail@nextbar{7}
wenzelm@43576
   683
\rail@nont{\hyperlink{syntax.prop-pat}{\mbox{\isa{prop{\isaliteral{5F}{\isacharunderscore}}pat}}}}[]
wenzelm@43467
   684
\rail@endbar
wenzelm@43467
   685
\rail@nextplus{8}
wenzelm@43467
   686
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   687
\rail@endplus
wenzelm@43467
   688
\rail@nextbar{9}
wenzelm@43467
   689
\rail@term{\isa{\isakeyword{notes}}}[]
wenzelm@43467
   690
\rail@plus
wenzelm@43467
   691
\rail@bar
wenzelm@43467
   692
\rail@nextbar{10}
wenzelm@43467
   693
\rail@nont{\hyperlink{syntax.thmdef}{\mbox{\isa{thmdef}}}}[]
wenzelm@43467
   694
\rail@endbar
wenzelm@43467
   695
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@43467
   696
\rail@nextplus{11}
wenzelm@43467
   697
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   698
\rail@endplus
wenzelm@43467
   699
\rail@endbar
wenzelm@43467
   700
\rail@end
wenzelm@43467
   701
\end{railoutput}
wenzelm@43467
   702
wenzelm@27042
   703
wenzelm@28788
   704
  \begin{description}
wenzelm@27042
   705
  
wenzelm@40685
   706
  \item \hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}loc\ {\isaliteral{3D}{\isacharequal}}\ import\ {\isaliteral{2B}{\isacharplus}}\ body{\isaliteral{22}{\isachardoublequote}}} defines a
wenzelm@27042
   707
  new locale \isa{loc} as a context consisting of a certain view of
wenzelm@27042
   708
  existing locales (\isa{import}) plus some additional elements
wenzelm@27042
   709
  (\isa{body}).  Both \isa{import} and \isa{body} are optional;
wenzelm@27042
   710
  the degenerate form \hyperlink{command.locale}{\mbox{\isa{\isacommand{locale}}}}~\isa{loc} defines an empty
wenzelm@27042
   711
  locale, which may still be useful to collect declarations of facts
wenzelm@27042
   712
  later on.  Type-inference on locale expressions automatically takes
wenzelm@27042
   713
  care of the most general typing that the combined context elements
wenzelm@27042
   714
  may acquire.
wenzelm@27042
   715
ballarin@33846
   716
  The \isa{import} consists of a structured locale expression; see
ballarin@33846
   717
  \secref{sec:proof-context} above.  Its for clause defines the local
ballarin@33846
   718
  parameters of the \isa{import}.  In addition, locale parameters
ballarin@33846
   719
  whose instantance is omitted automatically extend the (possibly
ballarin@33846
   720
  empty) for clause: they are inserted at its beginning.  This means
ballarin@33846
   721
  that these parameters may be referred to from within the expression
ballarin@33846
   722
  and also in the subsequent context elements and provides a
ballarin@33846
   723
  notational convenience for the inheritance of parameters in locale
ballarin@33846
   724
  declarations.
wenzelm@27042
   725
ballarin@33846
   726
  The \isa{body} consists of context elements.
wenzelm@27042
   727
wenzelm@28788
   728
  \begin{description}
wenzelm@27042
   729
wenzelm@40685
   730
  \item \hyperlink{element.fixes}{\mbox{\isa{\isakeyword{fixes}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}\ {\isaliteral{28}{\isacharparenleft}}mx{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} declares a local
wenzelm@40685
   731
  parameter of type \isa{{\isaliteral{5C3C7461753E}{\isasymtau}}} and mixfix annotation \isa{mx} (both
wenzelm@40685
   732
  are optional).  The special syntax declaration ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C5354525543545552453E}{\isasymSTRUCTURE}}{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}'' means that \isa{x} may be referenced
wenzelm@27042
   733
  implicitly in this context.
wenzelm@27042
   734
wenzelm@40685
   735
  \item \hyperlink{element.constrains}{\mbox{\isa{\isakeyword{constrains}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}x\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}} introduces a type
wenzelm@40685
   736
  constraint \isa{{\isaliteral{5C3C7461753E}{\isasymtau}}} on the local parameter \isa{x}.  This
ballarin@38356
   737
  element is deprecated.  The type constraint should be introduced in
ballarin@33846
   738
  the for clause or the relevant \hyperlink{element.fixes}{\mbox{\isa{\isakeyword{fixes}}}} element.
wenzelm@27042
   739
wenzelm@40685
   740
  \item \hyperlink{element.assumes}{\mbox{\isa{\isakeyword{assumes}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}a{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7068693E}{\isasymphi}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ {\isaliteral{5C3C7068693E}{\isasymphi}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}
wenzelm@27042
   741
  introduces local premises, similar to \hyperlink{command.assume}{\mbox{\isa{\isacommand{assume}}}} within a
wenzelm@27042
   742
  proof (cf.\ \secref{sec:proof-context}).
wenzelm@27042
   743
wenzelm@40685
   744
  \item \hyperlink{element.defines}{\mbox{\isa{\isakeyword{defines}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}a{\isaliteral{3A}{\isacharcolon}}\ x\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{22}{\isachardoublequote}}} defines a previously
wenzelm@27042
   745
  declared parameter.  This is similar to \hyperlink{command.def}{\mbox{\isa{\isacommand{def}}}} within a
wenzelm@27042
   746
  proof (cf.\ \secref{sec:proof-context}), but \hyperlink{element.defines}{\mbox{\isa{\isakeyword{defines}}}}
wenzelm@27042
   747
  takes an equational proposition instead of variable-term pair.  The
wenzelm@27042
   748
  left-hand side of the equation may have additional arguments, e.g.\
wenzelm@40685
   749
  ``\hyperlink{element.defines}{\mbox{\isa{\isakeyword{defines}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}f\ x\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ x\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{22}{\isachardoublequote}}}''.
wenzelm@27042
   750
wenzelm@40685
   751
  \item \hyperlink{element.notes}{\mbox{\isa{\isakeyword{notes}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}a\ {\isaliteral{3D}{\isacharequal}}\ b\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ b\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}
wenzelm@27042
   752
  reconsiders facts within a local context.  Most notably, this may
wenzelm@27042
   753
  include arbitrary declarations in any attribute specifications
wenzelm@27042
   754
  included here, e.g.\ a local \hyperlink{attribute.simp}{\mbox{\isa{simp}}} rule.
wenzelm@27042
   755
wenzelm@28788
   756
  The initial \isa{import} specification of a locale expression
wenzelm@28788
   757
  maintains a dynamic relation to the locales being referenced
wenzelm@28788
   758
  (benefiting from any later fact declarations in the obvious manner).
wenzelm@27042
   759
wenzelm@28788
   760
  \end{description}
wenzelm@27042
   761
  
wenzelm@40685
   762
  Note that ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C49533E}{\isasymIS}}\ p\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ p\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}'' patterns given
wenzelm@27042
   763
  in the syntax of \hyperlink{element.assumes}{\mbox{\isa{\isakeyword{assumes}}}} and \hyperlink{element.defines}{\mbox{\isa{\isakeyword{defines}}}} above
wenzelm@27042
   764
  are illegal in locale definitions.  In the long goal format of
wenzelm@27042
   765
  \secref{sec:goals}, term bindings may be included as expected,
wenzelm@27042
   766
  though.
wenzelm@27042
   767
  
ballarin@33846
   768
  \medskip Locale specifications are ``closed up'' by
wenzelm@40685
   769
  turning the given text into a predicate definition \isa{loc{\isaliteral{5F}{\isacharunderscore}}axioms} and deriving the original assumptions as local lemmas
wenzelm@27042
   770
  (modulo local definitions).  The predicate statement covers only the
wenzelm@27042
   771
  newly specified assumptions, omitting the content of included locale
wenzelm@27042
   772
  expressions.  The full cumulative view is only provided on export,
wenzelm@27042
   773
  involving another predicate \isa{loc} that refers to the complete
wenzelm@27042
   774
  specification text.
wenzelm@27042
   775
  
wenzelm@27042
   776
  In any case, the predicate arguments are those locale parameters
wenzelm@27042
   777
  that actually occur in the respective piece of text.  Also note that
wenzelm@27042
   778
  these predicates operate at the meta-level in theory, but the locale
wenzelm@27042
   779
  packages attempts to internalize statements according to the
wenzelm@40685
   780
  object-logic setup (e.g.\ replacing \isa{{\isaliteral{5C3C416E643E}{\isasymAnd}}} by \isa{{\isaliteral{5C3C666F72616C6C3E}{\isasymforall}}}, and
wenzelm@40685
   781
  \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}{\isaliteral{22}{\isachardoublequote}}} by \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C6C6F6E6772696768746172726F773E}{\isasymlongrightarrow}}{\isaliteral{22}{\isachardoublequote}}} in HOL; see also
wenzelm@40685
   782
  \secref{sec:object-logic}).  Separate introduction rules \isa{loc{\isaliteral{5F}{\isacharunderscore}}axioms{\isaliteral{2E}{\isachardot}}intro} and \isa{loc{\isaliteral{2E}{\isachardot}}intro} are provided as well.
wenzelm@27042
   783
  
wenzelm@40685
   784
  \item \hyperlink{command.print-locale}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}locale}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}locale{\isaliteral{22}{\isachardoublequote}}} prints the
ballarin@33868
   785
  contents of the named locale.  The command omits \hyperlink{element.notes}{\mbox{\isa{\isakeyword{notes}}}}
wenzelm@40685
   786
  elements by default.  Use \hyperlink{command.print-locale}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}locale}}}}\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{21}{\isacharbang}}{\isaliteral{22}{\isachardoublequote}}} to
ballarin@33868
   787
  have them included.
wenzelm@27042
   788
wenzelm@40685
   789
  \item \hyperlink{command.print-locales}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}locales}}}} prints the names of all locales
wenzelm@27042
   790
  of the current theory.
wenzelm@27042
   791
wenzelm@40685
   792
  \item \hyperlink{method.intro-locales}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}locales}}} and \hyperlink{method.unfold-locales}{\mbox{\isa{unfold{\isaliteral{5F}{\isacharunderscore}}locales}}}
wenzelm@27042
   793
  repeatedly expand all introduction rules of locale predicates of the
wenzelm@40685
   794
  theory.  While \hyperlink{method.intro-locales}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}locales}}} only applies the \isa{loc{\isaliteral{2E}{\isachardot}}intro} introduction rules and therefore does not decend to
wenzelm@40685
   795
  assumptions, \hyperlink{method.unfold-locales}{\mbox{\isa{unfold{\isaliteral{5F}{\isacharunderscore}}locales}}} is more aggressive and applies
wenzelm@40685
   796
  \isa{loc{\isaliteral{5F}{\isacharunderscore}}axioms{\isaliteral{2E}{\isachardot}}intro} as well.  Both methods are aware of locale
ballarin@28728
   797
  specifications entailed by the context, both from target statements,
ballarin@28728
   798
  and from interpretations (see below).  New goals that are entailed
ballarin@28728
   799
  by the current context are discharged automatically.
wenzelm@27042
   800
wenzelm@28788
   801
  \end{description}%
wenzelm@27042
   802
\end{isamarkuptext}%
wenzelm@27042
   803
\isamarkuptrue%
wenzelm@27042
   804
%
ballarin@33846
   805
\isamarkupsubsection{Locale interpretations%
wenzelm@27042
   806
}
wenzelm@27042
   807
\isamarkuptrue%
wenzelm@27042
   808
%
wenzelm@27042
   809
\begin{isamarkuptext}%
ballarin@33846
   810
Locale expressions may be instantiated, and the instantiated facts
ballarin@33846
   811
  added to the current context.  This requires a proof of the
ballarin@33846
   812
  instantiated specification and is called \emph{locale
ballarin@33846
   813
  interpretation}.  Interpretation is possible in locales \hyperlink{command.sublocale}{\mbox{\isa{\isacommand{sublocale}}}}, theories (command \hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}}) and
ballarin@33846
   814
  also within a proof body (command \hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}}).
wenzelm@27042
   815
wenzelm@27042
   816
  \begin{matharray}{rcl}
wenzelm@40685
   817
    \indexdef{}{command}{interpretation}\hypertarget{command.interpretation}{\hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   818
    \indexdef{}{command}{interpret}\hypertarget{command.interpret}{\hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof{\isaliteral{28}{\isacharparenleft}}state{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{7C}{\isacharbar}}\ proof{\isaliteral{28}{\isacharparenleft}}chain{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
ballarin@41682
   819
    \indexdef{}{command}{sublocale}\hypertarget{command.sublocale}{\hyperlink{command.sublocale}{\mbox{\isa{\isacommand{sublocale}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
ballarin@41683
   820
    \indexdef{}{command}{print\_dependencies}\hypertarget{command.print-dependencies}{\hyperlink{command.print-dependencies}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}dependencies}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   821
    \indexdef{}{command}{print\_interps}\hypertarget{command.print-interps}{\hyperlink{command.print-interps}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}interps}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
   822
  \end{matharray}
wenzelm@27042
   823
wenzelm@43467
   824
  \begin{railoutput}
wenzelm@43535
   825
\rail@begin{2}{}
wenzelm@43467
   826
\rail@term{\hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}}}[]
wenzelm@43488
   827
\rail@nont{\hyperlink{syntax.locale-expr}{\mbox{\isa{locale{\isaliteral{5F}{\isacharunderscore}}expr}}}}[]
wenzelm@43467
   828
\rail@bar
wenzelm@43467
   829
\rail@nextbar{1}
wenzelm@43467
   830
\rail@nont{\isa{equations}}[]
wenzelm@43467
   831
\rail@endbar
wenzelm@43467
   832
\rail@end
wenzelm@43535
   833
\rail@begin{2}{}
wenzelm@43467
   834
\rail@term{\hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}}}[]
wenzelm@43488
   835
\rail@nont{\hyperlink{syntax.locale-expr}{\mbox{\isa{locale{\isaliteral{5F}{\isacharunderscore}}expr}}}}[]
wenzelm@43467
   836
\rail@bar
wenzelm@43467
   837
\rail@nextbar{1}
wenzelm@43467
   838
\rail@nont{\isa{equations}}[]
wenzelm@43467
   839
\rail@endbar
wenzelm@43467
   840
\rail@end
wenzelm@43575
   841
\rail@begin{5}{}
wenzelm@43467
   842
\rail@term{\hyperlink{command.sublocale}{\mbox{\isa{\isacommand{sublocale}}}}}[]
wenzelm@43467
   843
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   844
\rail@bar
wenzelm@43467
   845
\rail@term{\isa{{\isaliteral{3C}{\isacharless}}}}[]
wenzelm@43467
   846
\rail@nextbar{1}
wenzelm@43467
   847
\rail@term{\isa{{\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}}}[]
wenzelm@43467
   848
\rail@endbar
wenzelm@43488
   849
\rail@nont{\hyperlink{syntax.locale-expr}{\mbox{\isa{locale{\isaliteral{5F}{\isacharunderscore}}expr}}}}[]
wenzelm@43575
   850
\rail@cr{3}
wenzelm@43467
   851
\rail@bar
wenzelm@43575
   852
\rail@nextbar{4}
wenzelm@43467
   853
\rail@nont{\isa{equations}}[]
wenzelm@43467
   854
\rail@endbar
wenzelm@43467
   855
\rail@end
wenzelm@43535
   856
\rail@begin{2}{}
wenzelm@43467
   857
\rail@term{\hyperlink{command.print-dependencies}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}dependencies}}}}}[]
wenzelm@43467
   858
\rail@bar
wenzelm@43467
   859
\rail@nextbar{1}
wenzelm@43467
   860
\rail@term{\isa{{\isaliteral{21}{\isacharbang}}}}[]
wenzelm@43467
   861
\rail@endbar
wenzelm@43488
   862
\rail@nont{\hyperlink{syntax.locale-expr}{\mbox{\isa{locale{\isaliteral{5F}{\isacharunderscore}}expr}}}}[]
wenzelm@43467
   863
\rail@end
wenzelm@43535
   864
\rail@begin{1}{}
wenzelm@43467
   865
\rail@term{\hyperlink{command.print-interps}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}interps}}}}}[]
wenzelm@43467
   866
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
   867
\rail@end
wenzelm@43467
   868
\rail@begin{3}{\isa{equations}}
wenzelm@43467
   869
\rail@term{\isa{\isakeyword{where}}}[]
wenzelm@43467
   870
\rail@plus
wenzelm@43467
   871
\rail@bar
wenzelm@43467
   872
\rail@nextbar{1}
wenzelm@43467
   873
\rail@nont{\hyperlink{syntax.thmdecl}{\mbox{\isa{thmdecl}}}}[]
wenzelm@43467
   874
\rail@endbar
wenzelm@43467
   875
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
   876
\rail@nextplus{2}
wenzelm@43467
   877
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
   878
\rail@endplus
wenzelm@43467
   879
\rail@end
wenzelm@43467
   880
\end{railoutput}
wenzelm@43467
   881
wenzelm@27042
   882
wenzelm@28788
   883
  \begin{description}
wenzelm@27042
   884
wenzelm@40685
   885
  \item \hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}expr\ {\isaliteral{5C3C57484552453E}{\isasymWHERE}}\ eqns{\isaliteral{22}{\isachardoublequote}}}
ballarin@33846
   886
  interprets \isa{expr} in the theory.  The command generates proof
ballarin@33846
   887
  obligations for the instantiated specifications (assumes and defines
ballarin@33846
   888
  elements).  Once these are discharged by the user, instantiated
ballarin@33846
   889
  facts are added to the theory in a post-processing phase.
wenzelm@27042
   890
ballarin@33846
   891
  Additional equations, which are unfolded during
wenzelm@27042
   892
  post-processing, may be given after the keyword \hyperlink{keyword.where}{\mbox{\isa{\isakeyword{where}}}}.
wenzelm@27042
   893
  This is useful for interpreting concepts introduced through
ballarin@41682
   894
  definitions.  The equations must be proved.
wenzelm@27042
   895
wenzelm@27042
   896
  The command is aware of interpretations already active in the
ballarin@28085
   897
  theory, but does not simplify the goal automatically.  In order to
wenzelm@40685
   898
  simplify the proof obligations use methods \hyperlink{method.intro-locales}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}locales}}}
wenzelm@40685
   899
  or \hyperlink{method.unfold-locales}{\mbox{\isa{unfold{\isaliteral{5F}{\isacharunderscore}}locales}}}.  Post-processing is not applied to
ballarin@28085
   900
  facts of interpretations that are already active.  This avoids
ballarin@28085
   901
  duplication of interpreted facts, in particular.  Note that, in the
ballarin@28085
   902
  case of a locale with import, parts of the interpretation may
ballarin@28085
   903
  already be active.  The command will only process facts for new
ballarin@28085
   904
  parts.
wenzelm@27042
   905
wenzelm@27042
   906
  Adding facts to locales has the effect of adding interpreted facts
ballarin@41682
   907
  to the theory for all interpretations as well.  That is,
wenzelm@27042
   908
  interpretations dynamically participate in any facts added to
ballarin@41682
   909
  locales.  Note that if a theory inherits additional facts for a
ballarin@41682
   910
  locale through one parent and an interpretation of that locale
ballarin@41682
   911
  through another parent, the additional facts will not be
ballarin@41682
   912
  interpreted.
wenzelm@27042
   913
wenzelm@40685
   914
  \item \hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}expr\ {\isaliteral{5C3C57484552453E}{\isasymWHERE}}\ eqns{\isaliteral{22}{\isachardoublequote}}} interprets
ballarin@38356
   915
  \isa{expr} in the proof context and is otherwise similar to
ballarin@38356
   916
  interpretation in theories.  Note that rewrite rules given to
ballarin@41682
   917
  \hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}} after the \hyperlink{keyword.where}{\mbox{\isa{\isakeyword{where}}}} keyword should be
ballarin@41682
   918
  explicitly universally quantified.
ballarin@41682
   919
ballarin@41682
   920
  \item \hyperlink{command.sublocale}{\mbox{\isa{\isacommand{sublocale}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}name\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ expr\ {\isaliteral{5C3C57484552453E}{\isasymWHERE}}\ eqns{\isaliteral{22}{\isachardoublequote}}}
ballarin@41682
   921
  interprets \isa{expr} in the locale \isa{name}.  A proof that
ballarin@41682
   922
  the specification of \isa{name} implies the specification of
ballarin@41682
   923
  \isa{expr} is required.  As in the localized version of the
ballarin@41682
   924
  theorem command, the proof is in the context of \isa{name}.  After
ballarin@41682
   925
  the proof obligation has been discharged, the facts of \isa{expr}
ballarin@41682
   926
  become part of locale \isa{name} as \emph{derived} context
ballarin@41682
   927
  elements and are available when the context \isa{name} is
ballarin@41682
   928
  subsequently entered.  Note that, like import, this is dynamic:
ballarin@41682
   929
  facts added to a locale part of \isa{expr} after interpretation
ballarin@41682
   930
  become also available in \isa{name}.
ballarin@41682
   931
ballarin@41682
   932
  Only specification fragments of \isa{expr} that are not already
ballarin@41682
   933
  part of \isa{name} (be it imported, derived or a derived fragment
ballarin@41682
   934
  of the import) are considered in this process.  This enables
ballarin@41682
   935
  circular interpretations provided that no infinite chains are
ballarin@41682
   936
  generated in the locale hierarchy.
ballarin@41682
   937
ballarin@41682
   938
  If interpretations of \isa{name} exist in the current theory, the
ballarin@41682
   939
  command adds interpretations for \isa{expr} as well, with the same
ballarin@41682
   940
  qualifier, although only for fragments of \isa{expr} that are not
ballarin@41682
   941
  interpreted in the theory already.
ballarin@41682
   942
ballarin@41682
   943
  Equations given after \hyperlink{keyword.where}{\mbox{\isa{\isakeyword{where}}}} amend the morphism through
ballarin@41682
   944
  which \isa{expr} is interpreted.  This enables to map definitions
ballarin@41682
   945
  from the interpreted locales to entities of \isa{name}.  This
ballarin@41682
   946
  feature is experimental.
wenzelm@27042
   947
ballarin@41683
   948
  \item \hyperlink{command.print-dependencies}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}dependencies}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}expr{\isaliteral{22}{\isachardoublequote}}} is useful for
ballarin@41683
   949
  understanding the effect of an interpretation of \isa{{\isaliteral{22}{\isachardoublequote}}expr{\isaliteral{22}{\isachardoublequote}}}.  It
ballarin@41683
   950
  lists all locale instances for which interpretations would be added
ballarin@41683
   951
  to the current context.  Variant \hyperlink{command.print-dependencies}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}dependencies}}}}\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{21}{\isacharbang}}{\isaliteral{22}{\isachardoublequote}}} prints all locale instances that
ballarin@41683
   952
  would be considered for interpretation, and would be interpreted in
ballarin@41683
   953
  an empty context (that is, without interpretations).
ballarin@41683
   954
wenzelm@40685
   955
  \item \hyperlink{command.print-interps}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}interps}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}locale{\isaliteral{22}{\isachardoublequote}}} lists all
wenzelm@40685
   956
  interpretations of \isa{{\isaliteral{22}{\isachardoublequote}}locale{\isaliteral{22}{\isachardoublequote}}} in the current theory or proof
ballarin@38356
   957
  context, including those due to a combination of a \hyperlink{command.interpretation}{\mbox{\isa{\isacommand{interpretation}}}} or \hyperlink{command.interpret}{\mbox{\isa{\isacommand{interpret}}}} and one or several
ballarin@38356
   958
  \hyperlink{command.sublocale}{\mbox{\isa{\isacommand{sublocale}}}} declarations.
ballarin@33868
   959
wenzelm@28788
   960
  \end{description}
wenzelm@27042
   961
wenzelm@27042
   962
  \begin{warn}
wenzelm@27042
   963
    Since attributes are applied to interpreted theorems,
wenzelm@27042
   964
    interpretation may modify the context of common proof tools, e.g.\
ballarin@33868
   965
    the Simplifier or Classical Reasoner.  As the behavior of such
ballarin@33868
   966
    tools is \emph{not} stable under interpretation morphisms, manual
ballarin@33868
   967
    declarations might have to be added to the target context of the
ballarin@33868
   968
    interpretation to revert such declarations.
wenzelm@27042
   969
  \end{warn}
wenzelm@27042
   970
wenzelm@27042
   971
  \begin{warn}
ballarin@38356
   972
    An interpretation in a theory or proof context may subsume previous
wenzelm@27042
   973
    interpretations.  This happens if the same specification fragment
wenzelm@27042
   974
    is interpreted twice and the instantiation of the second
wenzelm@27042
   975
    interpretation is more general than the interpretation of the
ballarin@33846
   976
    first.  The locale package does not attempt to remove subsumed
ballarin@33846
   977
    interpretations.
wenzelm@27042
   978
  \end{warn}%
wenzelm@27042
   979
\end{isamarkuptext}%
wenzelm@27042
   980
\isamarkuptrue%
wenzelm@27042
   981
%
wenzelm@27042
   982
\isamarkupsection{Classes \label{sec:class}%
wenzelm@27042
   983
}
wenzelm@27042
   984
\isamarkuptrue%
wenzelm@27042
   985
%
wenzelm@27042
   986
\begin{isamarkuptext}%
wenzelm@27042
   987
A class is a particular locale with \emph{exactly one} type variable
wenzelm@40685
   988
  \isa{{\isaliteral{5C3C616C7068613E}{\isasymalpha}}}.  Beyond the underlying locale, a corresponding type class
wenzelm@27042
   989
  is established which is interpreted logically as axiomatic type
wenzelm@27042
   990
  class \cite{Wenzel:1997:TPHOL} whose logical content are the
wenzelm@27042
   991
  assumptions of the locale.  Thus, classes provide the full
wenzelm@27042
   992
  generality of locales combined with the commodity of type classes
wenzelm@27042
   993
  (notably type-inference).  See \cite{isabelle-classes} for a short
wenzelm@27042
   994
  tutorial.
wenzelm@27042
   995
wenzelm@27042
   996
  \begin{matharray}{rcl}
wenzelm@40685
   997
    \indexdef{}{command}{class}\hypertarget{command.class}{\hyperlink{command.class}{\mbox{\isa{\isacommand{class}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   998
    \indexdef{}{command}{instantiation}\hypertarget{command.instantiation}{\hyperlink{command.instantiation}{\mbox{\isa{\isacommand{instantiation}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
   999
    \indexdef{}{command}{instance}\hypertarget{command.instance}{\hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@43497
  1000
    \hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{28}{\isacharparenleft}}prove{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1001
    \indexdef{}{command}{subclass}\hypertarget{command.subclass}{\hyperlink{command.subclass}{\mbox{\isa{\isacommand{subclass}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1002
    \indexdef{}{command}{print\_classes}\hypertarget{command.print-classes}{\hyperlink{command.print-classes}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}classes}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1003
    \indexdef{}{command}{class\_deps}\hypertarget{command.class-deps}{\hyperlink{command.class-deps}{\mbox{\isa{\isacommand{class{\isaliteral{5F}{\isacharunderscore}}deps}}}}}\isa{{\isaliteral{22}{\isachardoublequote}}\isaliteral{5C3C5E7375703E}{}\isactrlsup {\isaliteral{2A}{\isacharasterisk}}{\isaliteral{22}{\isachardoublequote}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}context\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1004
    \indexdef{}{method}{intro\_classes}\hypertarget{method.intro-classes}{\hyperlink{method.intro-classes}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}classes}}}} & : & \isa{method} \\
wenzelm@27042
  1005
  \end{matharray}
wenzelm@27042
  1006
wenzelm@43467
  1007
  \begin{railoutput}
wenzelm@43575
  1008
\rail@begin{2}{}
wenzelm@43467
  1009
\rail@term{\hyperlink{command.class}{\mbox{\isa{\isacommand{class}}}}}[]
wenzelm@43575
  1010
\rail@nont{\isa{class{\isaliteral{5F}{\isacharunderscore}}spec}}[]
wenzelm@43575
  1011
\rail@bar
wenzelm@43575
  1012
\rail@nextbar{1}
wenzelm@43575
  1013
\rail@term{\isa{\isakeyword{begin}}}[]
wenzelm@43575
  1014
\rail@endbar
wenzelm@43575
  1015
\rail@end
wenzelm@43575
  1016
\rail@begin{5}{\isa{class{\isaliteral{5F}{\isacharunderscore}}spec}}
wenzelm@43467
  1017
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1018
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  1019
\rail@bar
wenzelm@43488
  1020
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1021
\rail@term{\isa{{\isaliteral{2B}{\isacharplus}}}}[]
wenzelm@43467
  1022
\rail@plus
wenzelm@43488
  1023
\rail@nont{\hyperlink{syntax.context-elem}{\mbox{\isa{context{\isaliteral{5F}{\isacharunderscore}}elem}}}}[]
wenzelm@43467
  1024
\rail@nextplus{1}
wenzelm@43467
  1025
\rail@endplus
wenzelm@43467
  1026
\rail@nextbar{2}
wenzelm@43488
  1027
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1028
\rail@nextbar{3}
wenzelm@43467
  1029
\rail@plus
wenzelm@43488
  1030
\rail@nont{\hyperlink{syntax.context-elem}{\mbox{\isa{context{\isaliteral{5F}{\isacharunderscore}}elem}}}}[]
wenzelm@43467
  1031
\rail@nextplus{4}
wenzelm@43467
  1032
\rail@endplus
wenzelm@43467
  1033
\rail@endbar
wenzelm@43467
  1034
\rail@end
wenzelm@43535
  1035
\rail@begin{2}{}
wenzelm@43467
  1036
\rail@term{\hyperlink{command.instantiation}{\mbox{\isa{\isacommand{instantiation}}}}}[]
wenzelm@43467
  1037
\rail@plus
wenzelm@43467
  1038
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1039
\rail@nextplus{1}
wenzelm@43467
  1040
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1041
\rail@endplus
wenzelm@43467
  1042
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1043
\rail@nont{\hyperlink{syntax.arity}{\mbox{\isa{arity}}}}[]
wenzelm@43467
  1044
\rail@term{\isa{\isakeyword{begin}}}[]
wenzelm@43467
  1045
\rail@end
wenzelm@43575
  1046
\rail@begin{5}{}
wenzelm@43467
  1047
\rail@term{\hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}}}[]
wenzelm@43575
  1048
\rail@bar
wenzelm@43575
  1049
\rail@nextbar{1}
wenzelm@43467
  1050
\rail@plus
wenzelm@43467
  1051
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43575
  1052
\rail@nextplus{2}
wenzelm@43467
  1053
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1054
\rail@endplus
wenzelm@43467
  1055
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1056
\rail@nont{\hyperlink{syntax.arity}{\mbox{\isa{arity}}}}[]
wenzelm@43575
  1057
\rail@nextbar{3}
wenzelm@43575
  1058
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43575
  1059
\rail@bar
wenzelm@43575
  1060
\rail@term{\isa{{\isaliteral{3C}{\isacharless}}}}[]
wenzelm@43575
  1061
\rail@nextbar{4}
wenzelm@43575
  1062
\rail@term{\isa{{\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}}}[]
wenzelm@43575
  1063
\rail@endbar
wenzelm@43575
  1064
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43575
  1065
\rail@endbar
wenzelm@43467
  1066
\rail@end
wenzelm@43535
  1067
\rail@begin{2}{}
wenzelm@43467
  1068
\rail@term{\hyperlink{command.subclass}{\mbox{\isa{\isacommand{subclass}}}}}[]
wenzelm@43467
  1069
\rail@bar
wenzelm@43467
  1070
\rail@nextbar{1}
wenzelm@43467
  1071
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
  1072
\rail@endbar
wenzelm@43467
  1073
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1074
\rail@end
wenzelm@43467
  1075
\end{railoutput}
wenzelm@43488
  1076
wenzelm@27042
  1077
wenzelm@28788
  1078
  \begin{description}
wenzelm@27042
  1079
wenzelm@40685
  1080
  \item \hyperlink{command.class}{\mbox{\isa{\isacommand{class}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{3D}{\isacharequal}}\ superclasses\ {\isaliteral{2B}{\isacharplus}}\ body{\isaliteral{22}{\isachardoublequote}}} defines
wenzelm@27042
  1081
  a new class \isa{c}, inheriting from \isa{superclasses}.  This
wenzelm@27042
  1082
  introduces a locale \isa{c} with import of all locales \isa{superclasses}.
wenzelm@27042
  1083
wenzelm@27042
  1084
  Any \hyperlink{element.fixes}{\mbox{\isa{\isakeyword{fixes}}}} in \isa{body} are lifted to the global
wenzelm@40685
  1085
  theory level (\emph{class operations} \isa{{\isaliteral{22}{\isachardoublequote}}f\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ f\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}} of class \isa{c}), mapping the local type parameter
wenzelm@40685
  1086
  \isa{{\isaliteral{5C3C616C7068613E}{\isasymalpha}}} to a schematic type variable \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ c{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@27042
  1087
wenzelm@27042
  1088
  Likewise, \hyperlink{element.assumes}{\mbox{\isa{\isakeyword{assumes}}}} in \isa{body} are also lifted,
wenzelm@40685
  1089
  mapping each local parameter \isa{{\isaliteral{22}{\isachardoublequote}}f\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} to its
wenzelm@40685
  1090
  corresponding global constant \isa{{\isaliteral{22}{\isachardoublequote}}f\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ c{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}}.  The
wenzelm@40685
  1091
  corresponding introduction rule is provided as \isa{c{\isaliteral{5F}{\isacharunderscore}}class{\isaliteral{5F}{\isacharunderscore}}axioms{\isaliteral{2E}{\isachardot}}intro}.  This rule should be rarely needed directly
wenzelm@40685
  1092
  --- the \hyperlink{method.intro-classes}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}classes}}} method takes care of the details of
wenzelm@27042
  1093
  class membership proofs.
wenzelm@27042
  1094
wenzelm@40685
  1095
  \item \hyperlink{command.instantiation}{\mbox{\isa{\isacommand{instantiation}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}s\ {\isaliteral{5C3C424547494E3E}{\isasymBEGIN}}{\isaliteral{22}{\isachardoublequote}}} opens a theory target (cf.\ \secref{sec:target}) which
wenzelm@40685
  1096
  allows to specify class operations \isa{{\isaliteral{22}{\isachardoublequote}}f\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ f\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}} corresponding
wenzelm@40685
  1097
  to sort \isa{s} at the particular type instance \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}}.  A plain \hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}} command in the
wenzelm@28788
  1098
  target body poses a goal stating these type arities.  The target is
wenzelm@28788
  1099
  concluded by an \indexref{local}{command}{end}\hyperlink{command.local.end}{\mbox{\isa{\isacommand{end}}}} command.
wenzelm@27042
  1100
wenzelm@27042
  1101
  Note that a list of simultaneous type constructors may be given;
haftmann@31908
  1102
  this corresponds nicely to mutually recursive type definitions, e.g.\
wenzelm@27042
  1103
  in Isabelle/HOL.
wenzelm@27042
  1104
wenzelm@28788
  1105
  \item \hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}} in an instantiation target body sets
wenzelm@40685
  1106
  up a goal stating the type arities claimed at the opening \hyperlink{command.instantiation}{\mbox{\isa{\isacommand{instantiation}}}}.  The proof would usually proceed by \hyperlink{method.intro-classes}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}classes}}}, and then establish the characteristic theorems of
wenzelm@27042
  1107
  the type classes involved.  After finishing the proof, the
wenzelm@27042
  1108
  background theory will be augmented by the proven type arities.
wenzelm@27042
  1109
wenzelm@40685
  1110
  On the theory level, \hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}s{\isaliteral{22}{\isachardoublequote}}} provides a convenient way to instantiate a type class with no
wenzelm@37115
  1111
  need to specify operations: one can continue with the
haftmann@31681
  1112
  instantiation proof immediately.
haftmann@31681
  1113
wenzelm@28788
  1114
  \item \hyperlink{command.subclass}{\mbox{\isa{\isacommand{subclass}}}}~\isa{c} in a class context for class
wenzelm@27042
  1115
  \isa{d} sets up a goal stating that class \isa{c} is logically
wenzelm@27042
  1116
  contained in class \isa{d}.  After finishing the proof, class
wenzelm@27042
  1117
  \isa{d} is proven to be subclass \isa{c} and the locale \isa{c} is interpreted into \isa{d} simultaneously.
wenzelm@27042
  1118
haftmann@31681
  1119
  A weakend form of this is available through a further variant of
wenzelm@40685
  1120
  \hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}}:  \hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}} opens
wenzelm@40685
  1121
  a proof that class \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}} implies \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E697375623E}{}\isactrlisub {\isadigit{1}}{\isaliteral{22}{\isachardoublequote}}} without reference
haftmann@31681
  1122
  to the underlying locales;  this is useful if the properties to prove
haftmann@31681
  1123
  the logical connection are not sufficent on the locale level but on
haftmann@31681
  1124
  the theory level.
haftmann@31681
  1125
wenzelm@40685
  1126
  \item \hyperlink{command.print-classes}{\mbox{\isa{\isacommand{print{\isaliteral{5F}{\isacharunderscore}}classes}}}} prints all classes in the current
wenzelm@27042
  1127
  theory.
wenzelm@27042
  1128
wenzelm@40685
  1129
  \item \hyperlink{command.class-deps}{\mbox{\isa{\isacommand{class{\isaliteral{5F}{\isacharunderscore}}deps}}}} visualizes all classes and their
haftmann@29706
  1130
  subclass relations as a Hasse diagram.
haftmann@29706
  1131
wenzelm@40685
  1132
  \item \hyperlink{method.intro-classes}{\mbox{\isa{intro{\isaliteral{5F}{\isacharunderscore}}classes}}} repeatedly expands all class
wenzelm@27042
  1133
  introduction rules of this theory.  Note that this method usually
wenzelm@27042
  1134
  needs not be named explicitly, as it is already included in the
wenzelm@27042
  1135
  default proof step (e.g.\ of \hyperlink{command.proof}{\mbox{\isa{\isacommand{proof}}}}).  In particular,
wenzelm@27042
  1136
  instantiation of trivial (syntactic) classes may be performed by a
wenzelm@40685
  1137
  single ``\hyperlink{command.ddot}{\mbox{\isa{\isacommand{{\isaliteral{2E}{\isachardot}}{\isaliteral{2E}{\isachardot}}}}}}'' proof step.
wenzelm@27042
  1138
wenzelm@28788
  1139
  \end{description}%
wenzelm@27042
  1140
\end{isamarkuptext}%
wenzelm@27042
  1141
\isamarkuptrue%
wenzelm@27042
  1142
%
wenzelm@27042
  1143
\isamarkupsubsection{The class target%
wenzelm@27042
  1144
}
wenzelm@27042
  1145
\isamarkuptrue%
wenzelm@27042
  1146
%
wenzelm@27042
  1147
\begin{isamarkuptext}%
wenzelm@27042
  1148
%FIXME check
wenzelm@27042
  1149
wenzelm@27042
  1150
  A named context may refer to a locale (cf.\ \secref{sec:target}).
wenzelm@27042
  1151
  If this locale is also a class \isa{c}, apart from the common
wenzelm@27042
  1152
  locale target behaviour the following happens.
wenzelm@27042
  1153
wenzelm@27042
  1154
  \begin{itemize}
wenzelm@27042
  1155
wenzelm@40685
  1156
  \item Local constant declarations \isa{{\isaliteral{22}{\isachardoublequote}}g{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} referring to the
wenzelm@40685
  1157
  local type parameter \isa{{\isaliteral{5C3C616C7068613E}{\isasymalpha}}} and local parameters \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
  1158
  are accompanied by theory-level constants \isa{{\isaliteral{22}{\isachardoublequote}}g{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ c{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
  1159
  referring to theory-level class operations \isa{{\isaliteral{22}{\isachardoublequote}}f{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ c{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@27042
  1160
wenzelm@27042
  1161
  \item Local theorem bindings are lifted as are assumptions.
wenzelm@27042
  1162
wenzelm@40685
  1163
  \item Local syntax refers to local operations \isa{{\isaliteral{22}{\isachardoublequote}}g{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} and
wenzelm@40685
  1164
  global operations \isa{{\isaliteral{22}{\isachardoublequote}}g{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ c{\isaliteral{5D}{\isacharbrackright}}{\isaliteral{22}{\isachardoublequote}}} uniformly.  Type inference
wenzelm@27042
  1165
  resolves ambiguities.  In rare cases, manual type annotations are
wenzelm@27042
  1166
  needed.
wenzelm@27042
  1167
  
wenzelm@27042
  1168
  \end{itemize}%
wenzelm@27042
  1169
\end{isamarkuptext}%
wenzelm@27042
  1170
\isamarkuptrue%
wenzelm@27042
  1171
%
haftmann@37768
  1172
\isamarkupsubsection{Co-regularity of type classes and arities%
haftmann@37768
  1173
}
haftmann@37768
  1174
\isamarkuptrue%
haftmann@37768
  1175
%
haftmann@37768
  1176
\begin{isamarkuptext}%
haftmann@37768
  1177
The class relation together with the collection of
haftmann@37768
  1178
  type-constructor arities must obey the principle of
haftmann@37768
  1179
  \emph{co-regularity} as defined below.
haftmann@37768
  1180
haftmann@37768
  1181
  \medskip For the subsequent formulation of co-regularity we assume
haftmann@37768
  1182
  that the class relation is closed by transitivity and reflexivity.
wenzelm@40685
  1183
  Moreover the collection of arities \isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec s{\isaliteral{29}{\isacharparenright}}c{\isaliteral{22}{\isachardoublequote}}} is
wenzelm@40685
  1184
  completed such that \isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec s{\isaliteral{29}{\isacharparenright}}c{\isaliteral{22}{\isachardoublequote}}} and \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c{\isaliteral{27}{\isacharprime}}{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
  1185
  implies \isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec s{\isaliteral{29}{\isacharparenright}}c{\isaliteral{27}{\isacharprime}}{\isaliteral{22}{\isachardoublequote}}} for all such declarations.
haftmann@37768
  1186
haftmann@37768
  1187
  Treating sorts as finite sets of classes (meaning the intersection),
wenzelm@40685
  1188
  the class relation \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}} is extended to sorts as
haftmann@37768
  1189
  follows:
haftmann@37768
  1190
  \[
wenzelm@40685
  1191
    \isa{{\isaliteral{22}{\isachardoublequote}}s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ {\isaliteral{5C3C666F72616C6C3E}{\isasymforall}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ {\isaliteral{5C3C696E3E}{\isasymin}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{2E}{\isachardot}}\ {\isaliteral{5C3C6578697374733E}{\isasymexists}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C696E3E}{\isasymin}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2E}{\isachardot}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}}
haftmann@37768
  1192
  \]
haftmann@37768
  1193
haftmann@37768
  1194
  This relation on sorts is further extended to tuples of sorts (of
haftmann@37768
  1195
  the same length) in the component-wise way.
haftmann@37768
  1196
haftmann@37768
  1197
  \smallskip Co-regularity of the class relation together with the
haftmann@37768
  1198
  arities relation means:
haftmann@37768
  1199
  \[
wenzelm@40685
  1200
    \isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{29}{\isacharparenright}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}\isaliteral{5C3C5E7665633E}{}\isactrlvec s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{29}{\isacharparenright}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ \isaliteral{5C3C5E7665633E}{}\isactrlvec s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}}
haftmann@37768
  1201
  \]
haftmann@37768
  1202
  \noindent for all such arities.  In other words, whenever the result
haftmann@37768
  1203
  classes of some type-constructor arities are related, then the
haftmann@37768
  1204
  argument sorts need to be related in the same way.
haftmann@37768
  1205
haftmann@37768
  1206
  \medskip Co-regularity is a very fundamental property of the
haftmann@37768
  1207
  order-sorted algebra of types.  For example, it entails principle
haftmann@37768
  1208
  types and most general unifiers, e.g.\ see \cite{nipkow-prehofer}.%
haftmann@37768
  1209
\end{isamarkuptext}%
haftmann@37768
  1210
\isamarkuptrue%
haftmann@37768
  1211
%
wenzelm@27042
  1212
\isamarkupsection{Unrestricted overloading%
wenzelm@27042
  1213
}
wenzelm@27042
  1214
\isamarkuptrue%
wenzelm@27042
  1215
%
wenzelm@27042
  1216
\begin{isamarkuptext}%
wenzelm@27042
  1217
Isabelle/Pure's definitional schemes support certain forms of
haftmann@31047
  1218
  overloading (see \secref{sec:consts}).  Overloading means that a
wenzelm@40685
  1219
  constant being declared as \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ decl{\isaliteral{22}{\isachardoublequote}}} may be
haftmann@31047
  1220
  defined separately on type instances
wenzelm@40685
  1221
  \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t\ decl{\isaliteral{22}{\isachardoublequote}}}
haftmann@31047
  1222
  for each type constructor \isa{t}.  At most occassions
wenzelm@27042
  1223
  overloading will be used in a Haskell-like fashion together with
wenzelm@27042
  1224
  type classes by means of \hyperlink{command.instantiation}{\mbox{\isa{\isacommand{instantiation}}}} (see
wenzelm@27042
  1225
  \secref{sec:class}).  Sometimes low-level overloading is desirable.
wenzelm@27042
  1226
  The \hyperlink{command.overloading}{\mbox{\isa{\isacommand{overloading}}}} target provides a convenient view for
wenzelm@27042
  1227
  end-users.
wenzelm@27042
  1228
wenzelm@27042
  1229
  \begin{matharray}{rcl}
wenzelm@40685
  1230
    \indexdef{}{command}{overloading}\hypertarget{command.overloading}{\hyperlink{command.overloading}{\mbox{\isa{\isacommand{overloading}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
  1231
  \end{matharray}
wenzelm@27042
  1232
wenzelm@43467
  1233
  \begin{railoutput}
wenzelm@43575
  1234
\rail@begin{2}{}
wenzelm@43467
  1235
\rail@term{\hyperlink{command.overloading}{\mbox{\isa{\isacommand{overloading}}}}}[]
wenzelm@43467
  1236
\rail@plus
wenzelm@43575
  1237
\rail@nont{\isa{spec}}[]
wenzelm@43575
  1238
\rail@nextplus{1}
wenzelm@43575
  1239
\rail@endplus
wenzelm@43575
  1240
\rail@term{\isa{\isakeyword{begin}}}[]
wenzelm@43575
  1241
\rail@end
wenzelm@43575
  1242
\rail@begin{2}{\isa{spec}}
wenzelm@43488
  1243
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1244
\rail@bar
wenzelm@43467
  1245
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43575
  1246
\rail@nextbar{1}
wenzelm@43467
  1247
\rail@term{\isa{{\isaliteral{5C3C65717569763E}{\isasymequiv}}}}[]
wenzelm@43467
  1248
\rail@endbar
wenzelm@43467
  1249
\rail@nont{\hyperlink{syntax.term}{\mbox{\isa{term}}}}[]
wenzelm@43467
  1250
\rail@bar
wenzelm@43575
  1251
\rail@nextbar{1}
wenzelm@43467
  1252
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1253
\rail@term{\isa{\isakeyword{unchecked}}}[]
wenzelm@43467
  1254
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1255
\rail@endbar
wenzelm@43467
  1256
\rail@end
wenzelm@43467
  1257
\end{railoutput}
wenzelm@43488
  1258
wenzelm@27042
  1259
wenzelm@28788
  1260
  \begin{description}
wenzelm@27042
  1261
wenzelm@40685
  1262
  \item \hyperlink{command.overloading}{\mbox{\isa{\isacommand{overloading}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}x\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C414E443E}{\isasymAND}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ x\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n\ {\isaliteral{5C3C424547494E3E}{\isasymBEGIN}}{\isaliteral{22}{\isachardoublequote}}}
wenzelm@27042
  1263
  opens a theory target (cf.\ \secref{sec:target}) which allows to
wenzelm@27042
  1264
  specify constants with overloaded definitions.  These are identified
wenzelm@40685
  1265
  by an explicitly given mapping from variable names \isa{{\isaliteral{22}{\isachardoublequote}}x\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} to
wenzelm@40685
  1266
  constants \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} at particular type instances.  The
wenzelm@28788
  1267
  definitions themselves are established using common specification
wenzelm@40685
  1268
  tools, using the names \isa{{\isaliteral{22}{\isachardoublequote}}x\isaliteral{5C3C5E7375623E}{}\isactrlsub i{\isaliteral{22}{\isachardoublequote}}} as reference to the
wenzelm@28788
  1269
  corresponding constants.  The target is concluded by \hyperlink{command.local.end}{\mbox{\isa{\isacommand{end}}}}.
wenzelm@27042
  1270
wenzelm@40685
  1271
  A \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}unchecked{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} option disables global dependency checks for
wenzelm@27042
  1272
  the corresponding definition, which is occasionally useful for
haftmann@31047
  1273
  exotic overloading (see \secref{sec:consts} for a precise description).
haftmann@31047
  1274
  It is at the discretion of the user to avoid
wenzelm@27042
  1275
  malformed theory specifications!
wenzelm@27042
  1276
wenzelm@28788
  1277
  \end{description}%
wenzelm@27042
  1278
\end{isamarkuptext}%
wenzelm@27042
  1279
\isamarkuptrue%
wenzelm@27042
  1280
%
wenzelm@27042
  1281
\isamarkupsection{Incorporating ML code \label{sec:ML}%
wenzelm@27042
  1282
}
wenzelm@27042
  1283
\isamarkuptrue%
wenzelm@27042
  1284
%
wenzelm@27042
  1285
\begin{isamarkuptext}%
wenzelm@27042
  1286
\begin{matharray}{rcl}
wenzelm@40685
  1287
    \indexdef{}{command}{use}\hypertarget{command.use}{\hyperlink{command.use}{\mbox{\isa{\isacommand{use}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1288
    \indexdef{}{command}{ML}\hypertarget{command.ML}{\hyperlink{command.ML}{\mbox{\isa{\isacommand{ML}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1289
    \indexdef{}{command}{ML\_prf}\hypertarget{command.ML-prf}{\hyperlink{command.ML-prf}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}prf}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}proof\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ proof{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1290
    \indexdef{}{command}{ML\_val}\hypertarget{command.ML-val}{\hyperlink{command.ML-val}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}val}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}any\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1291
    \indexdef{}{command}{ML\_command}\hypertarget{command.ML-command}{\hyperlink{command.ML-command}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}command}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}any\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1292
    \indexdef{}{command}{setup}\hypertarget{command.setup}{\hyperlink{command.setup}{\mbox{\isa{\isacommand{setup}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1293
    \indexdef{}{command}{local\_setup}\hypertarget{command.local-setup}{\hyperlink{command.local-setup}{\mbox{\isa{\isacommand{local{\isaliteral{5F}{\isacharunderscore}}setup}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1294
    \indexdef{}{command}{attribute\_setup}\hypertarget{command.attribute-setup}{\hyperlink{command.attribute-setup}{\mbox{\isa{\isacommand{attribute{\isaliteral{5F}{\isacharunderscore}}setup}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
  1295
  \end{matharray}
wenzelm@27042
  1296
wenzelm@43467
  1297
  \begin{railoutput}
wenzelm@43535
  1298
\rail@begin{1}{}
wenzelm@43467
  1299
\rail@term{\hyperlink{command.use}{\mbox{\isa{\isacommand{use}}}}}[]
wenzelm@43467
  1300
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1301
\rail@end
wenzelm@43535
  1302
\rail@begin{6}{}
wenzelm@43467
  1303
\rail@bar
wenzelm@43467
  1304
\rail@term{\hyperlink{command.ML}{\mbox{\isa{\isacommand{ML}}}}}[]
wenzelm@43467
  1305
\rail@nextbar{1}
wenzelm@43467
  1306
\rail@term{\hyperlink{command.ML-prf}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}prf}}}}}[]
wenzelm@43467
  1307
\rail@nextbar{2}
wenzelm@43467
  1308
\rail@term{\hyperlink{command.ML-val}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}val}}}}}[]
wenzelm@43467
  1309
\rail@nextbar{3}
wenzelm@43467
  1310
\rail@term{\hyperlink{command.ML-command}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}command}}}}}[]
wenzelm@43467
  1311
\rail@nextbar{4}
wenzelm@43467
  1312
\rail@term{\hyperlink{command.setup}{\mbox{\isa{\isacommand{setup}}}}}[]
wenzelm@43467
  1313
\rail@nextbar{5}
wenzelm@43467
  1314
\rail@term{\hyperlink{command.local-setup}{\mbox{\isa{\isacommand{local{\isaliteral{5F}{\isacharunderscore}}setup}}}}}[]
wenzelm@43467
  1315
\rail@endbar
wenzelm@43467
  1316
\rail@nont{\hyperlink{syntax.text}{\mbox{\isa{text}}}}[]
wenzelm@43467
  1317
\rail@end
wenzelm@43684
  1318
\rail@begin{2}{}
wenzelm@43467
  1319
\rail@term{\hyperlink{command.attribute-setup}{\mbox{\isa{\isacommand{attribute{\isaliteral{5F}{\isacharunderscore}}setup}}}}}[]
wenzelm@43467
  1320
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1321
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  1322
\rail@nont{\hyperlink{syntax.text}{\mbox{\isa{text}}}}[]
wenzelm@43684
  1323
\rail@bar
wenzelm@43684
  1324
\rail@nextbar{1}
wenzelm@43467
  1325
\rail@nont{\hyperlink{syntax.text}{\mbox{\isa{text}}}}[]
wenzelm@43684
  1326
\rail@endbar
wenzelm@43467
  1327
\rail@end
wenzelm@43467
  1328
\end{railoutput}
wenzelm@43467
  1329
wenzelm@27042
  1330
wenzelm@28788
  1331
  \begin{description}
wenzelm@27042
  1332
wenzelm@40685
  1333
  \item \hyperlink{command.use}{\mbox{\isa{\isacommand{use}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}file{\isaliteral{22}{\isachardoublequote}}} reads and executes ML
wenzelm@40685
  1334
  commands from \isa{{\isaliteral{22}{\isachardoublequote}}file{\isaliteral{22}{\isachardoublequote}}}.  The current theory context is passed
wenzelm@28788
  1335
  down to the ML toplevel and may be modified, using \verb|Context.>>| or derived ML commands.  The file name is checked with
wenzelm@27042
  1336
  the \indexref{}{keyword}{uses}\hyperlink{keyword.uses}{\mbox{\isa{\isakeyword{uses}}}} dependency declaration given in the theory
wenzelm@27042
  1337
  header (see also \secref{sec:begin-thy}).
wenzelm@28281
  1338
wenzelm@28281
  1339
  Top-level ML bindings are stored within the (global or local) theory
wenzelm@28281
  1340
  context.
wenzelm@27042
  1341
  
wenzelm@40685
  1342
  \item \hyperlink{command.ML}{\mbox{\isa{\isacommand{ML}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}text{\isaliteral{22}{\isachardoublequote}}} is similar to \hyperlink{command.use}{\mbox{\isa{\isacommand{use}}}},
wenzelm@40685
  1343
  but executes ML commands directly from the given \isa{{\isaliteral{22}{\isachardoublequote}}text{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@28788
  1344
  Top-level ML bindings are stored within the (global or local) theory
wenzelm@28788
  1345
  context.
wenzelm@28281
  1346
wenzelm@40685
  1347
  \item \hyperlink{command.ML-prf}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}prf}}}} is analogous to \hyperlink{command.ML}{\mbox{\isa{\isacommand{ML}}}} but works
wenzelm@28788
  1348
  within a proof context.
wenzelm@28281
  1349
wenzelm@28281
  1350
  Top-level ML bindings are stored within the proof context in a
wenzelm@28281
  1351
  purely sequential fashion, disregarding the nested proof structure.
wenzelm@40685
  1352
  ML bindings introduced by \hyperlink{command.ML-prf}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}prf}}}} are discarded at the
wenzelm@28281
  1353
  end of the proof.
wenzelm@27042
  1354
wenzelm@40685
  1355
  \item \hyperlink{command.ML-val}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}val}}}} and \hyperlink{command.ML-command}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}command}}}} are diagnostic
wenzelm@28788
  1356
  versions of \hyperlink{command.ML}{\mbox{\isa{\isacommand{ML}}}}, which means that the context may not be
wenzelm@40685
  1357
  updated.  \hyperlink{command.ML-val}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}val}}}} echos the bindings produced at the ML
wenzelm@40685
  1358
  toplevel, but \hyperlink{command.ML-command}{\mbox{\isa{\isacommand{ML{\isaliteral{5F}{\isacharunderscore}}command}}}} is silent.
wenzelm@27042
  1359
  
wenzelm@40685
  1360
  \item \hyperlink{command.setup}{\mbox{\isa{\isacommand{setup}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}text{\isaliteral{22}{\isachardoublequote}}} changes the current theory
wenzelm@40685
  1361
  context by applying \isa{{\isaliteral{22}{\isachardoublequote}}text{\isaliteral{22}{\isachardoublequote}}}, which refers to an ML expression
wenzelm@30463
  1362
  of type \verb|theory -> theory|.  This enables to initialize
wenzelm@30463
  1363
  any object-logic specific tools and packages written in ML, for
wenzelm@30463
  1364
  example.
wenzelm@30463
  1365
wenzelm@40685
  1366
  \item \hyperlink{command.local-setup}{\mbox{\isa{\isacommand{local{\isaliteral{5F}{\isacharunderscore}}setup}}}} is similar to \hyperlink{command.setup}{\mbox{\isa{\isacommand{setup}}}} for
wenzelm@30463
  1367
  a local theory context, and an ML expression of type \verb|local_theory -> local_theory|.  This allows to
wenzelm@30463
  1368
  invoke local theory specification packages without going through
wenzelm@30463
  1369
  concrete outer syntax, for example.
wenzelm@28788
  1370
wenzelm@40685
  1371
  \item \hyperlink{command.attribute-setup}{\mbox{\isa{\isacommand{attribute{\isaliteral{5F}{\isacharunderscore}}setup}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}name\ {\isaliteral{3D}{\isacharequal}}\ text\ description{\isaliteral{22}{\isachardoublequote}}}
wenzelm@40685
  1372
  defines an attribute in the current theory.  The given \isa{{\isaliteral{22}{\isachardoublequote}}text{\isaliteral{22}{\isachardoublequote}}} has to be an ML expression of type
wenzelm@30529
  1373
  \verb|attribute context_parser|, cf.\ basic parsers defined in
wenzelm@30529
  1374
  structure \verb|Args| and \verb|Attrib|.
wenzelm@30529
  1375
wenzelm@30529
  1376
  In principle, attributes can operate both on a given theorem and the
wenzelm@30529
  1377
  implicit context, although in practice only one is modified and the
wenzelm@30529
  1378
  other serves as parameter.  Here are examples for these two cases:
wenzelm@30529
  1379
wenzelm@30529
  1380
  \end{description}%
wenzelm@30529
  1381
\end{isamarkuptext}%
wenzelm@30529
  1382
\isamarkuptrue%
wenzelm@30529
  1383
%
wenzelm@30529
  1384
\isadelimML
wenzelm@43575
  1385
\ \ %
wenzelm@30529
  1386
\endisadelimML
wenzelm@30529
  1387
%
wenzelm@30529
  1388
\isatagML
wenzelm@40685
  1389
\isacommand{attribute{\isaliteral{5F}{\isacharunderscore}}setup}\isamarkupfalse%
wenzelm@40685
  1390
\ my{\isaliteral{5F}{\isacharunderscore}}rule\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{7B2A}{\isacharverbatimopen}}\isanewline
wenzelm@43575
  1391
\ \ \ \ Attrib{\isaliteral{2E}{\isachardot}}thms\ {\isaliteral{3E}{\isachargreater}}{\isaliteral{3E}{\isachargreater}}\ {\isaliteral{28}{\isacharparenleft}}fn\ ths\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{3E}{\isachargreater}}\isanewline
wenzelm@43575
  1392
\ \ \ \ \ \ Thm{\isaliteral{2E}{\isachardot}}rule{\isaliteral{5F}{\isacharunderscore}}attribute\isanewline
wenzelm@43575
  1393
\ \ \ \ \ \ \ \ {\isaliteral{28}{\isacharparenleft}}fn\ context{\isaliteral{3A}{\isacharcolon}}\ Context{\isaliteral{2E}{\isachardot}}generic\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{3E}{\isachargreater}}\ fn\ th{\isaliteral{3A}{\isacharcolon}}\ thm\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{3E}{\isachargreater}}\isanewline
wenzelm@40685
  1394
\ \ \ \ \ \ \ \ \ \ let\ val\ th{\isaliteral{27}{\isacharprime}}\ {\isaliteral{3D}{\isacharequal}}\ th\ OF\ ths\isanewline
wenzelm@44140
  1395
\ \ \ \ \ \ \ \ \ \ in\ th{\isaliteral{27}{\isacharprime}}\ end{\isaliteral{29}{\isacharparenright}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{2A7D}{\isacharverbatimclose}}\isanewline
wenzelm@30529
  1396
\isanewline
wenzelm@43575
  1397
\ \ \isacommand{attribute{\isaliteral{5F}{\isacharunderscore}}setup}\isamarkupfalse%
wenzelm@40685
  1398
\ my{\isaliteral{5F}{\isacharunderscore}}declaration\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{7B2A}{\isacharverbatimopen}}\isanewline
wenzelm@43575
  1399
\ \ \ \ Attrib{\isaliteral{2E}{\isachardot}}thms\ {\isaliteral{3E}{\isachargreater}}{\isaliteral{3E}{\isachargreater}}\ {\isaliteral{28}{\isacharparenleft}}fn\ ths\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{3E}{\isachargreater}}\isanewline
wenzelm@43575
  1400
\ \ \ \ \ \ Thm{\isaliteral{2E}{\isachardot}}declaration{\isaliteral{5F}{\isacharunderscore}}attribute\isanewline
wenzelm@43575
  1401
\ \ \ \ \ \ \ \ {\isaliteral{28}{\isacharparenleft}}fn\ th{\isaliteral{3A}{\isacharcolon}}\ thm\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{3E}{\isachargreater}}\ fn\ context{\isaliteral{3A}{\isacharcolon}}\ Context{\isaliteral{2E}{\isachardot}}generic\ {\isaliteral{3D}{\isacharequal}}{\isaliteral{3E}{\isachargreater}}\isanewline
wenzelm@40685
  1402
\ \ \ \ \ \ \ \ \ \ let\ val\ context{\isaliteral{27}{\isacharprime}}\ {\isaliteral{3D}{\isacharequal}}\ context\isanewline
wenzelm@44140
  1403
\ \ \ \ \ \ \ \ \ \ in\ context{\isaliteral{27}{\isacharprime}}\ end{\isaliteral{29}{\isacharparenright}}{\isaliteral{29}{\isacharparenright}}\ {\isaliteral{2A7D}{\isacharverbatimclose}}%
wenzelm@30529
  1404
\endisatagML
wenzelm@30529
  1405
{\isafoldML}%
wenzelm@30529
  1406
%
wenzelm@30529
  1407
\isadelimML
wenzelm@30529
  1408
%
wenzelm@30529
  1409
\endisadelimML
wenzelm@30529
  1410
%
wenzelm@27042
  1411
\isamarkupsection{Primitive specification elements%
wenzelm@27042
  1412
}
wenzelm@27042
  1413
\isamarkuptrue%
wenzelm@27042
  1414
%
wenzelm@27042
  1415
\isamarkupsubsection{Type classes and sorts \label{sec:classes}%
wenzelm@27042
  1416
}
wenzelm@27042
  1417
\isamarkuptrue%
wenzelm@27042
  1418
%
wenzelm@27042
  1419
\begin{isamarkuptext}%
wenzelm@27042
  1420
\begin{matharray}{rcll}
wenzelm@40685
  1421
    \indexdef{}{command}{classes}\hypertarget{command.classes}{\hyperlink{command.classes}{\mbox{\isa{\isacommand{classes}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1422
    \indexdef{}{command}{classrel}\hypertarget{command.classrel}{\hyperlink{command.classrel}{\mbox{\isa{\isacommand{classrel}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} & (axiomatic!) \\
wenzelm@40685
  1423
    \indexdef{}{command}{default\_sort}\hypertarget{command.default-sort}{\hyperlink{command.default-sort}{\mbox{\isa{\isacommand{default{\isaliteral{5F}{\isacharunderscore}}sort}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}}
wenzelm@27042
  1424
  \end{matharray}
wenzelm@27042
  1425
wenzelm@43467
  1426
  \begin{railoutput}
wenzelm@43535
  1427
\rail@begin{2}{}
wenzelm@43467
  1428
\rail@term{\hyperlink{command.classes}{\mbox{\isa{\isacommand{classes}}}}}[]
wenzelm@43467
  1429
\rail@plus
wenzelm@43467
  1430
\rail@nont{\hyperlink{syntax.classdecl}{\mbox{\isa{classdecl}}}}[]
wenzelm@43467
  1431
\rail@nextplus{1}
wenzelm@43467
  1432
\rail@endplus
wenzelm@43467
  1433
\rail@end
wenzelm@43535
  1434
\rail@begin{3}{}
wenzelm@43467
  1435
\rail@term{\hyperlink{command.classrel}{\mbox{\isa{\isacommand{classrel}}}}}[]
wenzelm@43467
  1436
\rail@plus
wenzelm@43467
  1437
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1438
\rail@bar
wenzelm@43467
  1439
\rail@term{\isa{{\isaliteral{3C}{\isacharless}}}}[]
wenzelm@43467
  1440
\rail@nextbar{1}
wenzelm@43467
  1441
\rail@term{\isa{{\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}}}[]
wenzelm@43467
  1442
\rail@endbar
wenzelm@43467
  1443
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1444
\rail@nextplus{2}
wenzelm@43467
  1445
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1446
\rail@endplus
wenzelm@43467
  1447
\rail@end
wenzelm@43535
  1448
\rail@begin{1}{}
wenzelm@43467
  1449
\rail@term{\hyperlink{command.default-sort}{\mbox{\isa{\isacommand{default{\isaliteral{5F}{\isacharunderscore}}sort}}}}}[]
wenzelm@43467
  1450
\rail@nont{\hyperlink{syntax.sort}{\mbox{\isa{sort}}}}[]
wenzelm@43467
  1451
\rail@end
wenzelm@43467
  1452
\end{railoutput}
wenzelm@43467
  1453
wenzelm@27042
  1454
wenzelm@28788
  1455
  \begin{description}
wenzelm@27042
  1456
wenzelm@40685
  1457
  \item \hyperlink{command.classes}{\mbox{\isa{\isacommand{classes}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}} declares class
wenzelm@40685
  1458
  \isa{c} to be a subclass of existing classes \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@28788
  1459
  Isabelle implicitly maintains the transitive closure of the class
wenzelm@28788
  1460
  hierarchy.  Cyclic class structures are not permitted.
wenzelm@27042
  1461
wenzelm@40685
  1462
  \item \hyperlink{command.classrel}{\mbox{\isa{\isacommand{classrel}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C73756273657465713E}{\isasymsubseteq}}\ c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}} states subclass
wenzelm@40685
  1463
  relations between existing classes \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{22}{\isachardoublequote}}} and \isa{{\isaliteral{22}{\isachardoublequote}}c\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{22}{\isachardoublequote}}}.
haftmann@37768
  1464
  This is done axiomatically!  The \indexref{}{command}{subclass}\hyperlink{command.subclass}{\mbox{\isa{\isacommand{subclass}}}} and
haftmann@37768
  1465
  \indexref{}{command}{instance}\hyperlink{command.instance}{\mbox{\isa{\isacommand{instance}}}} commands (see \secref{sec:class}) provide
haftmann@37768
  1466
  a way to introduce proven class relations.
wenzelm@27042
  1467
wenzelm@40685
  1468
  \item \hyperlink{command.default-sort}{\mbox{\isa{\isacommand{default{\isaliteral{5F}{\isacharunderscore}}sort}}}}~\isa{s} makes sort \isa{s} the
wenzelm@28788
  1469
  new default sort for any type variable that is given explicitly in
wenzelm@28788
  1470
  the text, but lacks a sort constraint (wrt.\ the current context).
wenzelm@28788
  1471
  Type variables generated by type inference are not affected.
wenzelm@27042
  1472
wenzelm@28788
  1473
  Usually the default sort is only changed when defining a new
wenzelm@28788
  1474
  object-logic.  For example, the default sort in Isabelle/HOL is
wenzelm@40270
  1475
  \isa{type}, the class of all HOL types.
wenzelm@28788
  1476
wenzelm@28788
  1477
  When merging theories, the default sorts of the parents are
wenzelm@28788
  1478
  logically intersected, i.e.\ the representations as lists of classes
wenzelm@28788
  1479
  are joined.
wenzelm@28788
  1480
wenzelm@28788
  1481
  \end{description}%
wenzelm@27042
  1482
\end{isamarkuptext}%
wenzelm@27042
  1483
\isamarkuptrue%
wenzelm@27042
  1484
%
wenzelm@27042
  1485
\isamarkupsubsection{Types and type abbreviations \label{sec:types-pure}%
wenzelm@27042
  1486
}
wenzelm@27042
  1487
\isamarkuptrue%
wenzelm@27042
  1488
%
wenzelm@27042
  1489
\begin{isamarkuptext}%
wenzelm@27042
  1490
\begin{matharray}{rcll}
wenzelm@41497
  1491
    \indexdef{}{command}{type\_synonym}\hypertarget{command.type-synonym}{\hyperlink{command.type-synonym}{\mbox{\isa{\isacommand{type{\isaliteral{5F}{\isacharunderscore}}synonym}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1492
    \indexdef{}{command}{typedecl}\hypertarget{command.typedecl}{\hyperlink{command.typedecl}{\mbox{\isa{\isacommand{typedecl}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1493
    \indexdef{}{command}{arities}\hypertarget{command.arities}{\hyperlink{command.arities}{\mbox{\isa{\isacommand{arities}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} & (axiomatic!) \\
wenzelm@27042
  1494
  \end{matharray}
wenzelm@27042
  1495
wenzelm@43467
  1496
  \begin{railoutput}
wenzelm@43535
  1497
\rail@begin{2}{}
wenzelm@43467
  1498
\rail@term{\hyperlink{command.type-synonym}{\mbox{\isa{\isacommand{type{\isaliteral{5F}{\isacharunderscore}}synonym}}}}}[]
wenzelm@43467
  1499
\rail@nont{\hyperlink{syntax.typespec}{\mbox{\isa{typespec}}}}[]
wenzelm@43467
  1500
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  1501
\rail@nont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
  1502
\rail@bar
wenzelm@43467
  1503
\rail@nextbar{1}
wenzelm@43467
  1504
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
  1505
\rail@endbar
wenzelm@43467
  1506
\rail@end
wenzelm@43535
  1507
\rail@begin{2}{}
wenzelm@43467
  1508
\rail@term{\hyperlink{command.typedecl}{\mbox{\isa{\isacommand{typedecl}}}}}[]
wenzelm@43467
  1509
\rail@nont{\hyperlink{syntax.typespec}{\mbox{\isa{typespec}}}}[]
wenzelm@43467
  1510
\rail@bar
wenzelm@43467
  1511
\rail@nextbar{1}
wenzelm@43467
  1512
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
  1513
\rail@endbar
wenzelm@43467
  1514
\rail@end
wenzelm@43535
  1515
\rail@begin{2}{}
wenzelm@43467
  1516
\rail@term{\hyperlink{command.arities}{\mbox{\isa{\isacommand{arities}}}}}[]
wenzelm@43467
  1517
\rail@plus
wenzelm@43467
  1518
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1519
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1520
\rail@nont{\hyperlink{syntax.arity}{\mbox{\isa{arity}}}}[]
wenzelm@43467
  1521
\rail@nextplus{1}
wenzelm@43467
  1522
\rail@endplus
wenzelm@43467
  1523
\rail@end
wenzelm@43467
  1524
\end{railoutput}
wenzelm@43467
  1525
wenzelm@27042
  1526
wenzelm@28788
  1527
  \begin{description}
wenzelm@27042
  1528
wenzelm@41497
  1529
  \item \hyperlink{command.type-synonym}{\mbox{\isa{\isacommand{type{\isaliteral{5F}{\isacharunderscore}}synonym}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t\ {\isaliteral{3D}{\isacharequal}}\ {\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}}
wenzelm@41497
  1530
  introduces a \emph{type synonym} \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} for the
wenzelm@41497
  1531
  existing type \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C7461753E}{\isasymtau}}{\isaliteral{22}{\isachardoublequote}}}.  Unlike actual type definitions, as are
wenzelm@41497
  1532
  available in Isabelle/HOL for example, type synonyms are merely
wenzelm@41497
  1533
  syntactic abbreviations without any logical significance.
wenzelm@41497
  1534
  Internally, type synonyms are fully expanded.
wenzelm@27042
  1535
  
wenzelm@40685
  1536
  \item \hyperlink{command.typedecl}{\mbox{\isa{\isacommand{typedecl}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}{\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}\ t{\isaliteral{22}{\isachardoublequote}}} declares a new
wenzelm@28788
  1537
  type constructor \isa{t}.  If the object-logic defines a base sort
wenzelm@28788
  1538
  \isa{s}, then the constructor is declared to operate on that, via
wenzelm@40685
  1539
  the axiomatic specification \hyperlink{command.arities}{\mbox{\isa{\isacommand{arities}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}s{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ s{\isaliteral{29}{\isacharparenright}}s{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@27042
  1540
wenzelm@40685
  1541
  \item \hyperlink{command.arities}{\mbox{\isa{\isacommand{arities}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}t\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{28}{\isacharparenleft}}s\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ s\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{29}{\isacharparenright}}s{\isaliteral{22}{\isachardoublequote}}} augments
wenzelm@28788
  1542
  Isabelle's order-sorted signature of types by new type constructor
haftmann@35282
  1543
  arities.  This is done axiomatically!  The \indexref{}{command}{instantiation}\hyperlink{command.instantiation}{\mbox{\isa{\isacommand{instantiation}}}}
haftmann@35282
  1544
  target (see \secref{sec:class}) provides a way to introduce
wenzelm@28788
  1545
  proven type arities.
wenzelm@27042
  1546
wenzelm@28788
  1547
  \end{description}%
wenzelm@28788
  1548
\end{isamarkuptext}%
wenzelm@28788
  1549
\isamarkuptrue%
wenzelm@28788
  1550
%
wenzelm@27042
  1551
\isamarkupsubsection{Constants and definitions \label{sec:consts}%
wenzelm@27042
  1552
}
wenzelm@27042
  1553
\isamarkuptrue%
wenzelm@27042
  1554
%
wenzelm@27042
  1555
\begin{isamarkuptext}%
wenzelm@27042
  1556
Definitions essentially express abbreviations within the logic.  The
wenzelm@40685
  1557
  simplest form of a definition is \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{22}{\isachardoublequote}}}, where \isa{c} is a newly declared constant.  Isabelle also allows derived forms
wenzelm@27042
  1558
  where the arguments of \isa{c} appear on the left, abbreviating a
wenzelm@40685
  1559
  prefix of \isa{{\isaliteral{5C3C6C616D6264613E}{\isasymlambda}}}-abstractions, e.g.\ \isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ {\isaliteral{5C3C6C616D6264613E}{\isasymlambda}}x\ y{\isaliteral{2E}{\isachardot}}\ t{\isaliteral{22}{\isachardoublequote}}} may be
wenzelm@40685
  1560
  written more conveniently as \isa{{\isaliteral{22}{\isachardoublequote}}c\ x\ y\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{22}{\isachardoublequote}}}.  Moreover,
wenzelm@27042
  1561
  definitions may be weakened by adding arbitrary pre-conditions:
wenzelm@40685
  1562
  \isa{{\isaliteral{22}{\isachardoublequote}}A\ {\isaliteral{5C3C4C6F6E6772696768746172726F773E}{\isasymLongrightarrow}}\ c\ x\ y\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ t{\isaliteral{22}{\isachardoublequote}}}.
wenzelm@27042
  1563
wenzelm@27042
  1564
  \medskip The built-in well-formedness conditions for definitional
wenzelm@27042
  1565
  specifications are:
wenzelm@27042
  1566
wenzelm@27042
  1567
  \begin{itemize}
wenzelm@27042
  1568
wenzelm@27042
  1569
  \item Arguments (on the left-hand side) must be distinct variables.
wenzelm@27042
  1570
wenzelm@27042
  1571
  \item All variables on the right-hand side must also appear on the
wenzelm@27042
  1572
  left-hand side.
wenzelm@27042
  1573
wenzelm@27042
  1574
  \item All type variables on the right-hand side must also appear on
wenzelm@40685
  1575
  the left-hand side; this prohibits \isa{{\isaliteral{22}{\isachardoublequote}}{\isadigit{0}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ nat\ {\isaliteral{5C3C65717569763E}{\isasymequiv}}\ length\ {\isaliteral{28}{\isacharparenleft}}{\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5D}{\isacharbrackright}}\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ list{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} for example.
wenzelm@27042
  1576
wenzelm@27042
  1577
  \item The definition must not be recursive.  Most object-logics
wenzelm@27042
  1578
  provide definitional principles that can be used to express
wenzelm@27042
  1579
  recursion safely.
wenzelm@27042
  1580
wenzelm@27042
  1581
  \end{itemize}
wenzelm@27042
  1582
haftmann@31047
  1583
  The right-hand side of overloaded definitions may mention overloaded constants
wenzelm@27042
  1584
  recursively at type instances corresponding to the immediate
wenzelm@40685
  1585
  argument types \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C626574613E}{\isasymbeta}}\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}.  Incomplete
wenzelm@27042
  1586
  specification patterns impose global constraints on all occurrences,
wenzelm@40685
  1587
  e.g.\ \isa{{\isaliteral{22}{\isachardoublequote}}d\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{5C3C74696D65733E}{\isasymtimes}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}{\isaliteral{22}{\isachardoublequote}}} on the left-hand side means that all
wenzelm@27042
  1588
  corresponding occurrences on some right-hand side need to be an
wenzelm@40685
  1589
  instance of this, general \isa{{\isaliteral{22}{\isachardoublequote}}d\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C616C7068613E}{\isasymalpha}}\ {\isaliteral{5C3C74696D65733E}{\isasymtimes}}\ {\isaliteral{5C3C626574613E}{\isasymbeta}}{\isaliteral{22}{\isachardoublequote}}} will be disallowed.
wenzelm@27042
  1590
wenzelm@27042
  1591
  \begin{matharray}{rcl}
wenzelm@40685
  1592
    \indexdef{}{command}{consts}\hypertarget{command.consts}{\hyperlink{command.consts}{\mbox{\isa{\isacommand{consts}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1593
    \indexdef{}{command}{defs}\hypertarget{command.defs}{\hyperlink{command.defs}{\mbox{\isa{\isacommand{defs}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
  1594
  \end{matharray}
wenzelm@27042
  1595
wenzelm@43467
  1596
  \begin{railoutput}
wenzelm@43535
  1597
\rail@begin{3}{}
wenzelm@43467
  1598
\rail@term{\hyperlink{command.consts}{\mbox{\isa{\isacommand{consts}}}}}[]
wenzelm@43467
  1599
\rail@plus
wenzelm@43467
  1600
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1601
\rail@term{\isa{{\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}}}[]
wenzelm@43467
  1602
\rail@nont{\hyperlink{syntax.type}{\mbox{\isa{type}}}}[]
wenzelm@43467
  1603
\rail@bar
wenzelm@43467
  1604
\rail@nextbar{1}
wenzelm@43467
  1605
\rail@nont{\hyperlink{syntax.mixfix}{\mbox{\isa{mixfix}}}}[]
wenzelm@43467
  1606
\rail@endbar
wenzelm@43467
  1607
\rail@nextplus{2}
wenzelm@43467
  1608
\rail@endplus
wenzelm@43467
  1609
\rail@end
wenzelm@43575
  1610
\rail@begin{2}{}
wenzelm@43467
  1611
\rail@term{\hyperlink{command.defs}{\mbox{\isa{\isacommand{defs}}}}}[]
wenzelm@43467
  1612
\rail@bar
wenzelm@43467
  1613
\rail@nextbar{1}
wenzelm@43575
  1614
\rail@nont{\isa{opt}}[]
wenzelm@43575
  1615
\rail@endbar
wenzelm@43575
  1616
\rail@plus
wenzelm@43575
  1617
\rail@nont{\hyperlink{syntax.axmdecl}{\mbox{\isa{axmdecl}}}}[]
wenzelm@43575
  1618
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43575
  1619
\rail@nextplus{1}
wenzelm@43575
  1620
\rail@endplus
wenzelm@43575
  1621
\rail@end
wenzelm@43575
  1622
\rail@begin{2}{\isa{opt}}
wenzelm@43467
  1623
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1624
\rail@bar
wenzelm@43575
  1625
\rail@nextbar{1}
wenzelm@43467
  1626
\rail@term{\isa{\isakeyword{unchecked}}}[]
wenzelm@43467
  1627
\rail@endbar
wenzelm@43467
  1628
\rail@bar
wenzelm@43575
  1629
\rail@nextbar{1}
wenzelm@43467
  1630
\rail@term{\isa{\isakeyword{overloaded}}}[]
wenzelm@43467
  1631
\rail@endbar
wenzelm@43467
  1632
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1633
\rail@end
wenzelm@43467
  1634
\end{railoutput}
wenzelm@43467
  1635
wenzelm@27042
  1636
wenzelm@28788
  1637
  \begin{description}
wenzelm@27042
  1638
wenzelm@40685
  1639
  \item \hyperlink{command.consts}{\mbox{\isa{\isacommand{consts}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}c\ {\isaliteral{3A}{\isacharcolon}}{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7369676D613E}{\isasymsigma}}{\isaliteral{22}{\isachardoublequote}}} declares constant \isa{c} to have any instance of type scheme \isa{{\isaliteral{5C3C7369676D613E}{\isasymsigma}}}.  The optional
wenzelm@28788
  1640
  mixfix annotations may attach concrete syntax to the constants
wenzelm@28788
  1641
  declared.
wenzelm@27042
  1642
  
wenzelm@40685
  1643
  \item \hyperlink{command.defs}{\mbox{\isa{\isacommand{defs}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}name{\isaliteral{3A}{\isacharcolon}}\ eqn{\isaliteral{22}{\isachardoublequote}}} introduces \isa{eqn}
wenzelm@27042
  1644
  as a definitional axiom for some existing constant.
wenzelm@27042
  1645
  
wenzelm@40685
  1646
  The \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}unchecked{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} option disables global dependency checks
wenzelm@27042
  1647
  for this definition, which is occasionally useful for exotic
wenzelm@27042
  1648
  overloading.  It is at the discretion of the user to avoid malformed
wenzelm@27042
  1649
  theory specifications!
wenzelm@27042
  1650
  
wenzelm@40685
  1651
  The \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}overloaded{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}} option declares definitions to be
wenzelm@27042
  1652
  potentially overloaded.  Unless this option is given, a warning
wenzelm@27042
  1653
  message would be issued for any definitional equation with a more
wenzelm@27042
  1654
  special type than that of the corresponding constant declaration.
wenzelm@27042
  1655
  
wenzelm@28788
  1656
  \end{description}%
wenzelm@27042
  1657
\end{isamarkuptext}%
wenzelm@27042
  1658
\isamarkuptrue%
wenzelm@27042
  1659
%
wenzelm@27042
  1660
\isamarkupsection{Axioms and theorems \label{sec:axms-thms}%
wenzelm@27042
  1661
}
wenzelm@27042
  1662
\isamarkuptrue%
wenzelm@27042
  1663
%
wenzelm@27042
  1664
\begin{isamarkuptext}%
wenzelm@27042
  1665
\begin{matharray}{rcll}
wenzelm@40685
  1666
    \indexdef{}{command}{axioms}\hypertarget{command.axioms}{\hyperlink{command.axioms}{\mbox{\isa{\isacommand{axioms}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} & (axiomatic!) \\
wenzelm@40685
  1667
    \indexdef{}{command}{lemmas}\hypertarget{command.lemmas}{\hyperlink{command.lemmas}{\mbox{\isa{\isacommand{lemmas}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1668
    \indexdef{}{command}{theorems}\hypertarget{command.theorems}{\hyperlink{command.theorems}{\mbox{\isa{\isacommand{theorems}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}local{\isaliteral{5F}{\isacharunderscore}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ local{\isaliteral{5F}{\isacharunderscore}}theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
  1669
  \end{matharray}
wenzelm@27042
  1670
wenzelm@43467
  1671
  \begin{railoutput}
wenzelm@43535
  1672
\rail@begin{2}{}
wenzelm@43467
  1673
\rail@term{\hyperlink{command.axioms}{\mbox{\isa{\isacommand{axioms}}}}}[]
wenzelm@43467
  1674
\rail@plus
wenzelm@43467
  1675
\rail@nont{\hyperlink{syntax.axmdecl}{\mbox{\isa{axmdecl}}}}[]
wenzelm@43467
  1676
\rail@nont{\hyperlink{syntax.prop}{\mbox{\isa{prop}}}}[]
wenzelm@43467
  1677
\rail@nextplus{1}
wenzelm@43467
  1678
\rail@endplus
wenzelm@43467
  1679
\rail@end
wenzelm@46471
  1680
\rail@begin{6}{}
wenzelm@43467
  1681
\rail@bar
wenzelm@43467
  1682
\rail@term{\hyperlink{command.lemmas}{\mbox{\isa{\isacommand{lemmas}}}}}[]
wenzelm@43467
  1683
\rail@nextbar{1}
wenzelm@43467
  1684
\rail@term{\hyperlink{command.theorems}{\mbox{\isa{\isacommand{theorems}}}}}[]
wenzelm@43467
  1685
\rail@endbar
wenzelm@43467
  1686
\rail@bar
wenzelm@43467
  1687
\rail@nextbar{1}
wenzelm@43467
  1688
\rail@nont{\hyperlink{syntax.target}{\mbox{\isa{target}}}}[]
wenzelm@43467
  1689
\rail@endbar
wenzelm@46471
  1690
\rail@cr{3}
wenzelm@43467
  1691
\rail@plus
wenzelm@43467
  1692
\rail@bar
wenzelm@46471
  1693
\rail@nextbar{4}
wenzelm@43467
  1694
\rail@nont{\hyperlink{syntax.thmdef}{\mbox{\isa{thmdef}}}}[]
wenzelm@43467
  1695
\rail@endbar
wenzelm@43467
  1696
\rail@nont{\hyperlink{syntax.thmrefs}{\mbox{\isa{thmrefs}}}}[]
wenzelm@46471
  1697
\rail@nextplus{5}
wenzelm@43467
  1698
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@43467
  1699
\rail@endplus
wenzelm@46471
  1700
\rail@bar
wenzelm@46471
  1701
\rail@nextbar{4}
wenzelm@46471
  1702
\rail@term{\isa{\isakeyword{for}}}[]
wenzelm@46471
  1703
\rail@plus
wenzelm@46471
  1704
\rail@nont{\hyperlink{syntax.vars}{\mbox{\isa{vars}}}}[]
wenzelm@46471
  1705
\rail@nextplus{5}
wenzelm@46471
  1706
\rail@cterm{\isa{\isakeyword{and}}}[]
wenzelm@46471
  1707
\rail@endplus
wenzelm@46471
  1708
\rail@endbar
wenzelm@43467
  1709
\rail@end
wenzelm@43467
  1710
\end{railoutput}
wenzelm@43467
  1711
wenzelm@27042
  1712
wenzelm@28788
  1713
  \begin{description}
wenzelm@27042
  1714
  
wenzelm@40685
  1715
  \item \hyperlink{command.axioms}{\mbox{\isa{\isacommand{axioms}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}a{\isaliteral{3A}{\isacharcolon}}\ {\isaliteral{5C3C7068693E}{\isasymphi}}{\isaliteral{22}{\isachardoublequote}}} introduces arbitrary
wenzelm@27042
  1716
  statements as axioms of the meta-logic.  In fact, axioms are
wenzelm@27042
  1717
  ``axiomatic theorems'', and may be referred later just as any other
wenzelm@27042
  1718
  theorem.
wenzelm@27042
  1719
  
wenzelm@27042
  1720
  Axioms are usually only introduced when declaring new logical
wenzelm@27042
  1721
  systems.  Everyday work is typically done the hard way, with proper
wenzelm@27042
  1722
  definitions and proven theorems.
wenzelm@27042
  1723
  
wenzelm@46471
  1724
  \item \hyperlink{command.lemmas}{\mbox{\isa{\isacommand{lemmas}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}a\ {\isaliteral{3D}{\isacharequal}}\ b\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ b\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{22}{\isachardoublequote}}}~\indexdef{}{keyword}{for}\hypertarget{keyword.for}{\hyperlink{keyword.for}{\mbox{\isa{\isakeyword{for}}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}x\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ x\isaliteral{5C3C5E7375623E}{}\isactrlsub m{\isaliteral{22}{\isachardoublequote}}} evaluates given facts (with attributes) in
wenzelm@46471
  1725
  the current context, which may be augmented by local variables.
wenzelm@46471
  1726
  Results are standardized before being stored, i.e.\ schematic
wenzelm@46471
  1727
  variables are renamed to enforce index \isa{{\isaliteral{22}{\isachardoublequote}}{\isadigit{0}}{\isaliteral{22}{\isachardoublequote}}} uniformly.
wenzelm@46471
  1728
wenzelm@46471
  1729
  \item \hyperlink{command.theorems}{\mbox{\isa{\isacommand{theorems}}}} is the same as \hyperlink{command.lemmas}{\mbox{\isa{\isacommand{lemmas}}}}, but
wenzelm@46471
  1730
  marks the result as a different kind of facts.
wenzelm@27042
  1731
wenzelm@28788
  1732
  \end{description}%
wenzelm@27042
  1733
\end{isamarkuptext}%
wenzelm@27042
  1734
\isamarkuptrue%
wenzelm@27042
  1735
%
wenzelm@27042
  1736
\isamarkupsection{Oracles%
wenzelm@27042
  1737
}
wenzelm@27042
  1738
\isamarkuptrue%
wenzelm@27042
  1739
%
wenzelm@27042
  1740
\begin{isamarkuptext}%
wenzelm@28788
  1741
Oracles allow Isabelle to take advantage of external reasoners
wenzelm@28788
  1742
  such as arithmetic decision procedures, model checkers, fast
wenzelm@28788
  1743
  tautology checkers or computer algebra systems.  Invoked as an
wenzelm@28788
  1744
  oracle, an external reasoner can create arbitrary Isabelle theorems.
wenzelm@28788
  1745
wenzelm@28788
  1746
  It is the responsibility of the user to ensure that the external
wenzelm@28788
  1747
  reasoner is as trustworthy as the application requires.  Another
wenzelm@28788
  1748
  typical source of errors is the linkup between Isabelle and the
wenzelm@28788
  1749
  external tool, not just its concrete implementation, but also the
wenzelm@28788
  1750
  required translation between two different logical environments.
wenzelm@28788
  1751
wenzelm@28788
  1752
  Isabelle merely guarantees well-formedness of the propositions being
wenzelm@28788
  1753
  asserted, and records within the internal derivation object how
wenzelm@28788
  1754
  presumed theorems depend on unproven suppositions.
wenzelm@28788
  1755
wenzelm@40496
  1756
  \begin{matharray}{rcll}
wenzelm@40685
  1757
    \indexdef{}{command}{oracle}\hypertarget{command.oracle}{\hyperlink{command.oracle}{\mbox{\isa{\isacommand{oracle}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} & (axiomatic!) \\
wenzelm@27042
  1758
  \end{matharray}
wenzelm@27042
  1759
wenzelm@43467
  1760
  \begin{railoutput}
wenzelm@43535
  1761
\rail@begin{1}{}
wenzelm@43467
  1762
\rail@term{\hyperlink{command.oracle}{\mbox{\isa{\isacommand{oracle}}}}}[]
wenzelm@43467
  1763
\rail@nont{\hyperlink{syntax.name}{\mbox{\isa{name}}}}[]
wenzelm@43467
  1764
\rail@term{\isa{{\isaliteral{3D}{\isacharequal}}}}[]
wenzelm@43467
  1765
\rail@nont{\hyperlink{syntax.text}{\mbox{\isa{text}}}}[]
wenzelm@43467
  1766
\rail@end
wenzelm@43467
  1767
\end{railoutput}
wenzelm@43467
  1768
wenzelm@27042
  1769
wenzelm@28788
  1770
  \begin{description}
wenzelm@27042
  1771
wenzelm@40685
  1772
  \item \hyperlink{command.oracle}{\mbox{\isa{\isacommand{oracle}}}}~\isa{{\isaliteral{22}{\isachardoublequote}}name\ {\isaliteral{3D}{\isacharequal}}\ text{\isaliteral{22}{\isachardoublequote}}} turns the given ML
wenzelm@40685
  1773
  expression \isa{{\isaliteral{22}{\isachardoublequote}}text{\isaliteral{22}{\isachardoublequote}}} of type \verb|'a -> cterm| into an
wenzelm@28291
  1774
  ML function of type \verb|'a -> thm|, which is bound to the
wenzelm@28788
  1775
  global identifier \verb|name|.  This acts like an infinitary
wenzelm@28788
  1776
  specification of axioms!  Invoking the oracle only works within the
wenzelm@28788
  1777
  scope of the resulting theory.
wenzelm@27042
  1778
wenzelm@28788
  1779
  \end{description}
wenzelm@28788
  1780
wenzelm@41052
  1781
  See \verb|~~/src/HOL/ex/Iff_Oracle.thy| for a worked example of
wenzelm@28788
  1782
  defining a new primitive rule as oracle, and turning it into a proof
wenzelm@28788
  1783
  method.%
wenzelm@27042
  1784
\end{isamarkuptext}%
wenzelm@27042
  1785
\isamarkuptrue%
wenzelm@27042
  1786
%
wenzelm@27042
  1787
\isamarkupsection{Name spaces%
wenzelm@27042
  1788
}
wenzelm@27042
  1789
\isamarkuptrue%
wenzelm@27042
  1790
%
wenzelm@27042
  1791
\begin{isamarkuptext}%
wenzelm@27042
  1792
\begin{matharray}{rcl}
wenzelm@40685
  1793
    \indexdef{}{command}{hide\_class}\hypertarget{command.hide-class}{\hyperlink{command.hide-class}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}class}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1794
    \indexdef{}{command}{hide\_type}\hypertarget{command.hide-type}{\hyperlink{command.hide-type}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}type}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1795
    \indexdef{}{command}{hide\_const}\hypertarget{command.hide-const}{\hyperlink{command.hide-const}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}const}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@40685
  1796
    \indexdef{}{command}{hide\_fact}\hypertarget{command.hide-fact}{\hyperlink{command.hide-fact}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}fact}}}}} & : & \isa{{\isaliteral{22}{\isachardoublequote}}theory\ {\isaliteral{5C3C72696768746172726F773E}{\isasymrightarrow}}\ theory{\isaliteral{22}{\isachardoublequote}}} \\
wenzelm@27042
  1797
  \end{matharray}
wenzelm@27042
  1798
wenzelm@43467
  1799
  \begin{railoutput}
wenzelm@43535
  1800
\rail@begin{4}{}
wenzelm@43467
  1801
\rail@bar
wenzelm@43467
  1802
\rail@nont{\hyperlink{command.hide-class}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}class}}}}}[]
wenzelm@43467
  1803
\rail@nextbar{1}
wenzelm@43467
  1804
\rail@nont{\hyperlink{command.hide-type}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}type}}}}}[]
wenzelm@43467
  1805
\rail@nextbar{2}
wenzelm@43467
  1806
\rail@nont{\hyperlink{command.hide-const}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}const}}}}}[]
wenzelm@43467
  1807
\rail@nextbar{3}
wenzelm@43467
  1808
\rail@nont{\hyperlink{command.hide-fact}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}fact}}}}}[]
wenzelm@43467
  1809
\rail@endbar
wenzelm@43467
  1810
\rail@bar
wenzelm@43467
  1811
\rail@nextbar{1}
wenzelm@43467
  1812
\rail@term{\isa{{\isaliteral{28}{\isacharparenleft}}}}[]
wenzelm@43467
  1813
\rail@term{\isa{\isakeyword{open}}}[]
wenzelm@43467
  1814
\rail@term{\isa{{\isaliteral{29}{\isacharparenright}}}}[]
wenzelm@43467
  1815
\rail@endbar
wenzelm@43467
  1816
\rail@plus
wenzelm@43467
  1817
\rail@nont{\hyperlink{syntax.nameref}{\mbox{\isa{nameref}}}}[]
wenzelm@43467
  1818
\rail@nextplus{1}
wenzelm@43467
  1819
\rail@endplus
wenzelm@43467
  1820
\rail@end
wenzelm@43467
  1821
\end{railoutput}
wenzelm@43467
  1822
wenzelm@27042
  1823
wenzelm@27042
  1824
  Isabelle organizes any kind of name declarations (of types,
wenzelm@27042
  1825
  constants, theorems etc.) by separate hierarchically structured name
wenzelm@27042
  1826
  spaces.  Normally the user does not have to control the behavior of
wenzelm@27042
  1827
  name spaces by hand, yet the following commands provide some way to
wenzelm@27042
  1828
  do so.
wenzelm@27042
  1829
wenzelm@28788
  1830
  \begin{description}
wenzelm@27042
  1831
wenzelm@40685
  1832
  \item \hyperlink{command.hide-class}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}class}}}}~\isa{names} fully removes class
wenzelm@40685
  1833
  declarations from a given name space; with the \isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{28}{\isacharparenleft}}open{\isaliteral{29}{\isacharparenright}}{\isaliteral{22}{\isachardoublequote}}}
krauss@40158
  1834
  option, only the base name is hidden.
wenzelm@36177
  1835
wenzelm@27042
  1836
  Note that hiding name space accesses has no impact on logical
wenzelm@28788
  1837
  declarations --- they remain valid internally.  Entities that are no
wenzelm@27042
  1838
  longer accessible to the user are printed with the special qualifier
wenzelm@40685
  1839
  ``\isa{{\isaliteral{22}{\isachardoublequote}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{3F}{\isacharquery}}{\isaliteral{22}{\isachardoublequote}}}'' prefixed to the full internal name.
wenzelm@27042
  1840
wenzelm@40685
  1841
  \item \hyperlink{command.hide-type}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}type}}}}, \hyperlink{command.hide-const}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}const}}}}, and \hyperlink{command.hide-fact}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}fact}}}} are similar to \hyperlink{command.hide-class}{\mbox{\isa{\isacommand{hide{\isaliteral{5F}{\isacharunderscore}}class}}}}, but hide types,
wenzelm@36177
  1842
  constants, and facts, respectively.
wenzelm@36177
  1843
  
wenzelm@28788
  1844
  \end{description}%
wenzelm@27042
  1845
\end{isamarkuptext}%
wenzelm@27042
  1846
\isamarkuptrue%
wenzelm@27042
  1847
%
wenzelm@26869
  1848
\isadelimtheory
wenzelm@26869
  1849
%
wenzelm@26869
  1850
\endisadelimtheory
wenzelm@26869
  1851
%
wenzelm@26869
  1852
\isatagtheory
wenzelm@26869
  1853
\isacommand{end}\isamarkupfalse%
wenzelm@26869
  1854
%
wenzelm@26869
  1855
\endisatagtheory
wenzelm@26869
  1856
{\isafoldtheory}%
wenzelm@26869
  1857
%
wenzelm@26869
  1858
\isadelimtheory
wenzelm@26869
  1859
%
wenzelm@26869
  1860
\endisadelimtheory
wenzelm@26869
  1861
\isanewline
wenzelm@26869
  1862
\end{isabellebody}%
wenzelm@26869
  1863
%%% Local Variables:
wenzelm@26869
  1864
%%% mode: latex
wenzelm@26869
  1865
%%% TeX-master: "root"
wenzelm@26869
  1866
%%% End: