| author | nipkow | 
| Wed, 12 Feb 1997 18:53:59 +0100 | |
| changeset 2608 | 450c9b682a92 | 
| parent 2044 | e8d52d05530a | 
| child 3108 | 335efc3f5632 | 
| permissions | -rw-r--r-- | 
| 104 | 1 | %% $Id$ | 
| 2 | \chapter{Theorems and Forward Proof}
 | |
| 3 | \index{theorems|(}
 | |
| 326 | 4 | |
| 104 | 5 | Theorems, which represent the axioms, theorems and rules of object-logics, | 
| 326 | 6 | have type \mltydx{thm}.  This chapter begins by describing operations that
 | 
| 7 | print theorems and that join them in forward proof. Most theorem | |
| 8 | operations are intended for advanced applications, such as programming new | |
| 9 | proof procedures. Many of these operations refer to signatures, certified | |
| 10 | terms and certified types, which have the \ML{} types {\tt Sign.sg}, {\tt
 | |
| 11 |   Sign.cterm} and {\tt Sign.ctyp} and are discussed in
 | |
| 104 | 12 | Chapter~\ref{theories}.  Beginning users should ignore such complexities
 | 
| 13 | --- and skip all but the first section of this chapter. | |
| 14 | ||
| 15 | The theorem operations do not print error messages. Instead, they raise | |
| 326 | 16 | exception~\xdx{THM}\@.  Use \ttindex{print_exn} to display
 | 
| 104 | 17 | exceptions nicely: | 
| 18 | \begin{ttbox} 
 | |
| 19 | allI RS mp handle e => print_exn e; | |
| 20 | {\out Exception THM raised:}
 | |
| 21 | {\out RSN: no unifiers -- premise 1}
 | |
| 22 | {\out (!!x. ?P(x)) ==> ALL x. ?P(x)}
 | |
| 23 | {\out [| ?P --> ?Q; ?P |] ==> ?Q}
 | |
| 24 | {\out}
 | |
| 25 | {\out uncaught exception THM}
 | |
| 26 | \end{ttbox}
 | |
| 27 | ||
| 28 | ||
| 29 | \section{Basic operations on theorems}
 | |
| 30 | \subsection{Pretty-printing a theorem}
 | |
| 326 | 31 | \index{theorems!printing of}
 | 
| 104 | 32 | \begin{ttbox} 
 | 
| 326 | 33 | prth : thm -> thm | 
| 34 | prths : thm list -> thm list | |
| 35 | prthq : thm Sequence.seq -> thm Sequence.seq | |
| 36 | print_thm : thm -> unit | |
| 37 | print_goals : int -> thm -> unit | |
| 38 | string_of_thm : thm -> string | |
| 104 | 39 | \end{ttbox}
 | 
| 326 | 40 | The first three commands are for interactive use. They are identity | 
| 41 | functions that display, then return, their argument.  The \ML{} identifier
 | |
| 42 | {\tt it} will refer to the value just displayed.
 | |
| 43 | ||
| 44 | The others are for use in programs.  Functions with result type {\tt unit}
 | |
| 45 | are convenient for imperative programming. | |
| 46 | ||
| 47 | \begin{ttdescription}
 | |
| 104 | 48 | \item[\ttindexbold{prth} {\it thm}]  
 | 
| 49 | prints {\it thm\/} at the terminal.
 | |
| 50 | ||
| 51 | \item[\ttindexbold{prths} {\it thms}]  
 | |
| 52 | prints {\it thms}, a list of theorems.
 | |
| 53 | ||
| 54 | \item[\ttindexbold{prthq} {\it thmq}]  
 | |
| 55 | prints {\it thmq}, a sequence of theorems.  It is useful for inspecting
 | |
| 56 | the output of a tactic. | |
| 57 | ||
| 58 | \item[\ttindexbold{print_thm} {\it thm}]  
 | |
| 59 | prints {\it thm\/} at the terminal.
 | |
| 60 | ||
| 61 | \item[\ttindexbold{print_goals} {\it limit\/} {\it thm}]  
 | |
| 62 | prints {\it thm\/} in goal style, with the premises as subgoals.  It prints
 | |
| 63 | at most {\it limit\/} subgoals.  The subgoal module calls {\tt print_goals}
 | |
| 64 | to display proof states. | |
| 65 | ||
| 66 | \item[\ttindexbold{string_of_thm} {\it thm}]  
 | |
| 67 | converts {\it thm\/} to a string.
 | |
| 326 | 68 | \end{ttdescription}
 | 
| 104 | 69 | |
| 70 | ||
| 326 | 71 | \subsection{Forward proof: joining rules by resolution}
 | 
| 72 | \index{theorems!joining by resolution}
 | |
| 73 | \index{resolution}\index{forward proof}
 | |
| 104 | 74 | \begin{ttbox} 
 | 
| 75 | RSN : thm * (int * thm) -> thm                 \hfill{\bf infix}
 | |
| 76 | RS  : thm * thm -> thm                         \hfill{\bf infix}
 | |
| 77 | MRS : thm list * thm -> thm                    \hfill{\bf infix}
 | |
| 78 | RLN : thm list * (int * thm list) -> thm list  \hfill{\bf infix}
 | |
| 79 | RL  : thm list * thm list -> thm list          \hfill{\bf infix}
 | |
| 326 | 80 | MRL : thm list list * thm list -> thm list     \hfill{\bf infix}
 | 
| 104 | 81 | \end{ttbox}
 | 
| 326 | 82 | Joining rules together is a simple way of deriving new rules. These | 
| 876 | 83 | functions are especially useful with destruction rules. To store | 
| 84 | the result in the theorem database, use \ttindex{bind_thm}
 | |
| 85 | (\S\ref{ExtractingAndStoringTheProvedTheorem}). 
 | |
| 326 | 86 | \begin{ttdescription}
 | 
| 104 | 87 | \item[\tt$thm@1$ RSN $(i,thm@2)$] \indexbold{*RSN} 
 | 
| 326 | 88 | resolves the conclusion of $thm@1$ with the $i$th premise of~$thm@2$. | 
| 89 | Unless there is precisely one resolvent it raises exception | |
| 90 |   \xdx{THM}; in that case, use {\tt RLN}.
 | |
| 104 | 91 | |
| 92 | \item[\tt$thm@1$ RS $thm@2$] \indexbold{*RS} 
 | |
| 93 | abbreviates \hbox{\tt$thm@1$ RSN $(1,thm@2)$}.  Thus, it resolves the
 | |
| 94 | conclusion of $thm@1$ with the first premise of~$thm@2$. | |
| 95 | ||
| 96 | \item[\tt {$[thm@1,\ldots,thm@n]$} MRS $thm$] \indexbold{*MRS} 
 | |
| 332 | 97 |   uses {\tt RSN} to resolve $thm@i$ against premise~$i$ of $thm$, for
 | 
| 104 | 98 | $i=n$, \ldots,~1. This applies $thm@n$, \ldots, $thm@1$ to the first $n$ | 
| 99 | premises of $thm$. Because the theorems are used from right to left, it | |
| 100 |   does not matter if the $thm@i$ create new premises.  {\tt MRS} is useful
 | |
| 101 | for expressing proof trees. | |
| 102 | ||
| 151 | 103 | \item[\tt$thms@1$ RLN $(i,thms@2)$] \indexbold{*RLN} 
 | 
| 326 | 104 | joins lists of theorems. For every $thm@1$ in $thms@1$ and $thm@2$ in | 
| 105 | $thms@2$, it resolves the conclusion of $thm@1$ with the $i$th premise | |
| 106 | of~$thm@2$, accumulating the results. | |
| 104 | 107 | |
| 151 | 108 | \item[\tt$thms@1$ RL $thms@2$] \indexbold{*RL} 
 | 
| 109 | abbreviates \hbox{\tt$thms@1$ RLN $(1,thms@2)$}. 
 | |
| 104 | 110 | |
| 111 | \item[\tt {$[thms@1,\ldots,thms@n]$} MRL $thms$] \indexbold{*MRL} 
 | |
| 112 | is analogous to {\tt MRS}, but combines theorem lists rather than theorems.
 | |
| 113 | It too is useful for expressing proof trees. | |
| 326 | 114 | \end{ttdescription}
 | 
| 104 | 115 | |
| 116 | ||
| 117 | \subsection{Expanding definitions in theorems}
 | |
| 326 | 118 | \index{meta-rewriting!in theorems}
 | 
| 104 | 119 | \begin{ttbox} 
 | 
| 120 | rewrite_rule : thm list -> thm -> thm | |
| 121 | rewrite_goals_rule : thm list -> thm -> thm | |
| 122 | \end{ttbox}
 | |
| 326 | 123 | \begin{ttdescription}
 | 
| 104 | 124 | \item[\ttindexbold{rewrite_rule} {\it defs} {\it thm}]  
 | 
| 125 | unfolds the {\it defs} throughout the theorem~{\it thm}.
 | |
| 126 | ||
| 127 | \item[\ttindexbold{rewrite_goals_rule} {\it defs} {\it thm}]  
 | |
| 128 | unfolds the {\it defs} in the premises of~{\it thm}, but leaves the
 | |
| 129 | conclusion unchanged.  This rule underlies \ttindex{rewrite_goals_tac}, but 
 | |
| 130 | serves little purpose in forward proof. | |
| 326 | 131 | \end{ttdescription}
 | 
| 104 | 132 | |
| 133 | ||
| 326 | 134 | \subsection{Instantiating a theorem}
 | 
| 135 | \index{instantiation}
 | |
| 286 | 136 | \begin{ttbox}
 | 
| 104 | 137 | read_instantiate : (string*string)list -> thm -> thm | 
| 138 | read_instantiate_sg : Sign.sg -> (string*string)list -> thm -> thm | |
| 139 | cterm_instantiate : (Sign.cterm*Sign.cterm)list -> thm -> thm | |
| 140 | \end{ttbox}
 | |
| 141 | These meta-rules instantiate type and term unknowns in a theorem. They are | |
| 142 | occasionally useful. They can prevent difficulties with higher-order | |
| 143 | unification, and define specialized versions of rules. | |
| 326 | 144 | \begin{ttdescription}
 | 
| 104 | 145 | \item[\ttindexbold{read_instantiate} {\it insts} {\it thm}] 
 | 
| 146 | processes the instantiations {\it insts} and instantiates the rule~{\it
 | |
| 147 | thm}. The processing of instantiations is described | |
| 326 | 148 | in \S\ref{res_inst_tac}, under {\tt res_inst_tac}.  
 | 
| 104 | 149 | |
| 150 | Use {\tt res_inst_tac}, not {\tt read_instantiate}, to instantiate a rule
 | |
| 151 | and refine a particular subgoal. The tactic allows instantiation by the | |
| 152 | subgoal's parameters, and reads the instantiations using the signature | |
| 326 | 153 | associated with the proof state. | 
| 154 | ||
| 155 | Use {\tt read_instantiate_sg} below if {\it insts\/} appears to be treated
 | |
| 156 | incorrectly. | |
| 104 | 157 | |
| 326 | 158 | \item[\ttindexbold{read_instantiate_sg} {\it sg} {\it insts} {\it thm}]
 | 
| 159 |   resembles \hbox{\tt read_instantiate {\it insts} {\it thm}}, but reads
 | |
| 160 |   the instantiations under signature~{\it sg}.  This is necessary to
 | |
| 161 | instantiate a rule from a general theory, such as first-order logic, | |
| 162 |   using the notation of some specialized theory.  Use the function {\tt
 | |
| 163 | sign_of} to get a theory's signature. | |
| 104 | 164 | |
| 165 | \item[\ttindexbold{cterm_instantiate} {\it ctpairs} {\it thm}] 
 | |
| 166 | is similar to {\tt read_instantiate}, but the instantiations are provided
 | |
| 167 | as pairs of certified terms, not as strings to be read. | |
| 326 | 168 | \end{ttdescription}
 | 
| 104 | 169 | |
| 170 | ||
| 866 
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
 clasohm parents: 
332diff
changeset | 171 | \subsection{Miscellaneous forward rules}\label{MiscellaneousForwardRules}
 | 
| 326 | 172 | \index{theorems!standardizing}
 | 
| 104 | 173 | \begin{ttbox} 
 | 
| 332 | 174 | standard : thm -> thm | 
| 175 | zero_var_indexes : thm -> thm | |
| 176 | make_elim : thm -> thm | |
| 104 | 177 | rule_by_tactic : tactic -> thm -> thm | 
| 178 | \end{ttbox}
 | |
| 326 | 179 | \begin{ttdescription}
 | 
| 104 | 180 | \item[\ttindexbold{standard} $thm$]  
 | 
| 181 | puts $thm$ into the standard form of object-rules. It discharges all | |
| 332 | 182 | meta-assumptions, replaces free variables by schematic variables, and | 
| 104 | 183 | renames schematic variables to have subscript zero. | 
| 184 | ||
| 185 | \item[\ttindexbold{zero_var_indexes} $thm$] 
 | |
| 186 | makes all schematic variables have subscript zero, renaming them to avoid | |
| 187 | clashes. | |
| 188 | ||
| 189 | \item[\ttindexbold{make_elim} $thm$] 
 | |
| 190 | \index{rules!converting destruction to elimination}
 | |
| 191 | converts $thm$, a destruction rule of the form $\List{P@1;\ldots;P@m}\Imp
 | |
| 192 | Q$, to the elimination rule $\List{P@1; \ldots; P@m; Q\Imp R}\Imp R$.  This
 | |
| 193 | is the basis for destruct-resolution: {\tt dresolve_tac}, etc.
 | |
| 194 | ||
| 195 | \item[\ttindexbold{rule_by_tactic} {\it tac} {\it thm}] 
 | |
| 196 |   applies {\it tac\/} to the {\it thm}, freezing its variables first, then
 | |
| 197 | yields the proof state returned by the tactic. In typical usage, the | |
| 198 |   {\it thm\/} represents an instance of a rule with several premises, some
 | |
| 199 | with contradictory assumptions (because of the instantiation). The | |
| 200 | tactic proves those subgoals and does whatever else it can, and returns | |
| 201 | whatever is left. | |
| 326 | 202 | \end{ttdescription}
 | 
| 104 | 203 | |
| 204 | ||
| 205 | \subsection{Taking a theorem apart}
 | |
| 326 | 206 | \index{theorems!taking apart}
 | 
| 104 | 207 | \index{flex-flex constraints}
 | 
| 208 | \begin{ttbox} 
 | |
| 209 | concl_of : thm -> term | |
| 210 | prems_of : thm -> term list | |
| 211 | nprems_of : thm -> int | |
| 212 | tpairs_of : thm -> (term*term)list | |
| 213 | stamps_of_thy : thm -> string ref list | |
| 866 
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
 clasohm parents: 
332diff
changeset | 214 | theory_of_thm : thm -> theory | 
| 286 | 215 | dest_state : thm*int -> (term*term)list*term list*term*term | 
| 2040 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 216 | rep_thm       : thm -> \{prop: term, hyps: term list, der: deriv, 
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 217 | maxidx: int, sign: Sign.sg, shyps: sort list\} | 
| 104 | 218 | \end{ttbox}
 | 
| 326 | 219 | \begin{ttdescription}
 | 
| 104 | 220 | \item[\ttindexbold{concl_of} $thm$] 
 | 
| 221 | returns the conclusion of $thm$ as a term. | |
| 222 | ||
| 223 | \item[\ttindexbold{prems_of} $thm$] 
 | |
| 224 | returns the premises of $thm$ as a list of terms. | |
| 225 | ||
| 226 | \item[\ttindexbold{nprems_of} $thm$] 
 | |
| 286 | 227 | returns the number of premises in $thm$, and is equivalent to {\tt
 | 
| 228 | length(prems_of~$thm$)}. | |
| 104 | 229 | |
| 230 | \item[\ttindexbold{tpairs_of} $thm$] 
 | |
| 231 | returns the flex-flex constraints of $thm$. | |
| 232 | ||
| 233 | \item[\ttindexbold{stamps_of_thm} $thm$] 
 | |
| 332 | 234 | returns the \rmindex{stamps} of the signature associated with~$thm$.
 | 
| 104 | 235 | |
| 866 
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
 clasohm parents: 
332diff
changeset | 236 | \item[\ttindexbold{theory_of_thm} $thm$]
 | 
| 
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
 clasohm parents: 
332diff
changeset | 237 | returns the theory associated with $thm$. | 
| 
2d3d020eef11
added documentation of bind_thm, qed, qed_goal, get_thm, thms_of
 clasohm parents: 
332diff
changeset | 238 | |
| 104 | 239 | \item[\ttindexbold{dest_state} $(thm,i)$] 
 | 
| 240 | decomposes $thm$ as a tuple containing a list of flex-flex constraints, a | |
| 241 | list of the subgoals~1 to~$i-1$, subgoal~$i$, and the rest of the theorem | |
| 242 | (this will be an implication if there are more than $i$ subgoals). | |
| 243 | ||
| 2040 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 244 | \item[\ttindexbold{rep_thm} $thm$] decomposes $thm$ as a record containing the
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 245 |   statement of~$thm$ ({\tt prop}), its list of meta-assumptions ({\tt hyps}),
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 246 |   its derivation ({\tt der}), a bound on the maximum subscript of its
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 247 |   unknowns ({\tt maxidx}), and its signature ({\tt sign}).  The {\tt shyps}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 248 | field is discussed below. | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 249 | \end{ttdescription}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 250 | |
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 251 | |
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 252 | \subsection{*Sort hypotheses} 
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 253 | \index{sort hypotheses}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 254 | \begin{ttbox} 
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 255 | force_strip_shyps : bool ref \hfill{\bf initially true}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 256 | \end{ttbox}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 257 | |
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 258 | \begin{ttdescription}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 259 | \item[\ttindexbold{force_strip_shyps}]
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 260 | causes sort hypotheses to be deleted, printing a warning. | 
| 326 | 261 | \end{ttdescription}
 | 
| 104 | 262 | |
| 2044 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 263 | Isabelle's type variables are decorated with sorts, constraining them to | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 264 | certain ranges of types. This has little impact when sorts only serve for | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 265 | syntactic classification of types --- for example, FOL distinguishes between | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 266 | terms and other types. But when type classes are introduced through axioms, | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 267 | this may result in some sorts becoming {\em empty\/}: where one cannot exhibit
 | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 268 | a type belonging to it because certain axioms are unsatisfiable. | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 269 | |
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 270 | If a theorem contain a type variable whose sort is empty, then that theorem | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 271 | has no instances. In effect, it asserts nothing. But what if it is used to | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 272 | prove another theorem that no longer involves that sort? The latter theorem | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 273 | holds only if the sort is non-empty. | 
| 2040 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 274 | |
| 2044 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 275 | Therefore, Isabelle's theorems carry around sort hypotheses. The {\tt
 | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 276 | 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: 
2040diff
changeset | 277 | {\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: 
2040diff
changeset | 278 | theorem's proof that no longer appear in the {\tt prop} or {\tt hyps}
 | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 279 | fields --- so-called {\em dangling\/} sort constraints. These are the
 | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 280 | critical ones, asserting non-emptiness of the corresponding sorts. | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 281 | |
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 282 | Isabelle tries to remove extraneous sorts from the {\tt shyps} field whenever
 | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 283 | non-emptiness can be established by looking at the theorem's signature: from | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 284 | the {\tt arities} information, etc.  Because its current implementation is
 | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 285 | highly incomplete, the flag shown above is available. Setting it to true (the | 
| 
e8d52d05530a
Improved discussion of shyps thanks to Markus Wenzel
 paulson parents: 
2040diff
changeset | 286 | default) allows existing proofs to run. | 
| 2040 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 287 | |
| 104 | 288 | |
| 289 | \subsection{Tracing flags for unification}
 | |
| 326 | 290 | \index{tracing!of unification}
 | 
| 104 | 291 | \begin{ttbox} 
 | 
| 292 | Unify.trace_simp   : bool ref \hfill{\bf initially false}
 | |
| 293 | Unify.trace_types  : bool ref \hfill{\bf initially false}
 | |
| 294 | Unify.trace_bound  : int ref \hfill{\bf initially 10}
 | |
| 295 | Unify.search_bound : int ref \hfill{\bf initially 20}
 | |
| 296 | \end{ttbox}
 | |
| 297 | Tracing the search may be useful when higher-order unification behaves | |
| 298 | unexpectedly.  Letting {\tt res_inst_tac} circumvent the problem is easier,
 | |
| 299 | though. | |
| 326 | 300 | \begin{ttdescription}
 | 
| 301 | \item[Unify.trace_simp := true;] | |
| 104 | 302 | causes tracing of the simplification phase. | 
| 303 | ||
| 326 | 304 | \item[Unify.trace_types := true;] | 
| 104 | 305 | generates warnings of incompleteness, when unification is not considering | 
| 306 | all possible instantiations of type unknowns. | |
| 307 | ||
| 326 | 308 | \item[Unify.trace_bound := $n$;] | 
| 104 | 309 | causes unification to print tracing information once it reaches depth~$n$. | 
| 310 | Use $n=0$ for full tracing. At the default value of~10, tracing | |
| 311 | information is almost never printed. | |
| 312 | ||
| 326 | 313 | \item[Unify.search_bound := $n$;] | 
| 104 | 314 | causes unification to limit its search to depth~$n$. Because of this | 
| 315 | bound, higher-order unification cannot return an infinite sequence, though | |
| 316 | it can return a very long one. The search rarely approaches the default | |
| 317 | value of~20.  If the search is cut off, unification prints {\tt
 | |
| 318 | ***Unification bound exceeded}. | |
| 326 | 319 | \end{ttdescription}
 | 
| 104 | 320 | |
| 321 | ||
| 322 | \section{Primitive meta-level inference rules}
 | |
| 323 | \index{meta-rules|(}
 | |
| 324 | These implement the meta-logic in {\sc lcf} style, as functions from theorems
 | |
| 325 | to theorems. They are, rarely, useful for deriving results in the pure | |
| 326 | theory. Mainly, they are included for completeness, and most users should | |
| 326 | 327 | not bother with them.  The meta-rules raise exception \xdx{THM} to signal
 | 
| 104 | 328 | malformed premises, incompatible signatures and similar errors. | 
| 329 | ||
| 326 | 330 | \index{meta-assumptions}
 | 
| 104 | 331 | The meta-logic uses natural deduction. Each theorem may depend on | 
| 332 | 332 | meta-level assumptions.  Certain rules, such as $({\Imp}I)$,
 | 
| 104 | 333 | discharge assumptions; in most other rules, the conclusion depends on all | 
| 334 | of the assumptions of the premises. Formally, the system works with | |
| 335 | assertions of the form | |
| 336 | \[ \phi \quad [\phi@1,\ldots,\phi@n], \] | |
| 332 | 337 | where $\phi@1$,~\ldots,~$\phi@n$ are the assumptions. Do not confuse | 
| 104 | 338 | meta-level assumptions with the object-level assumptions in a subgoal, | 
| 339 | which are represented in the meta-logic using~$\Imp$. | |
| 340 | ||
| 341 | Each theorem has a signature. Certified terms have a signature. When a | |
| 342 | rule takes several premises and certified terms, it merges the signatures | |
| 343 | to make a signature for the conclusion. This fails if the signatures are | |
| 344 | incompatible. | |
| 345 | ||
| 326 | 346 | \index{meta-implication}
 | 
| 332 | 347 | The {\bf implication} rules are $({\Imp}I)$
 | 
| 104 | 348 | and $({\Imp}E)$:
 | 
| 349 | \[ \infer[({\Imp}I)]{\phi\Imp \psi}{\infer*{\psi}{[\phi]}}  \qquad
 | |
| 350 |    \infer[({\Imp}E)]{\psi}{\phi\Imp \psi & \phi}  \]
 | |
| 351 | ||
| 326 | 352 | \index{meta-equality}
 | 
| 104 | 353 | Equality of truth values means logical equivalence: | 
| 354 | \[ \infer[({\equiv}I)]{\phi\equiv\psi}{\infer*{\psi}{[\phi]} &
 | |
| 286 | 355 |                                        \infer*{\phi}{[\psi]}}  
 | 
| 104 | 356 | \qquad | 
| 357 |    \infer[({\equiv}E)]{\psi}{\phi\equiv \psi & \phi}   \]
 | |
| 358 | ||
| 332 | 359 | The {\bf equality} rules are reflexivity, symmetry, and transitivity:
 | 
| 104 | 360 | \[ {a\equiv a}\,(refl)  \qquad
 | 
| 361 |    \infer[(sym)]{b\equiv a}{a\equiv b}  \qquad
 | |
| 362 |    \infer[(trans)]{a\equiv c}{a\equiv b & b\equiv c}   \]
 | |
| 363 | ||
| 326 | 364 | \index{lambda calc@$\lambda$-calculus}
 | 
| 104 | 365 | The $\lambda$-conversions are $\alpha$-conversion, $\beta$-conversion, and | 
| 366 | extensionality:\footnote{$\alpha$-conversion holds if $y$ is not free
 | |
| 367 | in~$a$; $(ext)$ holds if $x$ is not free in the assumptions, $f$, or~$g$.} | |
| 368 | \[ {(\lambda x.a) \equiv (\lambda y.a[y/x])}    \qquad
 | |
| 369 |    {((\lambda x.a)(b)) \equiv a[b/x]}           \qquad
 | |
| 370 |    \infer[(ext)]{f\equiv g}{f(x) \equiv g(x)}   \]
 | |
| 371 | ||
| 332 | 372 | The {\bf abstraction} and {\bf combination} rules let conversions be
 | 
| 373 | applied to subterms:\footnote{Abstraction holds if $x$ is not free in the
 | |
| 104 | 374 | assumptions.} | 
| 375 | \[  \infer[(abs)]{(\lambda x.a) \equiv (\lambda x.b)}{a\equiv b}   \qquad
 | |
| 376 |     \infer[(comb)]{f(a)\equiv g(b)}{f\equiv g & a\equiv b}   \]
 | |
| 377 | ||
| 326 | 378 | \index{meta-quantifiers}
 | 
| 332 | 379 | The {\bf universal quantification} rules are $(\Forall I)$ and $(\Forall
 | 
| 104 | 380 | E)$:\footnote{$(\Forall I)$ holds if $x$ is not free in the assumptions.}
 | 
| 381 | \[ \infer[(\Forall I)]{\Forall x.\phi}{\phi}        \qquad
 | |
| 286 | 382 |    \infer[(\Forall E)]{\phi[b/x]}{\Forall x.\phi}   \]
 | 
| 104 | 383 | |
| 384 | ||
| 326 | 385 | \subsection{Assumption rule}
 | 
| 386 | \index{meta-assumptions}
 | |
| 104 | 387 | \begin{ttbox} 
 | 
| 388 | assume: Sign.cterm -> thm | |
| 389 | \end{ttbox}
 | |
| 326 | 390 | \begin{ttdescription}
 | 
| 104 | 391 | \item[\ttindexbold{assume} $ct$] 
 | 
| 332 | 392 | makes the theorem \(\phi \;[\phi]\), where $\phi$ is the value of~$ct$. | 
| 104 | 393 | The rule checks that $ct$ has type $prop$ and contains no unknowns, which | 
| 332 | 394 | are not allowed in assumptions. | 
| 326 | 395 | \end{ttdescription}
 | 
| 104 | 396 | |
| 326 | 397 | \subsection{Implication rules}
 | 
| 398 | \index{meta-implication}
 | |
| 104 | 399 | \begin{ttbox} 
 | 
| 400 | implies_intr : Sign.cterm -> thm -> thm | |
| 401 | implies_intr_list : Sign.cterm list -> thm -> thm | |
| 402 | implies_intr_hyps : thm -> thm | |
| 403 | implies_elim : thm -> thm -> thm | |
| 404 | implies_elim_list : thm -> thm list -> thm | |
| 405 | \end{ttbox}
 | |
| 326 | 406 | \begin{ttdescription}
 | 
| 104 | 407 | \item[\ttindexbold{implies_intr} $ct$ $thm$] 
 | 
| 408 | is $({\Imp}I)$, where $ct$ is the assumption to discharge, say~$\phi$.  It
 | |
| 332 | 409 | maps the premise~$\psi$ to the conclusion $\phi\Imp\psi$, removing all | 
| 410 | occurrences of~$\phi$ from the assumptions. The rule checks that $ct$ has | |
| 411 | type $prop$. | |
| 104 | 412 | |
| 413 | \item[\ttindexbold{implies_intr_list} $cts$ $thm$] 
 | |
| 414 | applies $({\Imp}I)$ repeatedly, on every element of the list~$cts$.
 | |
| 415 | ||
| 416 | \item[\ttindexbold{implies_intr_hyps} $thm$] 
 | |
| 332 | 417 | applies $({\Imp}I)$ to discharge all the hypotheses (assumptions) of~$thm$.
 | 
| 418 | It maps the premise $\phi \; [\phi@1,\ldots,\phi@n]$ to the conclusion | |
| 104 | 419 | $\List{\phi@1,\ldots,\phi@n}\Imp\phi$.
 | 
| 420 | ||
| 421 | \item[\ttindexbold{implies_elim} $thm@1$ $thm@2$] 
 | |
| 422 | applies $({\Imp}E)$ to $thm@1$ and~$thm@2$.  It maps the premises $\phi\Imp
 | |
| 423 | \psi$ and $\phi$ to the conclusion~$\psi$. | |
| 424 | ||
| 425 | \item[\ttindexbold{implies_elim_list} $thm$ $thms$] 
 | |
| 426 | applies $({\Imp}E)$ repeatedly to $thm$, using each element of~$thms$ in
 | |
| 151 | 427 | turn.  It maps the premises $\List{\phi@1,\ldots,\phi@n}\Imp\psi$ and
 | 
| 104 | 428 | $\phi@1$,\ldots,$\phi@n$ to the conclusion~$\psi$. | 
| 326 | 429 | \end{ttdescription}
 | 
| 104 | 430 | |
| 326 | 431 | \subsection{Logical equivalence rules}
 | 
| 432 | \index{meta-equality}
 | |
| 104 | 433 | \begin{ttbox} 
 | 
| 326 | 434 | equal_intr : thm -> thm -> thm | 
| 435 | equal_elim : thm -> thm -> thm | |
| 104 | 436 | \end{ttbox}
 | 
| 326 | 437 | \begin{ttdescription}
 | 
| 104 | 438 | \item[\ttindexbold{equal_intr} $thm@1$ $thm@2$] 
 | 
| 332 | 439 | applies $({\equiv}I)$ to $thm@1$ and~$thm@2$.  It maps the premises~$\psi$
 | 
| 440 | and~$\phi$ to the conclusion~$\phi\equiv\psi$; the assumptions are those of | |
| 441 | the first premise with~$\phi$ removed, plus those of | |
| 442 | the second premise with~$\psi$ removed. | |
| 104 | 443 | |
| 444 | \item[\ttindexbold{equal_elim} $thm@1$ $thm@2$] 
 | |
| 445 | applies $({\equiv}E)$ to $thm@1$ and~$thm@2$.  It maps the premises
 | |
| 446 | $\phi\equiv\psi$ and $\phi$ to the conclusion~$\psi$. | |
| 326 | 447 | \end{ttdescription}
 | 
| 104 | 448 | |
| 449 | ||
| 450 | \subsection{Equality rules}
 | |
| 326 | 451 | \index{meta-equality}
 | 
| 104 | 452 | \begin{ttbox} 
 | 
| 453 | reflexive : Sign.cterm -> thm | |
| 454 | symmetric : thm -> thm | |
| 455 | transitive : thm -> thm -> thm | |
| 456 | \end{ttbox}
 | |
| 326 | 457 | \begin{ttdescription}
 | 
| 104 | 458 | \item[\ttindexbold{reflexive} $ct$] 
 | 
| 151 | 459 | makes the theorem \(ct\equiv ct\). | 
| 104 | 460 | |
| 461 | \item[\ttindexbold{symmetric} $thm$] 
 | |
| 462 | maps the premise $a\equiv b$ to the conclusion $b\equiv a$. | |
| 463 | ||
| 464 | \item[\ttindexbold{transitive} $thm@1$ $thm@2$] 
 | |
| 465 | maps the premises $a\equiv b$ and $b\equiv c$ to the conclusion~${a\equiv c}$.
 | |
| 326 | 466 | \end{ttdescription}
 | 
| 104 | 467 | |
| 468 | ||
| 469 | \subsection{The $\lambda$-conversion rules}
 | |
| 326 | 470 | \index{lambda calc@$\lambda$-calculus}
 | 
| 104 | 471 | \begin{ttbox} 
 | 
| 472 | beta_conversion : Sign.cterm -> thm | |
| 473 | extensional : thm -> thm | |
| 474 | abstract_rule : string -> Sign.cterm -> thm -> thm | |
| 475 | combination : thm -> thm -> thm | |
| 476 | \end{ttbox} 
 | |
| 326 | 477 | There is no rule for $\alpha$-conversion because Isabelle regards | 
| 478 | $\alpha$-convertible theorems as equal. | |
| 479 | \begin{ttdescription}
 | |
| 104 | 480 | \item[\ttindexbold{beta_conversion} $ct$] 
 | 
| 481 | makes the theorem $((\lambda x.a)(b)) \equiv a[b/x]$, where $ct$ is the | |
| 482 | term $(\lambda x.a)(b)$. | |
| 483 | ||
| 484 | \item[\ttindexbold{extensional} $thm$] 
 | |
| 485 | maps the premise $f(x) \equiv g(x)$ to the conclusion $f\equiv g$. | |
| 486 | Parameter~$x$ is taken from the premise. It may be an unknown or a free | |
| 332 | 487 | variable (provided it does not occur in the assumptions); it must not occur | 
| 104 | 488 | in $f$ or~$g$. | 
| 489 | ||
| 490 | \item[\ttindexbold{abstract_rule} $v$ $x$ $thm$] 
 | |
| 491 | maps the premise $a\equiv b$ to the conclusion $(\lambda x.a) \equiv | |
| 492 | (\lambda x.b)$, abstracting over all occurrences (if any!) of~$x$. | |
| 493 | Parameter~$x$ is supplied as a cterm. It may be an unknown or a free | |
| 332 | 494 | variable (provided it does not occur in the assumptions). In the | 
| 104 | 495 | conclusion, the bound variable is named~$v$. | 
| 496 | ||
| 497 | \item[\ttindexbold{combination} $thm@1$ $thm@2$] 
 | |
| 498 | maps the premises $f\equiv g$ and $a\equiv b$ to the conclusion~$f(a)\equiv | |
| 499 | g(b)$. | |
| 326 | 500 | \end{ttdescription}
 | 
| 104 | 501 | |
| 502 | ||
| 326 | 503 | \subsection{Forall introduction rules}
 | 
| 504 | \index{meta-quantifiers}
 | |
| 104 | 505 | \begin{ttbox} 
 | 
| 506 | forall_intr : Sign.cterm -> thm -> thm | |
| 507 | forall_intr_list : Sign.cterm list -> thm -> thm | |
| 508 | forall_intr_frees : thm -> thm | |
| 509 | \end{ttbox}
 | |
| 510 | ||
| 326 | 511 | \begin{ttdescription}
 | 
| 104 | 512 | \item[\ttindexbold{forall_intr} $x$ $thm$] 
 | 
| 513 | applies $({\Forall}I)$, abstracting over all occurrences (if any!) of~$x$.
 | |
| 514 | The rule maps the premise $\phi$ to the conclusion $\Forall x.\phi$. | |
| 515 | Parameter~$x$ is supplied as a cterm. It may be an unknown or a free | |
| 332 | 516 | variable (provided it does not occur in the assumptions). | 
| 104 | 517 | |
| 518 | \item[\ttindexbold{forall_intr_list} $xs$ $thm$] 
 | |
| 519 | applies $({\Forall}I)$ repeatedly, on every element of the list~$xs$.
 | |
| 520 | ||
| 521 | \item[\ttindexbold{forall_intr_frees} $thm$] 
 | |
| 522 | applies $({\Forall}I)$ repeatedly, generalizing over all the free variables
 | |
| 523 | of the premise. | |
| 326 | 524 | \end{ttdescription}
 | 
| 104 | 525 | |
| 526 | ||
| 326 | 527 | \subsection{Forall elimination rules}
 | 
| 104 | 528 | \begin{ttbox} 
 | 
| 529 | forall_elim : Sign.cterm -> thm -> thm | |
| 530 | forall_elim_list : Sign.cterm list -> thm -> thm | |
| 531 | forall_elim_var : int -> thm -> thm | |
| 532 | forall_elim_vars : int -> thm -> thm | |
| 533 | \end{ttbox}
 | |
| 534 | ||
| 326 | 535 | \begin{ttdescription}
 | 
| 104 | 536 | \item[\ttindexbold{forall_elim} $ct$ $thm$] 
 | 
| 537 | applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
 | |
| 538 | $\phi[ct/x]$. The rule checks that $ct$ and $x$ have the same type. | |
| 539 | ||
| 540 | \item[\ttindexbold{forall_elim_list} $cts$ $thm$] 
 | |
| 541 | applies $({\Forall}E)$ repeatedly, on every element of the list~$cts$.
 | |
| 542 | ||
| 543 | \item[\ttindexbold{forall_elim_var} $k$ $thm$] 
 | |
| 544 | applies $({\Forall}E)$, mapping the premise $\Forall x.\phi$ to the conclusion
 | |
| 545 | $\phi[\Var{x@k}/x]$.  Thus, it replaces the outermost $\Forall$-bound
 | |
| 546 | variable by an unknown having subscript~$k$. | |
| 547 | ||
| 548 | \item[\ttindexbold{forall_elim_vars} $ks$ $thm$] 
 | |
| 549 | applies {\tt forall_elim_var} repeatedly, for every element of the list~$ks$.
 | |
| 326 | 550 | \end{ttdescription}
 | 
| 104 | 551 | |
| 326 | 552 | \subsection{Instantiation of unknowns}
 | 
| 553 | \index{instantiation}
 | |
| 104 | 554 | \begin{ttbox} 
 | 
| 286 | 555 | instantiate: (indexname*Sign.ctyp)list * | 
| 556 | (Sign.cterm*Sign.cterm)list -> thm -> thm | |
| 104 | 557 | \end{ttbox}
 | 
| 326 | 558 | \begin{ttdescription}
 | 
| 559 | \item[\ttindexbold{instantiate} ($tyinsts$, $insts$) $thm$] 
 | |
| 560 | simultaneously substitutes types for type unknowns (the | |
| 104 | 561 | $tyinsts$) and terms for term unknowns (the $insts$). Instantiations are | 
| 562 | given as $(v,t)$ pairs, where $v$ is an unknown and $t$ is a term (of the | |
| 563 | same type as $v$) or a type (of the same sort as~$v$). All the unknowns | |
| 564 | must be distinct. The rule normalizes its conclusion. | |
| 326 | 565 | \end{ttdescription}
 | 
| 104 | 566 | |
| 567 | ||
| 326 | 568 | \subsection{Freezing/thawing type unknowns}
 | 
| 569 | \index{type unknowns!freezing/thawing of}
 | |
| 104 | 570 | \begin{ttbox} 
 | 
| 571 | freezeT: thm -> thm | |
| 572 | varifyT: thm -> thm | |
| 573 | \end{ttbox}
 | |
| 326 | 574 | \begin{ttdescription}
 | 
| 104 | 575 | \item[\ttindexbold{freezeT} $thm$] 
 | 
| 576 | converts all the type unknowns in $thm$ to free type variables. | |
| 577 | ||
| 578 | \item[\ttindexbold{varifyT} $thm$] 
 | |
| 579 | converts all the free type variables in $thm$ to type unknowns. | |
| 326 | 580 | \end{ttdescription}
 | 
| 104 | 581 | |
| 582 | ||
| 583 | \section{Derived rules for goal-directed proof}
 | |
| 584 | Most of these rules have the sole purpose of implementing particular | |
| 585 | tactics. There are few occasions for applying them directly to a theorem. | |
| 586 | ||
| 587 | \subsection{Proof by assumption}
 | |
| 326 | 588 | \index{meta-assumptions}
 | 
| 104 | 589 | \begin{ttbox} 
 | 
| 590 | assumption : int -> thm -> thm Sequence.seq | |
| 591 | eq_assumption : int -> thm -> thm | |
| 592 | \end{ttbox}
 | |
| 326 | 593 | \begin{ttdescription}
 | 
| 104 | 594 | \item[\ttindexbold{assumption} {\it i} $thm$] 
 | 
| 595 | attempts to solve premise~$i$ of~$thm$ by assumption. | |
| 596 | ||
| 597 | \item[\ttindexbold{eq_assumption}] 
 | |
| 598 | is like {\tt assumption} but does not use unification.
 | |
| 326 | 599 | \end{ttdescription}
 | 
| 104 | 600 | |
| 601 | ||
| 602 | \subsection{Resolution}
 | |
| 326 | 603 | \index{resolution}
 | 
| 104 | 604 | \begin{ttbox} 
 | 
| 605 | biresolution : bool -> (bool*thm)list -> int -> thm | |
| 606 | -> thm Sequence.seq | |
| 607 | \end{ttbox}
 | |
| 326 | 608 | \begin{ttdescription}
 | 
| 104 | 609 | \item[\ttindexbold{biresolution} $match$ $rules$ $i$ $state$] 
 | 
| 326 | 610 | performs bi-resolution on subgoal~$i$ of $state$, using the list of $\it | 
| 104 | 611 | (flag,rule)$ pairs. For each pair, it applies resolution if the flag | 
| 612 | is~{\tt false} and elim-resolution if the flag is~{\tt true}.  If $match$
 | |
| 613 | is~{\tt true}, the $state$ is not instantiated.
 | |
| 326 | 614 | \end{ttdescription}
 | 
| 104 | 615 | |
| 616 | ||
| 617 | \subsection{Composition: resolution without lifting}
 | |
| 326 | 618 | \index{resolution!without lifting}
 | 
| 104 | 619 | \begin{ttbox}
 | 
| 620 | compose : thm * int * thm -> thm list | |
| 621 | COMP : thm * thm -> thm | |
| 622 | bicompose : bool -> bool * thm * int -> int -> thm | |
| 623 | -> thm Sequence.seq | |
| 624 | \end{ttbox}
 | |
| 625 | In forward proof, a typical use of composition is to regard an assertion of | |
| 626 | the form $\phi\Imp\psi$ as atomic. Schematic variables are not renamed, so | |
| 627 | beware of clashes! | |
| 326 | 628 | \begin{ttdescription}
 | 
| 104 | 629 | \item[\ttindexbold{compose} ($thm@1$, $i$, $thm@2$)] 
 | 
| 630 | uses $thm@1$, regarded as an atomic formula, to solve premise~$i$ | |
| 631 | of~$thm@2$.  Let $thm@1$ and $thm@2$ be $\psi$ and $\List{\phi@1; \ldots;
 | |
| 632 | \phi@n} \Imp \phi$. For each $s$ that unifies~$\psi$ and $\phi@i$, the | |
| 633 | result list contains the theorem | |
| 634 | \[ (\List{\phi@1; \ldots; \phi@{i-1}; \phi@{i+1}; \ldots; \phi@n} \Imp \phi)s.
 | |
| 635 | \] | |
| 636 | ||
| 1119 | 637 | \item[$thm@1$ \ttindexbold{COMP} $thm@2$] 
 | 
| 104 | 638 | calls \hbox{\tt compose ($thm@1$, 1, $thm@2$)} and returns the result, if
 | 
| 326 | 639 | unique; otherwise, it raises exception~\xdx{THM}\@.  It is
 | 
| 104 | 640 | analogous to {\tt RS}\@.  
 | 
| 641 | ||
| 642 | For example, suppose that $thm@1$ is $a=b\Imp b=a$, a symmetry rule, and | |
| 332 | 643 | that $thm@2$ is $\List{P\Imp Q; \neg Q} \Imp\neg P$, which is the
 | 
| 104 | 644 | principle of contrapositives. Then the result would be the | 
| 645 | derived rule $\neg(b=a)\Imp\neg(a=b)$. | |
| 646 | ||
| 647 | \item[\ttindexbold{bicompose} $match$ ($flag$, $rule$, $m$) $i$ $state$]
 | |
| 648 | refines subgoal~$i$ of $state$ using $rule$, without lifting. The $rule$ | |
| 649 | is taken to have the form $\List{\psi@1; \ldots; \psi@m} \Imp \psi$, where
 | |
| 326 | 650 | $\psi$ need not be atomic; thus $m$ determines the number of new | 
| 104 | 651 | subgoals.  If $flag$ is {\tt true} then it performs elim-resolution --- it
 | 
| 652 | solves the first premise of~$rule$ by assumption and deletes that | |
| 653 | assumption.  If $match$ is~{\tt true}, the $state$ is not instantiated.
 | |
| 326 | 654 | \end{ttdescription}
 | 
| 104 | 655 | |
| 656 | ||
| 657 | \subsection{Other meta-rules}
 | |
| 658 | \begin{ttbox} 
 | |
| 659 | trivial : Sign.cterm -> thm | |
| 660 | lift_rule : (thm * int) -> thm -> thm | |
| 661 | rename_params_rule : string list * int -> thm -> thm | |
| 662 | rewrite_cterm : thm list -> Sign.cterm -> thm | |
| 663 | flexflex_rule : thm -> thm Sequence.seq | |
| 664 | \end{ttbox}
 | |
| 326 | 665 | \begin{ttdescription}
 | 
| 104 | 666 | \item[\ttindexbold{trivial} $ct$] 
 | 
| 667 | makes the theorem \(\phi\Imp\phi\), where $\phi$ is the value of~$ct$. | |
| 668 | This is the initial state for a goal-directed proof of~$\phi$. The rule | |
| 669 | checks that $ct$ has type~$prop$. | |
| 670 | ||
| 671 | \item[\ttindexbold{lift_rule} ($state$, $i$) $rule$] \index{lifting}
 | |
| 672 | prepares $rule$ for resolution by lifting it over the parameters and | |
| 673 | assumptions of subgoal~$i$ of~$state$. | |
| 674 | ||
| 675 | \item[\ttindexbold{rename_params_rule} ({\it names}, {\it i}) $thm$] 
 | |
| 676 | uses the $names$ to rename the parameters of premise~$i$ of $thm$. The | |
| 677 | names must be distinct. If there are fewer names than parameters, then the | |
| 678 | rule renames the innermost parameters and may modify the remaining ones to | |
| 679 | ensure that all the parameters are distinct. | |
| 680 | \index{parameters!renaming}
 | |
| 681 | ||
| 682 | \item[\ttindexbold{rewrite_cterm} $defs$ $ct$]
 | |
| 683 | transforms $ct$ to $ct'$ by repeatedly applying $defs$ as rewrite rules; it | |
| 684 | returns the conclusion~$ct\equiv ct'$. This underlies the meta-rewriting | |
| 685 | tactics and rules. | |
| 326 | 686 | \index{meta-rewriting!in terms}
 | 
| 104 | 687 | |
| 688 | \item[\ttindexbold{flexflex_rule} $thm$]  \index{flex-flex constraints}
 | |
| 689 | removes all flex-flex pairs from $thm$ using the trivial unifier. | |
| 326 | 690 | \end{ttdescription}
 | 
| 1590 | 691 | \index{meta-rules|)}
 | 
| 692 | ||
| 693 | ||
| 1846 | 694 | \section{Proof objects}\label{sec:proofObjects}
 | 
| 1590 | 695 | \index{proof objects|(} Isabelle can record the full meta-level proof of each
 | 
| 696 | theorem. The proof object contains all logical inferences in detail, while | |
| 697 | omitting bookkeeping steps that have no logical meaning to an outside | |
| 698 | observer. Rewriting steps are recorded in similar detail as the output of | |
| 699 | simplifier tracing. The proof object can be inspected by a separate | |
| 700 | proof-checker, or used to generate human-readable proof digests. | |
| 701 | ||
| 702 | Full proof objects are large. They multiply storage requirements by about | |
| 703 | seven; attempts to build large logics (such as {\sc zf} and {\sc hol}) may
 | |
| 704 | fail. Isabelle normally builds minimal proof objects, which include only uses | |
| 705 | of oracles. You can also request an intermediate level of detail, containing | |
| 706 | uses of oracles, axioms and theorems. These smaller proof objects indicate a | |
| 707 | theorem's dependencies. | |
| 708 | ||
| 709 | Isabelle provides proof objects for the sake of transparency. Their aim is to | |
| 710 | increase your confidence in Isabelle. They let you inspect proofs constructed | |
| 711 | by the classical reasoner or simplifier, and inform you of all uses of | |
| 712 | oracles. Seldom will proof objects be given whole to an automatic | |
| 713 | proof-checker: none has been written. It is up to you to examine and | |
| 714 | interpret them sensibly. For example, when scrutinizing a theorem's | |
| 715 | derivation for dependence upon some oracle or axiom, remember to scrutinize | |
| 716 | all of its lemmas. Their proofs are included in the main derivation, through | |
| 717 | the {\tt Theorem} constructor.
 | |
| 718 | ||
| 719 | Proof objects are expressed using a polymorphic type of variable-branching | |
| 720 | trees.  Proof objects (formally known as {\em derivations\/}) are trees
 | |
| 721 | labelled by rules, where {\tt rule} is a complicated datatype declared in the
 | |
| 722 | file {\tt Pure/thm.ML}.
 | |
| 723 | \begin{ttbox} 
 | |
| 724 | datatype 'a mtree = Join of 'a * 'a mtree list; | |
| 725 | datatype rule = \(\ldots\); | |
| 726 | type deriv = rule mtree; | |
| 727 | \end{ttbox}
 | |
| 728 | % | |
| 729 | Each theorem's derivation is stored as the {\tt der} field of its internal
 | |
| 730 | record: | |
| 731 | \begin{ttbox} 
 | |
| 732 | #der (rep_thm conjI); | |
| 733 | {\out Join (Theorem ({ProtoPure, CPure, HOL},"conjI"),}
 | |
| 734 | {\out       [Join (MinProof,[])]) : deriv}
 | |
| 735 | \end{ttbox}
 | |
| 736 | This proof object identifies a labelled theorem, {\tt conjI}, whose underlying
 | |
| 737 | proof has not been recorded; all we have is {\tt MinProof}.
 | |
| 738 | ||
| 739 | Nontrivial proof objects are unreadably large and complex. Isabelle provides | |
| 740 | several functions to help you inspect them informally. These functions omit | |
| 741 | the more obscure inferences and attempt to restructure the others into natural | |
| 742 | formats, linear or tree-structured. | |
| 743 | ||
| 744 | \begin{ttbox} 
 | |
| 745 | keep_derivs : deriv_kind ref | |
| 746 | Deriv.size : deriv -> int | |
| 747 | Deriv.drop : 'a mtree * int -> 'a mtree | |
| 748 | Deriv.linear : deriv -> deriv list | |
| 1876 | 749 | Deriv.tree : deriv -> Deriv.orule mtree | 
| 1590 | 750 | \end{ttbox}
 | 
| 751 | ||
| 752 | \begin{ttdescription}
 | |
| 753 | \item[\ttindexbold{keep_derivs} := MinDeriv $|$ ThmDeriv $|$ FullDeriv;] 
 | |
| 754 | specifies one of the three options for keeping derivations. They can be | |
| 755 | minimal (oracles only), include theorems and axioms, or be full. | |
| 756 | ||
| 757 | \item[\ttindexbold{Deriv.size} $der$] yields the size of a derivation,
 | |
| 758 | excluding lemmas. | |
| 759 | ||
| 760 | \item[\ttindexbold{Deriv.drop} ($tree$,$n$)] returns the subtree $n$ levels
 | |
| 761 | down, always following the first child. It is good for stripping off | |
| 762 | outer level inferences that are used to put a theorem into standard form. | |
| 763 | ||
| 764 | \item[\ttindexbold{Deriv.linear} $der$] converts a derivation into a linear
 | |
| 765 | format, replacing the deep nesting by a list of rules. Intuitively, this | |
| 766 | reveals the single-step Isabelle proof that is constructed internally by | |
| 767 | tactics. | |
| 768 | ||
| 769 | \item[\ttindexbold{Deriv.tree} $der$] converts a derivation into an
 | |
| 770 | object-level proof tree. A resolution by an object-rule is converted to a | |
| 771 | tree node labelled by that rule. Complications arise if the object-rule is | |
| 772 | itself derived in some way. Nested resolutions are unravelled, but other | |
| 773 | operations on rules (such as rewriting) are left as-is. | |
| 774 | \end{ttdescription}
 | |
| 775 | ||
| 2040 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 776 | Functions {\tt Deriv.linear} and {\tt Deriv.tree} omit the proof of any named
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 777 | theorems (constructor {\tt Theorem}) they encounter in a derivation.  Applying
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 778 | them directly to the derivation of a named theorem is therefore pointless. | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 779 | Use {\tt Deriv.drop} with argument~1 to skip over the initial {\tt Theorem}
 | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 780 | constructor. | 
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 781 | |
| 
6db93e6f1b11
Documented sort hypotheses and improved discussion of derivations
 paulson parents: 
1876diff
changeset | 782 | |
| 1590 | 783 | \index{proof objects|)}
 | 
| 104 | 784 | \index{theorems|)}
 |