doc-src/IsarRef/Thy/document/pure.tex
author wenzelm
Tue, 06 May 2008 00:12:03 +0200
changeset 26788 57b54e586989
parent 26776 030db8c8b79d
child 26842 81308d44fe0a
permissions -rw-r--r--
updated generated file;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     1
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     2
\begin{isabellebody}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     3
\def\isabellecontext{pure}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     4
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     5
\isadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     6
\isanewline
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     7
\isanewline
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     8
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     9
\endisadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    10
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    11
\isatagtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    12
\isacommand{theory}\isamarkupfalse%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    13
\ pure\isanewline
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    14
\isakeyword{imports}\ CPure\isanewline
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    15
\isakeyword{begin}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    16
\endisatagtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    17
{\isafoldtheory}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    18
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    19
\isadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    20
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    21
\endisadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    22
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    23
\isamarkupchapter{Basic language elements \label{ch:pure-syntax}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    24
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    25
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    26
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    27
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    28
Subsequently, we introduce the main part of Pure theory and proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    29
  commands, together with fundamental proof methods and attributes.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    30
  \Chref{ch:gen-tools} describes further Isar elements provided by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    31
  generic tools and packages (such as the Simplifier) that are either
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    32
  part of Pure Isabelle or pre-installed in most object logics.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    33
  \Chref{ch:logics} refers to object-logic specific elements (mainly
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    34
  for HOL and ZF).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    35
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    36
  \medskip Isar commands may be either \emph{proper} document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    37
  constructors, or \emph{improper commands}.  Some proof methods and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    38
  attributes introduced later are classified as improper as well.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    39
  Improper Isar language elements, which are subsequently marked by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    40
  ``\isa{\isactrlsup {\isacharasterisk}}'', are often helpful when developing proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    41
  documents, while their use is discouraged for the final
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    42
  human-readable outcome.  Typical examples are diagnostic commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    43
  that print terms or theorems according to the current context; other
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    44
  commands emulate old-style tactical theorem proving.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    45
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    46
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    47
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    48
\isamarkupsection{Theory commands%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    49
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    50
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    51
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    52
\isamarkupsubsection{Defining theories \label{sec:begin-thy}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    53
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    54
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    55
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    56
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    57
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    58
    \indexdef{}{command}{header}\mbox{\isa{\isacommand{header}}} & : & \isarkeep{toplevel} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    59
    \indexdef{}{command}{theory}\mbox{\isa{\isacommand{theory}}} & : & \isartrans{toplevel}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    60
    \indexdef{}{command}{end}\mbox{\isa{\isacommand{end}}} & : & \isartrans{theory}{toplevel} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    61
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    62
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    63
  Isabelle/Isar theories are defined via theory, which contain both
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    64
  specifications and proofs; occasionally definitional mechanisms also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    65
  require some explicit proof.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    66
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    67
  The first ``real'' command of any theory has to be \mbox{\isa{\isacommand{theory}}}, which starts a new theory based on the merge of existing
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    68
  ones.  Just preceding the \mbox{\isa{\isacommand{theory}}} keyword, there may be
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    69
  an optional \mbox{\isa{\isacommand{header}}} declaration, which is relevant to
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    70
  document preparation only; it acts very much like a special
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    71
  pre-theory markup command (cf.\ \secref{sec:markup-thy} and
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    72
  \secref{sec:markup-thy}).  The \mbox{\isa{\isacommand{end}}} command concludes a
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    73
  theory development; it has to be the very last command of any theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    74
  file loaded in batch-mode.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    75
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    76
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    77
    'header' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    78
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    79
    'theory' name 'imports' (name +) uses? 'begin'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    80
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    81
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    82
    uses: 'uses' ((name | parname) +);
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    83
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    84
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    85
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    86
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    87
  \item [\mbox{\isa{\isacommand{header}}}~\isa{text}] provides plain text
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    88
  markup just preceding the formal beginning of a theory.  In actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    89
  document preparation the corresponding {\LaTeX} macro \verb|\isamarkupheader| may be redefined to produce chapter or section
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    90
  headings.  See also \secref{sec:markup-thy} and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    91
  \secref{sec:markup-prf} for further markup commands.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    92
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
    93
  \item [\mbox{\isa{\isacommand{theory}}}~\isa{A\ {\isasymIMPORTS}\ B\isactrlsub {\isadigit{1}}\ {\isasymdots}\ B\isactrlsub n\ {\isasymBEGIN}}] starts a new theory \isa{A} based on the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    94
  merge of existing theories \isa{B\isactrlsub {\isadigit{1}}\ {\isasymdots}\ B\isactrlsub n}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    95
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    96
  Due to inclusion of several ancestors, the overall theory structure
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    97
  emerging in an Isabelle session forms a directed acyclic graph
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    98
  (DAG).  Isabelle's theory loader ensures that the sources
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    99
  contributing to the development graph are always up-to-date.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   100
  Changed files are automatically reloaded when processing theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   101
  headers.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   102
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   103
  The optional \indexdef{}{keyword}{uses}\mbox{\isa{\isakeyword{uses}}} specification declares additional
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   104
  dependencies on extra files (usually ML sources).  Files will be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   105
  loaded immediately (as ML), unless the name is put in parentheses,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   106
  which merely documents the dependency to be resolved later in the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   107
  text (typically via explicit \indexref{}{command}{use}\mbox{\isa{\isacommand{use}}} in the body text,
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   108
  see \secref{sec:ML}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   109
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   110
  \item [\mbox{\isa{\isacommand{end}}}] concludes the current theory definition or
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   111
  context switch.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   112
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   113
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   114
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   115
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   116
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   117
\isamarkupsubsection{Markup commands \label{sec:markup-thy}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   118
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   119
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   120
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   121
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   122
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   123
    \indexdef{}{command}{chapter}\mbox{\isa{\isacommand{chapter}}} & : & \isarkeep{local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   124
    \indexdef{}{command}{section}\mbox{\isa{\isacommand{section}}} & : & \isarkeep{local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   125
    \indexdef{}{command}{subsection}\mbox{\isa{\isacommand{subsection}}} & : & \isarkeep{local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   126
    \indexdef{}{command}{subsubsection}\mbox{\isa{\isacommand{subsubsection}}} & : & \isarkeep{local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   127
    \indexdef{}{command}{text}\mbox{\isa{\isacommand{text}}} & : & \isarkeep{local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   128
    \indexdef{}{command}{text-raw}\mbox{\isa{\isacommand{text{\isacharunderscore}raw}}} & : & \isarkeep{local{\dsh}theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   129
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   130
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   131
  Apart from formal comments (see \secref{sec:comments}), markup
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   132
  commands provide a structured way to insert text into the document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   133
  generated from a theory (see \cite{isabelle-sys} for more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   134
  information on Isabelle's document preparation tools).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   135
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   136
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   137
    ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text') target? text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   138
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   139
    'text\_raw' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   140
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   141
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   142
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   143
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   144
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   145
  \item [\mbox{\isa{\isacommand{chapter}}}, \mbox{\isa{\isacommand{section}}}, \mbox{\isa{\isacommand{subsection}}}, and \mbox{\isa{\isacommand{subsubsection}}}] mark chapter and
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   146
  section headings.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   147
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   148
  \item [\mbox{\isa{\isacommand{text}}}] specifies paragraphs of plain text.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   149
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   150
  \item [\mbox{\isa{\isacommand{text{\isacharunderscore}raw}}}] inserts {\LaTeX} source into the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   151
  output, without additional markup.  Thus the full range of document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   152
  manipulations becomes available.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   153
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   154
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   155
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   156
  The \isa{text} argument of these markup commands (except for
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   157
  \mbox{\isa{\isacommand{text{\isacharunderscore}raw}}}) may contain references to formal entities
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   158
  (``antiquotations'', see also \secref{sec:antiq}).  These are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   159
  interpreted in the present theory context, or the named \isa{target}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   160
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   161
  Any of these markup elements corresponds to a {\LaTeX} command with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   162
  the name prefixed by \verb|\isamarkup|.  For the sectioning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   163
  commands this is a plain macro with a single argument, e.g.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   164
  \verb|\isamarkupchapter{|\isa{{\isasymdots}}\verb|}| for
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   165
  \mbox{\isa{\isacommand{chapter}}}.  The \mbox{\isa{\isacommand{text}}} markup results in a
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   166
  {\LaTeX} environment \verb|\begin{isamarkuptext}| \isa{{\isasymdots}} \verb|\end{isamarkuptext}|, while \mbox{\isa{\isacommand{text{\isacharunderscore}raw}}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   167
  causes the text to be inserted directly into the {\LaTeX} source.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   168
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   169
  \medskip Additional markup commands are available for proofs (see
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   170
  \secref{sec:markup-prf}).  Also note that the \indexref{}{command}{header}\mbox{\isa{\isacommand{header}}} declaration (see \secref{sec:begin-thy}) admits to insert
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   171
  section markup just preceding the actual theory definition.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   172
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   173
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   174
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   175
\isamarkupsubsection{Type classes and sorts \label{sec:classes}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   176
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   177
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   178
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   179
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   180
\begin{matharray}{rcll}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   181
    \indexdef{}{command}{classes}\mbox{\isa{\isacommand{classes}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   182
    \indexdef{}{command}{classrel}\mbox{\isa{\isacommand{classrel}}} & : & \isartrans{theory}{theory} & (axiomatic!) \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   183
    \indexdef{}{command}{defaultsort}\mbox{\isa{\isacommand{defaultsort}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   184
    \indexdef{}{command}{class-deps}\mbox{\isa{\isacommand{class{\isacharunderscore}deps}}} & : & \isarkeep{theory~|~proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   185
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   186
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   187
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   188
    'classes' (classdecl +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   189
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   190
    'classrel' (nameref ('<' | subseteq) nameref + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   191
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   192
    'defaultsort' sort
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   193
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   194
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   195
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   196
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   197
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   198
  \item [\mbox{\isa{\isacommand{classes}}}~\isa{c\ {\isasymsubseteq}\ c\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlsub n}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   199
  declares class \isa{c} to be a subclass of existing classes \isa{c\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ c\isactrlsub n}.  Cyclic class structures are not permitted.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   200
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   201
  \item [\mbox{\isa{\isacommand{classrel}}}~\isa{c\isactrlsub {\isadigit{1}}\ {\isasymsubseteq}\ c\isactrlsub {\isadigit{2}}}] states
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   202
  subclass relations between existing classes \isa{c\isactrlsub {\isadigit{1}}} and
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   203
  \isa{c\isactrlsub {\isadigit{2}}}.  This is done axiomatically!  The \indexref{}{command}{instance}\mbox{\isa{\isacommand{instance}}} command (see \secref{sec:axclass}) provides a way to
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   204
  introduce proven class relations.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   205
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   206
  \item [\mbox{\isa{\isacommand{defaultsort}}}~\isa{s}] makes sort \isa{s} the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   207
  new default sort for any type variables given without sort
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   208
  constraints.  Usually, the default sort would be only changed when
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   209
  defining a new object-logic.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   210
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   211
  \item [\mbox{\isa{\isacommand{class{\isacharunderscore}deps}}}] visualizes the subclass relation,
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   212
  using Isabelle's graph browser tool (see also \cite{isabelle-sys}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   213
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   214
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   215
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   216
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   217
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   218
\isamarkupsubsection{Primitive types and type abbreviations \label{sec:types-pure}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   219
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   220
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   221
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   222
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   223
\begin{matharray}{rcll}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   224
    \indexdef{}{command}{types}\mbox{\isa{\isacommand{types}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   225
    \indexdef{}{command}{typedecl}\mbox{\isa{\isacommand{typedecl}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   226
    \indexdef{}{command}{nonterminals}\mbox{\isa{\isacommand{nonterminals}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   227
    \indexdef{}{command}{arities}\mbox{\isa{\isacommand{arities}}} & : & \isartrans{theory}{theory} & (axiomatic!) \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   228
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   229
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   230
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   231
    'types' (typespec '=' type infix? +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   232
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   233
    'typedecl' typespec infix?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   234
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   235
    'nonterminals' (name +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   236
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   237
    'arities' (nameref '::' arity +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   238
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   239
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   240
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   241
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   242
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   243
  \item [\mbox{\isa{\isacommand{types}}}~\isa{{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub n{\isacharparenright}\ t\ {\isacharequal}\ {\isasymtau}}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   244
  introduces \emph{type synonym} \isa{{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub n{\isacharparenright}\ t}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   245
  for existing type \isa{{\isasymtau}}.  Unlike actual type definitions, as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   246
  are available in Isabelle/HOL for example, type synonyms are just
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   247
  purely syntactic abbreviations without any logical significance.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   248
  Internally, type synonyms are fully expanded.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   249
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   250
  \item [\mbox{\isa{\isacommand{typedecl}}}~\isa{{\isacharparenleft}{\isasymalpha}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymalpha}\isactrlsub n{\isacharparenright}\ t}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   251
  declares a new type constructor \isa{t}, intended as an actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   252
  logical type (of the object-logic, if available).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   253
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   254
  \item [\mbox{\isa{\isacommand{nonterminals}}}~\isa{c}] declares type
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   255
  constructors \isa{c} (without arguments) to act as purely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   256
  syntactic types, i.e.\ nonterminal symbols of Isabelle's inner
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   257
  syntax of terms or types.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   258
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   259
  \item [\mbox{\isa{\isacommand{arities}}}~\isa{t\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}s\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ s\isactrlsub n{\isacharparenright}\ s}] augments Isabelle's order-sorted signature of types by new type
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   260
  constructor arities.  This is done axiomatically!  The \indexref{}{command}{instance}\mbox{\isa{\isacommand{instance}}} command (see \S\ref{sec:axclass}) provides a way to
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   261
  introduce proven type arities.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   262
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   263
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   264
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   265
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   266
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   267
\isamarkupsubsection{Primitive constants and definitions \label{sec:consts}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   268
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   269
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   270
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   271
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   272
Definitions essentially express abbreviations within the logic.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   273
  simplest form of a definition is \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}\ {\isasymequiv}\ t}, where \isa{c} is a newly declared constant.  Isabelle also allows derived forms
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   274
  where the arguments of \isa{c} appear on the left, abbreviating a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   275
  prefix of \isa{{\isasymlambda}}-abstractions, e.g.\ \isa{c\ {\isasymequiv}\ {\isasymlambda}x\ y{\isachardot}\ t} may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   276
  written more conveniently as \isa{c\ x\ y\ {\isasymequiv}\ t}.  Moreover,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   277
  definitions may be weakened by adding arbitrary pre-conditions:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   278
  \isa{A\ {\isasymLongrightarrow}\ c\ x\ y\ {\isasymequiv}\ t}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   279
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   280
  \medskip The built-in well-formedness conditions for definitional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   281
  specifications are:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   282
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   283
  \begin{itemize}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   284
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   285
  \item Arguments (on the left-hand side) must be distinct variables.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   286
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   287
  \item All variables on the right-hand side must also appear on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   288
  left-hand side.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   289
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   290
  \item All type variables on the right-hand side must also appear on
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   291
  the left-hand side; this prohibits \isa{{\isadigit{0}}\ {\isacharcolon}{\isacharcolon}\ nat\ {\isasymequiv}\ length\ {\isacharparenleft}{\isacharbrackleft}{\isacharbrackright}\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ list{\isacharparenright}} for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   292
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   293
  \item The definition must not be recursive.  Most object-logics
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   294
  provide definitional principles that can be used to express
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   295
  recursion safely.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   296
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   297
  \end{itemize}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   298
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   299
  Overloading means that a constant being declared as \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ decl} may be defined separately on type instances \isa{c\ {\isacharcolon}{\isacharcolon}\ {\isacharparenleft}{\isasymbeta}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymbeta}\isactrlsub n{\isacharparenright}\ t\ decl} for each type constructor \isa{t}.  The right-hand side may mention overloaded constants
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   300
  recursively at type instances corresponding to the immediate
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   301
  argument types \isa{{\isasymbeta}\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ {\isasymbeta}\isactrlsub n}.  Incomplete
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   302
  specification patterns impose global constraints on all occurrences,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   303
  e.g.\ \isa{d\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymtimes}\ {\isasymalpha}} on the left-hand side means that all
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   304
  corresponding occurrences on some right-hand side need to be an
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   305
  instance of this, general \isa{d\ {\isacharcolon}{\isacharcolon}\ {\isasymalpha}\ {\isasymtimes}\ {\isasymbeta}} will be disallowed.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   306
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   307
  \begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   308
    \indexdef{}{command}{consts}\mbox{\isa{\isacommand{consts}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   309
    \indexdef{}{command}{defs}\mbox{\isa{\isacommand{defs}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   310
    \indexdef{}{command}{constdefs}\mbox{\isa{\isacommand{constdefs}}} & : & \isartrans{theory}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   311
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   312
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   313
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   314
    'consts' ((name '::' type mixfix?) +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   315
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   316
    'defs' ('(' 'unchecked'? 'overloaded'? ')')? \\ (axmdecl prop +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   317
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   318
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   319
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   320
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   321
    'constdefs' structs? (constdecl? constdef +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   322
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   323
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   324
    structs: '(' 'structure' (vars + 'and') ')'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   325
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   326
    constdecl:  ((name '::' type mixfix | name '::' type | name mixfix) 'where'?) | name 'where'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   327
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   328
    constdef: thmdecl? prop
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   329
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   330
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   331
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   332
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   333
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   334
  \item [\mbox{\isa{\isacommand{consts}}}~\isa{c\ {\isacharcolon}{\isacharcolon}\ {\isasymsigma}}] declares constant
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   335
  \isa{c} to have any instance of type scheme \isa{{\isasymsigma}}.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   336
  optional mixfix annotations may attach concrete syntax to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   337
  constants declared.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   338
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   339
  \item [\mbox{\isa{\isacommand{defs}}}~\isa{name{\isacharcolon}\ eqn}] introduces \isa{eqn}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   340
  as a definitional axiom for some existing constant.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   341
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   342
  The \isa{{\isacharparenleft}unchecked{\isacharparenright}} option disables global dependency checks
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   343
  for this definition, which is occasionally useful for exotic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   344
  overloading.  It is at the discretion of the user to avoid malformed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   345
  theory specifications!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   346
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   347
  The \isa{{\isacharparenleft}overloaded{\isacharparenright}} option declares definitions to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   348
  potentially overloaded.  Unless this option is given, a warning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   349
  message would be issued for any definitional equation with a more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   350
  special type than that of the corresponding constant declaration.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   351
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   352
  \item [\mbox{\isa{\isacommand{constdefs}}}] provides a streamlined combination of
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   353
  constants declarations and definitions: type-inference takes care of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   354
  the most general typing of the given specification (the optional
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   355
  type constraint may refer to type-inference dummies ``\isa{{\isacharunderscore}}'' as usual).  The resulting type declaration needs to agree with
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   356
  that of the specification; overloading is \emph{not} supported here!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   357
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   358
  The constant name may be omitted altogether, if neither type nor
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   359
  syntax declarations are given.  The canonical name of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   360
  definitional axiom for constant \isa{c} will be \isa{c{\isacharunderscore}def},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   361
  unless specified otherwise.  Also note that the given list of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   362
  specifications is processed in a strictly sequential manner, with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   363
  type-checking being performed independently.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   364
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   365
  An optional initial context of \isa{{\isacharparenleft}structure{\isacharparenright}} declarations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   366
  admits use of indexed syntax, using the special symbol \verb|\<index>| (printed as ``\isa{{\isasymindex}}'').  The latter concept is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   367
  particularly useful with locales (see also \S\ref{sec:locale}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   368
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   369
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   370
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   371
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   372
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   373
\isamarkupsubsection{Syntax and translations \label{sec:syn-trans}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   374
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   375
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   376
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   377
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   378
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   379
    \indexdef{}{command}{syntax}\mbox{\isa{\isacommand{syntax}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   380
    \indexdef{}{command}{no-syntax}\mbox{\isa{\isacommand{no{\isacharunderscore}syntax}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   381
    \indexdef{}{command}{translations}\mbox{\isa{\isacommand{translations}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   382
    \indexdef{}{command}{no-translations}\mbox{\isa{\isacommand{no{\isacharunderscore}translations}}} & : & \isartrans{theory}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   383
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   384
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   385
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   386
    ('syntax' | 'no\_syntax') mode? (constdecl +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   387
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   388
    ('translations' | 'no\_translations') (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   389
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   390
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   391
    mode: ('(' ( name | 'output' | name 'output' ) ')')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   392
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   393
    transpat: ('(' nameref ')')? string
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   394
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   395
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   396
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   397
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   398
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   399
  \item [\mbox{\isa{\isacommand{syntax}}}~\isa{{\isacharparenleft}mode{\isacharparenright}\ decls}] is similar to
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   400
  \mbox{\isa{\isacommand{consts}}}~\isa{decls}, except that the actual logical
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   401
  signature extension is omitted.  Thus the context free grammar of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   402
  Isabelle's inner syntax may be augmented in arbitrary ways,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   403
  independently of the logic.  The \isa{mode} argument refers to the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   404
  print mode that the grammar rules belong; unless the \indexref{}{keyword}{output}\mbox{\isa{\isakeyword{output}}} indicator is given, all productions are added both to the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   405
  input and output grammar.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   406
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   407
  \item [\mbox{\isa{\isacommand{no{\isacharunderscore}syntax}}}~\isa{{\isacharparenleft}mode{\isacharparenright}\ decls}] removes
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   408
  grammar declarations (and translations) resulting from \isa{decls}, which are interpreted in the same manner as for \mbox{\isa{\isacommand{syntax}}} above.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   409
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   410
  \item [\mbox{\isa{\isacommand{translations}}}~\isa{rules}] specifies syntactic
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   411
  translation rules (i.e.\ macros): parse~/ print rules (\isa{{\isasymrightleftharpoons}}),
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   412
  parse rules (\isa{{\isasymrightharpoonup}}), or print rules (\isa{{\isasymleftharpoondown}}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   413
  Translation patterns may be prefixed by the syntactic category to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   414
  used for parsing; the default is \isa{logic}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   415
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   416
  \item [\mbox{\isa{\isacommand{no{\isacharunderscore}translations}}}~\isa{rules}] removes syntactic
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   417
  translation rules, which are interpreted in the same manner as for
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   418
  \mbox{\isa{\isacommand{translations}}} above.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   419
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   420
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   421
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   422
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   423
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   424
\isamarkupsubsection{Axioms and theorems \label{sec:axms-thms}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   425
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   426
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   427
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   428
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   429
\begin{matharray}{rcll}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   430
    \indexdef{}{command}{axioms}\mbox{\isa{\isacommand{axioms}}} & : & \isartrans{theory}{theory} & (axiomatic!) \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   431
    \indexdef{}{command}{lemmas}\mbox{\isa{\isacommand{lemmas}}} & : & \isarkeep{local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   432
    \indexdef{}{command}{theorems}\mbox{\isa{\isacommand{theorems}}} & : & isarkeep{local{\dsh}theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   433
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   434
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   435
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   436
    'axioms' (axmdecl prop +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   437
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   438
    ('lemmas' | 'theorems') target? (thmdef? thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   439
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   440
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   441
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   442
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   443
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   444
  \item [\mbox{\isa{\isacommand{axioms}}}~\isa{a{\isacharcolon}\ {\isasymphi}}] introduces arbitrary
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   445
  statements as axioms of the meta-logic.  In fact, axioms are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   446
  ``axiomatic theorems'', and may be referred later just as any other
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   447
  theorem.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   448
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   449
  Axioms are usually only introduced when declaring new logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   450
  systems.  Everyday work is typically done the hard way, with proper
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   451
  definitions and proven theorems.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   452
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   453
  \item [\mbox{\isa{\isacommand{lemmas}}}~\isa{a\ {\isacharequal}\ b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   454
  retrieves and stores existing facts in the theory context, or the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   455
  specified target context (see also \secref{sec:target}).  Typical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   456
  applications would also involve attributes, to declare Simplifier
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   457
  rules, for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   458
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   459
  \item [\mbox{\isa{\isacommand{theorems}}}] is essentially the same as \mbox{\isa{\isacommand{lemmas}}}, but marks the result as a different kind of facts.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   460
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   461
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   462
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   463
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   464
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   465
\isamarkupsubsection{Name spaces%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   466
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   467
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   468
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   469
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   470
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   471
    \indexdef{}{command}{global}\mbox{\isa{\isacommand{global}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   472
    \indexdef{}{command}{local}\mbox{\isa{\isacommand{local}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   473
    \indexdef{}{command}{hide}\mbox{\isa{\isacommand{hide}}} & : & \isartrans{theory}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   474
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   475
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   476
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   477
    'hide' ('(open)')? name (nameref + )
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   478
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   479
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   480
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   481
  Isabelle organizes any kind of name declarations (of types,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   482
  constants, theorems etc.) by separate hierarchically structured name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   483
  spaces.  Normally the user does not have to control the behavior of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   484
  name spaces by hand, yet the following commands provide some way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   485
  do so.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   486
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   487
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   488
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   489
  \item [\mbox{\isa{\isacommand{global}}} and \mbox{\isa{\isacommand{local}}}] change the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   490
  current name declaration mode.  Initially, theories start in
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   491
  \mbox{\isa{\isacommand{local}}} mode, causing all names to be automatically
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   492
  qualified by the theory name.  Changing this to \mbox{\isa{\isacommand{global}}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   493
  causes all names to be declared without the theory prefix, until
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   494
  \mbox{\isa{\isacommand{local}}} is declared again.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   495
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   496
  Note that global names are prone to get hidden accidently later,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   497
  when qualified names of the same base name are introduced.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   498
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   499
  \item [\mbox{\isa{\isacommand{hide}}}~\isa{space\ names}] fully removes
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   500
  declarations from a given name space (which may be \isa{class},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   501
  \isa{type}, \isa{const}, or \isa{fact}); with the \isa{{\isacharparenleft}open{\isacharparenright}} option, only the base name is hidden.  Global
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   502
  (unqualified) names may never be hidden.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   503
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   504
  Note that hiding name space accesses has no impact on logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   505
  declarations -- they remain valid internally.  Entities that are no
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   506
  longer accessible to the user are printed with the special qualifier
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   507
  ``\isa{{\isacharquery}{\isacharquery}}'' prefixed to the full internal name.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   508
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   509
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   510
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   511
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   512
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   513
\isamarkupsubsection{Incorporating ML code \label{sec:ML}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   514
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   515
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   516
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   517
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   518
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   519
    \indexdef{}{command}{use}\mbox{\isa{\isacommand{use}}} & : & \isarkeep{theory~|~local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   520
    \indexdef{}{command}{ML}\mbox{\isa{\isacommand{ML}}} & : & \isarkeep{theory~|~local{\dsh}theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   521
    \indexdef{}{command}{ML-val}\mbox{\isa{\isacommand{ML{\isacharunderscore}val}}} & : & \isartrans{\cdot}{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   522
    \indexdef{}{command}{ML-command}\mbox{\isa{\isacommand{ML{\isacharunderscore}command}}} & : & \isartrans{\cdot}{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   523
    \indexdef{}{command}{setup}\mbox{\isa{\isacommand{setup}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   524
    \indexdef{}{command}{method-setup}\mbox{\isa{\isacommand{method{\isacharunderscore}setup}}} & : & \isartrans{theory}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   525
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   526
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   527
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   528
    'use' name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   529
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   530
    ('ML' | 'ML\_val' | 'ML\_command' | 'setup') text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   531
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   532
    'method\_setup' name '=' text text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   533
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   534
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   535
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   536
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   537
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   538
  \item [\mbox{\isa{\isacommand{use}}}~\isa{file}] reads and executes ML
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   539
  commands from \isa{file}.  The current theory context is passed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   540
  down to the ML toplevel and may be modified, using \verb|Context.>>| or derived ML commands.  The file name is checked with
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   541
  the \indexref{}{keyword}{uses}\mbox{\isa{\isakeyword{uses}}} dependency declaration given in the theory
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   542
  header (see also \secref{sec:begin-thy}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   543
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   544
  \item [\mbox{\isa{\isacommand{ML}}}~\isa{text}] is similar to \mbox{\isa{\isacommand{use}}}, but executes ML commands directly from the given \isa{text}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   545
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   546
  \item [\mbox{\isa{\isacommand{ML{\isacharunderscore}val}}} and \mbox{\isa{\isacommand{ML{\isacharunderscore}command}}}] are
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   547
  diagnostic versions of \mbox{\isa{\isacommand{ML}}}, which means that the context
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   548
  may not be updated.  \mbox{\isa{\isacommand{ML{\isacharunderscore}val}}} echos the bindings produced
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   549
  at the ML toplevel, but \mbox{\isa{\isacommand{ML{\isacharunderscore}command}}} is silent.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   550
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   551
  \item [\mbox{\isa{\isacommand{setup}}}~\isa{text}] changes the current theory
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   552
  context by applying \isa{text}, which refers to an ML expression
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   553
  of type \verb|theory -> theory|.  This enables to initialize
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   554
  any object-logic specific tools and packages written in ML, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   555
  example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   556
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   557
  \item [\mbox{\isa{\isacommand{method{\isacharunderscore}setup}}}~\isa{name\ {\isacharequal}\ text\ description}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   558
  defines a proof method in the current theory.  The given \isa{text} has to be an ML expression of type \verb|Args.src ->|\isasep\isanewline%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   559
\verb|  Proof.context -> Proof.method|.  Parsing concrete method syntax
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   560
  from \verb|Args.src| input can be quite tedious in general.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   561
  following simple examples are for methods without any explicit
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   562
  arguments, or a list of theorems, respectively.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   563
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   564
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   565
{\footnotesize
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   566
\begin{verbatim}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   567
 Method.no_args (Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   568
 Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   569
 Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   570
 Method.thms_ctxt_args (fn thms => fn ctxt =>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   571
    Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   572
\end{verbatim}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   573
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   574
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   575
  Note that mere tactic emulations may ignore the \isa{facts}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   576
  parameter above.  Proper proof methods would do something
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   577
  appropriate with the list of current facts, though.  Single-rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   578
  methods usually do strict forward-chaining (e.g.\ by using \verb|Drule.multi_resolves|), while automatic ones just insert the facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   579
  using \verb|Method.insert_tac| before applying the main tactic.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   580
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   581
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   582
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   583
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   584
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   585
\isamarkupsubsection{Syntax translation functions%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   586
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   587
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   588
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   589
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   590
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   591
    \indexdef{}{command}{parse-ast-translation}\mbox{\isa{\isacommand{parse{\isacharunderscore}ast{\isacharunderscore}translation}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   592
    \indexdef{}{command}{parse-translation}\mbox{\isa{\isacommand{parse{\isacharunderscore}translation}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   593
    \indexdef{}{command}{print-translation}\mbox{\isa{\isacommand{print{\isacharunderscore}translation}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   594
    \indexdef{}{command}{typed-print-translation}\mbox{\isa{\isacommand{typed{\isacharunderscore}print{\isacharunderscore}translation}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   595
    \indexdef{}{command}{print-ast-translation}\mbox{\isa{\isacommand{print{\isacharunderscore}ast{\isacharunderscore}translation}}} & : & \isartrans{theory}{theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   596
    \indexdef{}{command}{token-translation}\mbox{\isa{\isacommand{token{\isacharunderscore}translation}}} & : & \isartrans{theory}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   597
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   598
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   599
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   600
  ( 'parse\_ast\_translation' | 'parse\_translation' | 'print\_translation' |
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   601
    'typed\_print\_translation' | 'print\_ast\_translation' ) ('(advanced)')? text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   602
  ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   603
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   604
  'token\_translation' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   605
  ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   606
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   607
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   608
  Syntax translation functions written in ML admit almost arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   609
  manipulations of Isabelle's inner syntax.  Any of the above commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   610
  have a single \railqtok{text} argument that refers to an ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   611
  expression of appropriate type, which are as follows by default:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   612
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   613
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   614
\begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   615
val parse_ast_translation   : (string * (ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   616
val parse_translation       : (string * (term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   617
val print_translation       : (string * (term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   618
val typed_print_translation :
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   619
  (string * (bool -> typ -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   620
val print_ast_translation   : (string * (ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   621
val token_translation       :
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   622
  (string * string * (string -> string * real)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   623
\end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   624
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   625
  If the \isa{{\isacharparenleft}advanced{\isacharparenright}} option is given, the corresponding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   626
  translation functions may depend on the current theory or proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   627
  context.  This allows to implement advanced syntax mechanisms, as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   628
  translations functions may refer to specific theory declarations or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   629
  auxiliary proof data.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   630
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   631
  See also \cite[\S8]{isabelle-ref} for more information on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   632
  general concept of syntax transformations in Isabelle.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   633
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   634
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   635
\begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   636
val parse_ast_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   637
  (string * (Context.generic -> ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   638
val parse_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   639
  (string * (Context.generic -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   640
val print_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   641
  (string * (Context.generic -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   642
val typed_print_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   643
  (string * (Context.generic -> bool -> typ -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   644
val print_ast_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   645
  (string * (Context.generic -> ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   646
\end{ttbox}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   647
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   648
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   649
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   650
\isamarkupsubsection{Oracles%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   651
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   652
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   653
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   654
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   655
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   656
    \indexdef{}{command}{oracle}\mbox{\isa{\isacommand{oracle}}} & : & \isartrans{theory}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   657
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   658
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   659
  The oracle interface promotes a given ML function \verb|theory -> T -> term| to \verb|theory -> T -> thm|, for some
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   660
  type \verb|T| given by the user.  This acts like an infinitary
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   661
  specification of axioms -- there is no internal check of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   662
  correctness of the results!  The inference kernel records oracle
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   663
  invocations within the internal derivation object of theorems, and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   664
  the pretty printer attaches ``\isa{{\isacharbrackleft}{\isacharbang}{\isacharbrackright}}'' to indicate results
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   665
  that are not fully checked by Isabelle inferences.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   666
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   667
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   668
    'oracle' name '(' type ')' '=' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   669
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   670
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   671
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   672
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   673
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   674
  \item [\mbox{\isa{\isacommand{oracle}}}~\isa{name\ {\isacharparenleft}type{\isacharparenright}\ {\isacharequal}\ text}] turns the
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   675
  given ML expression \isa{text} of type
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   676
  \verb|theory ->|~\isa{type}~\verb|-> term| into an
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   677
  ML function of type
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   678
  \verb|theory ->|~\isa{type}~\verb|-> thm|, which is
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   679
  bound to the global identifier \verb|name|.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   680
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   681
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   682
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   683
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   684
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   685
\isamarkupsection{Proof commands%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   686
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   687
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   688
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   689
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   690
Proof commands perform transitions of Isar/VM machine
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   691
  configurations, which are block-structured, consisting of a stack of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   692
  nodes with three main components: logical proof context, current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   693
  facts, and open goals.  Isar/VM transitions are \emph{typed}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   694
  according to the following three different modes of operation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   695
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   696
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   697
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   698
  \item [\isa{proof{\isacharparenleft}prove{\isacharparenright}}] means that a new goal has just been
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   699
  stated that is now to be \emph{proven}; the next command may refine
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   700
  it by some proof method, and enter a sub-proof to establish the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   701
  actual result.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   702
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   703
  \item [\isa{proof{\isacharparenleft}state{\isacharparenright}}] is like a nested theory mode: the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   704
  context may be augmented by \emph{stating} additional assumptions,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   705
  intermediate results etc.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   706
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   707
  \item [\isa{proof{\isacharparenleft}chain{\isacharparenright}}] is intermediate between \isa{proof{\isacharparenleft}state{\isacharparenright}} and \isa{proof{\isacharparenleft}prove{\isacharparenright}}: existing facts (i.e.\
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   708
  the contents of the special ``\indexref{}{fact}{this}\mbox{\isa{this}}'' register) have been
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   709
  just picked up in order to be used when refining the goal claimed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   710
  next.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   711
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   712
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   713
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   714
  The proof mode indicator may be read as a verb telling the writer
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   715
  what kind of operation may be performed next.  The corresponding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   716
  typings of proof commands restricts the shape of well-formed proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   717
  texts to particular command sequences.  So dynamic arrangements of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   718
  commands eventually turn out as static texts of a certain structure.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   719
  \Appref{ap:refcard} gives a simplified grammar of the overall
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   720
  (extensible) language emerging that way.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   721
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   722
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   723
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   724
\isamarkupsubsection{Markup commands \label{sec:markup-prf}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   725
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   726
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   727
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   728
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   729
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   730
    \indexdef{}{command}{sect}\mbox{\isa{\isacommand{sect}}} & : & \isartrans{proof}{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   731
    \indexdef{}{command}{subsect}\mbox{\isa{\isacommand{subsect}}} & : & \isartrans{proof}{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   732
    \indexdef{}{command}{subsubsect}\mbox{\isa{\isacommand{subsubsect}}} & : & \isartrans{proof}{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   733
    \indexdef{}{command}{txt}\mbox{\isa{\isacommand{txt}}} & : & \isartrans{proof}{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   734
    \indexdef{}{command}{txt-raw}\mbox{\isa{\isacommand{txt{\isacharunderscore}raw}}} & : & \isartrans{proof}{proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   735
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   736
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   737
  These markup commands for proof mode closely correspond to the ones
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   738
  of theory mode (see \S\ref{sec:markup-thy}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   739
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   740
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   741
    ('sect' | 'subsect' | 'subsubsect' | 'txt' | 'txt\_raw') text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   742
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   743
  \end{rail}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   744
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   745
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   746
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   747
\isamarkupsubsection{Context elements \label{sec:proof-context}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   748
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   749
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   750
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   751
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   752
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   753
    \indexdef{}{command}{fix}\mbox{\isa{\isacommand{fix}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   754
    \indexdef{}{command}{assume}\mbox{\isa{\isacommand{assume}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   755
    \indexdef{}{command}{presume}\mbox{\isa{\isacommand{presume}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   756
    \indexdef{}{command}{def}\mbox{\isa{\isacommand{def}}} & : & \isartrans{proof(state)}{proof(state)} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   757
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   758
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   759
  The logical proof context consists of fixed variables and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   760
  assumptions.  The former closely correspond to Skolem constants, or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   761
  meta-level universal quantification as provided by the Isabelle/Pure
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   762
  logical framework.  Introducing some \emph{arbitrary, but fixed}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   763
  variable via ``\mbox{\isa{\isacommand{fix}}}~\isa{x}'' results in a local value
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   764
  that may be used in the subsequent proof as any other variable or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   765
  constant.  Furthermore, any result \isa{{\isasymturnstile}\ {\isasymphi}{\isacharbrackleft}x{\isacharbrackright}} exported from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   766
  the context will be universally closed wrt.\ \isa{x} at the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   767
  outermost level: \isa{{\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ {\isasymphi}{\isacharbrackleft}x{\isacharbrackright}} (this is expressed in normal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   768
  form using Isabelle's meta-variables).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   769
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   770
  Similarly, introducing some assumption \isa{{\isasymchi}} has two effects.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   771
  On the one hand, a local theorem is created that may be used as a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   772
  fact in subsequent proof steps.  On the other hand, any result
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   773
  \isa{{\isasymchi}\ {\isasymturnstile}\ {\isasymphi}} exported from the context becomes conditional wrt.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   774
  the assumption: \isa{{\isasymturnstile}\ {\isasymchi}\ {\isasymLongrightarrow}\ {\isasymphi}}.  Thus, solving an enclosing goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   775
  using such a result would basically introduce a new subgoal stemming
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   776
  from the assumption.  How this situation is handled depends on the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   777
  version of assumption command used: while \mbox{\isa{\isacommand{assume}}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   778
  insists on solving the subgoal by unification with some premise of
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   779
  the goal, \mbox{\isa{\isacommand{presume}}} leaves the subgoal unchanged in order
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   780
  to be proved later by the user.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   781
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   782
  Local definitions, introduced by ``\mbox{\isa{\isacommand{def}}}~\isa{x\ {\isasymequiv}\ t}'', are achieved by combining ``\mbox{\isa{\isacommand{fix}}}~\isa{x}'' with
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   783
  another version of assumption that causes any hypothetical equation
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   784
  \isa{x\ {\isasymequiv}\ t} to be eliminated by the reflexivity rule.  Thus,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   785
  exporting some result \isa{x\ {\isasymequiv}\ t\ {\isasymturnstile}\ {\isasymphi}{\isacharbrackleft}x{\isacharbrackright}} yields \isa{{\isasymturnstile}\ {\isasymphi}{\isacharbrackleft}t{\isacharbrackright}}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   786
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   787
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   788
    'fix' (vars + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   789
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   790
    ('assume' | 'presume') (props + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   791
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   792
    'def' (def + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   793
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   794
    def: thmdecl? \\ name ('==' | equiv) term termpat?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   795
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   796
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   797
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   798
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   799
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   800
  \item [\mbox{\isa{\isacommand{fix}}}~\isa{x}] introduces a local variable
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   801
  \isa{x} that is \emph{arbitrary, but fixed.}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   802
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   803
  \item [\mbox{\isa{\isacommand{assume}}}~\isa{a{\isacharcolon}\ {\isasymphi}} and \mbox{\isa{\isacommand{presume}}}~\isa{a{\isacharcolon}\ {\isasymphi}}] introduce a local fact \isa{{\isasymphi}\ {\isasymturnstile}\ {\isasymphi}} by
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   804
  assumption.  Subsequent results applied to an enclosing goal (e.g.\
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   805
  by \indexref{}{command}{show}\mbox{\isa{\isacommand{show}}}) are handled as follows: \mbox{\isa{\isacommand{assume}}} expects to be able to unify with existing premises in the
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   806
  goal, while \mbox{\isa{\isacommand{presume}}} leaves \isa{{\isasymphi}} as new subgoals.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   807
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   808
  Several lists of assumptions may be given (separated by
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   809
  \indexref{}{keyword}{and}\mbox{\isa{\isakeyword{and}}}; the resulting list of current facts consists
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   810
  of all of these concatenated.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   811
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   812
  \item [\mbox{\isa{\isacommand{def}}}~\isa{x\ {\isasymequiv}\ t}] introduces a local
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   813
  (non-polymorphic) definition.  In results exported from the context,
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   814
  \isa{x} is replaced by \isa{t}.  Basically, ``\mbox{\isa{\isacommand{def}}}~\isa{x\ {\isasymequiv}\ t}'' abbreviates ``\mbox{\isa{\isacommand{fix}}}~\isa{x}~\mbox{\isa{\isacommand{assume}}}~\isa{x\ {\isasymequiv}\ t}'', with the resulting
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   815
  hypothetical equation solved by reflexivity.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   816
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   817
  The default name for the definitional equation is \isa{x{\isacharunderscore}def}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   818
  Several simultaneous definitions may be given at the same time.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   819
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   820
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   821
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   822
  The special name \indexref{}{fact}{prems}\mbox{\isa{prems}} refers to all assumptions of the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   823
  current context as a list of theorems.  This feature should be used
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   824
  with great care!  It is better avoided in final proof texts.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   825
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   826
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   827
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   828
\isamarkupsubsection{Facts and forward chaining%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   829
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   830
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   831
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   832
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   833
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   834
    \indexdef{}{command}{note}\mbox{\isa{\isacommand{note}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   835
    \indexdef{}{command}{then}\mbox{\isa{\isacommand{then}}} & : & \isartrans{proof(state)}{proof(chain)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   836
    \indexdef{}{command}{from}\mbox{\isa{\isacommand{from}}} & : & \isartrans{proof(state)}{proof(chain)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   837
    \indexdef{}{command}{with}\mbox{\isa{\isacommand{with}}} & : & \isartrans{proof(state)}{proof(chain)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   838
    \indexdef{}{command}{using}\mbox{\isa{\isacommand{using}}} & : & \isartrans{proof(prove)}{proof(prove)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   839
    \indexdef{}{command}{unfolding}\mbox{\isa{\isacommand{unfolding}}} & : & \isartrans{proof(prove)}{proof(prove)} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   840
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   841
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   842
  New facts are established either by assumption or proof of local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   843
  statements.  Any fact will usually be involved in further proofs,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   844
  either as explicit arguments of proof methods, or when forward
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   845
  chaining towards the next goal via \mbox{\isa{\isacommand{then}}} (and variants);
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   846
  \mbox{\isa{\isacommand{from}}} and \mbox{\isa{\isacommand{with}}} are composite forms
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   847
  involving \mbox{\isa{\isacommand{note}}}.  The \mbox{\isa{\isacommand{using}}} elements
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   848
  augments the collection of used facts \emph{after} a goal has been
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   849
  stated.  Note that the special theorem name \indexref{}{fact}{this}\mbox{\isa{this}} refers
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   850
  to the most recently established facts, but only \emph{before}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   851
  issuing a follow-up claim.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   852
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   853
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   854
    'note' (thmdef? thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   855
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   856
    ('from' | 'with' | 'using' | 'unfolding') (thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   857
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   858
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   859
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   860
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   861
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   862
  \item [\mbox{\isa{\isacommand{note}}}~\isa{a\ {\isacharequal}\ b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   863
  recalls existing facts \isa{b\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ b\isactrlsub n}, binding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   864
  the result as \isa{a}.  Note that attributes may be involved as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   865
  well, both on the left and right hand sides.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   866
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   867
  \item [\mbox{\isa{\isacommand{then}}}] indicates forward chaining by the current
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   868
  facts in order to establish the goal to be claimed next.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   869
  initial proof method invoked to refine that will be offered the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   870
  facts to do ``anything appropriate'' (see also
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   871
  \secref{sec:proof-steps}).  For example, method \indexref{}{method}{rule}\mbox{\isa{rule}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   872
  (see \secref{sec:pure-meth-att}) would typically do an elimination
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   873
  rather than an introduction.  Automatic methods usually insert the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   874
  facts into the goal state before operation.  This provides a simple
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   875
  scheme to control relevance of facts in automated proof search.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   876
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   877
  \item [\mbox{\isa{\isacommand{from}}}~\isa{b}] abbreviates ``\mbox{\isa{\isacommand{note}}}~\isa{b}~\mbox{\isa{\isacommand{then}}}''; thus \mbox{\isa{\isacommand{then}}} is
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   878
  equivalent to ``\mbox{\isa{\isacommand{from}}}~\isa{this}''.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   879
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   880
  \item [\mbox{\isa{\isacommand{with}}}~\isa{b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n}]
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   881
  abbreviates ``\mbox{\isa{\isacommand{from}}}~\isa{b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n\ {\isasymAND}\ this}''; thus the forward chaining is from earlier facts together
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   882
  with the current ones.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   883
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   884
  \item [\mbox{\isa{\isacommand{using}}}~\isa{b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n}] augments
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   885
  the facts being currently indicated for use by a subsequent
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   886
  refinement step (such as \indexref{}{command}{apply}\mbox{\isa{\isacommand{apply}}} or \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}}).
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   887
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   888
  \item [\mbox{\isa{\isacommand{unfolding}}}~\isa{b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n}] is
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   889
  structurally similar to \mbox{\isa{\isacommand{using}}}, but unfolds definitional
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   890
  equations \isa{b\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}\ b\isactrlsub n} throughout the goal state
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   891
  and facts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   892
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   893
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   894
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   895
  Forward chaining with an empty list of theorems is the same as not
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   896
  chaining at all.  Thus ``\mbox{\isa{\isacommand{from}}}~\isa{nothing}'' has no
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   897
  effect apart from entering \isa{prove{\isacharparenleft}chain{\isacharparenright}} mode, since
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   898
  \indexref{}{fact}{nothing}\mbox{\isa{nothing}} is bound to the empty list of theorems.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   899
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   900
  Basic proof methods (such as \indexref{}{method}{rule}\mbox{\isa{rule}}) expect multiple
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   901
  facts to be given in their proper order, corresponding to a prefix
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   902
  of the premises of the rule involved.  Note that positions may be
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   903
  easily skipped using something like \mbox{\isa{\isacommand{from}}}~\isa{{\isacharunderscore}\ {\isasymAND}\ a\ {\isasymAND}\ b}, for example.  This involves the trivial rule
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   904
  \isa{PROP\ {\isasympsi}\ {\isasymLongrightarrow}\ PROP\ {\isasympsi}}, which is bound in Isabelle/Pure as
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   905
  ``\indexref{}{fact}{-}\mbox{\isa{{\isacharunderscore}}}'' (underscore).
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   906
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   907
  Automated methods (such as \mbox{\isa{simp}} or \mbox{\isa{auto}}) just
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   908
  insert any given facts before their usual operation.  Depending on
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   909
  the kind of procedure involved, the order of facts is less
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   910
  significant here.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   911
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   912
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   913
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   914
\isamarkupsubsection{Goal statements \label{sec:goals}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   915
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   916
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   917
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   918
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   919
\begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   920
    \isarcmd{lemma} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   921
    \isarcmd{theorem} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   922
    \isarcmd{corollary} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   923
    \isarcmd{have} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   924
    \isarcmd{show} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   925
    \isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   926
    \isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   927
    \isarcmd{print_statement}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   928
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   929
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   930
  From a theory context, proof mode is entered by an initial goal
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   931
  command such as \mbox{\isa{\isacommand{lemma}}}, \mbox{\isa{\isacommand{theorem}}}, or
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   932
  \mbox{\isa{\isacommand{corollary}}}.  Within a proof, new claims may be
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   933
  introduced locally as well; four variants are available here to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   934
  indicate whether forward chaining of facts should be performed
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   935
  initially (via \indexref{}{command}{then}\mbox{\isa{\isacommand{then}}}), and whether the final result
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   936
  is meant to solve some pending goal.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   937
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   938
  Goals may consist of multiple statements, resulting in a list of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   939
  facts eventually.  A pending multi-goal is internally represented as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   940
  a meta-level conjunction (printed as \isa{{\isacharampersand}{\isacharampersand}}), which is usually
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   941
  split into the corresponding number of sub-goals prior to an initial
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   942
  method application, via \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}}
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   943
  (\secref{sec:proof-steps}) or \indexref{}{command}{apply}\mbox{\isa{\isacommand{apply}}}
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   944
  (\secref{sec:tactic-commands}).  The \indexref{}{method}{induct}\mbox{\isa{induct}} method
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   945
  covered in \secref{sec:cases-induct} acts on multiple claims
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   946
  simultaneously.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   947
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   948
  Claims at the theory level may be either in short or long form.  A
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   949
  short goal merely consists of several simultaneous propositions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   950
  (often just one).  A long goal includes an explicit context
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   951
  specification for the subsequent conclusion, involving local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   952
  parameters and assumptions.  Here the role of each part of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   953
  statement is explicitly marked by separate keywords (see also
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   954
  \secref{sec:locale}); the local assumptions being introduced here
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   955
  are available as \indexref{}{fact}{assms}\mbox{\isa{assms}} in the proof.  Moreover, there
26788
57b54e586989 updated generated file;
wenzelm
parents: 26776
diff changeset
   956
  are two kinds of conclusions: \indexdef{}{element}{shows}\mbox{\isa{\isakeyword{shows}}} states several
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   957
  simultaneous propositions (essentially a big conjunction), while
26788
57b54e586989 updated generated file;
wenzelm
parents: 26776
diff changeset
   958
  \indexdef{}{element}{obtains}\mbox{\isa{\isakeyword{obtains}}} claims several simultaneous simultaneous
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   959
  contexts of (essentially a big disjunction of eliminated parameters
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   960
  and assumptions, cf.\ \secref{sec:obtain}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   961
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   962
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   963
    ('lemma' | 'theorem' | 'corollary') target? (goal | longgoal)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   964
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   965
    ('have' | 'show' | 'hence' | 'thus') goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   966
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   967
    'print\_statement' modes? thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   968
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   969
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   970
    goal: (props + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   971
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   972
    longgoal: thmdecl? (contextelem *) conclusion
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   973
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   974
    conclusion: 'shows' goal | 'obtains' (parname? case + '|')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   975
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   976
    case: (vars + 'and') 'where' (props + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   977
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   978
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   979
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   980
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   981
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   982
  \item [\mbox{\isa{\isacommand{lemma}}}~\isa{a{\isacharcolon}\ {\isasymphi}}] enters proof mode with
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   983
  \isa{{\isasymphi}} as main goal, eventually resulting in some fact \isa{{\isasymturnstile}\ {\isasymphi}} to be put back into the target context.  An additional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   984
  \railnonterm{context} specification may build up an initial proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   985
  context for the subsequent claim; this includes local definitions
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   986
  and syntax as well, see the definition of \mbox{\isa{contextelem}} in
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   987
  \secref{sec:locale}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   988
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   989
  \item [\mbox{\isa{\isacommand{theorem}}}~\isa{a{\isacharcolon}\ {\isasymphi}} and \mbox{\isa{\isacommand{corollary}}}~\isa{a{\isacharcolon}\ {\isasymphi}}] are essentially the same as \mbox{\isa{\isacommand{lemma}}}~\isa{a{\isacharcolon}\ {\isasymphi}}, but the facts are internally marked as
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   990
  being of a different kind.  This discrimination acts like a formal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   991
  comment.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   992
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   993
  \item [\mbox{\isa{\isacommand{have}}}~\isa{a{\isacharcolon}\ {\isasymphi}}] claims a local goal,
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   994
  eventually resulting in a fact within the current logical context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   995
  This operation is completely independent of any pending sub-goals of
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
   996
  an enclosing goal statements, so \mbox{\isa{\isacommand{have}}} may be freely
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   997
  used for experimental exploration of potential results within a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   998
  proof body.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   999
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1000
  \item [\mbox{\isa{\isacommand{show}}}~\isa{a{\isacharcolon}\ {\isasymphi}}] is like \mbox{\isa{\isacommand{have}}}~\isa{a{\isacharcolon}\ {\isasymphi}} plus a second stage to refine some pending
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1001
  sub-goal for each one of the finished result, after having been
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1002
  exported into the corresponding context (at the head of the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1003
  sub-proof of this \mbox{\isa{\isacommand{show}}} command).
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1004
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1005
  To accommodate interactive debugging, resulting rules are printed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1006
  before being applied internally.  Even more, interactive execution
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1007
  of \mbox{\isa{\isacommand{show}}} predicts potential failure and displays the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1008
  resulting error as a warning beforehand.  Watch out for the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1009
  following message:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1010
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1011
  %FIXME proper antiquitation
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1012
  \begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1013
  Problem! Local statement will fail to solve any pending goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1014
  \end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1015
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1016
  \item [\mbox{\isa{\isacommand{hence}}}] abbreviates ``\mbox{\isa{\isacommand{then}}}~\mbox{\isa{\isacommand{have}}}'', i.e.\ claims a local goal to be proven by forward
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1017
  chaining the current facts.  Note that \mbox{\isa{\isacommand{hence}}} is also
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1018
  equivalent to ``\mbox{\isa{\isacommand{from}}}~\isa{this}~\mbox{\isa{\isacommand{have}}}''.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1019
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1020
  \item [\mbox{\isa{\isacommand{thus}}}] abbreviates ``\mbox{\isa{\isacommand{then}}}~\mbox{\isa{\isacommand{show}}}''.  Note that \mbox{\isa{\isacommand{thus}}} is also equivalent to
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1021
  ``\mbox{\isa{\isacommand{from}}}~\isa{this}~\mbox{\isa{\isacommand{show}}}''.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1022
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1023
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}statement}}}~\isa{a}] prints facts from the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1024
  current theory or proof context in long statement form, according to
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1025
  the syntax for \mbox{\isa{\isacommand{lemma}}} given above.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1026
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1027
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1028
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1029
  Any goal statement causes some term abbreviations (such as
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1030
  \indexref{}{variable}{?thesis}\mbox{\isa{{\isacharquery}thesis}}) to be bound automatically, see also
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1031
  \secref{sec:term-abbrev}.  Furthermore, the local context of a
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1032
  (non-atomic) goal is provided via the \indexref{}{case}{rule-context}\mbox{\isa{rule{\isacharunderscore}context}} case.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1033
26788
57b54e586989 updated generated file;
wenzelm
parents: 26776
diff changeset
  1034
  The optional case names of \indexref{}{element}{obtains}\mbox{\isa{\isakeyword{obtains}}} have a twofold
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1035
  meaning: (1) during the of this claim they refer to the the local
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1036
  context introductions, (2) the resulting rule is annotated
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1037
  accordingly to support symbolic case splits when used with the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1038
  \indexref{}{method}{cases}\mbox{\isa{cases}} method (cf.  \secref{sec:cases-induct}).
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1039
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1040
  \medskip
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1041
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1042
  \begin{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1043
    Isabelle/Isar suffers theory-level goal statements to contain
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1044
    \emph{unbound schematic variables}, although this does not conform
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1045
    to the aim of human-readable proof documents!  The main problem
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1046
    with schematic goals is that the actual outcome is usually hard to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1047
    predict, depending on the behavior of the proof methods applied
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1048
    during the course of reasoning.  Note that most semi-automated
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1049
    methods heavily depend on several kinds of implicit rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1050
    declarations within the current theory context.  As this would
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1051
    also result in non-compositional checking of sub-proofs,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1052
    \emph{local goals} are not allowed to be schematic at all.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1053
    Nevertheless, schematic goals do have their use in Prolog-style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1054
    interactive synthesis of proven results, usually by stepwise
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1055
    refinement via emulation of traditional Isabelle tactic scripts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1056
    (see also \secref{sec:tactic-commands}).  In any case, users
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1057
    should know what they are doing.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1058
  \end{warn}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1059
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1060
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1061
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1062
\isamarkupsubsection{Initial and terminal proof steps \label{sec:proof-steps}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1063
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1064
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1065
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1066
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1067
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1068
    \indexdef{}{command}{proof}\mbox{\isa{\isacommand{proof}}} & : & \isartrans{proof(prove)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1069
    \indexdef{}{command}{qed}\mbox{\isa{\isacommand{qed}}} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1070
    \indexdef{}{command}{by}\mbox{\isa{\isacommand{by}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1071
    \indexdef{}{command}{..}\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1072
    \indexdef{}{command}{.}\mbox{\isa{\isacommand{{\isachardot}}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1073
    \indexdef{}{command}{sorry}\mbox{\isa{\isacommand{sorry}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1074
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1075
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1076
  Arbitrary goal refinement via tactics is considered harmful.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1077
  Structured proof composition in Isar admits proof methods to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1078
  invoked in two places only.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1079
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1080
  \begin{enumerate}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1081
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1082
  \item An \emph{initial} refinement step \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}}~\isa{m\isactrlsub {\isadigit{1}}} reduces a newly stated goal to a number
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1083
  of sub-goals that are to be solved later.  Facts are passed to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1084
  \isa{m\isactrlsub {\isadigit{1}}} for forward chaining, if so indicated by \isa{proof{\isacharparenleft}chain{\isacharparenright}} mode.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1085
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1086
  \item A \emph{terminal} conclusion step \indexref{}{command}{qed}\mbox{\isa{\isacommand{qed}}}~\isa{m\isactrlsub {\isadigit{2}}} is intended to solve remaining goals.  No facts are
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1087
  passed to \isa{m\isactrlsub {\isadigit{2}}}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1088
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1089
  \end{enumerate}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1090
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1091
  The only other (proper) way to affect pending goals in a proof body
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1092
  is by \indexref{}{command}{show}\mbox{\isa{\isacommand{show}}}, which involves an explicit statement of
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1093
  what is to be solved eventually.  Thus we avoid the fundamental
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1094
  problem of unstructured tactic scripts that consist of numerous
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1095
  consecutive goal transformations, with invisible effects.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1096
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1097
  \medskip As a general rule of thumb for good proof style, initial
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1098
  proof methods should either solve the goal completely, or constitute
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1099
  some well-understood reduction to new sub-goals.  Arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1100
  automatic proof tools that are prone leave a large number of badly
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1101
  structured sub-goals are no help in continuing the proof document in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1102
  an intelligible manner.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1103
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1104
  Unless given explicitly by the user, the default initial method is
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1105
  ``\indexref{}{method}{rule}\mbox{\isa{rule}}'', which applies a single standard elimination
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1106
  or introduction rule according to the topmost symbol involved.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1107
  There is no separate default terminal method.  Any remaining goals
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1108
  are always solved by assumption in the very last step.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1109
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1110
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1111
    'proof' method?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1112
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1113
    'qed' method?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1114
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1115
    'by' method method?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1116
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1117
    ('.' | '..' | 'sorry')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1118
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1119
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1120
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1121
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1122
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1123
  \item [\mbox{\isa{\isacommand{proof}}}~\isa{m\isactrlsub {\isadigit{1}}}] refines the goal by
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1124
  proof method \isa{m\isactrlsub {\isadigit{1}}}; facts for forward chaining are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1125
  passed if so indicated by \isa{proof{\isacharparenleft}chain{\isacharparenright}} mode.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1126
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1127
  \item [\mbox{\isa{\isacommand{qed}}}~\isa{m\isactrlsub {\isadigit{2}}}] refines any remaining
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1128
  goals by proof method \isa{m\isactrlsub {\isadigit{2}}} and concludes the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1129
  sub-proof by assumption.  If the goal had been \isa{show} (or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1130
  \isa{thus}), some pending sub-goal is solved as well by the rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1131
  resulting from the result \emph{exported} into the enclosing goal
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1132
  context.  Thus \isa{qed} may fail for two reasons: either \isa{m\isactrlsub {\isadigit{2}}} fails, or the resulting rule does not fit to any
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1133
  pending goal\footnote{This includes any additional ``strong''
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1134
  assumptions as introduced by \mbox{\isa{\isacommand{assume}}}.} of the enclosing
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1135
  context.  Debugging such a situation might involve temporarily
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1136
  changing \mbox{\isa{\isacommand{show}}} into \mbox{\isa{\isacommand{have}}}, or weakening the
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1137
  local context by replacing occurrences of \mbox{\isa{\isacommand{assume}}} by
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1138
  \mbox{\isa{\isacommand{presume}}}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1139
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1140
  \item [\mbox{\isa{\isacommand{by}}}~\isa{m\isactrlsub {\isadigit{1}}\ m\isactrlsub {\isadigit{2}}}] is a
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1141
  \emph{terminal proof}\index{proof!terminal}; it abbreviates
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1142
  \mbox{\isa{\isacommand{proof}}}~\isa{m\isactrlsub {\isadigit{1}}}~\isa{qed}~\isa{m\isactrlsub {\isadigit{2}}}, but with backtracking across both methods.  Debugging
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1143
  an unsuccessful \mbox{\isa{\isacommand{by}}}~\isa{m\isactrlsub {\isadigit{1}}\ m\isactrlsub {\isadigit{2}}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1144
  command can be done by expanding its definition; in many cases
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1145
  \mbox{\isa{\isacommand{proof}}}~\isa{m\isactrlsub {\isadigit{1}}} (or even \isa{apply}~\isa{m\isactrlsub {\isadigit{1}}}) is already sufficient to see the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1146
  problem.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1147
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1148
  \item [``\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}}''] is a \emph{default
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1149
  proof}\index{proof!default}; it abbreviates \mbox{\isa{\isacommand{by}}}~\isa{rule}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1150
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1151
  \item [``\mbox{\isa{\isacommand{{\isachardot}}}}''] is a \emph{trivial
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1152
  proof}\index{proof!trivial}; it abbreviates \mbox{\isa{\isacommand{by}}}~\isa{this}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1153
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1154
  \item [\mbox{\isa{\isacommand{sorry}}}] is a \emph{fake proof}\index{proof!fake}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1155
  pretending to solve the pending claim without further ado.  This
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1156
  only works in interactive development, or if the \verb|quick_and_dirty| flag is enabled (in ML).  Facts emerging from fake
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1157
  proofs are not the real thing.  Internally, each theorem container
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1158
  is tainted by an oracle invocation, which is indicated as ``\isa{{\isacharbrackleft}{\isacharbang}{\isacharbrackright}}'' in the printed result.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1159
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1160
  The most important application of \mbox{\isa{\isacommand{sorry}}} is to support
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1161
  experimentation and top-down proof development.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1162
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1163
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1164
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1165
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1166
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1167
\isamarkupsubsection{Fundamental methods and attributes \label{sec:pure-meth-att}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1168
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1169
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1170
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1171
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1172
The following proof methods and attributes refer to basic logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1173
  operations of Isar.  Further methods and attributes are provided by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1174
  several generic and object-logic specific tools and packages (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1175
  \chref{ch:gen-tools} and \chref{ch:logics}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1176
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1177
  \begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1178
    \indexdef{}{method}{-}\mbox{\isa{{\isacharminus}}} & : & \isarmeth \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1179
    \indexdef{}{method}{fact}\mbox{\isa{fact}} & : & \isarmeth \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1180
    \indexdef{}{method}{assumption}\mbox{\isa{assumption}} & : & \isarmeth \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1181
    \indexdef{}{method}{this}\mbox{\isa{this}} & : & \isarmeth \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1182
    \indexdef{}{method}{rule}\mbox{\isa{rule}} & : & \isarmeth \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1183
    \indexdef{}{method}{iprover}\mbox{\isa{iprover}} & : & \isarmeth \\[0.5ex]
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1184
    \indexdef{}{attribute}{intro}\mbox{\isa{intro}} & : & \isaratt \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1185
    \indexdef{}{attribute}{elim}\mbox{\isa{elim}} & : & \isaratt \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1186
    \indexdef{}{attribute}{dest}\mbox{\isa{dest}} & : & \isaratt \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1187
    \indexdef{}{attribute}{rule}\mbox{\isa{rule}} & : & \isaratt \\[0.5ex]
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1188
    \indexdef{}{attribute}{OF}\mbox{\isa{OF}} & : & \isaratt \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1189
    \indexdef{}{attribute}{of}\mbox{\isa{of}} & : & \isaratt \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1190
    \indexdef{}{attribute}{where}\mbox{\isa{where}} & : & \isaratt \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1191
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1192
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1193
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1194
    'fact' thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1195
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1196
    'rule' thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1197
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1198
    'iprover' ('!' ?) (rulemod *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1199
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1200
    rulemod: ('intro' | 'elim' | 'dest') ((('!' | () | '?') nat?) | 'del') ':' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1201
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1202
    ('intro' | 'elim' | 'dest') ('!' | () | '?') nat?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1203
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1204
    'rule' 'del'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1205
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1206
    'OF' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1207
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1208
    'of' insts ('concl' ':' insts)?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1209
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1210
    'where' ((name | var | typefree | typevar) '=' (type | term) * 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1211
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1212
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1213
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1214
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1215
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1216
  \item [``\mbox{\isa{{\isacharminus}}}'' (minus)] does nothing but insert the
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1217
  forward chaining facts as premises into the goal.  Note that command
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1218
  \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}} without any method actually performs a single
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1219
  reduction step using the \indexref{}{method}{rule}\mbox{\isa{rule}} method; thus a plain
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1220
  \emph{do-nothing} proof step would be ``\mbox{\isa{\isacommand{proof}}}~\isa{{\isacharminus}}'' rather than \mbox{\isa{\isacommand{proof}}} alone.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1221
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1222
  \item [\mbox{\isa{fact}}~\isa{a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n}] composes
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1223
  some fact from \isa{a\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ a\isactrlsub n} (or implicitly from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1224
  the current proof context) modulo unification of schematic type and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1225
  term variables.  The rule structure is not taken into account, i.e.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1226
  meta-level implication is considered atomic.  This is the same
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1227
  principle underlying literal facts (cf.\ \secref{sec:syn-att}):
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1228
  ``\mbox{\isa{\isacommand{have}}}~\isa{{\isasymphi}}~\mbox{\isa{\isacommand{by}}}~\isa{fact}'' is
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1229
  equivalent to ``\mbox{\isa{\isacommand{note}}}~\verb|`|\isa{{\isasymphi}}\verb|`|'' provided that \isa{{\isasymturnstile}\ {\isasymphi}} is an instance of some known
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1230
  \isa{{\isasymturnstile}\ {\isasymphi}} in the proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1231
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1232
  \item [\mbox{\isa{assumption}}] solves some goal by a single assumption
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1233
  step.  All given facts are guaranteed to participate in the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1234
  refinement; this means there may be only 0 or 1 in the first place.
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1235
  Recall that \mbox{\isa{\isacommand{qed}}} (\secref{sec:proof-steps}) already
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1236
  concludes any remaining sub-goals by assumption, so structured
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1237
  proofs usually need not quote the \mbox{\isa{assumption}} method at
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1238
  all.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1239
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1240
  \item [\mbox{\isa{this}}] applies all of the current facts directly as
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1241
  rules.  Recall that ``\mbox{\isa{\isacommand{{\isachardot}}}}'' (dot) abbreviates ``\mbox{\isa{\isacommand{by}}}~\isa{this}''.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1242
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1243
  \item [\mbox{\isa{rule}}~\isa{a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n}] applies some
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1244
  rule given as argument in backward manner; facts are used to reduce
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1245
  the rule before applying it to the goal.  Thus \mbox{\isa{rule}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1246
  without facts is plain introduction, while with facts it becomes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1247
  elimination.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1248
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1249
  When no arguments are given, the \mbox{\isa{rule}} method tries to pick
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1250
  appropriate rules automatically, as declared in the current context
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1251
  using the \mbox{\isa{intro}}, \mbox{\isa{elim}}, \mbox{\isa{dest}}
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1252
  attributes (see below).  This is the default behavior of \mbox{\isa{\isacommand{proof}}} and ``\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}}'' (double-dot) steps (see
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1253
  \secref{sec:proof-steps}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1254
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1255
  \item [\mbox{\isa{iprover}}] performs intuitionistic proof search,
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1256
  depending on specifically declared rules from the context, or given
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1257
  as explicit arguments.  Chained facts are inserted into the goal
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1258
  before commencing proof search; ``\mbox{\isa{iprover}}\isa{{\isacharbang}}'' 
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1259
  means to include the current \mbox{\isa{prems}} as well.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1260
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1261
  Rules need to be classified as \mbox{\isa{intro}}, \mbox{\isa{elim}}, or \mbox{\isa{dest}}; here the ``\isa{{\isacharbang}}'' indicator
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1262
  refers to ``safe'' rules, which may be applied aggressively (without
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1263
  considering back-tracking later).  Rules declared with ``\isa{{\isacharquery}}'' are ignored in proof search (the single-step \mbox{\isa{rule}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1264
  method still observes these).  An explicit weight annotation may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1265
  given as well; otherwise the number of rule premises will be taken
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1266
  into account here.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1267
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1268
  \item [\mbox{\isa{intro}}, \mbox{\isa{elim}}, and \mbox{\isa{dest}}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1269
  declare introduction, elimination, and destruct rules, to be used
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1270
  with the \mbox{\isa{rule}} and \mbox{\isa{iprover}} methods.  Note that
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1271
  the latter will ignore rules declared with ``\isa{{\isacharquery}}'', while
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1272
  ``\isa{{\isacharbang}}''  are used most aggressively.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1273
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1274
  The classical reasoner (see \secref{sec:classical}) introduces its
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1275
  own variants of these attributes; use qualified names to access the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1276
  present versions of Isabelle/Pure, i.e.\ \mbox{\isa{Pure{\isachardot}intro}}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1277
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1278
  \item [\mbox{\isa{rule}}~\isa{del}] undeclares introduction,
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1279
  elimination, or destruct rules.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1280
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1281
  \item [\mbox{\isa{OF}}~\isa{a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n}] applies some
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1282
  theorem to all of the given rules \isa{a\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ a\isactrlsub n}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1283
  (in parallel).  This corresponds to the \verb|op MRS| operation in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1284
  ML, but note the reversed order.  Positions may be effectively
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1285
  skipped by including ``\isa{{\isacharunderscore}}'' (underscore) as argument.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1286
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1287
  \item [\mbox{\isa{of}}~\isa{t\isactrlsub {\isadigit{1}}\ {\isasymdots}\ t\isactrlsub n}] performs
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1288
  positional instantiation of term variables.  The terms \isa{t\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ t\isactrlsub n} are substituted for any schematic
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1289
  variables occurring in a theorem from left to right; ``\isa{{\isacharunderscore}}'' (underscore) indicates to skip a position.  Arguments following
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1290
  a ``\mbox{\isa{\isakeyword{concl}}}\isa{{\isacharcolon}}'' specification refer to positions
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1291
  of the conclusion of a rule.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1292
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1293
  \item [\mbox{\isa{where}}~\isa{x\isactrlsub {\isadigit{1}}\ {\isacharequal}\ t\isactrlsub {\isadigit{1}}\ {\isasymAND}\ {\isasymdots}\ x\isactrlsub n\ {\isacharequal}\ t\isactrlsub n}] performs named instantiation of schematic
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1294
  type and term variables occurring in a theorem.  Schematic variables
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1295
  have to be specified on the left-hand side (e.g.\ \isa{{\isacharquery}x{\isadigit{1}}{\isachardot}{\isadigit{3}}}).
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1296
  The question mark may be omitted if the variable name is a plain
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1297
  identifier without index.  As type instantiations are inferred from
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1298
  term instantiations, explicit type instantiations are seldom
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1299
  necessary.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1300
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1301
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1302
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1303
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1304
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1305
\isamarkupsubsection{Term abbreviations \label{sec:term-abbrev}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1306
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1307
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1308
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1309
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1310
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1311
    \indexdef{}{command}{let}\mbox{\isa{\isacommand{let}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1312
    \indexdef{}{keyword}{is}\mbox{\isa{\isakeyword{is}}} & : & syntax \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1313
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1314
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1315
  Abbreviations may be either bound by explicit \mbox{\isa{\isacommand{let}}}~\isa{p\ {\isasymequiv}\ t} statements, or by annotating assumptions or
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1316
  goal statements with a list of patterns ``\isa{{\isacharparenleft}{\isasymIS}\ p\isactrlsub {\isadigit{1}}\ {\isasymdots}\ p\isactrlsub n{\isacharparenright}}''.  In both cases, higher-order matching is invoked to
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1317
  bind extra-logical term variables, which may be either named
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1318
  schematic variables of the form \isa{{\isacharquery}x}, or nameless dummies
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1319
  ``\mbox{\isa{{\isacharunderscore}}}'' (underscore). Note that in the \mbox{\isa{\isacommand{let}}}
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1320
  form the patterns occur on the left-hand side, while the \mbox{\isa{\isakeyword{is}}} patterns are in postfix position.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1321
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1322
  Polymorphism of term bindings is handled in Hindley-Milner style,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1323
  similar to ML.  Type variables referring to local assumptions or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1324
  open goal statements are \emph{fixed}, while those of finished
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1325
  results or bound by \mbox{\isa{\isacommand{let}}} may occur in \emph{arbitrary}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1326
  instances later.  Even though actual polymorphism should be rarely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1327
  used in practice, this mechanism is essential to achieve proper
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1328
  incremental type-inference, as the user proceeds to build up the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1329
  Isar proof text from left to right.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1330
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1331
  \medskip Term abbreviations are quite different from local
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1332
  definitions as introduced via \mbox{\isa{\isacommand{def}}} (see
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1333
  \secref{sec:proof-context}).  The latter are visible within the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1334
  logic as actual equations, while abbreviations disappear during the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1335
  input process just after type checking.  Also note that \mbox{\isa{\isacommand{def}}} does not support polymorphism.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1336
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1337
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1338
    'let' ((term + 'and') '=' term + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1339
    ;  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1340
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1341
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1342
  The syntax of \mbox{\isa{\isakeyword{is}}} patterns follows \railnonterm{termpat}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1343
  or \railnonterm{proppat} (see \secref{sec:term-decls}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1344
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1345
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1346
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1347
  \item [\mbox{\isa{\isacommand{let}}}~\isa{p\isactrlsub {\isadigit{1}}\ {\isacharequal}\ t\isactrlsub {\isadigit{1}}\ {\isasymAND}\ {\isasymdots}\ p\isactrlsub n\ {\isacharequal}\ t\isactrlsub n}] binds any text variables in patterns \isa{p\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ p\isactrlsub n} by simultaneous higher-order matching
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1348
  against terms \isa{t\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ t\isactrlsub n}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1349
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1350
  \item [\isa{{\isacharparenleft}{\isasymIS}\ p\isactrlsub {\isadigit{1}}\ {\isasymdots}\ p\isactrlsub n{\isacharparenright}}] resembles \mbox{\isa{\isacommand{let}}}, but matches \isa{p\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ p\isactrlsub n} against the
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1351
  preceding statement.  Also note that \mbox{\isa{\isakeyword{is}}} is not a
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1352
  separate command, but part of others (such as \mbox{\isa{\isacommand{assume}}},
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1353
  \mbox{\isa{\isacommand{have}}} etc.).
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1354
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1355
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1356
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1357
  Some \emph{implicit} term abbreviations\index{term abbreviations}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1358
  for goals and facts are available as well.  For any open goal,
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1359
  \indexref{}{variable}{thesis}\mbox{\isa{thesis}} refers to its object-level statement,
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1360
  abstracted over any meta-level parameters (if present).  Likewise,
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1361
  \indexref{}{variable}{this}\mbox{\isa{this}} is bound for fact statements resulting from
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1362
  assumptions or finished goals.  In case \mbox{\isa{this}} refers to
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1363
  an object-logic statement that is an application \isa{f\ t}, then
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1364
  \isa{t} is bound to the special text variable ``\mbox{\isa{{\isasymdots}}}''
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1365
  (three dots).  The canonical application of this convenience are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1366
  calculational proofs (see \secref{sec:calculation}).%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1367
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1368
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1369
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1370
\isamarkupsubsection{Block structure%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1371
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1372
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1373
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1374
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1375
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1376
    \indexdef{}{command}{next}\mbox{\isa{\isacommand{next}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1377
    \indexdef{}{command}{\{}\mbox{\isa{\isacommand{{\isacharbraceleft}}}} & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1378
    \indexdef{}{command}{\}}\mbox{\isa{\isacommand{{\isacharbraceright}}}} & : & \isartrans{proof(state)}{proof(state)} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1379
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1380
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1381
  While Isar is inherently block-structured, opening and closing
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1382
  blocks is mostly handled rather casually, with little explicit
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1383
  user-intervention.  Any local goal statement automatically opens
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1384
  \emph{two} internal blocks, which are closed again when concluding
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1385
  the sub-proof (by \mbox{\isa{\isacommand{qed}}} etc.).  Sections of different
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1386
  context within a sub-proof may be switched via \mbox{\isa{\isacommand{next}}},
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1387
  which is just a single block-close followed by block-open again.
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1388
  The effect of \mbox{\isa{\isacommand{next}}} is to reset the local proof context;
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1389
  there is no goal focus involved here!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1390
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1391
  For slightly more advanced applications, there are explicit block
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1392
  parentheses as well.  These typically achieve a stronger forward
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1393
  style of reasoning.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1394
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1395
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1396
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1397
  \item [\mbox{\isa{\isacommand{next}}}] switches to a fresh block within a
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1398
  sub-proof, resetting the local context to the initial one.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1399
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1400
  \item [\mbox{\isa{\isacommand{{\isacharbraceleft}}}} and \mbox{\isa{\isacommand{{\isacharbraceright}}}}] explicitly open and close
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1401
  blocks.  Any current facts pass through ``\mbox{\isa{\isacommand{{\isacharbraceleft}}}}''
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1402
  unchanged, while ``\mbox{\isa{\isacommand{{\isacharbraceright}}}}'' causes any result to be
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1403
  \emph{exported} into the enclosing context.  Thus fixed variables
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1404
  are generalized, assumptions discharged, and local definitions
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1405
  unfolded (cf.\ \secref{sec:proof-context}).  There is no difference
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1406
  of \mbox{\isa{\isacommand{assume}}} and \mbox{\isa{\isacommand{presume}}} in this mode of
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1407
  forward reasoning --- in contrast to plain backward reasoning with
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1408
  the result exported at \mbox{\isa{\isacommand{show}}} time.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1409
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1410
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1411
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1412
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1413
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1414
\isamarkupsubsection{Emulating tactic scripts \label{sec:tactic-commands}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1415
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1416
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1417
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1418
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1419
The Isar provides separate commands to accommodate tactic-style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1420
  proof scripts within the same system.  While being outside the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1421
  orthodox Isar proof language, these might come in handy for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1422
  interactive exploration and debugging, or even actual tactical proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1423
  within new-style theories (to benefit from document preparation, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1424
  example).  See also \secref{sec:tactics} for actual tactics, that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1425
  have been encapsulated as proof methods.  Proper proof methods may
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1426
  be used in scripts, too.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1427
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1428
  \begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1429
    \indexdef{}{command}{apply}\mbox{\isa{\isacommand{apply}}}^* & : & \isartrans{proof(prove)}{proof(prove)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1430
    \indexdef{}{command}{apply-end}\mbox{\isa{\isacommand{apply{\isacharunderscore}end}}}^* & : & \isartrans{proof(state)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1431
    \indexdef{}{command}{done}\mbox{\isa{\isacommand{done}}}^* & : & \isartrans{proof(prove)}{proof(state)} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1432
    \indexdef{}{command}{defer}\mbox{\isa{\isacommand{defer}}}^* & : & \isartrans{proof}{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1433
    \indexdef{}{command}{prefer}\mbox{\isa{\isacommand{prefer}}}^* & : & \isartrans{proof}{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1434
    \indexdef{}{command}{back}\mbox{\isa{\isacommand{back}}}^* & : & \isartrans{proof}{proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1435
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1436
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1437
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1438
    ( 'apply' | 'apply\_end' ) method
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1439
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1440
    'defer' nat?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1441
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1442
    'prefer' nat
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1443
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1444
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1445
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1446
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1447
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1448
  \item [\mbox{\isa{\isacommand{apply}}}~\isa{m}] applies proof method \isa{m}
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1449
  in initial position, but unlike \mbox{\isa{\isacommand{proof}}} it retains
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1450
  ``\isa{proof{\isacharparenleft}prove{\isacharparenright}}'' mode.  Thus consecutive method
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1451
  applications may be given just as in tactic scripts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1452
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1453
  Facts are passed to \isa{m} as indicated by the goal's
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1454
  forward-chain mode, and are \emph{consumed} afterwards.  Thus any
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1455
  further \mbox{\isa{\isacommand{apply}}} command would always work in a purely
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1456
  backward manner.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1457
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1458
  \item [\mbox{\isa{\isacommand{apply{\isacharunderscore}end}}}~\isa{m}] applies proof method
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1459
  \isa{m} as if in terminal position.  Basically, this simulates a
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1460
  multi-step tactic script for \mbox{\isa{\isacommand{qed}}}, but may be given
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1461
  anywhere within the proof body.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1462
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1463
  No facts are passed to \mbox{\isa{m}} here.  Furthermore, the static
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1464
  context is that of the enclosing goal (as for actual \mbox{\isa{\isacommand{qed}}}).  Thus the proof method may not refer to any assumptions
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1465
  introduced in the current body, for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1466
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1467
  \item [\mbox{\isa{\isacommand{done}}}] completes a proof script, provided that
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1468
  the current goal state is solved completely.  Note that actual
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1469
  structured proof commands (e.g.\ ``\mbox{\isa{\isacommand{{\isachardot}}}}'' or \mbox{\isa{\isacommand{sorry}}}) may be used to conclude proof scripts as well.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1470
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1471
  \item [\mbox{\isa{\isacommand{defer}}}~\isa{n} and \mbox{\isa{\isacommand{prefer}}}~\isa{n}] shuffle the list of pending goals: \mbox{\isa{\isacommand{defer}}} puts off
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1472
  sub-goal \isa{n} to the end of the list (\isa{n\ {\isacharequal}\ {\isadigit{1}}} by
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1473
  default), while \mbox{\isa{\isacommand{prefer}}} brings sub-goal \isa{n} to the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1474
  front.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1475
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1476
  \item [\mbox{\isa{\isacommand{back}}}] does back-tracking over the result
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1477
  sequence of the latest proof command.  Basically, any proof command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1478
  may return multiple results.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1479
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1480
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1481
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1482
  Any proper Isar proof method may be used with tactic script commands
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1483
  such as \mbox{\isa{\isacommand{apply}}}.  A few additional emulations of actual
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1484
  tactics are provided as well; these would be never used in actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1485
  structured proofs, of course.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1486
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1487
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1488
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1489
\isamarkupsubsection{Meta-linguistic features%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1490
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1491
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1492
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1493
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1494
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1495
    \indexdef{}{command}{oops}\mbox{\isa{\isacommand{oops}}} & : & \isartrans{proof}{theory} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1496
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1497
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1498
  The \mbox{\isa{\isacommand{oops}}} command discontinues the current proof
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1499
  attempt, while considering the partial proof text as properly
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1500
  processed.  This is conceptually quite different from ``faking''
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1501
  actual proofs via \indexref{}{command}{sorry}\mbox{\isa{\isacommand{sorry}}} (see
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1502
  \secref{sec:proof-steps}): \mbox{\isa{\isacommand{oops}}} does not observe the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1503
  proof structure at all, but goes back right to the theory level.
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1504
  Furthermore, \mbox{\isa{\isacommand{oops}}} does not produce any result theorem
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1505
  --- there is no intended claim to be able to complete the proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1506
  anyhow.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1507
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1508
  A typical application of \mbox{\isa{\isacommand{oops}}} is to explain Isar proofs
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1509
  \emph{within} the system itself, in conjunction with the document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1510
  preparation tools of Isabelle described in \cite{isabelle-sys}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1511
  Thus partial or even wrong proof attempts can be discussed in a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1512
  logically sound manner.  Note that the Isabelle {\LaTeX} macros can
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1513
  be easily adapted to print something like ``\isa{{\isasymdots}}'' instead of
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1514
  the keyword ``\mbox{\isa{\isacommand{oops}}}''.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1515
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1516
  \medskip The \mbox{\isa{\isacommand{oops}}} command is undo-able, unlike
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1517
  \indexref{}{command}{kill}\mbox{\isa{\isacommand{kill}}} (see \secref{sec:history}).  The effect is to
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1518
  get back to the theory just before the opening of the proof.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1519
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1520
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1521
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1522
\isamarkupsection{Other commands%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1523
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1524
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1525
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1526
\isamarkupsubsection{Diagnostics%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1527
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1528
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1529
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1530
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1531
\begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1532
    \isarcmd{pr}^* & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1533
    \isarcmd{thm}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1534
    \isarcmd{term}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1535
    \isarcmd{prop}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1536
    \isarcmd{typ}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1537
    \isarcmd{prf}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1538
    \isarcmd{full_prf}^* & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1539
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1540
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1541
  These diagnostic commands assist interactive development.  Note that
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1542
  \mbox{\isa{\isacommand{undo}}} does not apply here, the theory or proof
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1543
  configuration is not changed.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1544
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1545
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1546
    'pr' modes? nat? (',' nat)?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1547
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1548
    'thm' modes? thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1549
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1550
    'term' modes? term
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1551
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1552
    'prop' modes? prop
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1553
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1554
    'typ' modes? type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1555
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1556
    'prf' modes? thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1557
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1558
    'full\_prf' modes? thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1559
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1560
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1561
    modes: '(' (name + ) ')'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1562
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1563
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1564
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1565
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1566
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1567
  \item [\mbox{\isa{\isacommand{pr}}}~\isa{goals{\isacharcomma}\ prems}] prints the current
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1568
  proof state (if present), including the proof context, current facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1569
  and goals.  The optional limit arguments affect the number of goals
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1570
  and premises to be displayed, which is initially 10 for both.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1571
  Omitting limit values leaves the current setting unchanged.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1572
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1573
  \item [\mbox{\isa{\isacommand{thm}}}~\isa{a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n}] retrieves
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1574
  theorems from the current theory or proof context.  Note that any
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1575
  attributes included in the theorem specifications are applied to a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1576
  temporary context derived from the current theory or proof; the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1577
  result is discarded, i.e.\ attributes involved in \isa{a\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ a\isactrlsub n} do not have any permanent effect.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1578
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1579
  \item [\mbox{\isa{\isacommand{term}}}~\isa{t} and \mbox{\isa{\isacommand{prop}}}~\isa{{\isasymphi}}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1580
  read, type-check and print terms or propositions according to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1581
  current theory or proof context; the inferred type of \isa{t} is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1582
  output as well.  Note that these commands are also useful in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1583
  inspecting the current environment of term abbreviations.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1584
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1585
  \item [\mbox{\isa{\isacommand{typ}}}~\isa{{\isasymtau}}] reads and prints types of the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1586
  meta-logic according to the current theory or proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1587
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1588
  \item [\mbox{\isa{\isacommand{prf}}}] displays the (compact) proof term of the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1589
  current proof state (if present), or of the given theorems. Note
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1590
  that this requires proof terms to be switched on for the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1591
  object logic (see the ``Proof terms'' section of the Isabelle
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1592
  reference manual for information on how to do this).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1593
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1594
  \item [\mbox{\isa{\isacommand{full{\isacharunderscore}prf}}}] is like \mbox{\isa{\isacommand{prf}}}, but displays
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1595
  the full proof term, i.e.\ also displays information omitted in the
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1596
  compact proof term, which is denoted by ``\isa{{\isacharunderscore}}'' placeholders
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1597
  there.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1598
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1599
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1600
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1601
  All of the diagnostic commands above admit a list of \isa{modes}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1602
  to be specified, which is appended to the current print mode (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1603
  also \cite{isabelle-ref}).  Thus the output behavior may be modified
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1604
  according particular print mode features.  For example, \mbox{\isa{\isacommand{pr}}}~\isa{{\isacharparenleft}latex\ xsymbols\ symbols{\isacharparenright}} would print the current
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1605
  proof state with mathematical symbols and special characters
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1606
  represented in {\LaTeX} source, according to the Isabelle style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1607
  \cite{isabelle-sys}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1608
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1609
  Note that antiquotations (cf.\ \secref{sec:antiq}) provide a more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1610
  systematic way to include formal items into the printed text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1611
  document.%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1612
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1613
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1614
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1615
\isamarkupsubsection{Inspecting the context%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1616
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1617
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1618
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1619
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1620
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1621
    \indexdef{}{command}{print-commands}\mbox{\isa{\isacommand{print{\isacharunderscore}commands}}}^* & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1622
    \indexdef{}{command}{print-theory}\mbox{\isa{\isacommand{print{\isacharunderscore}theory}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1623
    \indexdef{}{command}{print-syntax}\mbox{\isa{\isacommand{print{\isacharunderscore}syntax}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1624
    \indexdef{}{command}{print-methods}\mbox{\isa{\isacommand{print{\isacharunderscore}methods}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1625
    \indexdef{}{command}{print-attributes}\mbox{\isa{\isacommand{print{\isacharunderscore}attributes}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1626
    \indexdef{}{command}{print-theorems}\mbox{\isa{\isacommand{print{\isacharunderscore}theorems}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1627
    \indexdef{}{command}{find-theorems}\mbox{\isa{\isacommand{find{\isacharunderscore}theorems}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1628
    \indexdef{}{command}{thms-deps}\mbox{\isa{\isacommand{thms{\isacharunderscore}deps}}}^* & : & \isarkeep{theory~|~proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1629
    \indexdef{}{command}{print-facts}\mbox{\isa{\isacommand{print{\isacharunderscore}facts}}}^* & : & \isarkeep{proof} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1630
    \indexdef{}{command}{print-binds}\mbox{\isa{\isacommand{print{\isacharunderscore}binds}}}^* & : & \isarkeep{proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1631
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1632
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1633
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1634
    'print\_theory' ( '!'?)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1635
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1636
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1637
    'find\_theorems' (('(' (nat)? ('with\_dups')? ')')?) (criterion *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1638
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1639
    criterion: ('-'?) ('name' ':' nameref | 'intro' | 'elim' | 'dest' |
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1640
      'simp' ':' term | term)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1641
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1642
    'thm\_deps' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1643
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1644
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1645
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1646
  These commands print certain parts of the theory and proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1647
  Note that there are some further ones available, such as for the set
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1648
  of rules declared for simplifications.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1649
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1650
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1651
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1652
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}commands}}}] prints Isabelle's outer theory
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1653
  syntax, including keywords and command.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1654
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1655
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}theory}}}] prints the main logical content of
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1656
  the theory context; the ``\isa{{\isacharbang}}'' option indicates extra
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1657
  verbosity.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1658
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1659
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}syntax}}}] prints the inner syntax of types
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1660
  and terms, depending on the current context.  The output can be very
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1661
  verbose, including grammar tables and syntax translation rules.  See
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1662
  \cite[\S7, \S8]{isabelle-ref} for further information on Isabelle's
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1663
  inner syntax.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1664
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1665
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}methods}}}] prints all proof methods
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1666
  available in the current theory context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1667
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1668
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}attributes}}}] prints all attributes
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1669
  available in the current theory context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1670
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1671
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}theorems}}}] prints theorems resulting from
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1672
  the last command.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1673
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1674
  \item [\mbox{\isa{\isacommand{find{\isacharunderscore}theorems}}}~\isa{criteria}] retrieves facts
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1675
  from the theory or proof context matching all of given search
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1676
  criteria.  The criterion \isa{name{\isacharcolon}\ p} selects all theorems
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1677
  whose fully qualified name matches pattern \isa{p}, which may
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1678
  contain ``\isa{{\isacharasterisk}}'' wildcards.  The criteria \isa{intro},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1679
  \isa{elim}, and \isa{dest} select theorems that match the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1680
  current goal as introduction, elimination or destruction rules,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1681
  respectively.  The criterion \isa{simp{\isacharcolon}\ t} selects all rewrite
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1682
  rules whose left-hand side matches the given term.  The criterion
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1683
  term \isa{t} selects all theorems that contain the pattern \isa{t} -- as usual, patterns may contain occurrences of the dummy
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1684
  ``\isa{{\isacharunderscore}}'', schematic variables, and type constraints.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1685
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1686
  Criteria can be preceded by ``\isa{{\isacharminus}}'' to select theorems that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1687
  do \emph{not} match. Note that giving the empty list of criteria
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1688
  yields \emph{all} currently known facts.  An optional limit for the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1689
  number of printed facts may be given; the default is 40.  By
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1690
  default, duplicates are removed from the search result. Use
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1691
  \mbox{\isa{\isakeyword{with{\isacharunderscore}dups}}} to display duplicates.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1692
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1693
  \item [\mbox{\isa{\isacommand{thm{\isacharunderscore}deps}}}~\isa{a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n}]
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1694
  visualizes dependencies of facts, using Isabelle's graph browser
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1695
  tool (see also \cite{isabelle-sys}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1696
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1697
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}facts}}}] prints all local facts of the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1698
  current context, both named and unnamed ones.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1699
  
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1700
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}binds}}}] prints all term abbreviations
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1701
  present in the context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1702
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1703
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1704
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1705
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1706
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1707
\isamarkupsubsection{History commands \label{sec:history}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1708
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1709
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1710
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1711
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1712
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1713
    \indexdef{}{command}{undo}\mbox{\isa{\isacommand{undo}}}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1714
    \indexdef{}{command}{redo}\mbox{\isa{\isacommand{redo}}}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1715
    \indexdef{}{command}{kill}\mbox{\isa{\isacommand{kill}}}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1716
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1717
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1718
  The Isabelle/Isar top-level maintains a two-stage history, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1719
  theory and proof state transformation.  Basically, any command can
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1720
  be undone using \mbox{\isa{\isacommand{undo}}}, excluding mere diagnostic
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1721
  elements.  Its effect may be revoked via \mbox{\isa{\isacommand{redo}}}, unless
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1722
  the corresponding \mbox{\isa{\isacommand{undo}}} step has crossed the beginning
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1723
  of a proof or theory.  The \mbox{\isa{\isacommand{kill}}} command aborts the
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1724
  current history node altogether, discontinuing a proof or even the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1725
  whole theory.  This operation is \emph{not} undo-able.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1726
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1727
  \begin{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1728
    History commands should never be used with user interfaces such as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1729
    Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1730
    care of stepping forth and back itself.  Interfering by manual
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1731
    \mbox{\isa{\isacommand{undo}}}, \mbox{\isa{\isacommand{redo}}}, or even \mbox{\isa{\isacommand{kill}}}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1732
    commands would quickly result in utter confusion.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1733
  \end{warn}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1734
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1735
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1736
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1737
\isamarkupsubsection{System operations%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1738
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1739
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1740
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1741
\begin{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1742
\begin{matharray}{rcl}
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1743
    \indexdef{}{command}{cd}\mbox{\isa{\isacommand{cd}}}^* & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1744
    \indexdef{}{command}{pwd}\mbox{\isa{\isacommand{pwd}}}^* & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1745
    \indexdef{}{command}{use-thy}\mbox{\isa{\isacommand{use{\isacharunderscore}thy}}}^* & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1746
    \indexdef{}{command}{display-drafts}\mbox{\isa{\isacommand{display{\isacharunderscore}drafts}}}^* & : & \isarkeep{\cdot} \\
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1747
    \indexdef{}{command}{print-drafts}\mbox{\isa{\isacommand{print{\isacharunderscore}drafts}}}^* & : & \isarkeep{\cdot} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1748
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1749
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1750
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1751
    ('cd' | 'use\_thy' | 'update\_thy') name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1752
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1753
    ('display\_drafts' | 'print\_drafts') (name +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1754
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1755
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1756
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1757
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1758
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1759
  \item [\mbox{\isa{\isacommand{cd}}}~\isa{path}] changes the current directory
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1760
  of the Isabelle process.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1761
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1762
  \item [\mbox{\isa{\isacommand{pwd}}}] prints the current working directory.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1763
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1764
  \item [\mbox{\isa{\isacommand{use{\isacharunderscore}thy}}}~\isa{A}] preload theory \isa{A}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1765
  These system commands are scarcely used when working interactively,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1766
  since loading of theories is done automatically as required.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1767
26776
030db8c8b79d updated generated file;
wenzelm
parents: 26767
diff changeset
  1768
  \item [\mbox{\isa{\isacommand{display{\isacharunderscore}drafts}}}~\isa{paths} and \mbox{\isa{\isacommand{print{\isacharunderscore}drafts}}}~\isa{paths}] perform simple output of a given list
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1769
  of raw source files.  Only those symbols that do not require
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1770
  additional {\LaTeX} packages are displayed properly, everything else
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1771
  is left verbatim.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1772
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1773
  \end{descr}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1774
\end{isamarkuptext}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1775
\isamarkuptrue%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1776
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1777
\isadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1778
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1779
\endisadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1780
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1781
\isatagtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1782
\isacommand{end}\isamarkupfalse%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1783
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1784
\endisatagtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1785
{\isafoldtheory}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1786
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1787
\isadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1788
%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1789
\endisadelimtheory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1790
\isanewline
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1791
\end{isabellebody}%
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1792
%%% Local Variables:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1793
%%% mode: latex
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1794
%%% TeX-master: "root"
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
  1795
%%% End: