doc-src/Ref/document/thm.tex
author wenzelm
Mon, 27 Aug 2012 17:24:01 +0200
changeset 48939 83bd9eb1c70c
parent 46486 doc-src/Ref/thm.tex@4a607979290d
permissions -rw-r--r--
more standard document preparation within session context;
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
42932
34ed34804d90 removed obsolete material (superseded by implementation manual);
wenzelm
parents: 30184
diff changeset
     6
object-logics, have type \mltydx{thm}.  This chapter describes
34ed34804d90 removed obsolete material (superseded by implementation manual);
wenzelm
parents: 30184
diff changeset
     7
operations that join theorems in forward proof.  Most theorem
34ed34804d90 removed obsolete material (superseded by implementation manual);
wenzelm
parents: 30184
diff changeset
     8
operations are intended for advanced applications, such as programming
34ed34804d90 removed obsolete material (superseded by implementation manual);
wenzelm
parents: 30184
diff changeset
     9
new proof procedures.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    10
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    11
4383
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
    12
\subsection{Instantiating unknowns in a theorem} \label{sec:instantiate}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    13
\index{instantiation}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    14
\begin{alltt}\footnotesize
4383
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
    15
read_instantiate    :                (string*string) list -> thm -> thm
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
    16
read_instantiate_sg :     Sign.sg -> (string*string) list -> thm -> thm
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
    17
cterm_instantiate   :                  (cterm*cterm) list -> thm -> thm
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
    18
