doc-src/Ref/thm.tex
author wenzelm
Sun, 01 Mar 2009 13:48:17 +0100
changeset 30184 37969710e61f
parent 11625 74cdf24724ea
child 42932 34ed34804d90
permissions -rw-r--r--
removed parts of the manual that are clearly obsolete, or covered by newer manuals already (notably "isar-ref" or "implementation");
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30184
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 11625
diff changeset
     1
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     2
\chapter{Theorems and Forward Proof}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     3
\index{theorems|(}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
     4
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
     5
Theorems, which represent the axioms, theorems and rules of
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
     6
object-logics, have type \mltydx{thm}.  This chapter begins by
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
     7
describing operations that print theorems and that join them in
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
     8
forward proof.  Most theorem operations are intended for advanced
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
     9
applications, such as programming new proof procedures.  Many of these
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    10
operations refer to signatures, certified terms and certified types,
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    11
which have the \ML{} types {\tt Sign.sg}, {\tt cterm} and {\tt ctyp}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    12
and are discussed in Chapter~\ref{theories}.  Beginning users should
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    13
ignore such complexities --- and skip all but the first section of
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    14
this chapter.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    15
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    16
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    17
\section{Basic operations on theorems}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    18
\subsection{Pretty-printing a theorem}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    19
\index{theorems!printing of}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    20
\begin{ttbox} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    21
prth          : thm -> thm
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    22
prths         : thm list -> thm list
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
    23
prthq         : thm Seq.seq -> thm Seq.seq
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    24
print_thm     : thm -> unit
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    25
print_goals   : int -> thm -> unit
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    26
string_of_thm : thm -> string
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    27
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    28
The first three commands are for interactive use.  They are identity
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    29
functions that display, then return, their argument.  The \ML{} identifier
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    30
{\tt it} will refer to the value just displayed.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    31
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    32
The others are for use in programs.  Functions with result type {\tt unit}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    33
are convenient for imperative programming.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    34
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    35
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    36
\item[\ttindexbold{prth} {\it thm}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    37
prints {\it thm\/} at the terminal.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    38
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    39
\item[\ttindexbold{prths} {\it thms}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    40
prints {\it thms}, a list of theorems.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    41
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    42
\item[\ttindexbold{prthq} {\it thmq}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    43
prints {\it thmq}, a sequence of theorems.  It is useful for inspecting
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    44
the output of a tactic.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    45
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    46
\item[\ttindexbold{print_thm} {\it thm}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    47
prints {\it thm\/} at the terminal.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    48
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    49
\item[\ttindexbold{print_goals} {\it limit\/} {\it thm}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    50
prints {\it thm\/} in goal style, with the premises as subgoals.  It prints
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    51
at most {\it limit\/} subgoals.  The subgoal module calls {\tt print_goals}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    52
to display proof states.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    53
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    54
\item[\ttindexbold{string_of_thm} {\it thm}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    55
converts {\it thm\/} to a string.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    56
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    57
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    58
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    59
\subsection{Forward proof: joining rules by resolution}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    60
\index{theorems!joining by resolution}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    61
\index{resolution}\index{forward proof}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    62
\begin{ttbox} 
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    63
RSN : thm * (int * thm) -> thm                 \hfill\textbf{infix}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    64
RS  : thm * thm -> thm                         \hfill\textbf{infix}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    65
MRS : thm list * thm -> thm                    \hfill\textbf{infix}
9288
06a55195741b infix 'OF' is a version of 'MRS' with more appropriate argument order;
wenzelm
parents: 9258
diff changeset
    66
OF  : thm * thm list -> thm                    \hfill\textbf{infix}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    67
RLN : thm list * (int * thm list) -> thm list  \hfill\textbf{infix}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    68
RL  : thm list * thm list -> thm list          \hfill\textbf{infix}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    69
MRL : thm list list * thm list -> thm list     \hfill\textbf{infix}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    70
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    71
Joining rules together is a simple way of deriving new rules.  These
876
5c18634db55d Under RS added cross reference to bind_thm
lcp
parents: 866
diff changeset
    72
functions are especially useful with destruction rules.  To store
5c18634db55d Under RS added cross reference to bind_thm
lcp
parents: 866
diff changeset
    73
the result in the theorem database, use \ttindex{bind_thm}
5c18634db55d Under RS added cross reference to bind_thm
lcp
parents: 866
diff changeset
    74
(\S\ref{ExtractingAndStoringTheProvedTheorem}). 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    75
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    76
\item[\tt$thm@1$ RSN $(i,thm@2)$] \indexbold{*RSN} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    77
  resolves the conclusion of $thm@1$ with the $i$th premise of~$thm@2$.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    78
  Unless there is precisely one resolvent it raises exception
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    79
  \xdx{THM}; in that case, use {\tt RLN}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    80
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    81
\item[\tt$thm@1$ RS $thm@2$] \indexbold{*RS} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    82
abbreviates \hbox{\tt$thm@1$ RSN $(1,thm@2)$}.  Thus, it resolves the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    83
conclusion of $thm@1$ with the first premise of~$thm@2$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    84
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    85
\item[\tt {$[thm@1,\ldots,thm@n]$} MRS $thm$] \indexbold{*MRS} 
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
    86
  uses {\tt RSN} to resolve $thm@i$ against premise~$i$ of $thm$, for
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    87
  $i=n$, \ldots,~1.  This applies $thm@n$, \ldots, $thm@1$ to the first $n$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    88
  premises of $thm$.  Because the theorems are used from right to left, it
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    89
  does not matter if the $thm@i$ create new premises.  {\tt MRS} is useful
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    90
  for expressing proof trees.
9288
06a55195741b infix 'OF' is a version of 'MRS' with more appropriate argument order;
wenzelm
parents: 9258
diff changeset
    91
  
06a55195741b infix 'OF' is a version of 'MRS' with more appropriate argument order;
wenzelm
parents: 9258
diff changeset
    92
\item[\tt {$thm$ OF $[thm@1,\ldots,thm@n]$}] \indexbold{*OF} is the same as
06a55195741b infix 'OF' is a version of 'MRS' with more appropriate argument order;
wenzelm
parents: 9258
diff changeset
    93
  \texttt{$[thm@1,\ldots,thm@n]$ MRS $thm$}, with slightly more readable
06a55195741b infix 'OF' is a version of 'MRS' with more appropriate argument order;
wenzelm
parents: 9258
diff changeset
    94
  argument order, though.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    95
151
c5e636ca6576 corrected some obvious errors;
wenzelm
parents: 104
diff changeset
    96
\item[\tt$thms@1$ RLN $(i,thms@2)$] \indexbold{*RLN} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    97
  joins lists of theorems.  For every $thm@1$ in $thms@1$ and $thm@2$ in
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    98
  $thms@2$, it resolves the conclusion of $thm@1$ with the $i$th premise
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    99
  of~$thm@2$, accumulating the results. 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   100
151
c5e636ca6576 corrected some obvious errors;
wenzelm
parents: 104
diff changeset
   101
\item[\tt$thms@1$ RL $thms@2$] \indexbold{*RL} 
c5e636ca6576 corrected some obvious errors;
wenzelm
parents: 104
diff changeset
   102
abbreviates \hbox{\tt$thms@1$ RLN $(1,thms@2)$}. 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   103
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   104
\item[\tt {$[thms@1,\ldots,thms@n]$} MRL $thms$] \indexbold{*MRL} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   105
is analogous to {\tt MRS}, but combines theorem lists rather than theorems.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   106
It too is useful for expressing proof trees.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   107
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   108
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   109
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   110
\subsection{Expanding definitions in theorems}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   111
\index{meta-rewriting!in theorems}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   112
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   113
rewrite_rule       : thm list -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   114
rewrite_goals_rule : thm list -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   116
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   117
\item[\ttindexbold{rewrite_rule} {\it defs} {\it thm}]  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   118
unfolds the {\it defs} throughout the theorem~{\it thm}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   119
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   120
\item[\ttindexbold{rewrite_goals_rule} {\it defs} {\it thm}]  
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   121
unfolds the {\it defs} in the premises of~{\it thm}, but it leaves the
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   122
conclusion unchanged.  This rule is the basis for \ttindex{rewrite_goals_tac},
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   123
but it serves little purpose in forward proof.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   124
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   125
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   126
4383
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   127
\subsection{Instantiating unknowns in a theorem} \label{sec:instantiate}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   128
\index{instantiation}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   129
\begin{alltt}\footnotesize
4383
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   130
read_instantiate    :                (string*string) list -> thm -> thm
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   131
read_instantiate_sg :     Sign.sg -> (string*string) list -> thm -> thm
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   132
cterm_instantiate   :                  (cterm*cterm) list -> thm -> thm
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   133
instantiate'      : ctyp option list -> cterm option list -> thm -> thm
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   134
\end{alltt}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   135
These meta-rules instantiate type and term unknowns in a theorem.  They are
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   136
occasionally useful.  They can prevent difficulties with higher-order
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   137
unification, and define specialized versions of rules.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   138
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   139
\item[\ttindexbold{read_instantiate} {\it insts} {\it thm}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   140
processes the instantiations {\it insts} and instantiates the rule~{\it
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   141
thm}.  The processing of instantiations is described
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   142
in \S\ref{res_inst_tac}, under {\tt res_inst_tac}.  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   143
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   144
Use {\tt res_inst_tac}, not {\tt read_instantiate}, to instantiate a rule
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   145
and refine a particular subgoal.  The tactic allows instantiation by the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   146
subgoal's parameters, and reads the instantiations using the signature
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   147
associated with the proof state.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   148
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   149
Use {\tt read_instantiate_sg} below if {\it insts\/} appears to be treated
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   150
incorrectly.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   151
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   152
\item[\ttindexbold{read_instantiate_sg} {\it sg} {\it insts} {\it thm}]
4597
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4383
diff changeset
   153
  is like \texttt{read_instantiate {\it insts}~{\it thm}}, but it reads
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   154
  the instantiations under signature~{\it sg}.  This is necessary to
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   155
  instantiate a rule from a general theory, such as first-order logic,
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   156
  using the notation of some specialized theory.  Use the function {\tt
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   157
    sign_of} to get a theory's signature.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   158
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   159
\item[\ttindexbold{cterm_instantiate} {\it ctpairs} {\it thm}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   160
is similar to {\tt read_instantiate}, but the instantiations are provided
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   161
as pairs of certified terms, not as strings to be read.
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   162
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   163
\item[\ttindexbold{instantiate'} {\it ctyps} {\it cterms} {\it thm}]
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   164
  instantiates {\it thm} according to the positional arguments {\it
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   165
    ctyps} and {\it cterms}.  Counting from left to right, schematic
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   166
  variables $?x$ are either replaced by $t$ for any argument
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   167
  \texttt{Some\(\;t\)}, or left unchanged in case of \texttt{None} or
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   168
  if the end of the argument list is encountered.  Types are
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   169
  instantiated before terms.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   170
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   171
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   172
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   173
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 332
diff changeset
   174
\subsection{Miscellaneous forward rules}\label{MiscellaneousForwardRules}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   175
\index{theorems!standardizing}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   176
\begin{ttbox} 
8969
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   177
standard         :               thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   178
zero_var_indexes :               thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   179
make_elim        :               thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   180
rule_by_tactic   :     tactic -> thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   181
rotate_prems     :        int -> thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   182
permute_prems    : int -> int -> thm -> thm
11163
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   183
rearrange_prems  :   int list -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   184
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   185
\begin{ttdescription}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   186
\item[\ttindexbold{standard} $thm$] puts $thm$ into the standard form
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   187
  of object-rules.  It discharges all meta-assumptions, replaces free
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   188
  variables by schematic variables, renames schematic variables to
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   189
  have subscript zero, also strips outer (meta) quantifiers and
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   190
  removes dangling sort hypotheses.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   191
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   192
\item[\ttindexbold{zero_var_indexes} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   193
makes all schematic variables have subscript zero, renaming them to avoid
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   194
clashes. 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   195
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   196
\item[\ttindexbold{make_elim} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   197
\index{rules!converting destruction to elimination}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   198
converts $thm$, which should be  a destruction rule of the form
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   199
$\List{P@1;\ldots;P@m}\Imp 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   200
Q$, to the elimination rule $\List{P@1; \ldots; P@m; Q\Imp R}\Imp R$.  This
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   201
is the basis for destruct-resolution: {\tt dresolve_tac}, etc.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   202
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   203
\item[\ttindexbold{rule_by_tactic} {\it tac} {\it thm}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   204
  applies {\it tac\/} to the {\it thm}, freezing its variables first, then
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   205
  yields the proof state returned by the tactic.  In typical usage, the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   206
  {\it thm\/} represents an instance of a rule with several premises, some
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   207
  with contradictory assumptions (because of the instantiation).  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   208
  tactic proves those subgoals and does whatever else it can, and returns
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   209
  whatever is left.
4607
6759ba6d3cc1 Added reference to rotate_prems
paulson
parents: 4597
diff changeset
   210
  
6759ba6d3cc1 Added reference to rotate_prems
paulson
parents: 4597
diff changeset
   211
\item[\ttindexbold{rotate_prems} $k$ $thm$] rotates the premises of $thm$ to
8969
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   212
  the left by~$k$ positions (to the right if $k<0$).  It simply calls
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   213
  \texttt{permute_prems}, below, with $j=0$.  Used with
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   214
  \texttt{eresolve_tac}\index{*eresolve_tac!on other than first premise}, it
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   215
  gives the effect of applying the tactic to some other premise of $thm$ than
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   216
  the first.
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   217
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   218
\item[\ttindexbold{permute_prems} $j$ $k$ $thm$] rotates the premises of $thm$
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   219
  leaving the first $j$ premises unchanged.  It
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   220
  requires $0\leq j\leq n$, where $n$ is the number of premises.  If $k$ is
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   221
  positive then it rotates the remaining $n-j$ premises to the left; if $k$ is
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   222
  negative then it rotates the premises to the right.
11163
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   223
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   224
\item[\ttindexbold{rearrange_prems} $ps$ $thm$] permutes the premises of $thm$
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   225
   where the value at the $i$-th position (counting from $0$) in the list $ps$
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   226
   gives the position within the original thm to be transferred to position $i$.
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   227
   Any remaining trailing positions are left unchanged.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   228
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   229
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   230
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   231
\subsection{Taking a theorem apart}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   232
\index{theorems!taking apart}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   233
\index{flex-flex constraints}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   234
\begin{ttbox} 
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   235
cprop_of      : thm -> cterm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   236
concl_of      : thm -> term
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   237
prems_of      : thm -> term list
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   238
cprems_of     : thm -> cterm list
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   239
nprems_of     : thm -> int
4383
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   240
tpairs_of     : thm -> (term*term) list
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   241
sign_of_thm   : thm -> Sign.sg
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 332
diff changeset
   242
theory_of_thm : thm -> theory
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   243
dest_state : thm * int -> (term*term) list * term list * term * term
9499
7e6988210488 rep_thm: 'der' field has additional bool for oracles;
wenzelm
parents: 9288
diff changeset
   244
rep_thm    : thm -> \{sign_ref: Sign.sg_ref, der: bool * deriv, maxidx: int,
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   245
                     shyps: sort list, hyps: term list, prop: term\}
9499
7e6988210488 rep_thm: 'der' field has additional bool for oracles;
wenzelm
parents: 9288
diff changeset
   246
crep_thm   : thm -> \{sign_ref: Sign.sg_ref, der: bool * deriv, maxidx: int,
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   247
                     shyps: sort list, hyps: cterm list, prop:{\ts}cterm\}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   248
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   249
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   250
\item[\ttindexbold{cprop_of} $thm$] returns the statement of $thm$ as
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   251
  a certified term.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   252
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   253
\item[\ttindexbold{concl_of} $thm$] returns the conclusion of $thm$ as
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   254
  a term.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   255
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   256
\item[\ttindexbold{prems_of} $thm$] returns the premises of $thm$ as a
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   257
  list of terms.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   258
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   259
\item[\ttindexbold{cprems_of} $thm$] returns the premises of $thm$ as
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   260
  a list of certified terms.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   261
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   262
\item[\ttindexbold{nprems_of} $thm$] 
286
e7efbf03562b first draft of Springer book
lcp
parents: 151
diff changeset
   263
returns the number of premises in $thm$, and is equivalent to {\tt
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   264
  length~(prems_of~$thm$)}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   265
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   266
\item[\ttindexbold{tpairs_of} $thm$] returns the flex-flex constraints
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   267
  of $thm$.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   268
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   269
\item[\ttindexbold{sign_of_thm} $thm$] returns the signature
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   270
  associated with $thm$.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   271
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   272
\item[\ttindexbold{theory_of_thm} $thm$] returns the theory associated
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   273
  with $thm$.  Note that this does a lookup in Isabelle's global
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   274
  database of loaded theories.
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 332
diff changeset
   275
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   276
\item[\ttindexbold{dest_state} $(thm,i)$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   277
decomposes $thm$ as a tuple containing a list of flex-flex constraints, a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   278
list of the subgoals~1 to~$i-1$, subgoal~$i$, and the rest of the theorem
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   279
(this will be an implication if there are more than $i$ subgoals).
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   280
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   281
\item[\ttindexbold{rep_thm} $thm$] decomposes $thm$ as a record
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   282
  containing the statement of~$thm$ ({\tt prop}), its list of
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   283
  meta-assumptions ({\tt hyps}), its derivation ({\tt der}), a bound
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   284
  on the maximum subscript of its unknowns ({\tt maxidx}), and a
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   285
  reference to its signature ({\tt sign_ref}).  The {\tt shyps} field
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   286
  is discussed below.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   287
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   288
\item[\ttindexbold{crep_thm} $thm$] like \texttt{rep_thm}, but returns
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   289
  the hypotheses and statement as certified terms.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   290
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   291
\end{ttdescription}
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   292
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   293
5777
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   294
\subsection{*Sort hypotheses} \label{sec:sort-hyps}
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   295
\index{sort hypotheses}
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   296
\begin{ttbox} 
7644
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   297
strip_shyps         : thm -> thm
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   298
strip_shyps_warning : thm -> thm
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   299
\end{ttbox}
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   300
2044
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   301
Isabelle's type variables are decorated with sorts, constraining them to
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   302
certain ranges of types.  This has little impact when sorts only serve for
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   303
syntactic classification of types --- for example, FOL distinguishes between
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   304
terms and other types.  But when type classes are introduced through axioms,
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   305
this may result in some sorts becoming {\em empty\/}: where one cannot exhibit
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   306
a type belonging to it because certain sets of axioms are unsatisfiable.
2044
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   307
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   308
If a theorem contains a type variable that is constrained by an empty
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3135
diff changeset
   309
sort, then that theorem has no instances.  It is basically an instance
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   310
of {\em ex falso quodlibet}.  But what if it is used to prove another
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   311
theorem that no longer involves that sort?  The latter theorem holds
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   312
only if under an additional non-emptiness assumption.
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   313
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3135
diff changeset
   314
Therefore, Isabelle's theorems carry around sort hypotheses.  The {\tt
2044
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   315
shyps} field is a list of sorts occurring in type variables in the current
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   316
{\tt prop} and {\tt hyps} fields.  It may also includes sorts used in the
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   317
theorem's proof that no longer appear in the {\tt prop} or {\tt hyps}
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3135
diff changeset
   318
fields --- so-called {\em dangling\/} sort constraints.  These are the
2044
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   319
critical ones, asserting non-emptiness of the corresponding sorts.
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   320
 
7644
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   321
Isabelle automatically removes extraneous sorts from the {\tt shyps} field at
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   322
the end of a proof, provided that non-emptiness can be established by looking
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   323
at the theorem's signature: from the {\tt classes} and {\tt arities}
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   324
information.  This operation is performed by \texttt{strip_shyps} and
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   325
\texttt{strip_shyps_warning}.
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   326
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   327
\begin{ttdescription}
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   328
  
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   329
\item[\ttindexbold{strip_shyps} $thm$] removes any extraneous sort hypotheses
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   330
  that can be witnessed from the type signature.
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   331
  
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   332
\item[\ttindexbold{strip_shyps_warning}] is like \texttt{strip_shyps}, but
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   333
  issues a warning message of any pending sort hypotheses that do not have a
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   334
  (syntactic) witness.
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   335
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   336
\end{ttdescription}
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   337
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   338
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   339
\subsection{Tracing flags for unification}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   340
\index{tracing!of unification}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   341
\begin{ttbox} 
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   342
Unify.trace_simp   : bool ref \hfill\textbf{initially false}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   343
Unify.trace_types  : bool ref \hfill\textbf{initially false}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   344
Unify.trace_bound  : int ref \hfill\textbf{initially 10}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   345
Unify.search_bound : int ref \hfill\textbf{initially 20}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   346
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   347
Tracing the search may be useful when higher-order unification behaves
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   348
unexpectedly.  Letting {\tt res_inst_tac} circumvent the problem is easier,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   349
though.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   350
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   351
\item[set Unify.trace_simp;] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   352
causes tracing of the simplification phase.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   353
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   354
\item[set Unify.trace_types;] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   355
generates warnings of incompleteness, when unification is not considering
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   356
all possible instantiations of type unknowns.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   357
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   358
\item[Unify.trace_bound := $n$;] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   359
causes unification to print tracing information once it reaches depth~$n$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   360
Use $n=0$ for full tracing.  At the default value of~10, tracing
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   361
information is almost never printed.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   362
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   363
\item[Unify.search_bound := $n$;] prevents unification from
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   364
  searching past the depth~$n$.  Because of this bound, higher-order
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   365
  unification cannot return an infinite sequence, though it can return
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   366
  an exponentially long one.  The search rarely approaches the default value
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   367
  of~20.  If the search is cut off, unification prints a warning
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   368
  \texttt{Unification bound exceeded}.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   369
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   370
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   371
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   372
\section{*Primitive meta-level inference rules}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   373
\index{meta-rules|(}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   374
These implement the meta-logic in the style of the {\sc lcf} system,
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   375
as functions from theorems to theorems.  They are, rarely, useful for
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   376
deriving results in the pure theory.  Mainly, they are included for
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   377
completeness, and most users should not bother with them.  The
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   378
meta-rules raise exception \xdx{THM} to signal malformed premises,
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   379
incompatible signatures and similar errors.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   380
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   381
\index{meta-assumptions}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   382
The meta-logic uses natural deduction.  Each theorem may depend on
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   383
meta-level assumptions.  Certain rules, such as $({\Imp}I)$,
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   384
discharge assumptions; in most other rules, the conclusion depends on all
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   385
of the assumptions of the premises.  Formally, the system works with
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   386
assertions of the form
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   387
\[ \phi \quad [\phi@1,\ldots,\phi@n], \]
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   388
where $\phi@1$,~\ldots,~$\phi@n$ are the assumptions.  This can be
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   389
also read as a single conclusion sequent $\phi@1,\ldots,\phi@n \vdash
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3135
diff changeset
   390
\phi$.  Do not confuse meta-level assumptions with the object-level
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   391
assumptions in a subgoal, which are represented in the meta-logic
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   392
using~$\Imp$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   393
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   394
Each theorem has a signature.  Certified terms have a signature.  When a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   395
rule takes several premises and certified terms, it merges the signatures
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   396
to make a signature for the conclusion.  This fails if the signatures are
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   397
incompatible. 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   398
5777
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   399
\medskip
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   400
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   401
The following presentation of primitive rules ignores sort
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   402
hypotheses\index{sort hypotheses} (see also \S\ref{sec:sort-hyps}).  These are
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   403
handled transparently by the logic implementation.
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   404
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   405
\bigskip
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   406
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   407
\index{meta-implication}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   408
The \textbf{implication} rules are $({\Imp}I)$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   409
and $({\Imp}E)$:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   410
\[ \infer[({\Imp}I)]{\phi\Imp \psi}{\infer*{\psi}{[\phi]}}  \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   411
   \infer[({\Imp}E)]{\psi}{\phi\Imp \psi & \phi}  \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   412
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   413
\index{meta-equality}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   414
Equality of truth values means logical equivalence:
3524
c02cb15830de fixed EqI meta rule;
wenzelm
parents: 3485
diff changeset
   415
\[ \infer[({\equiv}I)]{\phi\equiv\psi}{\phi\Imp\psi &
c02cb15830de fixed EqI meta rule;
wenzelm
parents: 3485
diff changeset
   416
                                       \psi\Imp\phi}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   417
   \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   418
   \infer[({\equiv}E)]{\psi}{\phi\equiv \psi & \phi}   \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   419
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   420
The \textbf{equality} rules are reflexivity, symmetry, and transitivity:
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   421
\[ {a\equiv a}\,(refl)  \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   422
   \infer[(sym)]{b\equiv a}{a\equiv b}  \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   423
   \infer[(trans)]{a\equiv c}{a\equiv b & b\equiv c}   \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   424
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   425
\index{lambda calc@$\lambda$-calculus}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   426
The $\lambda$-conversions are $\alpha$-conversion, $\beta$-conversion, and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   427
extensionality:\footnote{$\alpha$-conversion holds if $y$ is not free
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   428
in~$a$; $(ext)$ holds if $x$ is not free in the assumptions, $f$, or~$g$.}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   429
\[ {(\lambda x.a) \equiv (\lambda y.a[y/x])}    \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   430
   {((\lambda x.a)(b)) \equiv a[b/x]}           \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   431
   \infer[(ext)]{f\equiv g}{f(x) \equiv g(x)}   \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   432
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   433
The \textbf{abstraction} and \textbf{combination} rules let conversions be
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   434
applied to subterms:\footnote{Abstraction holds if $x$ is not free in the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   435
assumptions.}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   436
\[  \infer[(abs)]{(\lambda x.a) \equiv (\lambda x.b)}{a\equiv b}   \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   437
    \infer[(comb)]{f(a)\equiv g(b)}{f\equiv g & a\equiv b}   \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   438
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   439
\index{meta-quantifiers}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   440
The \textbf{universal quantification} rules are $(\Forall I)$ and $(\Forall
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   441
E)$:\footnote{$(\Forall I)$ holds if $x$ is not free in the assumptions.}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   442
\[ \infer[(\Forall I)]{\Forall x.\phi}{\phi}        \qquad
286
e7efbf03562b first draft of Springer book
lcp
parents: 151
diff changeset
   443
   \infer[(\Forall E)]{\phi[b/x]}{\Forall x.\phi}   \]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   444
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   445
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   446
\subsection{Assumption rule}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   447
\index{meta-assumptions}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   448
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   449
assume: cterm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   450
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   451
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   452
\item[\ttindexbold{assume} $ct$] 
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   453
makes the theorem \(\phi \;[\phi]\), where $\phi$ is the value of~$ct$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   454
The rule checks that $ct$ has type $prop$ and contains no unknowns, which
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   455
are not allowed in assumptions.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   456
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   457
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   458
\subsection{Implication rules}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   459
\index{meta-implication}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   460
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   461
implies_intr      : cterm -> thm -> thm
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   462
implies_intr_list : cterm list -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   463
implies_intr_hyps : thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   464
implies_elim      : thm -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   465
implies_elim_list : thm -> thm list -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   466
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   467
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   468
\item[\ttindexbold{implies_intr} $ct$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   469
is $({\Imp}I)$, where $ct$ is the assumption to discharge, say~$\phi$.  It
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   470
maps the premise~$\psi$ to the conclusion $\phi\Imp\psi$, removing all
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   471
occurrences of~$\phi$ from the assumptions.  The rule checks that $ct$ has
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   472
type $prop$. 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   473
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   474
\item[\ttindexbold{implies_intr_list} $cts$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   475
applies $({\Imp}I)$ repeatedly, on every element of the list~$cts$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   476
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   477
\item[\ttindexbold{implies_intr_hyps} $thm$] 
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   478
applies $({\Imp}I)$ to discharge all the hypotheses (assumptions) of~$thm$.
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   479
It maps the premise $\phi \; [\phi@1,\ldots,\phi@n]$ to the conclusion
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   480
$\List{\phi@1,\ldots,\phi@n}\Imp\phi$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   481
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   482
\item[\ttindexbold{implies_elim} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   483
applies $({\Imp}E)$ to $thm@1$ and~$thm@2$.  It maps the premises $\phi\Imp
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   484
\psi$ and $\phi$ to the conclusion~$\psi$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   485
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   486
\item[\ttindexbold{implies_elim_list} $thm$ $thms$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   487
applies $({\Imp}E)$ repeatedly to $thm$, using each element of~$thms$ in
151
c5e636ca6576 corrected some obvious errors;
wenzelm
parents: 104
diff changeset
   488
turn.  It maps the premises $\List{\phi@1,\ldots,\phi@n}\Imp\psi$ and
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   489
$\phi@1$,\ldots,$\phi@n$ to the conclusion~$\psi$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   490
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   491
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   492
\subsection{Logical equivalence rules}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   493
\index{meta-equality}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   494
\begin{ttbox} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   495
equal_intr : thm -> thm -> thm 
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   496
equal_elim : thm -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   497
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   498
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   499
\item[\ttindexbold{equal_intr} $thm@1$ $thm@2$] 
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   500
applies $({\equiv}I)$ to $thm@1$ and~$thm@2$.  It maps the premises~$\psi$
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   501
and~$\phi$ to the conclusion~$\phi\equiv\psi$; the assumptions are those of
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   502
the first premise with~$\phi$ removed, plus those of
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   503
the second premise with~$\psi$ removed.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   504
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   505
\item[\ttindexbold{equal_elim} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   506
applies $({\equiv}E)$ to $thm@1$ and~$thm@2$.  It maps the premises
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   507
$\phi\equiv\psi$ and $\phi$ to the conclusion~$\psi$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   508
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   509
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   510
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   511
\subsection{Equality rules}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   512
\index{meta-equality}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   513
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   514
reflexive  : cterm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   515
symmetric  : thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   516
transitive : thm -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   517
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   518
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   519
\item[\ttindexbold{reflexive} $ct$] 
151
c5e636ca6576 corrected some obvious errors;
wenzelm
parents: 104
diff changeset
   520
makes the theorem \(ct\equiv ct\). 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   521
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   522
\item[\ttindexbold{symmetric} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   523
maps the premise $a\equiv b$ to the conclusion $b\equiv a$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   524
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   525
\item[\ttindexbold{transitive} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   526
maps the premises $a\equiv b$ and $b\equiv c$ to the conclusion~${a\equiv c}$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   527
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   528
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   529
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   530
\subsection{The $\lambda$-conversion rules}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   531
\index{lambda calc@$\lambda$-calculus}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   532
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   533
beta_conversion : cterm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   534
extensional     : thm -> thm
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   535
abstract_rule   : string -> cterm -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   536
combination     : thm -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   537
\end{ttbox} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   538
There is no rule for $\alpha$-conversion because Isabelle regards
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   539
$\alpha$-convertible theorems as equal.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   540
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   541
\item[\ttindexbold{beta_conversion} $ct$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   542
makes the theorem $((\lambda x.a)(b)) \equiv a[b/x]$, where $ct$ is the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   543
term $(\lambda x.a)(b)$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   544
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   545
\item[\ttindexbold{extensional} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   546
maps the premise $f(x) \equiv g(x)$ to the conclusion $f\equiv g$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   547
Parameter~$x$ is taken from the premise.  It may be an unknown or a free
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   548
variable (provided it does not occur in the assumptions); it must not occur
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   549
in $f$ or~$g$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   550
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   551
\item[\ttindexbold{abstract_rule} $v$ $x$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   552
maps the premise $a\equiv b$ to the conclusion $(\lambda x.a) \equiv
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   553
(\lambda x.b)$, abstracting over all occurrences (if any!) of~$x$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   554
Parameter~$x$ is supplied as a cterm.  It may be an unknown or a free
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   555
variable (provided it does not occur in the assumptions).  In the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   556
conclusion, the bound variable is named~$v$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   557
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   558
\item[\ttindexbold{combination} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   559
maps the premises $f\equiv g$ and $a\equiv b$ to the conclusion~$f(a)\equiv
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   560
g(b)$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   561
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   562
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   563
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   564
\subsection{Forall introduction rules}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   565
\index{meta-quantifiers}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   566
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   567
forall_intr       : cterm      -> thm -> thm
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   568
forall_intr_list  : cterm list -> thm -> thm
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   569
forall_intr_frees :               thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   570
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   571
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   572
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   573
\item[\ttindexbold{forall_intr} $x$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   574
applies $({\Forall}I)$, abstracting over all occurrences (if any!) of~$x$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   575
The rule maps the premise $\phi$ to the conclusion $\Forall x.\phi$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   576
Parameter~$x$ is supplied as a cterm.  It may be an unknown or a free
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   577
variable (provided it does not occur in the assumptions).
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   578
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   579
\item[\ttindexbold{forall_intr_list} $xs$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   580
applies $({\Forall}I)$ repeatedly, on every element of the list~$xs$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   581
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   582
\item[\ttindexbold{forall_intr_frees} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   583
applies $({\Forall}I)$ repeatedly, generalizing over all the free variables
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   584
of the premise.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   585
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   586
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   587
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   588
\subsection{Forall elimination rules}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   589
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   590
forall_elim       : cterm      -> thm -> thm
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   591
forall_elim_list  : cterm list -> thm -> thm
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   592
forall_elim_var   :        int -> thm -> thm
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   593
forall_elim_vars  :        int -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   594
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   595
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   596
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   597
\item[\ttindexbold{forall_elim} $ct$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   598
applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   599
$\phi[ct/x]$.  The rule checks that $ct$ and $x$ have the same type.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   600
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   601
\item[\ttindexbold{forall_elim_list} $cts$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   602
applies $({\Forall}E)$ repeatedly, on every element of the list~$cts$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   603
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   604
\item[\ttindexbold{forall_elim_var} $k$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   605
applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   606
$\phi[\Var{x@k}/x]$.  Thus, it replaces the outermost $\Forall$-bound
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   607
variable by an unknown having subscript~$k$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   608
9258
2121ff73a37d fixed typos reported by Jeremy Dawson
paulson
parents: 8969
diff changeset
   609
\item[\ttindexbold{forall_elim_vars} $k$ $thm$] 
2121ff73a37d fixed typos reported by Jeremy Dawson
paulson
parents: 8969
diff changeset
   610
applies {\tt forall_elim_var}~$k$ repeatedly until the theorem no longer has
2121ff73a37d fixed typos reported by Jeremy Dawson
paulson
parents: 8969
diff changeset
   611
the form $\Forall x.\phi$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   612
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   613
8135
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   614
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   615
\subsection{Instantiation of unknowns}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   616
\index{instantiation}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   617
\begin{alltt}\footnotesize
3135
233aba197bf2 tuned spaces;
wenzelm
parents: 3108
diff changeset
   618
instantiate: (indexname * ctyp){\thinspace}list * (cterm * cterm){\thinspace}list -> thm -> thm
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   619
\end{alltt}
8135
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   620
There are two versions of this rule.  The primitive one is
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   621
\ttindexbold{Thm.instantiate}, which merely performs the instantiation and can
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   622
produce a conclusion not in normal form.  A derived version is  
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   623
\ttindexbold{Drule.instantiate}, which normalizes its conclusion.
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   624
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   625
\begin{ttdescription}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   626
\item[\ttindexbold{instantiate} ($tyinsts$,$insts$) $thm$] 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   627
simultaneously substitutes types for type unknowns (the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   628
$tyinsts$) and terms for term unknowns (the $insts$).  Instantiations are
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   629
given as $(v,t)$ pairs, where $v$ is an unknown and $t$ is a term (of the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   630
same type as $v$) or a type (of the same sort as~$v$).  All the unknowns
8135
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   631
must be distinct.  
4376
407f786d3059 instantiate';
wenzelm
parents: 4317
diff changeset
   632
8135
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   633
In some cases, \ttindex{instantiate'} (see \S\ref{sec:instantiate})
4376
407f786d3059 instantiate';
wenzelm
parents: 4317
diff changeset
   634
provides a more convenient interface to this rule.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   635
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   636
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   637
8135
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   638
ad1c4a678196 Documented Thm.instantiate (not normalizing) and Drule.instantiate
paulson
parents: 7871
diff changeset
   639
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   640
\subsection{Freezing/thawing type unknowns}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   641
\index{type unknowns!freezing/thawing of}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   642
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   643
freezeT: thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   644
varifyT: thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   645
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   646
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   647
\item[\ttindexbold{freezeT} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   648
converts all the type unknowns in $thm$ to free type variables.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   649
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   650
\item[\ttindexbold{varifyT} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   651
converts all the free type variables in $thm$ to type unknowns.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   652
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   653
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   654
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   655
\section{Derived rules for goal-directed proof}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   656
Most of these rules have the sole purpose of implementing particular
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   657
tactics.  There are few occasions for applying them directly to a theorem.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   658
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   659
\subsection{Proof by assumption}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   660
\index{meta-assumptions}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   661
\begin{ttbox} 
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
   662
assumption    : int -> thm -> thm Seq.seq
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   663
eq_assumption : int -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   664
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   665
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   666
\item[\ttindexbold{assumption} {\it i} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   667
attempts to solve premise~$i$ of~$thm$ by assumption.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   668
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   669
\item[\ttindexbold{eq_assumption}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   670
is like {\tt assumption} but does not use unification.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   671
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   672
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   673
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   674
\subsection{Resolution}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   675
\index{resolution}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   676
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   677
biresolution : bool -> (bool*thm)list -> int -> thm
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
   678
               -> thm Seq.seq
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   679
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   680
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   681
\item[\ttindexbold{biresolution} $match$ $rules$ $i$ $state$] 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   682
performs bi-resolution on subgoal~$i$ of $state$, using the list of $\it
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   683
(flag,rule)$ pairs.  For each pair, it applies resolution if the flag
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   684
is~{\tt false} and elim-resolution if the flag is~{\tt true}.  If $match$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   685
is~{\tt true}, the $state$ is not instantiated.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   686
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   687
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   688
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   689
\subsection{Composition: resolution without lifting}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   690
\index{resolution!without lifting}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   691
\begin{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   692
compose   : thm * int * thm -> thm list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   693
COMP      : thm * thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   694
bicompose : bool -> bool * thm * int -> int -> thm
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
   695
            -> thm Seq.seq
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   696
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   697
In forward proof, a typical use of composition is to regard an assertion of
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   698
the form $\phi\Imp\psi$ as atomic.  Schematic variables are not renamed, so
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   699
beware of clashes!
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   700
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   701
\item[\ttindexbold{compose} ($thm@1$, $i$, $thm@2$)] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   702
uses $thm@1$, regarded as an atomic formula, to solve premise~$i$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   703
of~$thm@2$.  Let $thm@1$ and $thm@2$ be $\psi$ and $\List{\phi@1; \ldots;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   704
\phi@n} \Imp \phi$.  For each $s$ that unifies~$\psi$ and $\phi@i$, the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   705
result list contains the theorem
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   706
\[ (\List{\phi@1; \ldots; \phi@{i-1}; \phi@{i+1}; \ldots; \phi@n} \Imp \phi)s.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   707
\]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   708
1119
49ed9a415637 Indexing of COMP
lcp
parents: 876
diff changeset
   709
\item[$thm@1$ \ttindexbold{COMP} $thm@2$] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   710
calls \hbox{\tt compose ($thm@1$, 1, $thm@2$)} and returns the result, if
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   711
unique; otherwise, it raises exception~\xdx{THM}\@.  It is
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   712
analogous to {\tt RS}\@.  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   713
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   714
For example, suppose that $thm@1$ is $a=b\Imp b=a$, a symmetry rule, and
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   715
that $thm@2$ is $\List{P\Imp Q; \neg Q} \Imp\neg P$, which is the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   716
principle of contrapositives.  Then the result would be the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   717
derived rule $\neg(b=a)\Imp\neg(a=b)$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   718
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   719
\item[\ttindexbold{bicompose} $match$ ($flag$, $rule$, $m$) $i$ $state$]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   720
refines subgoal~$i$ of $state$ using $rule$, without lifting.  The $rule$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   721
is taken to have the form $\List{\psi@1; \ldots; \psi@m} \Imp \psi$, where
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   722
$\psi$ need not be atomic; thus $m$ determines the number of new
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   723
subgoals.  If $flag$ is {\tt true} then it performs elim-resolution --- it
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   724
solves the first premise of~$rule$ by assumption and deletes that
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   725
assumption.  If $match$ is~{\tt true}, the $state$ is not instantiated.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   726
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   727
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   728
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   729
\subsection{Other meta-rules}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   730
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   731
trivial            : cterm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   732
lift_rule          : (thm * int) -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   733
rename_params_rule : string list * int -> thm -> thm
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
   734
flexflex_rule      : thm -> thm Seq.seq
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   735
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   736
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   737
\item[\ttindexbold{trivial} $ct$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   738
makes the theorem \(\phi\Imp\phi\), where $\phi$ is the value of~$ct$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   739
This is the initial state for a goal-directed proof of~$\phi$.  The rule
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   740
checks that $ct$ has type~$prop$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   741
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   742
\item[\ttindexbold{lift_rule} ($state$, $i$) $rule$] \index{lifting}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   743
prepares $rule$ for resolution by lifting it over the parameters and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   744
assumptions of subgoal~$i$ of~$state$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   745
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   746
\item[\ttindexbold{rename_params_rule} ({\it names}, {\it i}) $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   747
uses the $names$ to rename the parameters of premise~$i$ of $thm$.  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   748
names must be distinct.  If there are fewer names than parameters, then the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   749
rule renames the innermost parameters and may modify the remaining ones to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   750
ensure that all the parameters are distinct.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   751
\index{parameters!renaming}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   752
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   753
\item[\ttindexbold{flexflex_rule} $thm$]  \index{flex-flex constraints}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   754
removes all flex-flex pairs from $thm$ using the trivial unifier.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   755
\end{ttdescription}
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   756
\index{meta-rules|)}
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   757
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   758
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   759
\section{Proof terms}\label{sec:proofObjects}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   760
\index{proof terms|(} Isabelle can record the full meta-level proof of each
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   761
theorem.  The proof term contains all logical inferences in detail.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   762
%while
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   763
%omitting bookkeeping steps that have no logical meaning to an outside
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   764
%observer.  Rewriting steps are recorded in similar detail as the output of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   765
%simplifier tracing. 
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   766
Resolution and rewriting steps are broken down to primitive rules of the
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   767
meta-logic. The proof term can be inspected by a separate proof-checker,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   768
for example.
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   769
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   770
According to the well-known {\em Curry-Howard isomorphism}, a proof can
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   771
be viewed as a $\lambda$-term. Following this idea, proofs
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   772
in Isabelle are internally represented by a datatype similar to the one for
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   773
terms described in \S\ref{sec:terms}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   774
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   775
infix 8 % %%;
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   776
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   777
datatype proof =
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   778
   PBound of int
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   779
 | Abst of string * typ option * proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   780
 | AbsP of string * term option * proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   781
 | op % of proof * term option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   782
 | op %% of proof * proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   783
 | Hyp of term
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   784
 | PThm of (string * (string * string list) list) *
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   785
           proof * term * typ list option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   786
 | PAxm of string * term * typ list option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   787
 | Oracle of string * term * typ list option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   788
 | MinProof of proof list;
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   789
\end{ttbox}
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   790
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   791
\begin{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   792
\item[\ttindexbold{Abst} ($a$, $\tau$, $prf$)] is the abstraction over
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   793
a {\it term variable} of type $\tau$ in the body $prf$. Logically, this
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   794
corresponds to $\bigwedge$ introduction. The name $a$ is used only for
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   795
parsing and printing.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   796
\item[\ttindexbold{AbsP} ($a$, $\varphi$, $prf$)] is the abstraction
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   797
over a {\it proof variable} standing for a proof of proposition $\varphi$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   798
in the body $prf$. This corresponds to $\Longrightarrow$ introduction.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   799
\item[$prf$ \% $t$] \index{\%@{\tt\%}|bold}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   800
is the application of proof $prf$ to term $t$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   801
which corresponds to $\bigwedge$ elimination.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   802
\item[$prf@1$ \%\% $prf@2$] \index{\%\%@{\tt\%\%}|bold}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   803
is the application of proof $prf@1$ to
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   804
proof $prf@2$ which corresponds to $\Longrightarrow$ elimination.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   805
\item[\ttindexbold{PBound} $i$] is a {\em proof variable} with de Bruijn
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   806
\cite{debruijn72} index $i$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   807
\item[\ttindexbold{Hyp} $\varphi$] corresponds to the use of a meta level
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   808
hypothesis $\varphi$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   809
\item[\ttindexbold{PThm} (($name$, $tags$), $prf$, $\varphi$, $\overline{\tau}$)]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   810
stands for a pre-proved theorem, where $name$ is the name of the theorem,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   811
$prf$ is its actual proof, $\varphi$ is the proven proposition,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   812
and $\overline{\tau}$ is
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   813
a type assignment for the type variables occurring in the proposition.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   814
\item[\ttindexbold{PAxm} ($name$, $\varphi$, $\overline{\tau}$)]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   815
corresponds to the use of an axiom with name $name$ and proposition
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   816
$\varphi$, where $\overline{\tau}$ is a type assignment for the type
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   817
variables occurring in the proposition.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   818
\item[\ttindexbold{Oracle} ($name$, $\varphi$, $\overline{\tau}$)]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   819
denotes the invocation of an oracle with name $name$ which produced
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   820
a proposition $\varphi$, where $\overline{\tau}$ is a type assignment
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   821
for the type variables occurring in the proposition.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   822
\item[\ttindexbold{MinProof} $prfs$]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   823
represents a {\em minimal proof} where $prfs$ is a list of theorems,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   824
axioms or oracles.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   825
\end{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   826
Note that there are no separate constructors
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   827
for abstraction and application on the level of {\em types}, since
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   828
instantiation of type variables is accomplished via the type assignments
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   829
attached to {\tt Thm}, {\tt Axm} and {\tt Oracle}.
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   830
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   831
Each theorem's derivation is stored as the {\tt der} field of its internal
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   832
record: 
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   833
\begin{ttbox} 
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   834
#2 (#der (rep_thm conjI));
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   835
{\out PThm (("HOL.conjI", []),}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   836
{\out   AbsP ("H", None, AbsP ("H", None, \dots)), \dots, None) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   837
{\out     None % None : Proofterm.proof}
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   838
\end{ttbox}
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   839
This proof term identifies a labelled theorem, {\tt conjI} of theory
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   840
\texttt{HOL}, whose underlying proof is
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   841
{\tt AbsP ("H", None, AbsP ("H", None, $\dots$))}. 
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   842
The theorem is applied to two (implicit) term arguments, which correspond
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   843
to the two variables occurring in its proposition.
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   844
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   845
Isabelle's inference kernel can produce proof objects with different
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   846
levels of detail. This is controlled via the global reference variable
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   847
\ttindexbold{proofs}:
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   848
\begin{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   849
\item[proofs := 0;] only record uses of oracles
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   850
\item[proofs := 1;] record uses of oracles as well as dependencies
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   851
  on other theorems and axioms
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   852
\item[proofs := 2;] record inferences in full detail
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   853
\end{ttdescription}
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   854
Reconstruction and checking of proofs as described in \S\ref{sec:reconstruct_proofs}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   855
will not work for proofs constructed with {\tt proofs} set to
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   856
{\tt 0} or {\tt 1}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   857
Theorems involving oracles will be printed with a
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   858
suffixed \verb|[!]| to point out the different quality of confidence achieved.
5371
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   859
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   860
\medskip
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   861
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   862
The dependencies of theorems can be viewed using the function
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   863
\ttindexbold{thm_deps}\index{theorems!dependencies}:
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   864
\begin{ttbox}
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   865
thm_deps [\(thm@1\), \(\ldots\), \(thm@n\)];
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   866
\end{ttbox}
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   867
generates the dependency graph of the theorems $thm@1$, $\ldots$, $thm@n$ and
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   868
displays it using Isabelle's graph browser. For this to work properly,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   869
the theorems in question have to be proved with {\tt proofs} set to a value
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   870
greater than {\tt 0}. You can use
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   871
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   872
ThmDeps.enable : unit -> unit
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   873
ThmDeps.disable : unit -> unit
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   874
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   875
to set \texttt{proofs} appropriately.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   876
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   877
\subsection{Reconstructing and checking proof terms}\label{sec:reconstruct_proofs}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   878
\index{proof terms!reconstructing}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   879
\index{proof terms!checking}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   880
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   881
When looking at the above datatype of proofs more closely, one notices that
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   882
some arguments of constructors are {\it optional}. The reason for this is that
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   883
keeping a full proof term for each theorem would result in enormous memory
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   884
requirements. Fortunately, typical proof terms usually contain quite a lot of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   885
redundant information that can be reconstructed from the context. Therefore,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   886
Isabelle's inference kernel creates only {\em partial} (or {\em implicit})
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   887
\index{proof terms!partial} proof terms, in which
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   888
all typing information in terms, all term and type labels of abstractions
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   889
{\tt AbsP} and {\tt Abst}, and (if possible) some argument terms of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   890
\verb!%! are omitted. The following functions are available for
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   891
reconstructing and checking proof terms:
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   892
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   893
Reconstruct.reconstruct_proof :
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   894
  Sign.sg -> term -> Proofterm.proof -> Proofterm.proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   895
Reconstruct.expand_proof :
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   896
  Sign.sg -> string list -> Proofterm.proof -> Proofterm.proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   897
ProofChecker.thm_of_proof : theory -> Proofterm.proof -> thm
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   898
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   899
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   900
\begin{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   901
\item[Reconstruct.reconstruct_proof $sg$ $t$ $prf$]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   902
turns the partial proof $prf$ into a full proof of the
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   903
proposition denoted by $t$, with respect to signature $sg$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   904
Reconstruction will fail with an error message if $prf$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   905
is not a proof of $t$, is ill-formed, or does not contain
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   906
sufficient information for reconstruction by
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   907
{\em higher order pattern unification}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   908
\cite{nipkow-patterns, Berghofer-Nipkow:2000:TPHOL}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   909
The latter may only happen for proofs
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   910
built up ``by hand'' but not for those produced automatically
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   911
by Isabelle's inference kernel.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   912
\item[Reconstruct.expand_proof $sg$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   913
  \ttlbrack$name@1$, $\ldots$, $name@n${\ttrbrack} $prf$]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   914
expands and reconstructs the proofs of all theorems with names
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   915
$name@1$, $\ldots$, $name@n$ in the (full) proof $prf$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   916
\item[ProofChecker.thm_of_proof $thy$ $prf$] turns the (full) proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   917
$prf$ into a theorem with respect to theory $thy$ by replaying
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   918
it using only primitive rules from Isabelle's inference kernel.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   919
\end{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   920
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   921
\subsection{Parsing and printing proof terms}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   922
\index{proof terms!parsing}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   923
\index{proof terms!printing}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   924
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   925
Isabelle offers several functions for parsing and printing
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   926
proof terms. The concrete syntax for proof terms is described
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   927
in Fig.\ts\ref{fig:proof_gram}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   928
Implicit term arguments in partial proofs are indicated
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   929
by ``{\tt _}''.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   930
Type arguments for theorems and axioms may be specified using
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   931
\verb!%! or ``$\cdot$'' with an argument of the form {\tt TYPE($type$)}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   932
(see \S\ref{sec:basic_syntax}).
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   933
They must appear before any other term argument of a theorem
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   934
or axiom. In contrast to term arguments, type arguments may
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   935
be completely omitted.
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   936
\begin{ttbox}
11625
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   937
ProofSyntax.read_proof : theory -> bool -> string -> Proofterm.proof
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   938
ProofSyntax.pretty_proof : Sign.sg -> Proofterm.proof -> Pretty.T
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   939
ProofSyntax.pretty_proof_of : bool -> thm -> Pretty.T
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   940
ProofSyntax.print_proof_of : bool -> thm -> unit
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   941
\end{ttbox}
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   942
\begin{figure}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   943
\begin{center}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   944
\begin{tabular}{rcl}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   945
$proof$  & $=$ & {\tt Lam} $params${\tt .} $proof$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   946
                 $\Lambda params${\tt .} $proof$ \\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   947
         & $|$ & $proof$ \verb!%! $any$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   948
                 $proof$ $\cdot$ $any$ \\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   949
         & $|$ & $proof$ \verb!%%! $proof$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   950
                 $proof$ {\boldmath$\cdot$} $proof$ \\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   951
         & $|$ & $id$ ~~$|$~~ $longid$ \\\\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   952
$param$  & $=$ & $idt$ ~~$|$~~ $idt$ {\tt :} $prop$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   953
                 {\tt (} $param$ {\tt )} \\\\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   954
$params$ & $=$ & $param$ ~~$|$~~ $param$ $params$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   955
\end{tabular}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   956
\end{center}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   957
\caption{Proof term syntax}\label{fig:proof_gram}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   958
\end{figure}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   959
The function {\tt read_proof} reads in a proof term with
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   960
respect to a given theory. The boolean flag indicates whether
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   961
the proof term to be parsed contains explicit typing information
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   962
to be taken into account.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   963
Usually, typing information is left implicit and
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   964
is inferred during proof reconstruction. The pretty printing
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   965
functions operating on theorems take a boolean flag as an
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   966
argument which indicates whether the proof term should
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   967
be reconstructed before printing.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   968
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   969
The following example (based on Isabelle/HOL) illustrates how
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   970
to parse and check proof terms. We start by parsing a partial
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   971
proof term
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   972
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   973
val prf = ProofSyntax.read_proof Main.thy false
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   974
  "impI % _ % _ %% (Lam H : _. conjE % _ % _ % _ %% H %%
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   975
     (Lam (H1 : _) H2 : _. conjI % _ % _ %% H2 %% H1))";
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   976
{\out val prf = PThm (("HOL.impI", []), \dots, \dots, None) % None % None %%}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   977
{\out   AbsP ("H", None, PThm (("HOL.conjE", []), \dots, \dots, None) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   978
{\out     None % None % None %% PBound 0 %%}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   979
{\out     AbsP ("H1", None, AbsP ("H2", None, \dots))) : Proofterm.proof}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   980
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   981
The statement to be established by this proof is
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   982
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   983
val t = term_of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   984
  (read_cterm (sign_of Main.thy) ("A & B --> B & A", propT));
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   985
{\out val t = Const ("Trueprop", "bool => prop") $}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   986
{\out   (Const ("op -->", "[bool, bool] => bool") $}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   987
{\out     \dots $ \dots : Term.term}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   988
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   989
Using {\tt t} we can reconstruct the full proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   990
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   991
val prf' = Reconstruct.reconstruct_proof (sign_of Main.thy) t prf;
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   992
{\out val prf' = PThm (("HOL.impI", []), \dots, \dots, Some []) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   993
{\out   Some (Const ("op &", \dots) $ Free ("A", \dots) $ Free ("B", \dots)) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   994
{\out   Some (Const ("op &", \dots) $ Free ("B", \dots) $ Free ("A", \dots)) %%}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   995
{\out   AbsP ("H", Some (Const ("Trueprop", \dots) $ \dots), \dots)}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   996
{\out     : Proofterm.proof}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   997
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   998
This proof can finally be turned into a theorem
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   999
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
  1000
val thm = ProofChecker.thm_of_proof Main.thy prf';
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
  1001
{\out val thm = "A & B --> B & A" : Thm.thm}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
  1002
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
  1003
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
  1004
\index{proof terms|)}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
  1005
\index{theorems|)}
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
  1006
5371
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
  1007
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
  1008
%%% Local Variables: 
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
  1009
%%% mode: latex
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
  1010
%%% TeX-master: "ref"
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
  1011
%%% End: