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