instantiate'      : ctyp option list -> cterm option list -> thm -> thm
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    19
\end{alltt}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    20
These meta-rules instantiate type and term unknowns in a theorem.  They are
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    21
occasionally useful.  They can prevent difficulties with higher-order
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    22
unification, and define specialized versions of rules.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    23
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    24
\item[\ttindexbold{read_instantiate} {\it insts} {\it thm}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    25
processes the instantiations {\it insts} and instantiates the rule~{\it
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    26
thm}.  The processing of instantiations is described
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    27
in \S\ref{res_inst_tac}, under {\tt res_inst_tac}.  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    28
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    29
Use {\tt res_inst_tac}, not {\tt read_instantiate}, to instantiate a rule
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    30
and refine a particular subgoal.  The tactic allows instantiation by the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    31
subgoal's parameters, and reads the instantiations using the signature
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    32
associated with the proof state.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    33
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    34
Use {\tt read_instantiate_sg} below if {\it insts\/} appears to be treated
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    35
incorrectly.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    36
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    37
\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
    38
  is like \texttt{read_instantiate {\it insts}~{\it thm}}, but it reads
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    39
  the instantiations under signature~{\it sg}.  This is necessary to
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    40
  instantiate a rule from a general theory, such as first-order logic,
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    41
  using the notation of some specialized theory.  Use the function {\tt
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    42
    sign_of} to get a theory's signature.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    43
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    44
\item[\ttindexbold{cterm_instantiate} {\it ctpairs} {\it thm}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    45
is similar to {\tt read_instantiate}, but the instantiations are provided
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    46
as pairs of certified terms, not as strings to be read.
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    47
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    48
\item[\ttindexbold{instantiate'} {\it ctyps} {\it cterms} {\it thm}]
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    49
  instantiates {\it thm} according to the positional arguments {\it
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    50
    ctyps} and {\it cterms}.  Counting from left to right, schematic
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    51
  variables $?x$ are either replaced by $t$ for any argument
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    52
  \texttt{Some\(\;t\)}, or left unchanged in case of \texttt{None} or
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    53
  if the end of the argument list is encountered.  Types are
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    54
  instantiated before terms.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    55
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
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 332
diff changeset
    59
\subsection{Miscellaneous forward rules}\label{MiscellaneousForwardRules}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    60
\index{theorems!standardizing}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    61
\begin{ttbox} 
8969
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    62
standard         :               thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    63
zero_var_indexes :               thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    64
make_elim        :               thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    65
rule_by_tactic   :     tactic -> thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    66
rotate_prems     :        int -> thm -> thm
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    67
permute_prems    : int -> int -> thm -> thm
11163
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
    68
rearrange_prems  :   int list -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    69
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
    70
\begin{ttdescription}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    71
\item[\ttindexbold{standard} $thm$] puts $thm$ into the standard form
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    72
  of object-rules.  It discharges all meta-assumptions, replaces free
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    73
  variables by schematic variables, renames schematic variables to
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    74
  have subscript zero, also strips outer (meta) quantifiers and
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
    75
  removes dangling sort hypotheses.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    76
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    77
\item[\ttindexbold{zero_var_indexes} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    78
makes all schematic variables have subscript zero, renaming them to avoid
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    79
clashes. 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    80
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    81
\item[\ttindexbold{make_elim} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    82
\index{rules!converting destruction to elimination}
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    83
converts $thm$, which should be  a destruction rule of the form
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
    84
$\List{P@1;\ldots;P@m}\Imp 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    85
Q$, to the elimination rule $\List{P@1; \ldots; P@m; Q\Imp R}\Imp R$.  This
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    86
is the basis for destruct-resolution: {\tt dresolve_tac}, etc.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    87
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    88
\item[\ttindexbold{rule_by_tactic} {\it tac} {\it thm}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    89
  applies {\it tac\/} to the {\it thm}, freezing its variables first, then
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    90
  yields the proof state returned by the tactic.  In typical usage, the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    91
  {\it thm\/} represents an instance of a rule with several premises, some
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    92
  with contradictory assumptions (because of the instantiation).  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    93
  tactic proves those subgoals and does whatever else it can, and returns
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    94
  whatever is left.
4607
6759ba6d3cc1 Added reference to rotate_prems
paulson
parents: 4597
diff changeset
    95
  
6759ba6d3cc1 Added reference to rotate_prems
paulson
parents: 4597
diff changeset
    96
\item[\ttindexbold{rotate_prems} $k$ $thm$] rotates the premises of $thm$ to
8969
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    97
  the left by~$k$ positions (to the right if $k<0$).  It simply calls
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    98
  \texttt{permute_prems}, below, with $j=0$.  Used with
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
    99
  \texttt{eresolve_tac}\index{*eresolve_tac!on other than first premise}, it
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   100
  gives the effect of applying the tactic to some other premise of $thm$ than
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   101
  the first.
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   102
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   103
\item[\ttindexbold{permute_prems} $j$ $k$ $thm$] rotates the premises of $thm$
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   104
  leaving the first $j$ premises unchanged.  It
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   105
  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
   106
  positive then it rotates the remaining $n-j$ premises to the left; if $k$ is
23c6e0ca0086 documented permute_prems
paulson
parents: 8136
diff changeset
   107
  negative then it rotates the premises to the right.
11163
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   108
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   109
\item[\ttindexbold{rearrange_prems} $ps$ $thm$] permutes the premises of $thm$
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   110
   where the value at the $i$-th position (counting from $0$) in the list $ps$
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   111
   gives the position within the original thm to be transferred to position $i$.
14732e3eaa6e added rearrange_prems
oheimb
parents: 9499
diff changeset
   112
   Any remaining trailing positions are left unchanged.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   113
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   114
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   116
\subsection{Taking a theorem apart}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   117
\index{theorems!taking apart}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   118
\index{flex-flex constraints}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   119
\begin{ttbox} 
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   120
cprop_of      : thm -> cterm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   121
concl_of      : thm -> term
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   122
prems_of      : thm -> term list
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   123
cprems_of     : thm -> cterm list
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   124
nprems_of     : thm -> int
4383
25704541008b Tidying to fix overfull lines, etc
paulson
parents: 4376
diff changeset
   125
tpairs_of     : thm -> (term*term) list
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 332
diff changeset
   126
theory_of_thm : thm -> theory
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   127
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   128
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   129
\item[\ttindexbold{cprop_of} $thm$] returns the statement of $thm$ as
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   130
  a certified term.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   131
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   132
\item[\ttindexbold{concl_of} $thm$] returns the conclusion of $thm$ as
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   133
  a term.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   134
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   135
\item[\ttindexbold{prems_of} $thm$] returns the premises of $thm$ as a
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   136
  list of terms.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   137
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   138
\item[\ttindexbold{cprems_of} $thm$] returns the premises of $thm$ as
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   139
  a list of certified terms.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   140
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   141
\item[\ttindexbold{nprems_of} $thm$] 
286
e7efbf03562b first draft of Springer book
lcp
parents: 151
diff changeset
   142
returns the number of premises in $thm$, and is equivalent to {\tt
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   143
  length~(prems_of~$thm$)}.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   144
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   145
\item[\ttindexbold{tpairs_of} $thm$] returns the flex-flex constraints
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   146
  of $thm$.
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   147
  
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   148
\item[\ttindexbold{theory_of_thm} $thm$] returns the theory associated
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   149
  with $thm$.  Note that this does a lookup in Isabelle's global
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   150
  database of loaded theories.
866
2d3d020eef11 added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
clasohm
parents: 332
diff changeset
   151
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   152
\end{ttdescription}
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   153
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   154
5777
5c0aa825c18e shyps note for prim. rules;
wenzelm
parents: 5371
diff changeset
   155
\subsection{*Sort hypotheses} \label{sec:sort-hyps}
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   156
\index{sort hypotheses}
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   157
\begin{ttbox} 
7644
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   158
strip_shyps         : thm -> thm
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   159
strip_shyps_warning : thm -> thm
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   160
\end{ttbox}
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   161
2044
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   162
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
   163
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
   164
syntactic classification of types --- for example, FOL distinguishes between
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   165
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
   166
this may result in some sorts becoming {\em empty\/}: where one cannot exhibit
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   167
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
   168
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   169
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
   170
sort, then that theorem has no instances.  It is basically an instance
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   171
of {\em ex falso quodlibet}.  But what if it is used to prove another
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   172
theorem that no longer involves that sort?  The latter theorem holds
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   173
only if under an additional non-emptiness assumption.
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   174
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3135
diff changeset
   175
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
   176
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
   177
{\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
   178
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
   179
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
   180
critical ones, asserting non-emptiness of the corresponding sorts.
e8d52d05530a Improved discussion of shyps thanks to Markus Wenzel
paulson
parents: 2040
diff changeset
   181
 
7644
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   182
Isabelle automatically removes extraneous sorts from the {\tt shyps} field at
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   183
the end of a proof, provided that non-emptiness can be established by looking
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   184
at the theorem's signature: from the {\tt classes} and {\tt arities}
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   185
information.  This operation is performed by \texttt{strip_shyps} and
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   186
\texttt{strip_shyps_warning}.
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   187
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   188
\begin{ttdescription}
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   189
  
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   190
\item[\ttindexbold{strip_shyps} $thm$] removes any extraneous sort hypotheses
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   191
  that can be witnessed from the type signature.
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   192
  
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   193
\item[\ttindexbold{strip_shyps_warning}] is like \texttt{strip_shyps}, but
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   194
  issues a warning message of any pending sort hypotheses that do not have a
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   195
  (syntactic) witness.
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   196
054ecaf3ca22 strip_shyps(_warning);
wenzelm
parents: 6924
diff changeset
   197
\end{ttdescription}
2040
6db93e6f1b11 Documented sort hypotheses and improved discussion of derivations
paulson
parents: 1876
diff changeset
   198
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   199
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   200
\subsection{Tracing flags for unification}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   201
\index{tracing!of unification}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   202
\begin{ttbox} 
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   203
Unify.trace_simp   : bool ref \hfill\textbf{initially false}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   204
Unify.trace_types  : bool ref \hfill\textbf{initially false}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   205
Unify.trace_bound  : int ref \hfill\textbf{initially 10}
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   206
Unify.search_bound : int ref \hfill\textbf{initially 20}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   207
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   208
Tracing the search may be useful when higher-order unification behaves
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   209
unexpectedly.  Letting {\tt res_inst_tac} circumvent the problem is easier,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   210
though.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   211
\begin{ttdescription}
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   212
\item[set Unify.trace_simp;] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   213
causes tracing of the simplification phase.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   214
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   215
\item[set Unify.trace_types;] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   216
generates warnings of incompleteness, when unification is not considering
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   217
all possible instantiations of type unknowns.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   218
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   219
\item[Unify.trace_bound := $n$;] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   220
causes unification to print tracing information once it reaches depth~$n$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   221
Use $n=0$ for full tracing.  At the default value of~10, tracing
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   222
information is almost never printed.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   223
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   224
\item[Unify.search_bound := $n$;] prevents unification from
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   225
  searching past the depth~$n$.  Because of this bound, higher-order
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   226
  unification cannot return an infinite sequence, though it can return
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 8135
diff changeset
   227
  an exponentially long one.  The search rarely approaches the default value
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   228
  of~20.  If the search is cut off, unification prints a warning
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   229
  \texttt{Unification bound exceeded}.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   230
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   231
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   232
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
   233
\section{*Primitive meta-level inference rules}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   234
\index{meta-rules|(}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   235
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   236
\subsection{Logical equivalence rules}
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   237
\index{meta-equality}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   238
\begin{ttbox} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   239
equal_intr : thm -> thm -> thm 
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   240
equal_elim : thm -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   241
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   242
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   243
\item[\ttindexbold{equal_intr} $thm@1$ $thm@2$] 
332
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   244
applies $({\equiv}I)$ to $thm@1$ and~$thm@2$.  It maps the premises~$\psi$
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   245
and~$\phi$ to the conclusion~$\phi\equiv\psi$; the assumptions are those of
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   246
the first premise with~$\phi$ removed, plus those of
01b87a921967 final Springer copy
lcp
parents: 326
diff changeset
   247
the second premise with~$\psi$ removed.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   248
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   249
\item[\ttindexbold{equal_elim} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   250
applies $({\equiv}E)$ to $thm@1$ and~$thm@2$.  It maps the premises
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   251
$\phi\equiv\psi$ and $\phi$ to the conclusion~$\psi$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   252
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   253
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   254
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   255
\subsection{Equality rules}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   256
\index{meta-equality}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   257
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   258
reflexive  : cterm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   259
symmetric  : thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   260
transitive : thm -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   261
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   262
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   263
\item[\ttindexbold{reflexive} $ct$] 
151
c5e636ca6576 corrected some obvious errors;
wenzelm
parents: 104
diff changeset
   264
makes the theorem \(ct\equiv ct\). 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   265
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   266
\item[\ttindexbold{symmetric} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   267
maps the premise $a\equiv b$ to the conclusion $b\equiv a$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   268
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   269
\item[\ttindexbold{transitive} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   270
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
   271
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   272
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   273
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   274
\subsection{The $\lambda$-conversion rules}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   275
\index{lambda calc@$\lambda$-calculus}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   276
\begin{ttbox} 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   277
beta_conversion : cterm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   278
extensional     : thm -> thm
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 2044
diff changeset
   279
abstract_rule   : string -> cterm -> thm -> thm
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   280
combination     : thm -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   281
\end{ttbox} 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   282
There is no rule for $\alpha$-conversion because Isabelle regards
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   283
$\alpha$-convertible theorems as equal.
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   284
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   285
\item[\ttindexbold{beta_conversion} $ct$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   286
makes the theorem $((\lambda x.a)(b)) \equiv a[b/x]$, where $ct$ is the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   287
term $(\lambda x.a)(b)$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   288
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   289
\item[\ttindexbold{extensional} $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   290
maps the premise $f(x) \equiv g(x)$ to the conclusion $f\equiv g$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   291
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
   292
variable (provided it does not occur in the assumptions); it must not occur
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   293
in $f$ or~$g$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   294
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   295
\item[\ttindexbold{abstract_rule} $v$ $x$ $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   296
maps the premise $a\equiv b$ to the conclusion $(\lambda x.a) \equiv
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   297
(\lambda x.b)$, abstracting over all occurrences (if any!) of~$x$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   298
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
   299
variable (provided it does not occur in the assumptions).  In the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   300
conclusion, the bound variable is named~$v$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   301
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   302
\item[\ttindexbold{combination} $thm@1$ $thm@2$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   303
maps the premises $f\equiv g$ and $a\equiv b$ to the conclusion~$f(a)\equiv
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   304
g(b)$.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   305
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   306
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   307
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   308
\section{Derived rules for goal-directed proof}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   309
Most of these rules have the sole purpose of implementing particular
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   310
tactics.  There are few occasions for applying them directly to a theorem.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   311
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   312
\subsection{Resolution}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   313
\index{resolution}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   314
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   315
biresolution : bool -> (bool*thm)list -> int -> thm
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
   316
               -> thm Seq.seq
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   317
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   318
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   319
\item[\ttindexbold{biresolution} $match$ $rules$ $i$ $state$] 
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   320
performs bi-resolution on subgoal~$i$ of $state$, using the list of $\it
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   321
(flag,rule)$ pairs.  For each pair, it applies resolution if the flag
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   322
is~{\tt false} and elim-resolution if the flag is~{\tt true}.  If $match$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   323
is~{\tt true}, the $state$ is not instantiated.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   324
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   325
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   326
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   327
\subsection{Composition: resolution without lifting}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   328
\index{resolution!without lifting}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   329
\begin{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   330
compose   : thm * int * thm -> thm list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   331
COMP      : thm * thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   332
bicompose : bool -> bool * thm * int -> int -> thm
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3657
diff changeset
   333
            -> thm Seq.seq
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   334
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   335
In forward proof, a typical use of composition is to regard an assertion of
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   336
the form $\phi\Imp\psi$ as atomic.  Schematic variables are not renamed, so
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   337
beware of clashes!
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   338
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   339
\item[\ttindexbold{compose} ($thm@1$, $i$, $thm@2$)] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   340
uses $thm@1$, regarded as an atomic formula, to solve premise~$i$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   341
of~$thm@2$.  Let $thm@1$ and $thm@2$ be $\psi$ and $\List{\phi@1; \ldots;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   342
\phi@n} \Imp \phi$.  For each $s$ that unifies~$\psi$ and $\phi@i$, the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   343
result list contains the theorem
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   344
\[ (\List{\phi@1; \ldots; \phi@{i-1}; \phi@{i+1}; \ldots; \phi@n} \Imp \phi)s.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   345
\]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   346
1119
49ed9a415637 Indexing of COMP
lcp
parents: 876
diff changeset
   347
\item[$thm@1$ \ttindexbold{COMP} $thm@2$] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   348
calls \hbox{\tt compose ($thm@1$, 1, $thm@2$)} and returns the result, if
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   349
unique; otherwise, it raises exception~\xdx{THM}\@.  It is
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   350
analogous to {\tt RS}\@.  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   351
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   352
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
   353
that $thm@2$ is $\List{P\Imp Q; \neg Q} \Imp\neg P$, which is the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   354
principle of contrapositives.  Then the result would be the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   355
derived rule $\neg(b=a)\Imp\neg(a=b)$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   356
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   357
\item[\ttindexbold{bicompose} $match$ ($flag$, $rule$, $m$) $i$ $state$]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   358
refines subgoal~$i$ of $state$ using $rule$, without lifting.  The $rule$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   359
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
   360
$\psi$ need not be atomic; thus $m$ determines the number of new
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   361
subgoals.  If $flag$ is {\tt true} then it performs elim-resolution --- it
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   362
solves the first premise of~$rule$ by assumption and deletes that
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   363
assumption.  If $match$ is~{\tt true}, the $state$ is not instantiated.
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   364
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   365
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   366
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   367
\subsection{Other meta-rules}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   368
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   369
rename_params_rule : string list * int -> thm -> thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   370
\end{ttbox}
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   371
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   372
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   373
\item[\ttindexbold{rename_params_rule} ({\it names}, {\it i}) $thm$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   374
uses the $names$ to rename the parameters of premise~$i$ of $thm$.  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   375
names must be distinct.  If there are fewer names than parameters, then the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   376
rule renames the innermost parameters and may modify the remaining ones to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   377
ensure that all the parameters are distinct.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   378
\index{parameters!renaming}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   379
326
bef614030e24 penultimate Springer draft
lcp
parents: 286
diff changeset
   380
\end{ttdescription}
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   381
\index{meta-rules|)}
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   382
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   383
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   384
\section{Proof terms}\label{sec:proofObjects}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   385
\index{proof terms|(} Isabelle can record the full meta-level proof of each
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   386
theorem.  The proof term contains all logical inferences in detail.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   387
%while
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   388
%omitting bookkeeping steps that have no logical meaning to an outside
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   389
%observer.  Rewriting steps are recorded in similar detail as the output of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   390
%simplifier tracing. 
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   391
Resolution and rewriting steps are broken down to primitive rules of the
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   392
meta-logic. The proof term can be inspected by a separate proof-checker,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   393
for example.
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   394
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   395
According to the well-known {\em Curry-Howard isomorphism}, a proof can
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   396
be viewed as a $\lambda$-term. Following this idea, proofs
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   397
in Isabelle are internally represented by a datatype similar to the one for
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   398
terms described in \S\ref{sec:terms}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   399
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   400
infix 8 % %%;
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   401
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   402
datatype proof =
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   403
   PBound of int
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   404
 | Abst of string * typ option * proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   405
 | AbsP of string * term option * proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   406
 | op % of proof * term option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   407
 | op %% of proof * proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   408
 | Hyp of term
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   409
 | PThm of (string * (string * string list) list) *
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   410
           proof * term * typ list option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   411
 | PAxm of string * term * typ list option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   412
 | Oracle of string * term * typ list option
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   413
 | MinProof of proof list;
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   414
\end{ttbox}
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   415
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   416
\begin{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   417
\item[\ttindexbold{Abst} ($a$, $\tau$, $prf$)] is the abstraction over
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   418
a {\it term variable} of type $\tau$ in the body $prf$. Logically, this
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   419
corresponds to $\bigwedge$ introduction. The name $a$ is used only for
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   420
parsing and printing.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   421
\item[\ttindexbold{AbsP} ($a$, $\varphi$, $prf$)] is the abstraction
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   422
over a {\it proof variable} standing for a proof of proposition $\varphi$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   423
in the body $prf$. This corresponds to $\Longrightarrow$ introduction.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   424
\item[$prf$ \% $t$] \index{\%@{\tt\%}|bold}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   425
is the application of proof $prf$ to term $t$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   426
which corresponds to $\bigwedge$ elimination.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   427
\item[$prf@1$ \%\% $prf@2$] \index{\%\%@{\tt\%\%}|bold}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   428
is the application of proof $prf@1$ to
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   429
proof $prf@2$ which corresponds to $\Longrightarrow$ elimination.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   430
\item[\ttindexbold{PBound} $i$] is a {\em proof variable} with de Bruijn
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   431
\cite{debruijn72} index $i$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   432
\item[\ttindexbold{Hyp} $\varphi$] corresponds to the use of a meta level
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   433
hypothesis $\varphi$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   434
\item[\ttindexbold{PThm} (($name$, $tags$), $prf$, $\varphi$, $\overline{\tau}$)]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   435
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
   436
$prf$ is its actual proof, $\varphi$ is the proven proposition,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   437
and $\overline{\tau}$ is
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   438
a type assignment for the type variables occurring in the proposition.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   439
\item[\ttindexbold{PAxm} ($name$, $\varphi$, $\overline{\tau}$)]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   440
corresponds to the use of an axiom with name $name$ and proposition
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   441
$\varphi$, where $\overline{\tau}$ is a type assignment for the type
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   442
variables occurring in the proposition.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   443
\item[\ttindexbold{Oracle} ($name$, $\varphi$, $\overline{\tau}$)]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   444
denotes the invocation of an oracle with name $name$ which produced
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   445
a proposition $\varphi$, where $\overline{\tau}$ is a type assignment
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   446
for the type variables occurring in the proposition.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   447
\item[\ttindexbold{MinProof} $prfs$]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   448
represents a {\em minimal proof} where $prfs$ is a list of theorems,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   449
axioms or oracles.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   450
\end{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   451
Note that there are no separate constructors
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   452
for abstraction and application on the level of {\em types}, since
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   453
instantiation of type variables is accomplished via the type assignments
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   454
attached to {\tt Thm}, {\tt Axm} and {\tt Oracle}.
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   455
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   456
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
   457
record: 
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   458
\begin{ttbox} 
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   459
#2 (#der (rep_thm conjI));
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   460
{\out PThm (("HOL.conjI", []),}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   461
{\out   AbsP ("H", None, AbsP ("H", None, \dots)), \dots, None) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   462
{\out     None % None : Proofterm.proof}
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   463
\end{ttbox}
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   464
This proof term identifies a labelled theorem, {\tt conjI} of theory
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   465
\texttt{HOL}, whose underlying proof is
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   466
{\tt AbsP ("H", None, AbsP ("H", None, $\dots$))}. 
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   467
The theorem is applied to two (implicit) term arguments, which correspond
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   468
to the two variables occurring in its proposition.
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   469
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   470
Isabelle's inference kernel can produce proof objects with different
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   471
levels of detail. This is controlled via the global reference variable
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   472
\ttindexbold{proofs}:
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   473
\begin{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   474
\item[proofs := 0;] only record uses of oracles
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   475
\item[proofs := 1;] record uses of oracles as well as dependencies
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   476
  on other theorems and axioms
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   477
\item[proofs := 2;] record inferences in full detail
1590
1547174673e1 Describes proof objects and Deriv module
paulson
parents: 1119
diff changeset
   478
\end{ttdescription}
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   479
Reconstruction and checking of proofs as described in \S\ref{sec:reconstruct_proofs}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   480
will not work for proofs constructed with {\tt proofs} set to
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   481
{\tt 0} or {\tt 1}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   482
Theorems involving oracles will be printed with a
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   483
suffixed \verb|[!]| to point out the different quality of confidence achieved.
5371
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   484
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   485
\medskip
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   486
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   487
The dependencies of theorems can be viewed using the function
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   488
\ttindexbold{thm_deps}\index{theorems!dependencies}:
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   489
\begin{ttbox}
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   490
thm_deps [\(thm@1\), \(\ldots\), \(thm@n\)];
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   491
\end{ttbox}
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   492
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
   493
displays it using Isabelle's graph browser. For this to work properly,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   494
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
   495
greater than {\tt 0}. You can use
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   496
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   497
ThmDeps.enable : unit -> unit
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   498
ThmDeps.disable : unit -> unit
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   499
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   500
to set \texttt{proofs} appropriately.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   501
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   502
\subsection{Reconstructing and checking proof terms}\label{sec:reconstruct_proofs}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   503
\index{proof terms!reconstructing}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   504
\index{proof terms!checking}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   505
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   506
When looking at the above datatype of proofs more closely, one notices that
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   507
some arguments of constructors are {\it optional}. The reason for this is that
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   508
keeping a full proof term for each theorem would result in enormous memory
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   509
requirements. Fortunately, typical proof terms usually contain quite a lot of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   510
redundant information that can be reconstructed from the context. Therefore,
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   511
Isabelle's inference kernel creates only {\em partial} (or {\em implicit})
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   512
\index{proof terms!partial} proof terms, in which
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   513
all typing information in terms, all term and type labels of abstractions
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   514
{\tt AbsP} and {\tt Abst}, and (if possible) some argument terms of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   515
\verb!%! are omitted. The following functions are available for
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   516
reconstructing and checking proof terms:
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   517
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   518
Reconstruct.reconstruct_proof :
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   519
  Sign.sg -> term -> Proofterm.proof -> Proofterm.proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   520
Reconstruct.expand_proof :
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   521
  Sign.sg -> string list -> Proofterm.proof -> Proofterm.proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   522
ProofChecker.thm_of_proof : theory -> Proofterm.proof -> thm
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   523
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   524
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   525
\begin{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   526
\item[Reconstruct.reconstruct_proof $sg$ $t$ $prf$]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   527
turns the partial proof $prf$ into a full proof of the
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   528
proposition denoted by $t$, with respect to signature $sg$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   529
Reconstruction will fail with an error message if $prf$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   530
is not a proof of $t$, is ill-formed, or does not contain
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   531
sufficient information for reconstruction by
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   532
{\em higher order pattern unification}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   533
\cite{nipkow-patterns, Berghofer-Nipkow:2000:TPHOL}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   534
The latter may only happen for proofs
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   535
built up ``by hand'' but not for those produced automatically
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   536
by Isabelle's inference kernel.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   537
\item[Reconstruct.expand_proof $sg$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   538
  \ttlbrack$name@1$, $\ldots$, $name@n${\ttrbrack} $prf$]
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   539
expands and reconstructs the proofs of all theorems with names
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   540
$name@1$, $\ldots$, $name@n$ in the (full) proof $prf$.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   541
\item[ProofChecker.thm_of_proof $thy$ $prf$] turns the (full) proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   542
$prf$ into a theorem with respect to theory $thy$ by replaying
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   543
it using only primitive rules from Isabelle's inference kernel.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   544
\end{ttdescription}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   545
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   546
\subsection{Parsing and printing proof terms}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   547
\index{proof terms!parsing}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   548
\index{proof terms!printing}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   549
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   550
Isabelle offers several functions for parsing and printing
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   551
proof terms. The concrete syntax for proof terms is described
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   552
in Fig.\ts\ref{fig:proof_gram}.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   553
Implicit term arguments in partial proofs are indicated
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   554
by ``{\tt _}''.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   555
Type arguments for theorems and axioms may be specified using
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   556
\verb!%! or ``$\cdot$'' with an argument of the form {\tt TYPE($type$)}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   557
(see \S\ref{sec:basic_syntax}).
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   558
They must appear before any other term argument of a theorem
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   559
or axiom. In contrast to term arguments, type arguments may
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   560
be completely omitted.
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   561
\begin{ttbox}
11625
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   562
ProofSyntax.read_proof : theory -> bool -> string -> Proofterm.proof
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   563
ProofSyntax.pretty_proof : Sign.sg -> Proofterm.proof -> Pretty.T
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   564
ProofSyntax.pretty_proof_of : bool -> thm -> Pretty.T
74cdf24724ea Tuned section about parsing and printing proof terms.
berghofe
parents: 11622
diff changeset
   565
ProofSyntax.print_proof_of : bool -> thm -> unit
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   566
\end{ttbox}
11622
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   567
\begin{figure}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   568
\begin{center}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   569
\begin{tabular}{rcl}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   570
$proof$  & $=$ & {\tt Lam} $params${\tt .} $proof$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   571
                 $\Lambda params${\tt .} $proof$ \\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   572
         & $|$ & $proof$ \verb!%! $any$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   573
                 $proof$ $\cdot$ $any$ \\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   574
         & $|$ & $proof$ \verb!%%! $proof$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   575
                 $proof$ {\boldmath$\cdot$} $proof$ \\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   576
         & $|$ & $id$ ~~$|$~~ $longid$ \\\\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   577
$param$  & $=$ & $idt$ ~~$|$~~ $idt$ {\tt :} $prop$ ~~$|$~~
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   578
                 {\tt (} $param$ {\tt )} \\\\
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   579
$params$ & $=$ & $param$ ~~$|$~~ $param$ $params$
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   580
\end{tabular}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   581
\end{center}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   582
\caption{Proof term syntax}\label{fig:proof_gram}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   583
\end{figure}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   584
The function {\tt read_proof} reads in a proof term with
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   585
respect to a given theory. The boolean flag indicates whether
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   586
the proof term to be parsed contains explicit typing information
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   587
to be taken into account.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   588
Usually, typing information is left implicit and
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   589
is inferred during proof reconstruction. The pretty printing
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   590
functions operating on theorems take a boolean flag as an
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   591
argument which indicates whether the proof term should
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   592
be reconstructed before printing.
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   593
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   594
The following example (based on Isabelle/HOL) illustrates how
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   595
to parse and check proof terms. We start by parsing a partial
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   596
proof term
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   597
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   598
val prf = ProofSyntax.read_proof Main.thy false
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   599
  "impI % _ % _ %% (Lam H : _. conjE % _ % _ % _ %% H %%
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   600
     (Lam (H1 : _) H2 : _. conjI % _ % _ %% H2 %% H1))";
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   601
{\out val prf = PThm (("HOL.impI", []), \dots, \dots, None) % None % None %%}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   602
{\out   AbsP ("H", None, PThm (("HOL.conjE", []), \dots, \dots, None) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   603
{\out     None % None % None %% PBound 0 %%}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   604
{\out     AbsP ("H1", None, AbsP ("H2", None, \dots))) : Proofterm.proof}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   605
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   606
The statement to be established by this proof is
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   607
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   608
val t = term_of
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   609
  (read_cterm (sign_of Main.thy) ("A & B --> B & A", propT));
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   610
{\out val t = Const ("Trueprop", "bool => prop") $}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   611
{\out   (Const ("op -->", "[bool, bool] => bool") $}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   612
{\out     \dots $ \dots : Term.term}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   613
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   614
Using {\tt t} we can reconstruct the full proof
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   615
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   616
val prf' = Reconstruct.reconstruct_proof (sign_of Main.thy) t prf;
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   617
{\out val prf' = PThm (("HOL.impI", []), \dots, \dots, Some []) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   618
{\out   Some (Const ("op &", \dots) $ Free ("A", \dots) $ Free ("B", \dots)) %}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   619
{\out   Some (Const ("op &", \dots) $ Free ("B", \dots) $ Free ("A", \dots)) %%}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   620
{\out   AbsP ("H", Some (Const ("Trueprop", \dots) $ \dots), \dots)}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   621
{\out     : Proofterm.proof}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   622
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   623
This proof can finally be turned into a theorem
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   624
\begin{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   625
val thm = ProofChecker.thm_of_proof Main.thy prf';
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   626
{\out val thm = "A & B --> B & A" : Thm.thm}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   627
\end{ttbox}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   628
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   629
\index{proof terms|)}
27f858e70b3f Added documentation for proof terms.
berghofe
parents: 11163
diff changeset
   630
\index{theorems|)}
7871
30fb773113a1 Documented thm_deps.
berghofe
parents: 7644
diff changeset
   631
5371
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   632
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   633
%%% Local Variables: 
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   634
%%% mode: latex
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   635
%%% TeX-master: "ref"
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   636
%%% End: