author | huffman |
Fri, 06 Nov 2009 09:50:37 -0800 | |
changeset 33506 | afb577487b15 |
parent 32201 | 3689b647356d |
child 34930 | f3bce1cc513c |
permissions | -rw-r--r-- |
29755 | 1 |
theory Tactic |
2 |
imports Base |
|
3 |
begin |
|
18537 | 4 |
|
20452 | 5 |
chapter {* Tactical reasoning *} |
18537 | 6 |
|
20451 | 7 |
text {* |
20474 | 8 |
Tactical reasoning works by refining the initial claim in a |
9 |
backwards fashion, until a solved form is reached. A @{text "goal"} |
|
10 |
consists of several subgoals that need to be solved in order to |
|
11 |
achieve the main statement; zero subgoals means that the proof may |
|
12 |
be finished. A @{text "tactic"} is a refinement operation that maps |
|
13 |
a goal to a lazy sequence of potential successors. A @{text |
|
14 |
"tactical"} is a combinator for composing tactics. |
|
20451 | 15 |
*} |
18537 | 16 |
|
17 |
||
18 |
section {* Goals \label{sec:tactical-goals} *} |
|
19 |
||
20451 | 20 |
text {* |
29758 | 21 |
Isabelle/Pure represents a goal as a theorem stating that the |
22 |
subgoals imply the main goal: @{text "A\<^sub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^sub>n \<Longrightarrow> |
|
23 |
C"}. The outermost goal structure is that of a Horn Clause: i.e.\ |
|
24 |
an iterated implication without any quantifiers\footnote{Recall that |
|
25 |
outermost @{text "\<And>x. \<phi>[x]"} is always represented via schematic |
|
26 |
variables in the body: @{text "\<phi>[?x]"}. These variables may get |
|
27 |
instantiated during the course of reasoning.}. For @{text "n = 0"} |
|
28 |
a goal is called ``solved''. |
|
18537 | 29 |
|
29761 | 30 |
The structure of each subgoal @{text "A\<^sub>i"} is that of a |
31 |
general Hereditary Harrop Formula @{text "\<And>x\<^sub>1 \<dots> |
|
32 |
\<And>x\<^sub>k. H\<^sub>1 \<Longrightarrow> \<dots> \<Longrightarrow> H\<^sub>m \<Longrightarrow> B"}. Here @{text |
|
33 |
"x\<^sub>1, \<dots>, x\<^sub>k"} are goal parameters, i.e.\ |
|
34 |
arbitrary-but-fixed entities of certain types, and @{text |
|
35 |
"H\<^sub>1, \<dots>, H\<^sub>m"} are goal hypotheses, i.e.\ facts that may |
|
36 |
be assumed locally. Together, this forms the goal context of the |
|
37 |
conclusion @{text B} to be established. The goal hypotheses may be |
|
38 |
again arbitrary Hereditary Harrop Formulas, although the level of |
|
39 |
nesting rarely exceeds 1--2 in practice. |
|
18537 | 40 |
|
20451 | 41 |
The main conclusion @{text C} is internally marked as a protected |
29758 | 42 |
proposition, which is represented explicitly by the notation @{text |
43 |
"#C"}. This ensures that the decomposition into subgoals and main |
|
44 |
conclusion is well-defined for arbitrarily structured claims. |
|
18537 | 45 |
|
20451 | 46 |
\medskip Basic goal management is performed via the following |
47 |
Isabelle/Pure rules: |
|
18537 | 48 |
|
49 |
\[ |
|
50 |
\infer[@{text "(init)"}]{@{text "C \<Longrightarrow> #C"}}{} \qquad |
|
20547 | 51 |
\infer[@{text "(finish)"}]{@{text "C"}}{@{text "#C"}} |
18537 | 52 |
\] |
53 |
||
54 |
\medskip The following low-level variants admit general reasoning |
|
55 |
with protected propositions: |
|
56 |
||
57 |
\[ |
|
58 |
\infer[@{text "(protect)"}]{@{text "#C"}}{@{text "C"}} \qquad |
|
59 |
\infer[@{text "(conclude)"}]{@{text "A\<^sub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^sub>n \<Longrightarrow> C"}}{@{text "A\<^sub>1 \<Longrightarrow> \<dots> \<Longrightarrow> A\<^sub>n \<Longrightarrow> #C"}} |
|
60 |
\] |
|
61 |
*} |
|
62 |
||
63 |
text %mlref {* |
|
64 |
\begin{mldecls} |
|
65 |
@{index_ML Goal.init: "cterm -> thm"} \\ |
|
32201
3689b647356d
updated Variable.focus, SUBPROOF, Obtain.result, Goal.finish;
wenzelm
parents:
30272
diff
changeset
|
66 |
@{index_ML Goal.finish: "Proof.context -> thm -> thm"} \\ |
18537 | 67 |
@{index_ML Goal.protect: "thm -> thm"} \\ |
68 |
@{index_ML Goal.conclude: "thm -> thm"} \\ |
|
69 |
\end{mldecls} |
|
70 |
||
71 |
\begin{description} |
|
72 |
||
20474 | 73 |
\item @{ML "Goal.init"}~@{text C} initializes a tactical goal from |
74 |
the well-formed proposition @{text C}. |
|
18537 | 75 |
|
32201
3689b647356d
updated Variable.focus, SUBPROOF, Obtain.result, Goal.finish;
wenzelm
parents:
30272
diff
changeset
|
76 |
\item @{ML "Goal.finish"}~@{text "ctxt thm"} checks whether theorem |
20474 | 77 |
@{text "thm"} is a solved goal (no subgoals), and concludes the |
32201
3689b647356d
updated Variable.focus, SUBPROOF, Obtain.result, Goal.finish;
wenzelm
parents:
30272
diff
changeset
|
78 |
result by removing the goal protection. The context is only |
3689b647356d
updated Variable.focus, SUBPROOF, Obtain.result, Goal.finish;
wenzelm
parents:
30272
diff
changeset
|
79 |
required for printing error messages. |
18537 | 80 |
|
20474 | 81 |
\item @{ML "Goal.protect"}~@{text "thm"} protects the full statement |
82 |
of theorem @{text "thm"}. |
|
18537 | 83 |
|
20474 | 84 |
\item @{ML "Goal.conclude"}~@{text "thm"} removes the goal |
85 |
protection, even if there are pending subgoals. |
|
18537 | 86 |
|
87 |
\end{description} |
|
88 |
*} |
|
89 |
||
90 |
||
91 |
section {* Tactics *} |
|
92 |
||
28781 | 93 |
text {* A @{text "tactic"} is a function @{text "goal \<rightarrow> goal\<^sup>*\<^sup>*"} that |
94 |
maps a given goal state (represented as a theorem, cf.\ |
|
95 |
\secref{sec:tactical-goals}) to a lazy sequence of potential |
|
96 |
successor states. The underlying sequence implementation is lazy |
|
97 |
both in head and tail, and is purely functional in \emph{not} |
|
98 |
supporting memoing.\footnote{The lack of memoing and the strict |
|
99 |
nature of SML requires some care when working with low-level |
|
100 |
sequence operations, to avoid duplicate or premature evaluation of |
|
101 |
results.} |
|
18537 | 102 |
|
28781 | 103 |
An \emph{empty result sequence} means that the tactic has failed: in |
104 |
a compound tactic expressions other tactics might be tried instead, |
|
105 |
or the whole refinement step might fail outright, producing a |
|
106 |
toplevel error message. When implementing tactics from scratch, one |
|
107 |
should take care to observe the basic protocol of mapping regular |
|
108 |
error conditions to an empty result; only serious faults should |
|
109 |
emerge as exceptions. |
|
110 |
||
111 |
By enumerating \emph{multiple results}, a tactic can easily express |
|
112 |
the potential outcome of an internal search process. There are also |
|
113 |
combinators for building proof tools that involve search |
|
114 |
systematically, see also \secref{sec:tacticals}. |
|
115 |
||
116 |
\medskip As explained in \secref{sec:tactical-goals}, a goal state |
|
117 |
essentially consists of a list of subgoals that imply the main goal |
|
118 |
(conclusion). Tactics may operate on all subgoals or on a |
|
119 |
particularly specified subgoal, but must not change the main |
|
120 |
conclusion (apart from instantiating schematic goal variables). |
|
18537 | 121 |
|
28781 | 122 |
Tactics with explicit \emph{subgoal addressing} are of the form |
123 |
@{text "int \<rightarrow> tactic"} and may be applied to a particular subgoal |
|
124 |
(counting from 1). If the subgoal number is out of range, the |
|
125 |
tactic should fail with an empty result sequence, but must not raise |
|
126 |
an exception! |
|
127 |
||
128 |
Operating on a particular subgoal means to replace it by an interval |
|
129 |
of zero or more subgoals in the same place; other subgoals must not |
|
130 |
be affected, apart from instantiating schematic variables ranging |
|
131 |
over the whole goal state. |
|
132 |
||
133 |
A common pattern of composing tactics with subgoal addressing is to |
|
134 |
try the first one, and then the second one only if the subgoal has |
|
135 |
not been solved yet. Special care is required here to avoid bumping |
|
28782 | 136 |
into unrelated subgoals that happen to come after the original |
137 |
subgoal. Assuming that there is only a single initial subgoal is a |
|
138 |
very common error when implementing tactics! |
|
139 |
||
140 |
Tactics with internal subgoal addressing should expose the subgoal |
|
141 |
index as @{text "int"} argument in full generality; a hardwired |
|
142 |
subgoal 1 inappropriate. |
|
28781 | 143 |
|
144 |
\medskip The main well-formedness conditions for proper tactics are |
|
145 |
summarized as follows. |
|
146 |
||
147 |
\begin{itemize} |
|
148 |
||
149 |
\item General tactic failure is indicated by an empty result, only |
|
150 |
serious faults may produce an exception. |
|
151 |
||
152 |
\item The main conclusion must not be changed, apart from |
|
153 |
instantiating schematic variables. |
|
154 |
||
155 |
\item A tactic operates either uniformly on all subgoals, or |
|
156 |
specifically on a selected subgoal (without bumping into unrelated |
|
157 |
subgoals). |
|
158 |
||
159 |
\item Range errors in subgoal addressing produce an empty result. |
|
160 |
||
161 |
\end{itemize} |
|
28782 | 162 |
|
163 |
Some of these conditions are checked by higher-level goal |
|
164 |
infrastructure (\secref{sec:results}); others are not checked |
|
165 |
explicitly, and violating them merely results in ill-behaved tactics |
|
166 |
experienced by the user (e.g.\ tactics that insist in being |
|
167 |
applicable only to singleton goals, or disallow composition with |
|
168 |
basic tacticals). |
|
169 |
*} |
|
170 |
||
171 |
text %mlref {* |
|
172 |
\begin{mldecls} |
|
173 |
@{index_ML_type tactic: "thm -> thm Seq.seq"} \\ |
|
28783 | 174 |
@{index_ML no_tac: tactic} \\ |
175 |
@{index_ML all_tac: tactic} \\ |
|
176 |
@{index_ML print_tac: "string -> tactic"} \\[1ex] |
|
177 |
@{index_ML PRIMITIVE: "(thm -> thm) -> tactic"} \\[1ex] |
|
28782 | 178 |
@{index_ML SUBGOAL: "(term * int -> tactic) -> int -> tactic"} \\ |
179 |
@{index_ML CSUBGOAL: "(cterm * int -> tactic) -> int -> tactic"} \\ |
|
180 |
\end{mldecls} |
|
181 |
||
182 |
\begin{description} |
|
183 |
||
184 |
\item @{ML_type tactic} represents tactics. The well-formedness |
|
185 |
conditions described above need to be observed. See also @{"file" |
|
186 |
"~~/src/Pure/General/seq.ML"} for the underlying implementation of |
|
187 |
lazy sequences. |
|
188 |
||
189 |
\item @{ML_type "int -> tactic"} represents tactics with explicit |
|
190 |
subgoal addressing, with well-formedness conditions as described |
|
191 |
above. |
|
192 |
||
28783 | 193 |
\item @{ML no_tac} is a tactic that always fails, returning the |
194 |
empty sequence. |
|
195 |
||
196 |
\item @{ML all_tac} is a tactic that always succeeds, returning a |
|
197 |
singleton sequence with unchanged goal state. |
|
198 |
||
199 |
\item @{ML print_tac}~@{text "message"} is like @{ML all_tac}, but |
|
200 |
prints a message together with the goal state on the tracing |
|
201 |
channel. |
|
202 |
||
28782 | 203 |
\item @{ML PRIMITIVE}~@{text rule} turns a primitive inference rule |
204 |
into a tactic with unique result. Exception @{ML THM} is considered |
|
205 |
a regular tactic failure and produces an empty result; other |
|
206 |
exceptions are passed through. |
|
207 |
||
208 |
\item @{ML SUBGOAL}~@{text "(fn (subgoal, i) => tactic)"} is the |
|
28783 | 209 |
most basic form to produce a tactic with subgoal addressing. The |
28782 | 210 |
given abstraction over the subgoal term and subgoal number allows to |
211 |
peek at the relevant information of the full goal state. The |
|
212 |
subgoal range is checked as required above. |
|
213 |
||
214 |
\item @{ML CSUBGOAL} is similar to @{ML SUBGOAL}, but passes the |
|
28783 | 215 |
subgoal as @{ML_type cterm} instead of raw @{ML_type term}. This |
28782 | 216 |
avoids expensive re-certification in situations where the subgoal is |
217 |
used directly for primitive inferences. |
|
218 |
||
219 |
\end{description} |
|
28781 | 220 |
*} |
18537 | 221 |
|
222 |
||
28785
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
223 |
subsection {* Resolution and assumption tactics \label{sec:resolve-assume-tac} *} |
28783 | 224 |
|
225 |
text {* \emph{Resolution} is the most basic mechanism for refining a |
|
226 |
subgoal using a theorem as object-level rule. |
|
227 |
\emph{Elim-resolution} is particularly suited for elimination rules: |
|
228 |
it resolves with a rule, proves its first premise by assumption, and |
|
229 |
finally deletes that assumption from any new subgoals. |
|
230 |
\emph{Destruct-resolution} is like elim-resolution, but the given |
|
231 |
destruction rules are first turned into canonical elimination |
|
232 |
format. \emph{Forward-resolution} is like destruct-resolution, but |
|
28785
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
233 |
without deleting the selected assumption. The @{text "r/e/d/f"} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
234 |
naming convention is maintained for several different kinds of |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
235 |
resolution rules and tactics. |
28783 | 236 |
|
237 |
Assumption tactics close a subgoal by unifying some of its premises |
|
238 |
against its conclusion. |
|
239 |
||
240 |
\medskip All the tactics in this section operate on a subgoal |
|
241 |
designated by a positive integer. Other subgoals might be affected |
|
242 |
indirectly, due to instantiation of schematic variables. |
|
243 |
||
244 |
There are various sources of non-determinism, the tactic result |
|
245 |
sequence enumerates all possibilities of the following choices (if |
|
246 |
applicable): |
|
247 |
||
248 |
\begin{enumerate} |
|
249 |
||
250 |
\item selecting one of the rules given as argument to the tactic; |
|
251 |
||
252 |
\item selecting a subgoal premise to eliminate, unifying it against |
|
253 |
the first premise of the rule; |
|
254 |
||
255 |
\item unifying the conclusion of the subgoal to the conclusion of |
|
256 |
the rule. |
|
257 |
||
258 |
\end{enumerate} |
|
259 |
||
260 |
Recall that higher-order unification may produce multiple results |
|
261 |
that are enumerated here. |
|
262 |
*} |
|
263 |
||
264 |
text %mlref {* |
|
265 |
\begin{mldecls} |
|
266 |
@{index_ML resolve_tac: "thm list -> int -> tactic"} \\ |
|
267 |
@{index_ML eresolve_tac: "thm list -> int -> tactic"} \\ |
|
268 |
@{index_ML dresolve_tac: "thm list -> int -> tactic"} \\ |
|
269 |
@{index_ML forward_tac: "thm list -> int -> tactic"} \\[1ex] |
|
270 |
@{index_ML assume_tac: "int -> tactic"} \\ |
|
271 |
@{index_ML eq_assume_tac: "int -> tactic"} \\[1ex] |
|
272 |
@{index_ML match_tac: "thm list -> int -> tactic"} \\ |
|
273 |
@{index_ML ematch_tac: "thm list -> int -> tactic"} \\ |
|
274 |
@{index_ML dmatch_tac: "thm list -> int -> tactic"} \\ |
|
275 |
\end{mldecls} |
|
276 |
||
277 |
\begin{description} |
|
278 |
||
279 |
\item @{ML resolve_tac}~@{text "thms i"} refines the goal state |
|
280 |
using the given theorems, which should normally be introduction |
|
281 |
rules. The tactic resolves a rule's conclusion with subgoal @{text |
|
282 |
i}, replacing it by the corresponding versions of the rule's |
|
283 |
premises. |
|
284 |
||
285 |
\item @{ML eresolve_tac}~@{text "thms i"} performs elim-resolution |
|
286 |
with the given theorems, which should normally be elimination rules. |
|
287 |
||
288 |
\item @{ML dresolve_tac}~@{text "thms i"} performs |
|
289 |
destruct-resolution with the given theorems, which should normally |
|
290 |
be destruction rules. This replaces an assumption by the result of |
|
291 |
applying one of the rules. |
|
292 |
||
293 |
\item @{ML forward_tac} is like @{ML dresolve_tac} except that the |
|
294 |
selected assumption is not deleted. It applies a rule to an |
|
295 |
assumption, adding the result as a new assumption. |
|
296 |
||
297 |
\item @{ML assume_tac}~@{text i} attempts to solve subgoal @{text i} |
|
298 |
by assumption (modulo higher-order unification). |
|
299 |
||
300 |
\item @{ML eq_assume_tac} is similar to @{ML assume_tac}, but checks |
|
301 |
only for immediate @{text "\<alpha>"}-convertibility instead of using |
|
302 |
unification. It succeeds (with a unique next state) if one of the |
|
303 |
assumptions is equal to the subgoal's conclusion. Since it does not |
|
304 |
instantiate variables, it cannot make other subgoals unprovable. |
|
305 |
||
306 |
\item @{ML match_tac}, @{ML ematch_tac}, and @{ML dmatch_tac} are |
|
307 |
similar to @{ML resolve_tac}, @{ML eresolve_tac}, and @{ML |
|
308 |
dresolve_tac}, respectively, but do not instantiate schematic |
|
309 |
variables in the goal state. |
|
310 |
||
311 |
Flexible subgoals are not updated at will, but are left alone. |
|
312 |
Strictly speaking, matching means to treat the unknowns in the goal |
|
313 |
state as constants; these tactics merely discard unifiers that would |
|
314 |
update the goal state. |
|
315 |
||
316 |
\end{description} |
|
317 |
*} |
|
318 |
||
319 |
||
28785
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
320 |
subsection {* Explicit instantiation within a subgoal context *} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
321 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
322 |
text {* The main resolution tactics (\secref{sec:resolve-assume-tac}) |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
323 |
use higher-order unification, which works well in many practical |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
324 |
situations despite its daunting theoretical properties. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
325 |
Nonetheless, there are important problem classes where unguided |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
326 |
higher-order unification is not so useful. This typically involves |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
327 |
rules like universal elimination, existential introduction, or |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
328 |
equational substitution. Here the unification problem involves |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
329 |
fully flexible @{text "?P ?x"} schemes, which are hard to manage |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
330 |
without further hints. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
331 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
332 |
By providing a (small) rigid term for @{text "?x"} explicitly, the |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
333 |
remaining unification problem is to assign a (large) term to @{text |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
334 |
"?P"}, according to the shape of the given subgoal. This is |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
335 |
sufficiently well-behaved in most practical situations. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
336 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
337 |
\medskip Isabelle provides separate versions of the standard @{text |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
338 |
"r/e/d/f"} resolution tactics that allow to provide explicit |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
339 |
instantiations of unknowns of the given rule, wrt.\ terms that refer |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
340 |
to the implicit context of the selected subgoal. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
341 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
342 |
An instantiation consists of a list of pairs of the form @{text |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
343 |
"(?x, t)"}, where @{text ?x} is a schematic variable occurring in |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
344 |
the given rule, and @{text t} is a term from the current proof |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
345 |
context, augmented by the local goal parameters of the selected |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
346 |
subgoal; cf.\ the @{text "focus"} operation described in |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
347 |
\secref{sec:variables}. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
348 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
349 |
Entering the syntactic context of a subgoal is a brittle operation, |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
350 |
because its exact form is somewhat accidental, and the choice of |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
351 |
bound variable names depends on the presence of other local and |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
352 |
global names. Explicit renaming of subgoal parameters prior to |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
353 |
explicit instantiation might help to achieve a bit more robustness. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
354 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
355 |
Type instantiations may be given as well, via pairs like @{text |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
356 |
"(?'a, \<tau>)"}. Type instantiations are distinguished from term |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
357 |
instantiations by the syntactic form of the schematic variable. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
358 |
Types are instantiated before terms are. Since term instantiation |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
359 |
already performs type-inference as expected, explicit type |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
360 |
instantiations are seldom necessary. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
361 |
*} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
362 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
363 |
text %mlref {* |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
364 |
\begin{mldecls} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
365 |
@{index_ML res_inst_tac: "Proof.context -> (indexname * string) list -> thm -> int -> tactic"} \\ |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
366 |
@{index_ML eres_inst_tac: "Proof.context -> (indexname * string) list -> thm -> int -> tactic"} \\ |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
367 |
@{index_ML dres_inst_tac: "Proof.context -> (indexname * string) list -> thm -> int -> tactic"} \\ |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
368 |
@{index_ML forw_inst_tac: "Proof.context -> (indexname * string) list -> thm -> int -> tactic"} \\[1ex] |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
369 |
@{index_ML rename_tac: "string list -> int -> tactic"} \\ |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
370 |
\end{mldecls} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
371 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
372 |
\begin{description} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
373 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
374 |
\item @{ML res_inst_tac}~@{text "ctxt insts thm i"} instantiates the |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
375 |
rule @{text thm} with the instantiations @{text insts}, as described |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
376 |
above, and then performs resolution on subgoal @{text i}. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
377 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
378 |
\item @{ML eres_inst_tac} is like @{ML res_inst_tac}, but performs |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
379 |
elim-resolution. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
380 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
381 |
\item @{ML dres_inst_tac} is like @{ML res_inst_tac}, but performs |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
382 |
destruct-resolution. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
383 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
384 |
\item @{ML forw_inst_tac} is like @{ML dres_inst_tac} except that |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
385 |
the selected assumption is not deleted. |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
386 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
387 |
\item @{ML rename_tac}~@{text "names i"} renames the innermost |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
388 |
parameters of subgoal @{text i} according to the provided @{text |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
389 |
names} (which need to be distinct indentifiers). |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
390 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
391 |
\end{description} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
392 |
*} |
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
393 |
|
64163cddf3e6
added section "Explicit instantiation within a subgoal context";
wenzelm
parents:
28783
diff
changeset
|
394 |
|
28781 | 395 |
section {* Tacticals \label{sec:tacticals} *} |
18537 | 396 |
|
397 |
text {* |
|
29758 | 398 |
A \emph{tactical} is a functional combinator for building up complex |
399 |
tactics from simpler ones. Typical tactical perform sequential |
|
400 |
composition, disjunction (choice), iteration, or goal addressing. |
|
401 |
Various search strategies may be expressed via tacticals. |
|
18537 | 402 |
|
29758 | 403 |
\medskip FIXME |
18537 | 404 |
*} |
30272 | 405 |
|
18537 | 406 |
end |