doc-src/IsarRef/Thy/document/Proof.tex
author wenzelm
Wed, 14 May 2008 20:31:41 +0200
changeset 26895 d066f9db833b
parent 26870 94bedbb34b92
child 26902 8db1e960d636
permissions -rw-r--r--
updated generated file;
wenzelm@26869
     1
%
wenzelm@26869
     2
\begin{isabellebody}%
wenzelm@26869
     3
\def\isabellecontext{Proof}%
wenzelm@26869
     4
%
wenzelm@26869
     5
\isadelimtheory
wenzelm@26869
     6
\isanewline
wenzelm@26869
     7
\isanewline
wenzelm@26869
     8
%
wenzelm@26869
     9
\endisadelimtheory
wenzelm@26869
    10
%
wenzelm@26869
    11
\isatagtheory
wenzelm@26869
    12
\isacommand{theory}\isamarkupfalse%
wenzelm@26869
    13
\ Proof\isanewline
wenzelm@26869
    14
\isakeyword{imports}\ Main\isanewline
wenzelm@26869
    15
\isakeyword{begin}%
wenzelm@26869
    16
\endisatagtheory
wenzelm@26869
    17
{\isafoldtheory}%
wenzelm@26869
    18
%
wenzelm@26869
    19
\isadelimtheory
wenzelm@26869
    20
%
wenzelm@26869
    21
\endisadelimtheory
wenzelm@26869
    22
%
wenzelm@26869
    23
\isamarkupchapter{Proofs%
wenzelm@26869
    24
}
wenzelm@26869
    25
\isamarkuptrue%
wenzelm@26869
    26
%
wenzelm@26870
    27
\begin{isamarkuptext}%
wenzelm@26870
    28
Proof commands perform transitions of Isar/VM machine
wenzelm@26870
    29
  configurations, which are block-structured, consisting of a stack of
wenzelm@26870
    30
  nodes with three main components: logical proof context, current
wenzelm@26870
    31
  facts, and open goals.  Isar/VM transitions are \emph{typed}
wenzelm@26870
    32
  according to the following three different modes of operation:
wenzelm@26870
    33
wenzelm@26870
    34
  \begin{descr}
wenzelm@26870
    35
wenzelm@26870
    36
  \item [\isa{{\isachardoublequote}proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}}] means that a new goal has just been
wenzelm@26870
    37
  stated that is now to be \emph{proven}; the next command may refine
wenzelm@26870
    38
  it by some proof method, and enter a sub-proof to establish the
wenzelm@26870
    39
  actual result.
wenzelm@26870
    40
wenzelm@26870
    41
  \item [\isa{{\isachardoublequote}proof{\isacharparenleft}state{\isacharparenright}{\isachardoublequote}}] is like a nested theory mode: the
wenzelm@26870
    42
  context may be augmented by \emph{stating} additional assumptions,
wenzelm@26870
    43
  intermediate results etc.
wenzelm@26870
    44
wenzelm@26870
    45
  \item [\isa{{\isachardoublequote}proof{\isacharparenleft}chain{\isacharparenright}{\isachardoublequote}}] is intermediate between \isa{{\isachardoublequote}proof{\isacharparenleft}state{\isacharparenright}{\isachardoublequote}} and \isa{{\isachardoublequote}proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}}: existing facts (i.e.\
wenzelm@26870
    46
  the contents of the special ``\indexref{}{fact}{this}\mbox{\isa{this}}'' register) have been
wenzelm@26870
    47
  just picked up in order to be used when refining the goal claimed
wenzelm@26870
    48
  next.
wenzelm@26870
    49
wenzelm@26870
    50
  \end{descr}
wenzelm@26870
    51
wenzelm@26870
    52
  The proof mode indicator may be read as a verb telling the writer
wenzelm@26870
    53
  what kind of operation may be performed next.  The corresponding
wenzelm@26870
    54
  typings of proof commands restricts the shape of well-formed proof
wenzelm@26870
    55
  texts to particular command sequences.  So dynamic arrangements of
wenzelm@26870
    56
  commands eventually turn out as static texts of a certain structure.
wenzelm@26870
    57
  \Appref{ap:refcard} gives a simplified grammar of the overall
wenzelm@26870
    58
  (extensible) language emerging that way.%
wenzelm@26870
    59
\end{isamarkuptext}%
wenzelm@26870
    60
\isamarkuptrue%
wenzelm@26870
    61
%
wenzelm@26870
    62
\isamarkupsection{Context elements \label{sec:proof-context}%
wenzelm@26870
    63
}
wenzelm@26870
    64
\isamarkuptrue%
wenzelm@26870
    65
%
wenzelm@26870
    66
\begin{isamarkuptext}%
wenzelm@26870
    67
\begin{matharray}{rcl}
wenzelm@26870
    68
    \indexdef{}{command}{fix}\mbox{\isa{\isacommand{fix}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
    69
    \indexdef{}{command}{assume}\mbox{\isa{\isacommand{assume}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
    70
    \indexdef{}{command}{presume}\mbox{\isa{\isacommand{presume}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
    71
    \indexdef{}{command}{def}\mbox{\isa{\isacommand{def}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
    72
  \end{matharray}
wenzelm@26870
    73
wenzelm@26870
    74
  The logical proof context consists of fixed variables and
wenzelm@26870
    75
  assumptions.  The former closely correspond to Skolem constants, or
wenzelm@26870
    76
  meta-level universal quantification as provided by the Isabelle/Pure
wenzelm@26870
    77
  logical framework.  Introducing some \emph{arbitrary, but fixed}
wenzelm@26870
    78
  variable via ``\mbox{\isa{\isacommand{fix}}}~\isa{x}'' results in a local value
wenzelm@26870
    79
  that may be used in the subsequent proof as any other variable or
wenzelm@26870
    80
  constant.  Furthermore, any result \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymphi}{\isacharbrackleft}x{\isacharbrackright}{\isachardoublequote}} exported from
wenzelm@26870
    81
  the context will be universally closed wrt.\ \isa{x} at the
wenzelm@26870
    82
  outermost level: \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymAnd}x{\isachardot}\ {\isasymphi}{\isacharbrackleft}x{\isacharbrackright}{\isachardoublequote}} (this is expressed in normal
wenzelm@26870
    83
  form using Isabelle's meta-variables).
wenzelm@26870
    84
wenzelm@26870
    85
  Similarly, introducing some assumption \isa{{\isasymchi}} has two effects.
wenzelm@26870
    86
  On the one hand, a local theorem is created that may be used as a
wenzelm@26870
    87
  fact in subsequent proof steps.  On the other hand, any result
wenzelm@26870
    88
  \isa{{\isachardoublequote}{\isasymchi}\ {\isasymturnstile}\ {\isasymphi}{\isachardoublequote}} exported from the context becomes conditional wrt.\
wenzelm@26870
    89
  the assumption: \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymchi}\ {\isasymLongrightarrow}\ {\isasymphi}{\isachardoublequote}}.  Thus, solving an enclosing goal
wenzelm@26870
    90
  using such a result would basically introduce a new subgoal stemming
wenzelm@26870
    91
  from the assumption.  How this situation is handled depends on the
wenzelm@26870
    92
  version of assumption command used: while \mbox{\isa{\isacommand{assume}}}
wenzelm@26870
    93
  insists on solving the subgoal by unification with some premise of
wenzelm@26870
    94
  the goal, \mbox{\isa{\isacommand{presume}}} leaves the subgoal unchanged in order
wenzelm@26870
    95
  to be proved later by the user.
wenzelm@26870
    96
wenzelm@26870
    97
  Local definitions, introduced by ``\mbox{\isa{\isacommand{def}}}~\isa{{\isachardoublequote}x\ {\isasymequiv}\ t{\isachardoublequote}}'', are achieved by combining ``\mbox{\isa{\isacommand{fix}}}~\isa{x}'' with
wenzelm@26870
    98
  another version of assumption that causes any hypothetical equation
wenzelm@26870
    99
  \isa{{\isachardoublequote}x\ {\isasymequiv}\ t{\isachardoublequote}} to be eliminated by the reflexivity rule.  Thus,
wenzelm@26870
   100
  exporting some result \isa{{\isachardoublequote}x\ {\isasymequiv}\ t\ {\isasymturnstile}\ {\isasymphi}{\isacharbrackleft}x{\isacharbrackright}{\isachardoublequote}} yields \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymphi}{\isacharbrackleft}t{\isacharbrackright}{\isachardoublequote}}.
wenzelm@26870
   101
wenzelm@26870
   102
  \begin{rail}
wenzelm@26870
   103
    'fix' (vars + 'and')
wenzelm@26870
   104
    ;
wenzelm@26870
   105
    ('assume' | 'presume') (props + 'and')
wenzelm@26870
   106
    ;
wenzelm@26870
   107
    'def' (def + 'and')
wenzelm@26870
   108
    ;
wenzelm@26870
   109
    def: thmdecl? \\ name ('==' | equiv) term termpat?
wenzelm@26870
   110
    ;
wenzelm@26870
   111
  \end{rail}
wenzelm@26870
   112
wenzelm@26870
   113
  \begin{descr}
wenzelm@26870
   114
  
wenzelm@26870
   115
  \item [\mbox{\isa{\isacommand{fix}}}~\isa{x}] introduces a local variable
wenzelm@26870
   116
  \isa{x} that is \emph{arbitrary, but fixed.}
wenzelm@26870
   117
  
wenzelm@26870
   118
  \item [\mbox{\isa{\isacommand{assume}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}} and \mbox{\isa{\isacommand{presume}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}}] introduce a local fact \isa{{\isachardoublequote}{\isasymphi}\ {\isasymturnstile}\ {\isasymphi}{\isachardoublequote}} by
wenzelm@26870
   119
  assumption.  Subsequent results applied to an enclosing goal (e.g.\
wenzelm@26870
   120
  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
wenzelm@26870
   121
  goal, while \mbox{\isa{\isacommand{presume}}} leaves \isa{{\isasymphi}} as new subgoals.
wenzelm@26870
   122
  
wenzelm@26870
   123
  Several lists of assumptions may be given (separated by
wenzelm@26870
   124
  \indexref{}{keyword}{and}\mbox{\isa{\isakeyword{and}}}; the resulting list of current facts consists
wenzelm@26870
   125
  of all of these concatenated.
wenzelm@26870
   126
  
wenzelm@26870
   127
  \item [\mbox{\isa{\isacommand{def}}}~\isa{{\isachardoublequote}x\ {\isasymequiv}\ t{\isachardoublequote}}] introduces a local
wenzelm@26870
   128
  (non-polymorphic) definition.  In results exported from the context,
wenzelm@26870
   129
  \isa{x} is replaced by \isa{t}.  Basically, ``\mbox{\isa{\isacommand{def}}}~\isa{{\isachardoublequote}x\ {\isasymequiv}\ t{\isachardoublequote}}'' abbreviates ``\mbox{\isa{\isacommand{fix}}}~\isa{x}~\mbox{\isa{\isacommand{assume}}}~\isa{{\isachardoublequote}x\ {\isasymequiv}\ t{\isachardoublequote}}'', with the resulting
wenzelm@26870
   130
  hypothetical equation solved by reflexivity.
wenzelm@26870
   131
  
wenzelm@26870
   132
  The default name for the definitional equation is \isa{x{\isacharunderscore}def}.
wenzelm@26870
   133
  Several simultaneous definitions may be given at the same time.
wenzelm@26870
   134
wenzelm@26870
   135
  \end{descr}
wenzelm@26870
   136
wenzelm@26870
   137
  The special name \indexref{}{fact}{prems}\mbox{\isa{prems}} refers to all assumptions of the
wenzelm@26870
   138
  current context as a list of theorems.  This feature should be used
wenzelm@26870
   139
  with great care!  It is better avoided in final proof texts.%
wenzelm@26870
   140
\end{isamarkuptext}%
wenzelm@26870
   141
\isamarkuptrue%
wenzelm@26870
   142
%
wenzelm@26870
   143
\isamarkupsection{Facts and forward chaining%
wenzelm@26870
   144
}
wenzelm@26870
   145
\isamarkuptrue%
wenzelm@26870
   146
%
wenzelm@26870
   147
\begin{isamarkuptext}%
wenzelm@26870
   148
\begin{matharray}{rcl}
wenzelm@26870
   149
    \indexdef{}{command}{note}\mbox{\isa{\isacommand{note}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   150
    \indexdef{}{command}{then}\mbox{\isa{\isacommand{then}}} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@26870
   151
    \indexdef{}{command}{from}\mbox{\isa{\isacommand{from}}} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@26870
   152
    \indexdef{}{command}{with}\mbox{\isa{\isacommand{with}}} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@26870
   153
    \indexdef{}{command}{using}\mbox{\isa{\isacommand{using}}} & : & \isartrans{proof(prove)}{proof(prove)} \\
wenzelm@26870
   154
    \indexdef{}{command}{unfolding}\mbox{\isa{\isacommand{unfolding}}} & : & \isartrans{proof(prove)}{proof(prove)} \\
wenzelm@26870
   155
  \end{matharray}
wenzelm@26870
   156
wenzelm@26870
   157
  New facts are established either by assumption or proof of local
wenzelm@26870
   158
  statements.  Any fact will usually be involved in further proofs,
wenzelm@26870
   159
  either as explicit arguments of proof methods, or when forward
wenzelm@26870
   160
  chaining towards the next goal via \mbox{\isa{\isacommand{then}}} (and variants);
wenzelm@26870
   161
  \mbox{\isa{\isacommand{from}}} and \mbox{\isa{\isacommand{with}}} are composite forms
wenzelm@26870
   162
  involving \mbox{\isa{\isacommand{note}}}.  The \mbox{\isa{\isacommand{using}}} elements
wenzelm@26870
   163
  augments the collection of used facts \emph{after} a goal has been
wenzelm@26870
   164
  stated.  Note that the special theorem name \indexref{}{fact}{this}\mbox{\isa{this}} refers
wenzelm@26870
   165
  to the most recently established facts, but only \emph{before}
wenzelm@26870
   166
  issuing a follow-up claim.
wenzelm@26870
   167
wenzelm@26870
   168
  \begin{rail}
wenzelm@26870
   169
    'note' (thmdef? thmrefs + 'and')
wenzelm@26870
   170
    ;
wenzelm@26870
   171
    ('from' | 'with' | 'using' | 'unfolding') (thmrefs + 'and')
wenzelm@26870
   172
    ;
wenzelm@26870
   173
  \end{rail}
wenzelm@26870
   174
wenzelm@26870
   175
  \begin{descr}
wenzelm@26870
   176
wenzelm@26870
   177
  \item [\mbox{\isa{\isacommand{note}}}~\isa{{\isachardoublequote}a\ {\isacharequal}\ b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n{\isachardoublequote}}]
wenzelm@26870
   178
  recalls existing facts \isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ b\isactrlsub n{\isachardoublequote}}, binding
wenzelm@26870
   179
  the result as \isa{a}.  Note that attributes may be involved as
wenzelm@26870
   180
  well, both on the left and right hand sides.
wenzelm@26870
   181
wenzelm@26870
   182
  \item [\mbox{\isa{\isacommand{then}}}] indicates forward chaining by the current
wenzelm@26870
   183
  facts in order to establish the goal to be claimed next.  The
wenzelm@26870
   184
  initial proof method invoked to refine that will be offered the
wenzelm@26870
   185
  facts to do ``anything appropriate'' (see also
wenzelm@26870
   186
  \secref{sec:proof-steps}).  For example, method \indexref{}{method}{rule}\mbox{\isa{rule}}
wenzelm@26870
   187
  (see \secref{sec:pure-meth-att}) would typically do an elimination
wenzelm@26870
   188
  rather than an introduction.  Automatic methods usually insert the
wenzelm@26870
   189
  facts into the goal state before operation.  This provides a simple
wenzelm@26870
   190
  scheme to control relevance of facts in automated proof search.
wenzelm@26870
   191
  
wenzelm@26870
   192
  \item [\mbox{\isa{\isacommand{from}}}~\isa{b}] abbreviates ``\mbox{\isa{\isacommand{note}}}~\isa{b}~\mbox{\isa{\isacommand{then}}}''; thus \mbox{\isa{\isacommand{then}}} is
wenzelm@26870
   193
  equivalent to ``\mbox{\isa{\isacommand{from}}}~\isa{this}''.
wenzelm@26870
   194
  
wenzelm@26870
   195
  \item [\mbox{\isa{\isacommand{with}}}~\isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n{\isachardoublequote}}]
wenzelm@26870
   196
  abbreviates ``\mbox{\isa{\isacommand{from}}}~\isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n\ {\isasymAND}\ this{\isachardoublequote}}''; thus the forward chaining is from earlier facts together
wenzelm@26870
   197
  with the current ones.
wenzelm@26870
   198
  
wenzelm@26870
   199
  \item [\mbox{\isa{\isacommand{using}}}~\isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n{\isachardoublequote}}] augments
wenzelm@26870
   200
  the facts being currently indicated for use by a subsequent
wenzelm@26870
   201
  refinement step (such as \indexref{}{command}{apply}\mbox{\isa{\isacommand{apply}}} or \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}}).
wenzelm@26870
   202
  
wenzelm@26870
   203
  \item [\mbox{\isa{\isacommand{unfolding}}}~\isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub n{\isachardoublequote}}] is
wenzelm@26870
   204
  structurally similar to \mbox{\isa{\isacommand{using}}}, but unfolds definitional
wenzelm@26870
   205
  equations \isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}\ b\isactrlsub n{\isachardoublequote}} throughout the goal state
wenzelm@26870
   206
  and facts.
wenzelm@26870
   207
wenzelm@26870
   208
  \end{descr}
wenzelm@26870
   209
wenzelm@26870
   210
  Forward chaining with an empty list of theorems is the same as not
wenzelm@26870
   211
  chaining at all.  Thus ``\mbox{\isa{\isacommand{from}}}~\isa{nothing}'' has no
wenzelm@26870
   212
  effect apart from entering \isa{{\isachardoublequote}prove{\isacharparenleft}chain{\isacharparenright}{\isachardoublequote}} mode, since
wenzelm@26870
   213
  \indexref{}{fact}{nothing}\mbox{\isa{nothing}} is bound to the empty list of theorems.
wenzelm@26870
   214
wenzelm@26870
   215
  Basic proof methods (such as \indexref{}{method}{rule}\mbox{\isa{rule}}) expect multiple
wenzelm@26870
   216
  facts to be given in their proper order, corresponding to a prefix
wenzelm@26870
   217
  of the premises of the rule involved.  Note that positions may be
wenzelm@26870
   218
  easily skipped using something like \mbox{\isa{\isacommand{from}}}~\isa{{\isachardoublequote}{\isacharunderscore}\ {\isasymAND}\ a\ {\isasymAND}\ b{\isachardoublequote}}, for example.  This involves the trivial rule
wenzelm@26870
   219
  \isa{{\isachardoublequote}PROP\ {\isasympsi}\ {\isasymLongrightarrow}\ PROP\ {\isasympsi}{\isachardoublequote}}, which is bound in Isabelle/Pure as
wenzelm@26870
   220
  ``\indexref{}{fact}{\_}\mbox{\isa{{\isacharunderscore}}}'' (underscore).
wenzelm@26870
   221
wenzelm@26870
   222
  Automated methods (such as \mbox{\isa{simp}} or \mbox{\isa{auto}}) just
wenzelm@26870
   223
  insert any given facts before their usual operation.  Depending on
wenzelm@26870
   224
  the kind of procedure involved, the order of facts is less
wenzelm@26870
   225
  significant here.%
wenzelm@26870
   226
\end{isamarkuptext}%
wenzelm@26870
   227
\isamarkuptrue%
wenzelm@26870
   228
%
wenzelm@26870
   229
\isamarkupsection{Goal statements \label{sec:goals}%
wenzelm@26870
   230
}
wenzelm@26870
   231
\isamarkuptrue%
wenzelm@26870
   232
%
wenzelm@26870
   233
\begin{isamarkuptext}%
wenzelm@26870
   234
\begin{matharray}{rcl}
wenzelm@26870
   235
    \indexdef{}{command}{lemma}\mbox{\isa{\isacommand{lemma}}} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
wenzelm@26870
   236
    \indexdef{}{command}{theorem}\mbox{\isa{\isacommand{theorem}}} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
wenzelm@26870
   237
    \indexdef{}{command}{corollary}\mbox{\isa{\isacommand{corollary}}} & : & \isartrans{local{\dsh}theory}{proof(prove)} \\
wenzelm@26870
   238
    \indexdef{}{command}{have}\mbox{\isa{\isacommand{have}}} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
wenzelm@26870
   239
    \indexdef{}{command}{show}\mbox{\isa{\isacommand{show}}} & : & \isartrans{proof(state) ~|~ proof(chain)}{proof(prove)} \\
wenzelm@26870
   240
    \indexdef{}{command}{hence}\mbox{\isa{\isacommand{hence}}} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@26870
   241
    \indexdef{}{command}{thus}\mbox{\isa{\isacommand{thus}}} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@26870
   242
    \indexdef{}{command}{print\_statement}\mbox{\isa{\isacommand{print{\isacharunderscore}statement}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isarkeep{theory~|~proof} \\
wenzelm@26870
   243
  \end{matharray}
wenzelm@26870
   244
wenzelm@26870
   245
  From a theory context, proof mode is entered by an initial goal
wenzelm@26870
   246
  command such as \mbox{\isa{\isacommand{lemma}}}, \mbox{\isa{\isacommand{theorem}}}, or
wenzelm@26870
   247
  \mbox{\isa{\isacommand{corollary}}}.  Within a proof, new claims may be
wenzelm@26870
   248
  introduced locally as well; four variants are available here to
wenzelm@26870
   249
  indicate whether forward chaining of facts should be performed
wenzelm@26870
   250
  initially (via \indexref{}{command}{then}\mbox{\isa{\isacommand{then}}}), and whether the final result
wenzelm@26870
   251
  is meant to solve some pending goal.
wenzelm@26870
   252
wenzelm@26870
   253
  Goals may consist of multiple statements, resulting in a list of
wenzelm@26870
   254
  facts eventually.  A pending multi-goal is internally represented as
wenzelm@26870
   255
  a meta-level conjunction (printed as \isa{{\isachardoublequote}{\isacharampersand}{\isacharampersand}{\isachardoublequote}}), which is usually
wenzelm@26870
   256
  split into the corresponding number of sub-goals prior to an initial
wenzelm@26870
   257
  method application, via \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}}
wenzelm@26870
   258
  (\secref{sec:proof-steps}) or \indexref{}{command}{apply}\mbox{\isa{\isacommand{apply}}}
wenzelm@26870
   259
  (\secref{sec:tactic-commands}).  The \indexref{}{method}{induct}\mbox{\isa{induct}} method
wenzelm@26870
   260
  covered in \secref{sec:cases-induct} acts on multiple claims
wenzelm@26870
   261
  simultaneously.
wenzelm@26870
   262
wenzelm@26870
   263
  Claims at the theory level may be either in short or long form.  A
wenzelm@26870
   264
  short goal merely consists of several simultaneous propositions
wenzelm@26870
   265
  (often just one).  A long goal includes an explicit context
wenzelm@26870
   266
  specification for the subsequent conclusion, involving local
wenzelm@26870
   267
  parameters and assumptions.  Here the role of each part of the
wenzelm@26870
   268
  statement is explicitly marked by separate keywords (see also
wenzelm@26870
   269
  \secref{sec:locale}); the local assumptions being introduced here
wenzelm@26870
   270
  are available as \indexref{}{fact}{assms}\mbox{\isa{assms}} in the proof.  Moreover, there
wenzelm@26870
   271
  are two kinds of conclusions: \indexdef{}{element}{shows}\mbox{\isa{\isakeyword{shows}}} states several
wenzelm@26870
   272
  simultaneous propositions (essentially a big conjunction), while
wenzelm@26870
   273
  \indexdef{}{element}{obtains}\mbox{\isa{\isakeyword{obtains}}} claims several simultaneous simultaneous
wenzelm@26870
   274
  contexts of (essentially a big disjunction of eliminated parameters
wenzelm@26870
   275
  and assumptions, cf.\ \secref{sec:obtain}).
wenzelm@26870
   276
wenzelm@26870
   277
  \begin{rail}
wenzelm@26870
   278
    ('lemma' | 'theorem' | 'corollary') target? (goal | longgoal)
wenzelm@26870
   279
    ;
wenzelm@26870
   280
    ('have' | 'show' | 'hence' | 'thus') goal
wenzelm@26870
   281
    ;
wenzelm@26870
   282
    'print\_statement' modes? thmrefs
wenzelm@26870
   283
    ;
wenzelm@26870
   284
  
wenzelm@26870
   285
    goal: (props + 'and')
wenzelm@26870
   286
    ;
wenzelm@26870
   287
    longgoal: thmdecl? (contextelem *) conclusion
wenzelm@26870
   288
    ;
wenzelm@26870
   289
    conclusion: 'shows' goal | 'obtains' (parname? case + '|')
wenzelm@26870
   290
    ;
wenzelm@26870
   291
    case: (vars + 'and') 'where' (props + 'and')
wenzelm@26870
   292
    ;
wenzelm@26870
   293
  \end{rail}
wenzelm@26870
   294
wenzelm@26870
   295
  \begin{descr}
wenzelm@26870
   296
  
wenzelm@26870
   297
  \item [\mbox{\isa{\isacommand{lemma}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}}] enters proof mode with
wenzelm@26870
   298
  \isa{{\isasymphi}} as main goal, eventually resulting in some fact \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymphi}{\isachardoublequote}} to be put back into the target context.  An additional
wenzelm@26870
   299
  \railnonterm{context} specification may build up an initial proof
wenzelm@26870
   300
  context for the subsequent claim; this includes local definitions
wenzelm@26870
   301
  and syntax as well, see the definition of \mbox{\isa{contextelem}} in
wenzelm@26870
   302
  \secref{sec:locale}.
wenzelm@26870
   303
  
wenzelm@26870
   304
  \item [\mbox{\isa{\isacommand{theorem}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}} and \mbox{\isa{\isacommand{corollary}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}}] are essentially the same as \mbox{\isa{\isacommand{lemma}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}}, but the facts are internally marked as
wenzelm@26870
   305
  being of a different kind.  This discrimination acts like a formal
wenzelm@26870
   306
  comment.
wenzelm@26870
   307
  
wenzelm@26870
   308
  \item [\mbox{\isa{\isacommand{have}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}}] claims a local goal,
wenzelm@26870
   309
  eventually resulting in a fact within the current logical context.
wenzelm@26870
   310
  This operation is completely independent of any pending sub-goals of
wenzelm@26870
   311
  an enclosing goal statements, so \mbox{\isa{\isacommand{have}}} may be freely
wenzelm@26870
   312
  used for experimental exploration of potential results within a
wenzelm@26870
   313
  proof body.
wenzelm@26870
   314
  
wenzelm@26870
   315
  \item [\mbox{\isa{\isacommand{show}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}}] is like \mbox{\isa{\isacommand{have}}}~\isa{{\isachardoublequote}a{\isacharcolon}\ {\isasymphi}{\isachardoublequote}} plus a second stage to refine some pending
wenzelm@26870
   316
  sub-goal for each one of the finished result, after having been
wenzelm@26870
   317
  exported into the corresponding context (at the head of the
wenzelm@26870
   318
  sub-proof of this \mbox{\isa{\isacommand{show}}} command).
wenzelm@26870
   319
  
wenzelm@26870
   320
  To accommodate interactive debugging, resulting rules are printed
wenzelm@26870
   321
  before being applied internally.  Even more, interactive execution
wenzelm@26870
   322
  of \mbox{\isa{\isacommand{show}}} predicts potential failure and displays the
wenzelm@26870
   323
  resulting error as a warning beforehand.  Watch out for the
wenzelm@26870
   324
  following message:
wenzelm@26870
   325
wenzelm@26870
   326
  %FIXME proper antiquitation
wenzelm@26870
   327
  \begin{ttbox}
wenzelm@26870
   328
  Problem! Local statement will fail to solve any pending goal
wenzelm@26870
   329
  \end{ttbox}
wenzelm@26870
   330
  
wenzelm@26870
   331
  \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
wenzelm@26870
   332
  chaining the current facts.  Note that \mbox{\isa{\isacommand{hence}}} is also
wenzelm@26870
   333
  equivalent to ``\mbox{\isa{\isacommand{from}}}~\isa{this}~\mbox{\isa{\isacommand{have}}}''.
wenzelm@26870
   334
  
wenzelm@26870
   335
  \item [\mbox{\isa{\isacommand{thus}}}] abbreviates ``\mbox{\isa{\isacommand{then}}}~\mbox{\isa{\isacommand{show}}}''.  Note that \mbox{\isa{\isacommand{thus}}} is also equivalent to
wenzelm@26870
   336
  ``\mbox{\isa{\isacommand{from}}}~\isa{this}~\mbox{\isa{\isacommand{show}}}''.
wenzelm@26870
   337
  
wenzelm@26870
   338
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}statement}}}~\isa{a}] prints facts from the
wenzelm@26870
   339
  current theory or proof context in long statement form, according to
wenzelm@26870
   340
  the syntax for \mbox{\isa{\isacommand{lemma}}} given above.
wenzelm@26870
   341
wenzelm@26870
   342
  \end{descr}
wenzelm@26870
   343
wenzelm@26870
   344
  Any goal statement causes some term abbreviations (such as
wenzelm@26870
   345
  \indexref{}{variable}{?thesis}\mbox{\isa{{\isacharquery}thesis}}) to be bound automatically, see also
wenzelm@26870
   346
  \secref{sec:term-abbrev}.  Furthermore, the local context of a
wenzelm@26870
   347
  (non-atomic) goal is provided via the \indexref{}{case}{rule\_context}\mbox{\isa{rule{\isacharunderscore}context}} case.
wenzelm@26870
   348
wenzelm@26870
   349
  The optional case names of \indexref{}{element}{obtains}\mbox{\isa{\isakeyword{obtains}}} have a twofold
wenzelm@26870
   350
  meaning: (1) during the of this claim they refer to the the local
wenzelm@26870
   351
  context introductions, (2) the resulting rule is annotated
wenzelm@26870
   352
  accordingly to support symbolic case splits when used with the
wenzelm@26870
   353
  \indexref{}{method}{cases}\mbox{\isa{cases}} method (cf.  \secref{sec:cases-induct}).
wenzelm@26870
   354
wenzelm@26870
   355
  \medskip
wenzelm@26870
   356
wenzelm@26870
   357
  \begin{warn}
wenzelm@26870
   358
    Isabelle/Isar suffers theory-level goal statements to contain
wenzelm@26870
   359
    \emph{unbound schematic variables}, although this does not conform
wenzelm@26870
   360
    to the aim of human-readable proof documents!  The main problem
wenzelm@26870
   361
    with schematic goals is that the actual outcome is usually hard to
wenzelm@26870
   362
    predict, depending on the behavior of the proof methods applied
wenzelm@26870
   363
    during the course of reasoning.  Note that most semi-automated
wenzelm@26870
   364
    methods heavily depend on several kinds of implicit rule
wenzelm@26870
   365
    declarations within the current theory context.  As this would
wenzelm@26870
   366
    also result in non-compositional checking of sub-proofs,
wenzelm@26870
   367
    \emph{local goals} are not allowed to be schematic at all.
wenzelm@26870
   368
    Nevertheless, schematic goals do have their use in Prolog-style
wenzelm@26870
   369
    interactive synthesis of proven results, usually by stepwise
wenzelm@26870
   370
    refinement via emulation of traditional Isabelle tactic scripts
wenzelm@26870
   371
    (see also \secref{sec:tactic-commands}).  In any case, users
wenzelm@26870
   372
    should know what they are doing.
wenzelm@26870
   373
  \end{warn}%
wenzelm@26870
   374
\end{isamarkuptext}%
wenzelm@26870
   375
\isamarkuptrue%
wenzelm@26870
   376
%
wenzelm@26870
   377
\isamarkupsection{Initial and terminal proof steps \label{sec:proof-steps}%
wenzelm@26870
   378
}
wenzelm@26870
   379
\isamarkuptrue%
wenzelm@26870
   380
%
wenzelm@26870
   381
\begin{isamarkuptext}%
wenzelm@26870
   382
\begin{matharray}{rcl}
wenzelm@26870
   383
    \indexdef{}{command}{proof}\mbox{\isa{\isacommand{proof}}} & : & \isartrans{proof(prove)}{proof(state)} \\
wenzelm@26870
   384
    \indexdef{}{command}{qed}\mbox{\isa{\isacommand{qed}}} & : & \isartrans{proof(state)}{proof(state) ~|~ theory} \\
wenzelm@26870
   385
    \indexdef{}{command}{by}\mbox{\isa{\isacommand{by}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@26870
   386
    \indexdef{}{command}{..}\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@26870
   387
    \indexdef{}{command}{.}\mbox{\isa{\isacommand{{\isachardot}}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@26870
   388
    \indexdef{}{command}{sorry}\mbox{\isa{\isacommand{sorry}}} & : & \isartrans{proof(prove)}{proof(state) ~|~ theory} \\
wenzelm@26870
   389
  \end{matharray}
wenzelm@26870
   390
wenzelm@26870
   391
  Arbitrary goal refinement via tactics is considered harmful.
wenzelm@26870
   392
  Structured proof composition in Isar admits proof methods to be
wenzelm@26870
   393
  invoked in two places only.
wenzelm@26870
   394
wenzelm@26870
   395
  \begin{enumerate}
wenzelm@26870
   396
wenzelm@26870
   397
  \item An \emph{initial} refinement step \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}} reduces a newly stated goal to a number
wenzelm@26870
   398
  of sub-goals that are to be solved later.  Facts are passed to
wenzelm@26870
   399
  \isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}} for forward chaining, if so indicated by \isa{{\isachardoublequote}proof{\isacharparenleft}chain{\isacharparenright}{\isachardoublequote}} mode.
wenzelm@26870
   400
  
wenzelm@26870
   401
  \item A \emph{terminal} conclusion step \indexref{}{command}{qed}\mbox{\isa{\isacommand{qed}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{2}}{\isachardoublequote}} is intended to solve remaining goals.  No facts are
wenzelm@26870
   402
  passed to \isa{{\isachardoublequote}m\isactrlsub {\isadigit{2}}{\isachardoublequote}}.
wenzelm@26870
   403
wenzelm@26870
   404
  \end{enumerate}
wenzelm@26870
   405
wenzelm@26870
   406
  The only other (proper) way to affect pending goals in a proof body
wenzelm@26870
   407
  is by \indexref{}{command}{show}\mbox{\isa{\isacommand{show}}}, which involves an explicit statement of
wenzelm@26870
   408
  what is to be solved eventually.  Thus we avoid the fundamental
wenzelm@26870
   409
  problem of unstructured tactic scripts that consist of numerous
wenzelm@26870
   410
  consecutive goal transformations, with invisible effects.
wenzelm@26870
   411
wenzelm@26870
   412
  \medskip As a general rule of thumb for good proof style, initial
wenzelm@26870
   413
  proof methods should either solve the goal completely, or constitute
wenzelm@26870
   414
  some well-understood reduction to new sub-goals.  Arbitrary
wenzelm@26870
   415
  automatic proof tools that are prone leave a large number of badly
wenzelm@26870
   416
  structured sub-goals are no help in continuing the proof document in
wenzelm@26870
   417
  an intelligible manner.
wenzelm@26870
   418
wenzelm@26870
   419
  Unless given explicitly by the user, the default initial method is
wenzelm@26870
   420
  ``\indexref{}{method}{rule}\mbox{\isa{rule}}'', which applies a single standard elimination
wenzelm@26870
   421
  or introduction rule according to the topmost symbol involved.
wenzelm@26870
   422
  There is no separate default terminal method.  Any remaining goals
wenzelm@26870
   423
  are always solved by assumption in the very last step.
wenzelm@26870
   424
wenzelm@26870
   425
  \begin{rail}
wenzelm@26870
   426
    'proof' method?
wenzelm@26870
   427
    ;
wenzelm@26870
   428
    'qed' method?
wenzelm@26870
   429
    ;
wenzelm@26870
   430
    'by' method method?
wenzelm@26870
   431
    ;
wenzelm@26870
   432
    ('.' | '..' | 'sorry')
wenzelm@26870
   433
    ;
wenzelm@26870
   434
  \end{rail}
wenzelm@26870
   435
wenzelm@26870
   436
  \begin{descr}
wenzelm@26870
   437
  
wenzelm@26870
   438
  \item [\mbox{\isa{\isacommand{proof}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}}] refines the goal by
wenzelm@26870
   439
  proof method \isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}}; facts for forward chaining are
wenzelm@26870
   440
  passed if so indicated by \isa{{\isachardoublequote}proof{\isacharparenleft}chain{\isacharparenright}{\isachardoublequote}} mode.
wenzelm@26870
   441
  
wenzelm@26870
   442
  \item [\mbox{\isa{\isacommand{qed}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{2}}{\isachardoublequote}}] refines any remaining
wenzelm@26870
   443
  goals by proof method \isa{{\isachardoublequote}m\isactrlsub {\isadigit{2}}{\isachardoublequote}} and concludes the
wenzelm@26870
   444
  sub-proof by assumption.  If the goal had been \isa{{\isachardoublequote}show{\isachardoublequote}} (or
wenzelm@26870
   445
  \isa{{\isachardoublequote}thus{\isachardoublequote}}), some pending sub-goal is solved as well by the rule
wenzelm@26870
   446
  resulting from the result \emph{exported} into the enclosing goal
wenzelm@26870
   447
  context.  Thus \isa{{\isachardoublequote}qed{\isachardoublequote}} may fail for two reasons: either \isa{{\isachardoublequote}m\isactrlsub {\isadigit{2}}{\isachardoublequote}} fails, or the resulting rule does not fit to any
wenzelm@26870
   448
  pending goal\footnote{This includes any additional ``strong''
wenzelm@26870
   449
  assumptions as introduced by \mbox{\isa{\isacommand{assume}}}.} of the enclosing
wenzelm@26870
   450
  context.  Debugging such a situation might involve temporarily
wenzelm@26870
   451
  changing \mbox{\isa{\isacommand{show}}} into \mbox{\isa{\isacommand{have}}}, or weakening the
wenzelm@26870
   452
  local context by replacing occurrences of \mbox{\isa{\isacommand{assume}}} by
wenzelm@26870
   453
  \mbox{\isa{\isacommand{presume}}}.
wenzelm@26870
   454
  
wenzelm@26870
   455
  \item [\mbox{\isa{\isacommand{by}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}\ m\isactrlsub {\isadigit{2}}{\isachardoublequote}}] is a
wenzelm@26870
   456
  \emph{terminal proof}\index{proof!terminal}; it abbreviates
wenzelm@26870
   457
  \mbox{\isa{\isacommand{proof}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}}~\isa{{\isachardoublequote}qed{\isachardoublequote}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{2}}{\isachardoublequote}}, but with backtracking across both methods.  Debugging
wenzelm@26870
   458
  an unsuccessful \mbox{\isa{\isacommand{by}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}\ m\isactrlsub {\isadigit{2}}{\isachardoublequote}}
wenzelm@26870
   459
  command can be done by expanding its definition; in many cases
wenzelm@26870
   460
  \mbox{\isa{\isacommand{proof}}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}} (or even \isa{{\isachardoublequote}apply{\isachardoublequote}}~\isa{{\isachardoublequote}m\isactrlsub {\isadigit{1}}{\isachardoublequote}}) is already sufficient to see the
wenzelm@26870
   461
  problem.
wenzelm@26870
   462
wenzelm@26870
   463
  \item [``\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}}''] is a \emph{default
wenzelm@26870
   464
  proof}\index{proof!default}; it abbreviates \mbox{\isa{\isacommand{by}}}~\isa{{\isachardoublequote}rule{\isachardoublequote}}.
wenzelm@26870
   465
wenzelm@26870
   466
  \item [``\mbox{\isa{\isacommand{{\isachardot}}}}''] is a \emph{trivial
wenzelm@26870
   467
  proof}\index{proof!trivial}; it abbreviates \mbox{\isa{\isacommand{by}}}~\isa{{\isachardoublequote}this{\isachardoublequote}}.
wenzelm@26870
   468
  
wenzelm@26870
   469
  \item [\mbox{\isa{\isacommand{sorry}}}] is a \emph{fake proof}\index{proof!fake}
wenzelm@26870
   470
  pretending to solve the pending claim without further ado.  This
wenzelm@26870
   471
  only works in interactive development, or if the \verb|quick_and_dirty| flag is enabled (in ML).  Facts emerging from fake
wenzelm@26870
   472
  proofs are not the real thing.  Internally, each theorem container
wenzelm@26870
   473
  is tainted by an oracle invocation, which is indicated as ``\isa{{\isachardoublequote}{\isacharbrackleft}{\isacharbang}{\isacharbrackright}{\isachardoublequote}}'' in the printed result.
wenzelm@26870
   474
  
wenzelm@26870
   475
  The most important application of \mbox{\isa{\isacommand{sorry}}} is to support
wenzelm@26870
   476
  experimentation and top-down proof development.
wenzelm@26870
   477
wenzelm@26870
   478
  \end{descr}%
wenzelm@26870
   479
\end{isamarkuptext}%
wenzelm@26870
   480
\isamarkuptrue%
wenzelm@26870
   481
%
wenzelm@26870
   482
\isamarkupsection{Fundamental methods and attributes \label{sec:pure-meth-att}%
wenzelm@26870
   483
}
wenzelm@26870
   484
\isamarkuptrue%
wenzelm@26870
   485
%
wenzelm@26870
   486
\begin{isamarkuptext}%
wenzelm@26870
   487
The following proof methods and attributes refer to basic logical
wenzelm@26870
   488
  operations of Isar.  Further methods and attributes are provided by
wenzelm@26870
   489
  several generic and object-logic specific tools and packages (see
wenzelm@26870
   490
  \chref{ch:gen-tools} and \chref{ch:hol}).
wenzelm@26870
   491
wenzelm@26870
   492
  \begin{matharray}{rcl}
wenzelm@26870
   493
    \indexdef{}{method}{-}\mbox{\isa{{\isacharminus}}} & : & \isarmeth \\
wenzelm@26870
   494
    \indexdef{}{method}{fact}\mbox{\isa{fact}} & : & \isarmeth \\
wenzelm@26870
   495
    \indexdef{}{method}{assumption}\mbox{\isa{assumption}} & : & \isarmeth \\
wenzelm@26870
   496
    \indexdef{}{method}{this}\mbox{\isa{this}} & : & \isarmeth \\
wenzelm@26870
   497
    \indexdef{}{method}{rule}\mbox{\isa{rule}} & : & \isarmeth \\
wenzelm@26870
   498
    \indexdef{}{method}{iprover}\mbox{\isa{iprover}} & : & \isarmeth \\[0.5ex]
wenzelm@26870
   499
    \indexdef{}{attribute}{intro}\mbox{\isa{intro}} & : & \isaratt \\
wenzelm@26870
   500
    \indexdef{}{attribute}{elim}\mbox{\isa{elim}} & : & \isaratt \\
wenzelm@26870
   501
    \indexdef{}{attribute}{dest}\mbox{\isa{dest}} & : & \isaratt \\
wenzelm@26870
   502
    \indexdef{}{attribute}{rule}\mbox{\isa{rule}} & : & \isaratt \\[0.5ex]
wenzelm@26870
   503
    \indexdef{}{attribute}{OF}\mbox{\isa{OF}} & : & \isaratt \\
wenzelm@26870
   504
    \indexdef{}{attribute}{of}\mbox{\isa{of}} & : & \isaratt \\
wenzelm@26870
   505
    \indexdef{}{attribute}{where}\mbox{\isa{where}} & : & \isaratt \\
wenzelm@26870
   506
  \end{matharray}
wenzelm@26870
   507
wenzelm@26870
   508
  \begin{rail}
wenzelm@26870
   509
    'fact' thmrefs?
wenzelm@26870
   510
    ;
wenzelm@26870
   511
    'rule' thmrefs?
wenzelm@26870
   512
    ;
wenzelm@26870
   513
    'iprover' ('!' ?) (rulemod *)
wenzelm@26870
   514
    ;
wenzelm@26870
   515
    rulemod: ('intro' | 'elim' | 'dest') ((('!' | () | '?') nat?) | 'del') ':' thmrefs
wenzelm@26870
   516
    ;
wenzelm@26870
   517
    ('intro' | 'elim' | 'dest') ('!' | () | '?') nat?
wenzelm@26870
   518
    ;
wenzelm@26870
   519
    'rule' 'del'
wenzelm@26870
   520
    ;
wenzelm@26870
   521
    'OF' thmrefs
wenzelm@26870
   522
    ;
wenzelm@26870
   523
    'of' insts ('concl' ':' insts)?
wenzelm@26870
   524
    ;
wenzelm@26870
   525
    'where' ((name | var | typefree | typevar) '=' (type | term) * 'and')
wenzelm@26870
   526
    ;
wenzelm@26870
   527
  \end{rail}
wenzelm@26870
   528
wenzelm@26870
   529
  \begin{descr}
wenzelm@26870
   530
  
wenzelm@26870
   531
  \item [``\mbox{\isa{{\isacharminus}}}'' (minus)] does nothing but insert the
wenzelm@26870
   532
  forward chaining facts as premises into the goal.  Note that command
wenzelm@26870
   533
  \indexref{}{command}{proof}\mbox{\isa{\isacommand{proof}}} without any method actually performs a single
wenzelm@26870
   534
  reduction step using the \indexref{}{method}{rule}\mbox{\isa{rule}} method; thus a plain
wenzelm@26870
   535
  \emph{do-nothing} proof step would be ``\mbox{\isa{\isacommand{proof}}}~\isa{{\isachardoublequote}{\isacharminus}{\isachardoublequote}}'' rather than \mbox{\isa{\isacommand{proof}}} alone.
wenzelm@26870
   536
  
wenzelm@26870
   537
  \item [\mbox{\isa{fact}}~\isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isachardoublequote}}] composes
wenzelm@26870
   538
  some fact from \isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ a\isactrlsub n{\isachardoublequote}} (or implicitly from
wenzelm@26870
   539
  the current proof context) modulo unification of schematic type and
wenzelm@26870
   540
  term variables.  The rule structure is not taken into account, i.e.\
wenzelm@26870
   541
  meta-level implication is considered atomic.  This is the same
wenzelm@26870
   542
  principle underlying literal facts (cf.\ \secref{sec:syn-att}):
wenzelm@26870
   543
  ``\mbox{\isa{\isacommand{have}}}~\isa{{\isachardoublequote}{\isasymphi}{\isachardoublequote}}~\mbox{\isa{\isacommand{by}}}~\isa{fact}'' is
wenzelm@26870
   544
  equivalent to ``\mbox{\isa{\isacommand{note}}}~\verb|`|\isa{{\isasymphi}}\verb|`|'' provided that \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymphi}{\isachardoublequote}} is an instance of some known
wenzelm@26870
   545
  \isa{{\isachardoublequote}{\isasymturnstile}\ {\isasymphi}{\isachardoublequote}} in the proof context.
wenzelm@26870
   546
  
wenzelm@26870
   547
  \item [\mbox{\isa{assumption}}] solves some goal by a single assumption
