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