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