wenzelm@26870
   548
  step.  All given facts are guaranteed to participate in the
wenzelm@26870
   549
  refinement; this means there may be only 0 or 1 in the first place.
wenzelm@26870
   550
  Recall that \mbox{\isa{\isacommand{qed}}} (\secref{sec:proof-steps}) already
wenzelm@26870
   551
  concludes any remaining sub-goals by assumption, so structured
wenzelm@26870
   552
  proofs usually need not quote the \mbox{\isa{assumption}} method at
wenzelm@26870
   553
  all.
wenzelm@26870
   554
  
wenzelm@26870
   555
  \item [\mbox{\isa{this}}] applies all of the current facts directly as
wenzelm@26870
   556
  rules.  Recall that ``\mbox{\isa{\isacommand{{\isachardot}}}}'' (dot) abbreviates ``\mbox{\isa{\isacommand{by}}}~\isa{this}''.
wenzelm@26870
   557
  
wenzelm@26870
   558
  \item [\mbox{\isa{rule}}~\isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isachardoublequote}}] applies some
wenzelm@26870
   559
  rule given as argument in backward manner; facts are used to reduce
wenzelm@26870
   560
  the rule before applying it to the goal.  Thus \mbox{\isa{rule}}
wenzelm@26870
   561
  without facts is plain introduction, while with facts it becomes
wenzelm@26870
   562
  elimination.
wenzelm@26870
   563
  
wenzelm@26870
   564
  When no arguments are given, the \mbox{\isa{rule}} method tries to pick
wenzelm@26870
   565
  appropriate rules automatically, as declared in the current context
wenzelm@26870
   566
  using the \mbox{\isa{intro}}, \mbox{\isa{elim}}, \mbox{\isa{dest}}
wenzelm@26870
   567
  attributes (see below).  This is the default behavior of \mbox{\isa{\isacommand{proof}}} and ``\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}}'' (double-dot) steps (see
wenzelm@26870
   568
  \secref{sec:proof-steps}).
wenzelm@26870
   569
  
wenzelm@26870
   570
  \item [\mbox{\isa{iprover}}] performs intuitionistic proof search,
wenzelm@26870
   571
  depending on specifically declared rules from the context, or given
wenzelm@26870
   572
  as explicit arguments.  Chained facts are inserted into the goal
wenzelm@26870
   573
  before commencing proof search; ``\mbox{\isa{iprover}}\isa{{\isachardoublequote}{\isacharbang}{\isachardoublequote}}'' 
wenzelm@26870
   574
  means to include the current \mbox{\isa{prems}} as well.
wenzelm@26870
   575
  
wenzelm@26870
   576
  Rules need to be classified as \mbox{\isa{intro}}, \mbox{\isa{elim}}, or \mbox{\isa{dest}}; here the ``\isa{{\isachardoublequote}{\isacharbang}{\isachardoublequote}}'' indicator
wenzelm@26870
   577
  refers to ``safe'' rules, which may be applied aggressively (without
wenzelm@26870
   578
  considering back-tracking later).  Rules declared with ``\isa{{\isachardoublequote}{\isacharquery}{\isachardoublequote}}'' are ignored in proof search (the single-step \mbox{\isa{rule}}
wenzelm@26870
   579
  method still observes these).  An explicit weight annotation may be
wenzelm@26870
   580
  given as well; otherwise the number of rule premises will be taken
wenzelm@26870
   581
  into account here.
wenzelm@26870
   582
  
wenzelm@26870
   583
  \item [\mbox{\isa{intro}}, \mbox{\isa{elim}}, and \mbox{\isa{dest}}]
wenzelm@26870
   584
  declare introduction, elimination, and destruct rules, to be used
wenzelm@26870
   585
  with the \mbox{\isa{rule}} and \mbox{\isa{iprover}} methods.  Note that
wenzelm@26870
   586
  the latter will ignore rules declared with ``\isa{{\isachardoublequote}{\isacharquery}{\isachardoublequote}}'', while
wenzelm@26870
   587
  ``\isa{{\isachardoublequote}{\isacharbang}{\isachardoublequote}}''  are used most aggressively.
wenzelm@26870
   588
  
wenzelm@26870
   589
  The classical reasoner (see \secref{sec:classical}) introduces its
wenzelm@26870
   590
  own variants of these attributes; use qualified names to access the
wenzelm@26870
   591
  present versions of Isabelle/Pure, i.e.\ \mbox{\isa{Pure{\isachardot}intro}}.
wenzelm@26870
   592
  
wenzelm@26870
   593
  \item [\mbox{\isa{rule}}~\isa{del}] undeclares introduction,
wenzelm@26870
   594
  elimination, or destruct rules.
wenzelm@26870
   595
  
wenzelm@26870
   596
  \item [\mbox{\isa{OF}}~\isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isachardoublequote}}] applies some
wenzelm@26870
   597
  theorem to all of the given rules \isa{{\isachardoublequote}a\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ a\isactrlsub n{\isachardoublequote}}
wenzelm@26870
   598
  (in parallel).  This corresponds to the \verb|"op MRS"| operation in
wenzelm@26870
   599
  ML, but note the reversed order.  Positions may be effectively
wenzelm@26870
   600
  skipped by including ``\isa{{\isacharunderscore}}'' (underscore) as argument.
wenzelm@26870
   601
  
wenzelm@26870
   602
  \item [\mbox{\isa{of}}~\isa{{\isachardoublequote}t\isactrlsub {\isadigit{1}}\ {\isasymdots}\ t\isactrlsub n{\isachardoublequote}}] performs
wenzelm@26870
   603
  positional instantiation of term variables.  The terms \isa{{\isachardoublequote}t\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ t\isactrlsub n{\isachardoublequote}} are substituted for any schematic
wenzelm@26895
   604
  variables occurring in a theorem from left to right; ``\isa{{\isacharunderscore}}''
wenzelm@26895
   605
  (underscore) indicates to skip a position.  Arguments following a
wenzelm@26895
   606
  ``\isa{{\isachardoublequote}concl{\isacharcolon}{\isachardoublequote}}'' specification refer to positions of the
wenzelm@26895
   607
  conclusion of a rule.
wenzelm@26870
   608
  
wenzelm@26870
   609
  \item [\mbox{\isa{where}}~\isa{{\isachardoublequote}x\isactrlsub {\isadigit{1}}\ {\isacharequal}\ t\isactrlsub {\isadigit{1}}\ {\isasymAND}\ {\isasymdots}\ x\isactrlsub n\ {\isacharequal}\ t\isactrlsub n{\isachardoublequote}}] performs named instantiation of schematic
wenzelm@26870
   610
  type and term variables occurring in a theorem.  Schematic variables
wenzelm@26870
   611
  have to be specified on the left-hand side (e.g.\ \isa{{\isachardoublequote}{\isacharquery}x{\isadigit{1}}{\isachardot}{\isadigit{3}}{\isachardoublequote}}).
wenzelm@26870
   612
  The question mark may be omitted if the variable name is a plain
wenzelm@26870
   613
  identifier without index.  As type instantiations are inferred from
wenzelm@26870
   614
  term instantiations, explicit type instantiations are seldom
wenzelm@26870
   615
  necessary.
wenzelm@26870
   616
wenzelm@26870
   617
  \end{descr}%
wenzelm@26870
   618
\end{isamarkuptext}%
wenzelm@26870
   619
\isamarkuptrue%
wenzelm@26870
   620
%
wenzelm@26870
   621
\isamarkupsection{Term abbreviations \label{sec:term-abbrev}%
wenzelm@26870
   622
}
wenzelm@26870
   623
\isamarkuptrue%
wenzelm@26870
   624
%
wenzelm@26870
   625
\begin{isamarkuptext}%
wenzelm@26870
   626
