author | ballarin |
Fri, 12 Jan 2007 15:37:21 +0100 | |
changeset 22063 | 717425609192 |
parent 17818 | 38c889d77282 |
child 30184 | 37969710e61f |
permissions | -rw-r--r-- |
104 | 1 |
%% $Id$ |
2 |
\chapter{Tactics} \label{tactics} |
|
3108 | 3 |
\index{tactics|(} Tactics have type \mltydx{tactic}. This is just an |
4 |
abbreviation for functions from theorems to theorem sequences, where |
|
5 |
the theorems represent states of a backward proof. Tactics seldom |
|
6 |
need to be coded from scratch, as functions; instead they are |
|
7 |
expressed using basic tactics and tacticals. |
|
104 | 8 |
|
4317 | 9 |
This chapter only presents the primitive tactics. Substantial proofs |
10 |
require the power of automatic tools like simplification |
|
11 |
(Chapter~\ref{chap:simplification}) and classical tableau reasoning |
|
12 |
(Chapter~\ref{chap:classical}). |
|
2039
79c86b966257
Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents:
1212
diff
changeset
|
13 |
|
104 | 14 |
\section{Resolution and assumption tactics} |
15 |
{\bf Resolution} is Isabelle's basic mechanism for refining a subgoal using |
|
16 |
a rule. {\bf Elim-resolution} is particularly suited for elimination |
|
17 |
rules, while {\bf destruct-resolution} is particularly suited for |
|
18 |
destruction rules. The {\tt r}, {\tt e}, {\tt d} naming convention is |
|
19 |
maintained for several different kinds of resolution tactics, as well as |
|
20 |
the shortcuts in the subgoal module. |
|
21 |
||
22 |
All the tactics in this section act on a subgoal designated by a positive |
|
23 |
integer~$i$. They fail (by returning the empty sequence) if~$i$ is out of |
|
24 |
range. |
|
25 |
||
26 |
\subsection{Resolution tactics} |
|
323 | 27 |
\index{resolution!tactics} |
104 | 28 |
\index{tactics!resolution|bold} |
29 |
\begin{ttbox} |
|
30 |
resolve_tac : thm list -> int -> tactic |
|
31 |
eresolve_tac : thm list -> int -> tactic |
|
32 |
dresolve_tac : thm list -> int -> tactic |
|
33 |
forward_tac : thm list -> int -> tactic |
|
34 |
\end{ttbox} |
|
35 |
These perform resolution on a list of theorems, $thms$, representing a list |
|
36 |
of object-rules. When generating next states, they take each of the rules |
|
37 |
in the order given. Each rule may yield several next states, or none: |
|
38 |
higher-order resolution may yield multiple resolvents. |
|
323 | 39 |
\begin{ttdescription} |
104 | 40 |
\item[\ttindexbold{resolve_tac} {\it thms} {\it i}] |
323 | 41 |
refines the proof state using the rules, which should normally be |
42 |
introduction rules. It resolves a rule's conclusion with |
|
43 |
subgoal~$i$ of the proof state. |
|
104 | 44 |
|
45 |
\item[\ttindexbold{eresolve_tac} {\it thms} {\it i}] |
|
323 | 46 |
\index{elim-resolution} |
47 |
performs elim-resolution with the rules, which should normally be |
|
4607 | 48 |
elimination rules. It resolves with a rule, proves its first premise by |
49 |
assumption, and finally \emph{deletes} that assumption from any new |
|
50 |
subgoals. (To rotate a rule's premises, |
|
7491 | 51 |
see \texttt{rotate_prems} in~{\S}\ref{MiscellaneousForwardRules}.) |
104 | 52 |
|
53 |
\item[\ttindexbold{dresolve_tac} {\it thms} {\it i}] |
|
323 | 54 |
\index{forward proof}\index{destruct-resolution} |
55 |
performs destruct-resolution with the rules, which normally should |
|
56 |
be destruction rules. This replaces an assumption by the result of |
|
57 |
applying one of the rules. |
|
104 | 58 |
|
323 | 59 |
\item[\ttindexbold{forward_tac}]\index{forward proof} |
60 |
is like {\tt dresolve_tac} except that the selected assumption is not |
|
61 |
deleted. It applies a rule to an assumption, adding the result as a new |
|
62 |
assumption. |
|
63 |
\end{ttdescription} |
|
104 | 64 |
|
65 |
\subsection{Assumption tactics} |
|
323 | 66 |
\index{tactics!assumption|bold}\index{assumptions!tactics for} |
104 | 67 |
\begin{ttbox} |
68 |
assume_tac : int -> tactic |
|
69 |
eq_assume_tac : int -> tactic |
|
70 |
\end{ttbox} |
|
323 | 71 |
\begin{ttdescription} |
104 | 72 |
\item[\ttindexbold{assume_tac} {\it i}] |
73 |
attempts to solve subgoal~$i$ by assumption. |
|
74 |
||
75 |
\item[\ttindexbold{eq_assume_tac}] |
|
76 |
is like {\tt assume_tac} but does not use unification. It succeeds (with a |
|
4607 | 77 |
\emph{unique} next state) if one of the assumptions is identical to the |
104 | 78 |
subgoal's conclusion. Since it does not instantiate variables, it cannot |
79 |
make other subgoals unprovable. It is intended to be called from proof |
|
80 |
strategies, not interactively. |
|
323 | 81 |
\end{ttdescription} |
104 | 82 |
|
83 |
\subsection{Matching tactics} \label{match_tac} |
|
323 | 84 |
\index{tactics!matching} |
104 | 85 |
\begin{ttbox} |
86 |
match_tac : thm list -> int -> tactic |
|
87 |
ematch_tac : thm list -> int -> tactic |
|
88 |
dmatch_tac : thm list -> int -> tactic |
|
89 |
\end{ttbox} |
|
90 |
These are just like the resolution tactics except that they never |
|
91 |
instantiate unknowns in the proof state. Flexible subgoals are not updated |
|
92 |
willy-nilly, but are left alone. Matching --- strictly speaking --- means |
|
93 |
treating the unknowns in the proof state as constants; these tactics merely |
|
94 |
discard unifiers that would update the proof state. |
|
323 | 95 |
\begin{ttdescription} |
104 | 96 |
\item[\ttindexbold{match_tac} {\it thms} {\it i}] |
323 | 97 |
refines the proof state using the rules, matching a rule's |
104 | 98 |
conclusion with subgoal~$i$ of the proof state. |
99 |
||
100 |
\item[\ttindexbold{ematch_tac}] |
|
101 |
is like {\tt match_tac}, but performs elim-resolution. |
|
102 |
||
103 |
\item[\ttindexbold{dmatch_tac}] |
|
104 |
is like {\tt match_tac}, but performs destruct-resolution. |
|
323 | 105 |
\end{ttdescription} |
104 | 106 |
|
107 |
||
10347 | 108 |
\subsection{Explicit instantiation} \label{res_inst_tac} |
323 | 109 |
\index{tactics!instantiation}\index{instantiation} |
104 | 110 |
\begin{ttbox} |
10347 | 111 |
res_inst_tac : (string*string)list -> thm -> int -> tactic |
112 |
eres_inst_tac : (string*string)list -> thm -> int -> tactic |
|
113 |
dres_inst_tac : (string*string)list -> thm -> int -> tactic |
|
114 |
forw_inst_tac : (string*string)list -> thm -> int -> tactic |
|
115 |
instantiate_tac : (string*string)list -> tactic |
|
104 | 116 |
\end{ttbox} |
10347 | 117 |
The first four of these tactics are designed for applying rules by resolution |
118 |
such as substitution and induction, which cause difficulties for higher-order |
|
119 |
unification. The tactics accept explicit instantiations for unknowns |
|
120 |
in the rule ---typically, in the rule's conclusion. The last one, |
|
121 |
{\tt instantiate_tac}, may be used to instantiate unknowns in the proof state, |
|
122 |
independently of rule application. |
|
123 |
||
124 |
Each instantiation is a pair {\tt($v$,$e$)}, |
|
125 |
where $v$ is an unknown \emph{without} its leading question mark! |
|
104 | 126 |
\begin{itemize} |
332 | 127 |
\item If $v$ is the type unknown {\tt'a}, then |
128 |
the rule must contain a type unknown \verb$?'a$ of some |
|
104 | 129 |
sort~$s$, and $e$ should be a type of sort $s$. |
130 |
||
332 | 131 |
\item If $v$ is the unknown {\tt P}, then |
132 |
the rule must contain an unknown \verb$?P$ of some type~$\tau$, |
|
104 | 133 |
and $e$ should be a term of some type~$\sigma$ such that $\tau$ and |
134 |
$\sigma$ are unifiable. If the unification of $\tau$ and $\sigma$ |
|
332 | 135 |
instantiates any type unknowns in $\tau$, these instantiations |
104 | 136 |
are recorded for application to the rule. |
137 |
\end{itemize} |
|
8136 | 138 |
Types are instantiated before terms are. Because type instantiations are |
104 | 139 |
inferred from term instantiations, explicit type instantiations are seldom |
140 |
necessary --- if \verb$?t$ has type \verb$?'a$, then the instantiation list |
|
8136 | 141 |
\texttt{[("'a","bool"), ("t","True")]} may be simplified to |
142 |
\texttt{[("t","True")]}. Type unknowns in the proof state may cause |
|
104 | 143 |
failure because the tactics cannot instantiate them. |
144 |
||
10347 | 145 |
The first four instantiation tactics act on a given subgoal. Terms in the |
104 | 146 |
instantiations are type-checked in the context of that subgoal --- in |
147 |
particular, they may refer to that subgoal's parameters. Any unknowns in |
|
148 |
the terms receive subscripts and are lifted over the parameters; thus, you |
|
149 |
may not refer to unknowns in the subgoal. |
|
150 |
||
323 | 151 |
\begin{ttdescription} |
104 | 152 |
\item[\ttindexbold{res_inst_tac} {\it insts} {\it thm} {\it i}] |
153 |
instantiates the rule {\it thm} with the instantiations {\it insts}, as |
|
154 |
described above, and then performs resolution on subgoal~$i$. Resolution |
|
155 |
typically causes further instantiations; you need not give explicit |
|
332 | 156 |
instantiations for every unknown in the rule. |
104 | 157 |
|
158 |
\item[\ttindexbold{eres_inst_tac}] |
|
159 |
is like {\tt res_inst_tac}, but performs elim-resolution. |
|
160 |
||
161 |
\item[\ttindexbold{dres_inst_tac}] |
|
162 |
is like {\tt res_inst_tac}, but performs destruct-resolution. |
|
163 |
||
164 |
\item[\ttindexbold{forw_inst_tac}] |
|
165 |
is like {\tt dres_inst_tac} except that the selected assumption is not |
|
166 |
deleted. It applies the instantiated rule to an assumption, adding the |
|
167 |
result as a new assumption. |
|
10347 | 168 |
|
169 |
\item[\ttindexbold{instantiate_tac} {\it insts}] |
|
170 |
instantiates unknowns in the proof state. This affects the main goal as |
|
171 |
well as all subgoals. |
|
323 | 172 |
\end{ttdescription} |
104 | 173 |
|
174 |
||
175 |
\section{Other basic tactics} |
|
176 |
\subsection{Tactic shortcuts} |
|
323 | 177 |
\index{shortcuts!for tactics} |
104 | 178 |
\index{tactics!resolution}\index{tactics!assumption} |
179 |
\index{tactics!meta-rewriting} |
|
180 |
\begin{ttbox} |
|
7491 | 181 |
rtac : thm -> int -> tactic |
182 |
etac : thm -> int -> tactic |
|
183 |
dtac : thm -> int -> tactic |
|
184 |
ftac : thm -> int -> tactic |
|
185 |
atac : int -> tactic |
|
186 |
eatac : thm -> int -> int -> tactic |
|
187 |
datac : thm -> int -> int -> tactic |
|
188 |
fatac : thm -> int -> int -> tactic |
|
189 |
ares_tac : thm list -> int -> tactic |
|
190 |
rewtac : thm -> tactic |
|
104 | 191 |
\end{ttbox} |
192 |
These abbreviate common uses of tactics. |
|
323 | 193 |
\begin{ttdescription} |
104 | 194 |
\item[\ttindexbold{rtac} {\it thm} {\it i}] |
195 |
abbreviates \hbox{\tt resolve_tac [{\it thm}] {\it i}}, doing resolution. |
|
196 |
||
197 |
\item[\ttindexbold{etac} {\it thm} {\it i}] |
|
198 |
abbreviates \hbox{\tt eresolve_tac [{\it thm}] {\it i}}, doing elim-resolution. |
|
199 |
||
200 |
\item[\ttindexbold{dtac} {\it thm} {\it i}] |
|
201 |
abbreviates \hbox{\tt dresolve_tac [{\it thm}] {\it i}}, doing |
|
202 |
destruct-resolution. |
|
203 |
||
7491 | 204 |
\item[\ttindexbold{ftac} {\it thm} {\it i}] |
205 |
abbreviates \hbox{\tt forward_tac [{\it thm}] {\it i}}, doing |
|
206 |
destruct-resolution without deleting the assumption. |
|
207 |
||
104 | 208 |
\item[\ttindexbold{atac} {\it i}] |
332 | 209 |
abbreviates \hbox{\tt assume_tac {\it i}}, doing proof by assumption. |
104 | 210 |
|
7491 | 211 |
\item[\ttindexbold{eatac} {\it thm} {\it j} {\it i}] |
212 |
performs \hbox{\tt etac {\it thm}} and then {\it j} times \texttt{atac}, |
|
213 |
solving additionally {\it j}~premises of the rule {\it thm} by assumption. |
|
214 |
||
215 |
\item[\ttindexbold{datac} {\it thm} {\it j} {\it i}] |
|
216 |
performs \hbox{\tt dtac {\it thm}} and then {\it j} times \texttt{atac}, |
|
217 |
solving additionally {\it j}~premises of the rule {\it thm} by assumption. |
|
218 |
||
219 |
\item[\ttindexbold{fatac} {\it thm} {\it j} {\it i}] |
|
220 |
performs \hbox{\tt ftac {\it thm}} and then {\it j} times \texttt{atac}, |
|
221 |
solving additionally {\it j}~premises of the rule {\it thm} by assumption. |
|
222 |
||
104 | 223 |
\item[\ttindexbold{ares_tac} {\it thms} {\it i}] |
224 |
tries proof by assumption and resolution; it abbreviates |
|
225 |
\begin{ttbox} |
|
226 |
assume_tac {\it i} ORELSE resolve_tac {\it thms} {\it i} |
|
227 |
\end{ttbox} |
|
228 |
||
229 |
\item[\ttindexbold{rewtac} {\it def}] |
|
230 |
abbreviates \hbox{\tt rewrite_goals_tac [{\it def}]}, unfolding a definition. |
|
323 | 231 |
\end{ttdescription} |
104 | 232 |
|
233 |
||
234 |
\subsection{Inserting premises and facts}\label{cut_facts_tac} |
|
323 | 235 |
\index{tactics!for inserting facts}\index{assumptions!inserting} |
104 | 236 |
\begin{ttbox} |
237 |
cut_facts_tac : thm list -> int -> tactic |
|
286 | 238 |
cut_inst_tac : (string*string)list -> thm -> int -> tactic |
239 |
subgoal_tac : string -> int -> tactic |
|
9523 | 240 |
subgoals_tac : string list -> int -> tactic |
104 | 241 |
\end{ttbox} |
2039
79c86b966257
Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents:
1212
diff
changeset
|
242 |
These tactics add assumptions to a subgoal. |
323 | 243 |
\begin{ttdescription} |
104 | 244 |
\item[\ttindexbold{cut_facts_tac} {\it thms} {\it i}] |
245 |
adds the {\it thms} as new assumptions to subgoal~$i$. Once they have |
|
286 | 246 |
been inserted as assumptions, they become subject to tactics such as {\tt |
247 |
eresolve_tac} and {\tt rewrite_goals_tac}. Only rules with no premises |
|
248 |
are inserted: Isabelle cannot use assumptions that contain $\Imp$ |
|
249 |
or~$\Forall$. Sometimes the theorems are premises of a rule being |
|
250 |
derived, returned by~{\tt goal}; instead of calling this tactic, you |
|
251 |
could state the goal with an outermost meta-quantifier. |
|
252 |
||
253 |
\item[\ttindexbold{cut_inst_tac} {\it insts} {\it thm} {\it i}] |
|
254 |
instantiates the {\it thm} with the instantiations {\it insts}, as |
|
7491 | 255 |
described in {\S}\ref{res_inst_tac}. It adds the resulting theorem as a |
286 | 256 |
new assumption to subgoal~$i$. |
104 | 257 |
|
258 |
\item[\ttindexbold{subgoal_tac} {\it formula} {\it i}] |
|
9568 | 259 |
adds the {\it formula} as an assumption to subgoal~$i$, and inserts the same |
104 | 260 |
{\it formula} as a new subgoal, $i+1$. |
457 | 261 |
|
262 |
\item[\ttindexbold{subgoals_tac} {\it formulae} {\it i}] |
|
263 |
uses {\tt subgoal_tac} to add the members of the list of {\it |
|
264 |
formulae} as assumptions to subgoal~$i$. |
|
323 | 265 |
\end{ttdescription} |