\begin{matharray}{rcl}
wenzelm@26870
   627
    \indexdef{}{command}{let}\mbox{\isa{\isacommand{let}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   628
    \indexdef{}{keyword}{is}\mbox{\isa{\isakeyword{is}}} & : & syntax \\
wenzelm@26870
   629
  \end{matharray}
wenzelm@26870
   630
wenzelm@26870
   631
  Abbreviations may be either bound by explicit \mbox{\isa{\isacommand{let}}}~\isa{{\isachardoublequote}p\ {\isasymequiv}\ t{\isachardoublequote}} statements, or by annotating assumptions or
wenzelm@26870
   632
  goal statements with a list of patterns ``\isa{{\isachardoublequote}{\isacharparenleft}{\isasymIS}\ p\isactrlsub {\isadigit{1}}\ {\isasymdots}\ p\isactrlsub n{\isacharparenright}{\isachardoublequote}}''.  In both cases, higher-order matching is invoked to
wenzelm@26870
   633
  bind extra-logical term variables, which may be either named
wenzelm@26870
   634
  schematic variables of the form \isa{{\isacharquery}x}, or nameless dummies
wenzelm@26870
   635
  ``\mbox{\isa{{\isacharunderscore}}}'' (underscore). Note that in the \mbox{\isa{\isacommand{let}}}
wenzelm@26870
   636
  form the patterns occur on the left-hand side, while the \mbox{\isa{\isakeyword{is}}} patterns are in postfix position.
wenzelm@26870
   637
wenzelm@26870
   638
  Polymorphism of term bindings is handled in Hindley-Milner style,
wenzelm@26870
   639
  similar to ML.  Type variables referring to local assumptions or
wenzelm@26870
   640
  open goal statements are \emph{fixed}, while those of finished
wenzelm@26870
   641
  results or bound by \mbox{\isa{\isacommand{let}}} may occur in \emph{arbitrary}
wenzelm@26870
   642
  instances later.  Even though actual polymorphism should be rarely
wenzelm@26870
   643
  used in practice, this mechanism is essential to achieve proper
wenzelm@26870
   644
  incremental type-inference, as the user proceeds to build up the
wenzelm@26870
   645
  Isar proof text from left to right.
wenzelm@26870
   646
wenzelm@26870
   647
  \medskip Term abbreviations are quite different from local
wenzelm@26870
   648
  definitions as introduced via \mbox{\isa{\isacommand{def}}} (see
wenzelm@26870
   649
  \secref{sec:proof-context}).  The latter are visible within the
wenzelm@26870
   650
  logic as actual equations, while abbreviations disappear during the
wenzelm@26870
   651
  input process just after type checking.  Also note that \mbox{\isa{\isacommand{def}}} does not support polymorphism.
wenzelm@26870
   652
wenzelm@26870
   653
  \begin{rail}
wenzelm@26870
   654
    'let' ((term + 'and') '=' term + 'and')
wenzelm@26870
   655
    ;  
wenzelm@26870
   656
  \end{rail}
wenzelm@26870
   657
wenzelm@26870
   658
  The syntax of \mbox{\isa{\isakeyword{is}}} patterns follows \railnonterm{termpat}
wenzelm@26870
   659
  or \railnonterm{proppat} (see \secref{sec:term-decls}).
wenzelm@26870
   660
wenzelm@26870
   661
  \begin{descr}
wenzelm@26870
   662
wenzelm@26870
   663
  \item [\mbox{\isa{\isacommand{let}}}~\isa{{\isachardoublequote}p\isactrlsub {\isadigit{1}}\ {\isacharequal}\ t\isactrlsub {\isadigit{1}}\ {\isasymAND}\ {\isasymdots}\ p\isactrlsub n\ {\isacharequal}\ t\isactrlsub n{\isachardoublequote}}] binds any text variables in patterns \isa{{\isachardoublequote}p\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ p\isactrlsub n{\isachardoublequote}} by simultaneous higher-order matching
wenzelm@26870
   664
  against terms \isa{{\isachardoublequote}t\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ t\isactrlsub n{\isachardoublequote}}.
wenzelm@26870
   665
wenzelm@26870
   666
  \item [\isa{{\isachardoublequote}{\isacharparenleft}{\isasymIS}\ p\isactrlsub {\isadigit{1}}\ {\isasymdots}\ p\isactrlsub n{\isacharparenright}{\isachardoublequote}}] resembles \mbox{\isa{\isacommand{let}}}, but matches \isa{{\isachardoublequote}p\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ p\isactrlsub n{\isachardoublequote}} against the
wenzelm@26870
   667
  preceding statement.  Also note that \mbox{\isa{\isakeyword{is}}} is not a
wenzelm@26870
   668
  separate command, but part of others (such as \mbox{\isa{\isacommand{assume}}},
wenzelm@26870
   669
  \mbox{\isa{\isacommand{have}}} etc.).
wenzelm@26870
   670
wenzelm@26870
   671
  \end{descr}
wenzelm@26870
   672
wenzelm@26870
   673
  Some \emph{implicit} term abbreviations\index{term abbreviations}
wenzelm@26870
   674
  for goals and facts are available as well.  For any open goal,
wenzelm@26870
   675
  \indexref{}{variable}{thesis}\mbox{\isa{thesis}} refers to its object-level statement,
wenzelm@26870
   676
  abstracted over any meta-level parameters (if present).  Likewise,
wenzelm@26870
   677
  \indexref{}{variable}{this}\mbox{\isa{this}} is bound for fact statements resulting from
wenzelm@26870
   678
  assumptions or finished goals.  In case \mbox{\isa{this}} refers to
wenzelm@26870
   679
  an object-logic statement that is an application \isa{{\isachardoublequote}f\ t{\isachardoublequote}}, then
wenzelm@26870
   680
  \isa{t} is bound to the special text variable ``\mbox{\isa{{\isasymdots}}}''
wenzelm@26870
   681
  (three dots).  The canonical application of this convenience are
wenzelm@26870
   682
  calculational proofs (see \secref{sec:calculation}).%
wenzelm@26870
   683
\end{isamarkuptext}%
wenzelm@26870
   684
\isamarkuptrue%
wenzelm@26870
   685
%
wenzelm@26870
   686
\isamarkupsection{Block structure%
wenzelm@26870
   687
}
wenzelm@26870
   688
\isamarkuptrue%
wenzelm@26870
   689
%
wenzelm@26870
   690
\begin{isamarkuptext}%
wenzelm@26870
   691
\begin{matharray}{rcl}
wenzelm@26870
   692
    \indexdef{}{command}{next}\mbox{\isa{\isacommand{next}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   693
    \indexdef{}{command}{\{}\mbox{\isa{\isacommand{{\isacharbraceleft}}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   694
    \indexdef{}{command}{\}}\mbox{\isa{\isacommand{{\isacharbraceright}}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   695
  \end{matharray}
wenzelm@26870
   696
wenzelm@26870
   697
  While Isar is inherently block-structured, opening and closing
wenzelm@26870
   698
  blocks is mostly handled rather casually, with little explicit
wenzelm@26870
   699
  user-intervention.  Any local goal statement automatically opens
wenzelm@26870
   700
  \emph{two} internal blocks, which are closed again when concluding
wenzelm@26870
   701
  the sub-proof (by \mbox{\isa{\isacommand{qed}}} etc.).  Sections of different
wenzelm@26870
   702
  context within a sub-proof may be switched via \mbox{\isa{\isacommand{next}}},
wenzelm@26870
   703
  which is just a single block-close followed by block-open again.
wenzelm@26870
   704
  The effect of \mbox{\isa{\isacommand{next}}} is to reset the local proof context;
wenzelm@26870
   705
  there is no goal focus involved here!
wenzelm@26870
   706
wenzelm@26870
   707
  For slightly more advanced applications, there are explicit block
wenzelm@26870
   708
  parentheses as well.  These typically achieve a stronger forward
wenzelm@26870
   709
  style of reasoning.
wenzelm@26870
   710
wenzelm@26870
   711
  \begin{descr}
wenzelm@26870
   712
wenzelm@26870
   713
  \item [\mbox{\isa{\isacommand{next}}}] switches to a fresh block within a
wenzelm@26870
   714
  sub-proof, resetting the local context to the initial one.
wenzelm@26870
   715
wenzelm@26870
   716
  \item [\mbox{\isa{\isacommand{{\isacharbraceleft}}}} and \mbox{\isa{\isacommand{{\isacharbraceright}}}}] explicitly open and close
wenzelm@26870
   717
  blocks.  Any current facts pass through ``\mbox{\isa{\isacommand{{\isacharbraceleft}}}}''
wenzelm@26870
   718
  unchanged, while ``\mbox{\isa{\isacommand{{\isacharbraceright}}}}'' causes any result to be
wenzelm@26870
   719
  \emph{exported} into the enclosing context.  Thus fixed variables
wenzelm@26870
   720
  are generalized, assumptions discharged, and local definitions
wenzelm@26870
   721
  unfolded (cf.\ \secref{sec:proof-context}).  There is no difference
wenzelm@26870
   722
  of \mbox{\isa{\isacommand{assume}}} and \mbox{\isa{\isacommand{presume}}} in this mode of
wenzelm@26870
   723
  forward reasoning --- in contrast to plain backward reasoning with
wenzelm@26870
   724
  the result exported at \mbox{\isa{\isacommand{show}}} time.
wenzelm@26870
   725
wenzelm@26870
   726
  \end{descr}%
wenzelm@26870
   727
\end{isamarkuptext}%
wenzelm@26870
   728
\isamarkuptrue%
wenzelm@26870
   729
%
wenzelm@26870
   730
\isamarkupsection{Emulating tactic scripts \label{sec:tactic-commands}%
wenzelm@26870
   731
}
wenzelm@26870
   732
\isamarkuptrue%
wenzelm@26870
   733
%
wenzelm@26870
   734
\begin{isamarkuptext}%
wenzelm@26870
   735
The Isar provides separate commands to accommodate tactic-style
wenzelm@26870
   736
  proof scripts within the same system.  While being outside the
wenzelm@26870
   737
  orthodox Isar proof language, these might come in handy for
wenzelm@26870
   738
  interactive exploration and debugging, or even actual tactical proof
wenzelm@26870
   739
  within new-style theories (to benefit from document preparation, for
wenzelm@26870
   740
  example).  See also \secref{sec:tactics} for actual tactics, that
wenzelm@26870
   741
  have been encapsulated as proof methods.  Proper proof methods may
wenzelm@26870
   742
  be used in scripts, too.
wenzelm@26870
   743
wenzelm@26870
   744
  \begin{matharray}{rcl}
wenzelm@26870
   745
    \indexdef{}{command}{apply}\mbox{\isa{\isacommand{apply}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof(prove)}{proof(prove)} \\
wenzelm@26870
   746
    \indexdef{}{command}{apply\_end}\mbox{\isa{\isacommand{apply{\isacharunderscore}end}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   747
    \indexdef{}{command}{done}\mbox{\isa{\isacommand{done}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof(prove)}{proof(state)} \\
wenzelm@26870
   748
    \indexdef{}{command}{defer}\mbox{\isa{\isacommand{defer}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof}{proof} \\
wenzelm@26870
   749
    \indexdef{}{command}{prefer}\mbox{\isa{\isacommand{prefer}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof}{proof} \\
wenzelm@26870
   750
    \indexdef{}{command}{back}\mbox{\isa{\isacommand{back}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof}{proof} \\
wenzelm@26870
   751
  \end{matharray}
wenzelm@26870
   752
wenzelm@26870
   753
  \begin{rail}
wenzelm@26870
   754
    ( 'apply' | 'apply\_end' ) method
wenzelm@26870
   755
    ;
wenzelm@26870
   756
    'defer' nat?
wenzelm@26870
   757
    ;
wenzelm@26870
   758
    'prefer' nat
wenzelm@26870
   759
    ;
wenzelm@26870
   760
  \end{rail}
wenzelm@26870
   761
wenzelm@26870
   762
  \begin{descr}
wenzelm@26870
   763
wenzelm@26870
   764
  \item [\mbox{\isa{\isacommand{apply}}}~\isa{m}] applies proof method \isa{m}
wenzelm@26870
   765
  in initial position, but unlike \mbox{\isa{\isacommand{proof}}} it retains
wenzelm@26870
   766
  ``\isa{{\isachardoublequote}proof{\isacharparenleft}prove{\isacharparenright}{\isachardoublequote}}'' mode.  Thus consecutive method
wenzelm@26870
   767
  applications may be given just as in tactic scripts.
wenzelm@26870
   768
  
wenzelm@26870
   769
  Facts are passed to \isa{m} as indicated by the goal's
wenzelm@26870
   770
  forward-chain mode, and are \emph{consumed} afterwards.  Thus any
wenzelm@26870
   771
  further \mbox{\isa{\isacommand{apply}}} command would always work in a purely
wenzelm@26870
   772
  backward manner.
wenzelm@26870
   773
  
wenzelm@26870
   774
  \item [\mbox{\isa{\isacommand{apply{\isacharunderscore}end}}}~\isa{{\isachardoublequote}m{\isachardoublequote}}] applies proof method
wenzelm@26870
   775
  \isa{m} as if in terminal position.  Basically, this simulates a
wenzelm@26870
   776
  multi-step tactic script for \mbox{\isa{\isacommand{qed}}}, but may be given
wenzelm@26870
   777
  anywhere within the proof body.
wenzelm@26870
   778
  
wenzelm@26895
   779
  No facts are passed to \isa{m} here.  Furthermore, the static
wenzelm@26870
   780
  context is that of the enclosing goal (as for actual \mbox{\isa{\isacommand{qed}}}).  Thus the proof method may not refer to any assumptions
wenzelm@26870
   781
  introduced in the current body, for example.
wenzelm@26870
   782
  
wenzelm@26870
   783
  \item [\mbox{\isa{\isacommand{done}}}] completes a proof script, provided that
wenzelm@26870
   784
  the current goal state is solved completely.  Note that actual
wenzelm@26870
   785
  structured proof commands (e.g.\ ``\mbox{\isa{\isacommand{{\isachardot}}}}'' or \mbox{\isa{\isacommand{sorry}}}) may be used to conclude proof scripts as well.
wenzelm@26870
   786
wenzelm@26870
   787
  \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
wenzelm@26870
   788
  sub-goal \isa{n} to the end of the list (\isa{{\isachardoublequote}n\ {\isacharequal}\ {\isadigit{1}}{\isachardoublequote}} by
wenzelm@26870
   789
  default), while \mbox{\isa{\isacommand{prefer}}} brings sub-goal \isa{n} to the
wenzelm@26870
   790
  front.
wenzelm@26870
   791
  
wenzelm@26870
   792
  \item [\mbox{\isa{\isacommand{back}}}] does back-tracking over the result
wenzelm@26870
   793
  sequence of the latest proof command.  Basically, any proof command
wenzelm@26870
   794
  may return multiple results.
wenzelm@26870
   795
  
wenzelm@26870
   796
  \end{descr}
wenzelm@26870
   797
wenzelm@26870
   798
  Any proper Isar proof method may be used with tactic script commands
wenzelm@26870
   799
  such as \mbox{\isa{\isacommand{apply}}}.  A few additional emulations of actual
wenzelm@26870
   800
  tactics are provided as well; these would be never used in actual
wenzelm@26870
   801
  structured proofs, of course.%
wenzelm@26870
   802
\end{isamarkuptext}%
wenzelm@26870
   803
\isamarkuptrue%
wenzelm@26870
   804
%
wenzelm@26870
   805
\isamarkupsection{Omitting proofs%
wenzelm@26870
   806
}
wenzelm@26870
   807
\isamarkuptrue%
wenzelm@26870
   808
%
wenzelm@26870
   809
\begin{isamarkuptext}%
wenzelm@26870
   810
\begin{matharray}{rcl}
wenzelm@26870
   811
    \indexdef{}{command}{oops}\mbox{\isa{\isacommand{oops}}} & : & \isartrans{proof}{theory} \\
wenzelm@26870
   812
  \end{matharray}
wenzelm@26870
   813
wenzelm@26870
   814
  The \mbox{\isa{\isacommand{oops}}} command discontinues the current proof
wenzelm@26870
   815
  attempt, while considering the partial proof text as properly
wenzelm@26870
   816
  processed.  This is conceptually quite different from ``faking''
wenzelm@26870
   817
  actual proofs via \indexref{}{command}{sorry}\mbox{\isa{\isacommand{sorry}}} (see
wenzelm@26870
   818
  \secref{sec:proof-steps}): \mbox{\isa{\isacommand{oops}}} does not observe the
wenzelm@26870
   819
  proof structure at all, but goes back right to the theory level.
wenzelm@26870
   820
  Furthermore, \mbox{\isa{\isacommand{oops}}} does not produce any result theorem
wenzelm@26870
   821
  --- there is no intended claim to be able to complete the proof
wenzelm@26870
   822
  anyhow.
wenzelm@26870
   823
wenzelm@26870
   824
  A typical application of \mbox{\isa{\isacommand{oops}}} is to explain Isar proofs
wenzelm@26870
   825
  \emph{within} the system itself, in conjunction with the document
wenzelm@26870
   826
  preparation tools of Isabelle described in \cite{isabelle-sys}.
wenzelm@26870
   827
  Thus partial or even wrong proof attempts can be discussed in a
wenzelm@26870
   828
  logically sound manner.  Note that the Isabelle {\LaTeX} macros can
wenzelm@26870
   829
  be easily adapted to print something like ``\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}'' instead of
wenzelm@26870
   830
  the keyword ``\mbox{\isa{\isacommand{oops}}}''.
wenzelm@26870
   831
wenzelm@26870
   832
  \medskip The \mbox{\isa{\isacommand{oops}}} command is undo-able, unlike
wenzelm@26870
   833
  \indexref{}{command}{kill}\mbox{\isa{\isacommand{kill}}} (see \secref{sec:history}).  The effect is to
wenzelm@26870
   834
  get back to the theory just before the opening of the proof.%
wenzelm@26870
   835
\end{isamarkuptext}%
wenzelm@26870
   836
\isamarkuptrue%
wenzelm@26870
   837
%
wenzelm@26870
   838
\isamarkupsection{Generalized elimination \label{sec:obtain}%
wenzelm@26870
   839
}
wenzelm@26870
   840
\isamarkuptrue%
wenzelm@26870
   841
%
wenzelm@26870
   842
\begin{isamarkuptext}%
wenzelm@26870
   843
\begin{matharray}{rcl}
wenzelm@26870
   844
    \indexdef{}{command}{obtain}\mbox{\isa{\isacommand{obtain}}} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@26870
   845
    \indexdef{}{command}{guess}\mbox{\isa{\isacommand{guess}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isartrans{proof(state)}{proof(prove)} \\
wenzelm@26870
   846
  \end{matharray}
wenzelm@26870
   847
wenzelm@26870
   848
  Generalized elimination means that additional elements with certain
wenzelm@26870
   849
  properties may be introduced in the current context, by virtue of a
wenzelm@26870
   850
  locally proven ``soundness statement''.  Technically speaking, the
wenzelm@26870
   851
  \mbox{\isa{\isacommand{obtain}}} language element is like a declaration of
wenzelm@26870
   852
  \mbox{\isa{\isacommand{fix}}} and \mbox{\isa{\isacommand{assume}}} (see also see
wenzelm@26870
   853
  \secref{sec:proof-context}), together with a soundness proof of its
wenzelm@26870
   854
  additional claim.  According to the nature of existential reasoning,
wenzelm@26870
   855
  assumptions get eliminated from any result exported from the context
wenzelm@26870
   856
  later, provided that the corresponding parameters do \emph{not}
wenzelm@26870
   857
  occur in the conclusion.
wenzelm@26870
   858
wenzelm@26870
   859
  \begin{rail}
wenzelm@26870
   860
    'obtain' parname? (vars + 'and') 'where' (props + 'and')
wenzelm@26870
   861
    ;
wenzelm@26870
   862
    'guess' (vars + 'and')
wenzelm@26870
   863
    ;
wenzelm@26870
   864
  \end{rail}
wenzelm@26870
   865
wenzelm@26870
   866
  The derived Isar command \mbox{\isa{\isacommand{obtain}}} is defined as follows
wenzelm@26870
   867
  (where \isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ b\isactrlsub k{\isachardoublequote}} shall refer to (optional)
wenzelm@26870
   868
  facts indicated for forward chaining).
wenzelm@26870
   869
  \begin{matharray}{l}
wenzelm@26870
   870
    \isa{{\isachardoublequote}{\isasymlangle}using\ b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub k{\isasymrangle}{\isachardoublequote}}~~\mbox{\isa{\isacommand{obtain}}}~\isa{{\isachardoublequote}x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub m\ {\isasymWHERE}\ a{\isacharcolon}\ {\isasymphi}\isactrlsub {\isadigit{1}}\ {\isasymdots}\ {\isasymphi}\isactrlsub n\ \ {\isasymlangle}proof{\isasymrangle}\ {\isasymequiv}{\isachardoublequote}} \\[1ex]
wenzelm@26870
   871
    \quad \mbox{\isa{\isacommand{have}}}~\isa{{\isachardoublequote}{\isasymAnd}thesis{\isachardot}\ {\isacharparenleft}{\isasymAnd}x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub m{\isachardot}\ {\isasymphi}\isactrlsub {\isadigit{1}}\ {\isasymLongrightarrow}\ {\isasymdots}\ {\isasymphi}\isactrlsub n\ {\isasymLongrightarrow}\ thesis{\isacharparenright}\ {\isasymLongrightarrow}\ thesis{\isachardoublequote}} \\
wenzelm@26870
   872
    \quad \mbox{\isa{\isacommand{proof}}}~\isa{succeed} \\
wenzelm@26870
   873
    \qquad \mbox{\isa{\isacommand{fix}}}~\isa{thesis} \\
wenzelm@26870
   874
    \qquad \mbox{\isa{\isacommand{assume}}}~\isa{{\isachardoublequote}that\ {\isacharbrackleft}Pure{\isachardot}intro{\isacharquery}{\isacharbrackright}{\isacharcolon}\ {\isasymAnd}x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub m{\isachardot}\ {\isasymphi}\isactrlsub {\isadigit{1}}\ {\isasymLongrightarrow}\ {\isasymdots}\ {\isasymphi}\isactrlsub n\ {\isasymLongrightarrow}\ thesis{\isachardoublequote}} \\
wenzelm@26870
   875
    \qquad \mbox{\isa{\isacommand{then}}}~\mbox{\isa{\isacommand{show}}}~\isa{thesis} \\
wenzelm@26870
   876
    \quad\qquad \mbox{\isa{\isacommand{apply}}}~\isa{{\isacharminus}} \\
wenzelm@26870
   877
    \quad\qquad \mbox{\isa{\isacommand{using}}}~\isa{{\isachardoublequote}b\isactrlsub {\isadigit{1}}\ {\isasymdots}\ b\isactrlsub k\ \ {\isasymlangle}proof{\isasymrangle}{\isachardoublequote}} \\
wenzelm@26870
   878
    \quad \mbox{\isa{\isacommand{qed}}} \\
wenzelm@26870
   879
    \quad \mbox{\isa{\isacommand{fix}}}~\isa{{\isachardoublequote}x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub m{\isachardoublequote}}~\mbox{\isa{\isacommand{assume}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}\ a{\isacharcolon}\ {\isasymphi}\isactrlsub {\isadigit{1}}\ {\isasymdots}\ {\isasymphi}\isactrlsub n{\isachardoublequote}} \\
wenzelm@26870
   880
  \end{matharray}
wenzelm@26870
   881
wenzelm@26870
   882
  Typically, the soundness proof is relatively straight-forward, often
wenzelm@26870
   883
  just by canonical automated tools such as ``\mbox{\isa{\isacommand{by}}}~\isa{simp}'' or ``\mbox{\isa{\isacommand{by}}}~\isa{blast}''.  Accordingly, the
wenzelm@26870
   884
  ``\isa{that}'' reduction above is declared as simplification and
wenzelm@26870
   885
  introduction rule.
wenzelm@26870
   886
wenzelm@26870
   887
  In a sense, \mbox{\isa{\isacommand{obtain}}} represents at the level of Isar
wenzelm@26870
   888
  proofs what would be meta-logical existential quantifiers and
wenzelm@26870
   889
  conjunctions.  This concept has a broad range of useful
wenzelm@26870
   890
  applications, ranging from plain elimination (or introduction) of
wenzelm@26870
   891
  object-level existential and conjunctions, to elimination over
wenzelm@26870
   892
  results of symbolic evaluation of recursive definitions, for
wenzelm@26870
   893
  example.  Also note that \mbox{\isa{\isacommand{obtain}}} without parameters acts
wenzelm@26870
   894
  much like \mbox{\isa{\isacommand{have}}}, where the result is treated as a
wenzelm@26870
   895
  genuine assumption.
wenzelm@26870
   896
wenzelm@26870
   897
  An alternative name to be used instead of ``\isa{that}'' above may
wenzelm@26870
   898
  be given in parentheses.
wenzelm@26870
   899
wenzelm@26870
   900
  \medskip The improper variant \mbox{\isa{\isacommand{guess}}} is similar to
wenzelm@26870
   901
  \mbox{\isa{\isacommand{obtain}}}, but derives the obtained statement from the
wenzelm@26870
   902
  course of reasoning!  The proof starts with a fixed goal \isa{thesis}.  The subsequent proof may refine this to anything of the
wenzelm@26870
   903
  form like \isa{{\isachardoublequote}{\isasymAnd}x\isactrlsub {\isadigit{1}}\ {\isasymdots}\ x\isactrlsub m{\isachardot}\ {\isasymphi}\isactrlsub {\isadigit{1}}\ {\isasymLongrightarrow}\ {\isasymdots}\ {\isasymphi}\isactrlsub n\ {\isasymLongrightarrow}\ thesis{\isachardoublequote}}, but must not introduce new subgoals.  The
wenzelm@26870
   904
  final goal state is then used as reduction rule for the obtain
wenzelm@26870
   905
  scheme described above.  Obtained parameters \isa{{\isachardoublequote}x\isactrlsub {\isadigit{1}}{\isacharcomma}\ {\isasymdots}{\isacharcomma}\ x\isactrlsub m{\isachardoublequote}} are marked as internal by default, which prevents the
wenzelm@26870
   906
  proof context from being polluted by ad-hoc variables.  The variable
wenzelm@26870
   907
  names and type constraints given as arguments for \mbox{\isa{\isacommand{guess}}}
wenzelm@26870
   908
  specify a prefix of obtained parameters explicitly in the text.
wenzelm@26870
   909
wenzelm@26870
   910
  It is important to note that the facts introduced by \mbox{\isa{\isacommand{obtain}}} and \mbox{\isa{\isacommand{guess}}} may not be polymorphic: any
wenzelm@26870
   911
  type-variables occurring here are fixed in the present context!%
wenzelm@26870
   912
\end{isamarkuptext}%
wenzelm@26870
   913
\isamarkuptrue%
wenzelm@26870
   914
%
wenzelm@26870
   915
\isamarkupsection{Calculational reasoning \label{sec:calculation}%
wenzelm@26870
   916
}
wenzelm@26870
   917
\isamarkuptrue%
wenzelm@26870
   918
%
wenzelm@26870
   919
\begin{isamarkuptext}%
wenzelm@26870
   920
\begin{matharray}{rcl}
wenzelm@26870
   921
    \indexdef{}{command}{also}\mbox{\isa{\isacommand{also}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   922
    \indexdef{}{command}{finally}\mbox{\isa{\isacommand{finally}}} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@26870
   923
    \indexdef{}{command}{moreover}\mbox{\isa{\isacommand{moreover}}} & : & \isartrans{proof(state)}{proof(state)} \\
wenzelm@26870
   924
    \indexdef{}{command}{ultimately}\mbox{\isa{\isacommand{ultimately}}} & : & \isartrans{proof(state)}{proof(chain)} \\
wenzelm@26870
   925
    \indexdef{}{command}{print\_trans\_rules}\mbox{\isa{\isacommand{print{\isacharunderscore}trans{\isacharunderscore}rules}}}\isa{{\isachardoublequote}\isactrlsup {\isacharasterisk}{\isachardoublequote}} & : & \isarkeep{theory~|~proof} \\
wenzelm@26870
   926
    \mbox{\isa{trans}} & : & \isaratt \\
wenzelm@26870
   927
    \mbox{\isa{sym}} & : & \isaratt \\
wenzelm@26870
   928
    \mbox{\isa{symmetric}} & : & \isaratt \\
wenzelm@26870
   929
  \end{matharray}
wenzelm@26870
   930
wenzelm@26870
   931
  Calculational proof is forward reasoning with implicit application
wenzelm@26870
   932
  of transitivity rules (such those of \isa{{\isachardoublequote}{\isacharequal}{\isachardoublequote}}, \isa{{\isachardoublequote}{\isasymle}{\isachardoublequote}},
wenzelm@26870
   933
  \isa{{\isachardoublequote}{\isacharless}{\isachardoublequote}}).  Isabelle/Isar maintains an auxiliary fact register
wenzelm@26870
   934
  \indexref{}{fact}{calculation}\mbox{\isa{calculation}} for accumulating results obtained by
wenzelm@26870
   935
  transitivity composed with the current result.  Command \mbox{\isa{\isacommand{also}}} updates \mbox{\isa{calculation}} involving \mbox{\isa{this}}, while
wenzelm@26870
   936
  \mbox{\isa{\isacommand{finally}}} exhibits the final \mbox{\isa{calculation}} by
wenzelm@26870
   937
  forward chaining towards the next goal statement.  Both commands
wenzelm@26870
   938
  require valid current facts, i.e.\ may occur only after commands
wenzelm@26870
   939
  that produce theorems such as \mbox{\isa{\isacommand{assume}}}, \mbox{\isa{\isacommand{note}}}, or some finished proof of \mbox{\isa{\isacommand{have}}}, \mbox{\isa{\isacommand{show}}} etc.  The \mbox{\isa{\isacommand{moreover}}} and \mbox{\isa{\isacommand{ultimately}}}
wenzelm@26870
   940
  commands are similar to \mbox{\isa{\isacommand{also}}} and \mbox{\isa{\isacommand{finally}}},
wenzelm@26870
   941
  but only collect further results in \mbox{\isa{calculation}} without
wenzelm@26870
   942
  applying any rules yet.
wenzelm@26870
   943
wenzelm@26870
   944
  Also note that the implicit term abbreviation ``\isa{{\isachardoublequote}{\isasymdots}{\isachardoublequote}}'' has
wenzelm@26870
   945
  its canonical application with calculational proofs.  It refers to
wenzelm@26870
   946
  the argument of the preceding statement. (The argument of a curried
wenzelm@26870
   947
  infix expression happens to be its right-hand side.)
wenzelm@26870
   948
wenzelm@26870
   949
  Isabelle/Isar calculations are implicitly subject to block structure
wenzelm@26870
   950
  in the sense that new threads of calculational reasoning are
wenzelm@26870
   951
  commenced for any new block (as opened by a local goal, for
wenzelm@26870
   952
  example).  This means that, apart from being able to nest
wenzelm@26870
   953
  calculations, there is no separate \emph{begin-calculation} command
wenzelm@26870
   954
  required.
wenzelm@26870
   955
wenzelm@26870
   956
  \medskip The Isar calculation proof commands may be defined as
wenzelm@26870
   957
  follows:\footnote{We suppress internal bookkeeping such as proper
wenzelm@26870
   958
  handling of block-structure.}
wenzelm@26870
   959
wenzelm@26870
   960
  \begin{matharray}{rcl}
wenzelm@26870
   961
    \mbox{\isa{\isacommand{also}}}\isa{{\isachardoublequote}\isactrlsub {\isadigit{0}}{\isachardoublequote}} & \equiv & \mbox{\isa{\isacommand{note}}}~\isa{{\isachardoublequote}calculation\ {\isacharequal}\ this{\isachardoublequote}} \\
wenzelm@26870
   962
    \mbox{\isa{\isacommand{also}}}\isa{{\isachardoublequote}\isactrlsub n\isactrlsub {\isacharplus}\isactrlsub {\isadigit{1}}{\isachardoublequote}} & \equiv & \mbox{\isa{\isacommand{note}}}~\isa{{\isachardoublequote}calculation\ {\isacharequal}\ trans\ {\isacharbrackleft}OF\ calculation\ this{\isacharbrackright}{\isachardoublequote}} \\[0.5ex]
wenzelm@26870
   963
    \mbox{\isa{\isacommand{finally}}} & \equiv & \mbox{\isa{\isacommand{also}}}~\mbox{\isa{\isacommand{from}}}~\isa{calculation} \\[0.5ex]
wenzelm@26870
   964
    \mbox{\isa{\isacommand{moreover}}} & \equiv & \mbox{\isa{\isacommand{note}}}~\isa{{\isachardoublequote}calculation\ {\isacharequal}\ calculation\ this{\isachardoublequote}} \\
wenzelm@26870
   965
    \mbox{\isa{\isacommand{ultimately}}} & \equiv & \mbox{\isa{\isacommand{moreover}}}~\mbox{\isa{\isacommand{from}}}~\isa{calculation} \\
wenzelm@26870
   966
  \end{matharray}
wenzelm@26870
   967
wenzelm@26870
   968
  \begin{rail}
wenzelm@26870
   969
    ('also' | 'finally') ('(' thmrefs ')')?
wenzelm@26870
   970
    ;
wenzelm@26870
   971
    'trans' (() | 'add' | 'del')
wenzelm@26870
   972
    ;
wenzelm@26870
   973
  \end{rail}
wenzelm@26870
   974
wenzelm@26870
   975
  \begin{descr}
wenzelm@26870
   976
wenzelm@26870
   977
  \item [\mbox{\isa{\isacommand{also}}}~\isa{{\isachardoublequote}{\isacharparenleft}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isacharparenright}{\isachardoublequote}}]
wenzelm@26870
   978
  maintains the auxiliary \mbox{\isa{calculation}} register as follows.
wenzelm@26870
   979
  The first occurrence of \mbox{\isa{\isacommand{also}}} in some calculational
wenzelm@26870
   980
  thread initializes \mbox{\isa{calculation}} by \mbox{\isa{this}}. Any
wenzelm@26870
   981
  subsequent \mbox{\isa{\isacommand{also}}} on the same level of block-structure
wenzelm@26870
   982
  updates \mbox{\isa{calculation}} by some transitivity rule applied to
wenzelm@26870
   983
  \mbox{\isa{calculation}} and \mbox{\isa{this}} (in that order).  Transitivity
wenzelm@26870
   984
  rules are picked from the current context, unless alternative rules
wenzelm@26870
   985
  are given as explicit arguments.
wenzelm@26870
   986
wenzelm@26870
   987
  \item [\mbox{\isa{\isacommand{finally}}}~\isa{{\isachardoublequote}{\isacharparenleft}a\isactrlsub {\isadigit{1}}\ {\isasymdots}\ a\isactrlsub n{\isacharparenright}{\isachardoublequote}}]
wenzelm@26870
   988
  maintaining \mbox{\isa{calculation}} in the same way as \mbox{\isa{\isacommand{also}}}, and concludes the current calculational thread.  The final
wenzelm@26870
   989
  result is exhibited as fact for forward chaining towards the next
wenzelm@26870
   990
  goal. Basically, \mbox{\isa{\isacommand{finally}}} just abbreviates \mbox{\isa{\isacommand{also}}}~\mbox{\isa{\isacommand{from}}}~\mbox{\isa{calculation}}.  Typical idioms for
wenzelm@26870
   991
  concluding calculational proofs are ``\mbox{\isa{\isacommand{finally}}}~\mbox{\isa{\isacommand{show}}}~\isa{{\isacharquery}thesis}~\mbox{\isa{\isacommand{{\isachardot}}}}'' and ``\mbox{\isa{\isacommand{finally}}}~\mbox{\isa{\isacommand{have}}}~\isa{{\isasymphi}}~\mbox{\isa{\isacommand{{\isachardot}}}}''.
wenzelm@26870
   992
wenzelm@26870
   993
  \item [\mbox{\isa{\isacommand{moreover}}} and \mbox{\isa{\isacommand{ultimately}}}] are
wenzelm@26870
   994
  analogous to \mbox{\isa{\isacommand{also}}} and \mbox{\isa{\isacommand{finally}}}, but collect
wenzelm@26870
   995
  results only, without applying rules.
wenzelm@26870
   996
wenzelm@26870
   997
  \item [\mbox{\isa{\isacommand{print{\isacharunderscore}trans{\isacharunderscore}rules}}}] prints the list of
wenzelm@26870
   998
  transitivity rules (for calculational commands \mbox{\isa{\isacommand{also}}} and
wenzelm@26870
   999
  \mbox{\isa{\isacommand{finally}}}) and symmetry rules (for the \mbox{\isa{symmetric}} operation and single step elimination patters) of the
wenzelm@26870
  1000
  current context.
wenzelm@26870
  1001
wenzelm@26870
  1002
  \item [\mbox{\isa{trans}}] declares theorems as transitivity rules.
wenzelm@26870
  1003
wenzelm@26870
  1004
  \item [\mbox{\isa{sym}}] declares symmetry rules, as well as
wenzelm@26895
  1005
  \mbox{\isa{Pure{\isachardot}elim}}\isa{{\isachardoublequote}{\isacharquery}{\isachardoublequote}} rules.
wenzelm@26870
  1006
wenzelm@26870
  1007
  \item [\mbox{\isa{symmetric}}] resolves a theorem with some rule
wenzelm@26870
  1008
  declared as \mbox{\isa{sym}} in the current context.  For example,
wenzelm@26870
  1009
  ``\mbox{\isa{\isacommand{assume}}}~\isa{{\isachardoublequote}{\isacharbrackleft}symmetric{\isacharbrackright}{\isacharcolon}\ x\ {\isacharequal}\ y{\isachardoublequote}}'' produces a
wenzelm@26870
  1010
  swapped fact derived from that assumption.
wenzelm@26870
  1011
wenzelm@26870
  1012
  In structured proof texts it is often more appropriate to use an
wenzelm@26870
  1013
  explicit single-step elimination proof, such as ``\mbox{\isa{\isacommand{assume}}}~\isa{{\isachardoublequote}x\ {\isacharequal}\ y{\isachardoublequote}}~\mbox{\isa{\isacommand{then}}}~\mbox{\isa{\isacommand{have}}}~\isa{{\isachardoublequote}y\ {\isacharequal}\ x{\isachardoublequote}}~\mbox{\isa{\isacommand{{\isachardot}{\isachardot}}}}''.
wenzelm@26870
  1014
wenzelm@26870
  1015
  \end{descr}%
wenzelm@26870
  1016
\end{isamarkuptext}%
wenzelm@26870
  1017
\isamarkuptrue%
wenzelm@26870
  1018
%
wenzelm@26869
  1019
\isadelimtheory
wenzelm@26869
  1020
%
wenzelm@26869
  1021
\endisadelimtheory
wenzelm@26869
  1022
%
wenzelm@26869
  1023
\isatagtheory
wenzelm@26869
  1024
\isacommand{end}\isamarkupfalse%
wenzelm@26869
  1025
%
wenzelm@26869
  1026
\endisatagtheory
wenzelm@26869
  1027
{\isafoldtheory}%
wenzelm@26869
  1028
%
wenzelm@26869
  1029
\isadelimtheory
wenzelm@26869
  1030
%
wenzelm@26869
  1031
\endisadelimtheory
wenzelm@26869
  1032
\isanewline
wenzelm@26869
  1033
\end{isabellebody}%
wenzelm@26869
  1034
%%% Local Variables:
wenzelm@26869
  1035
%%% mode: latex
wenzelm@26869
  1036
%%% TeX-master: "root"
wenzelm@26869
  1037
%%% End: