author | wenzelm |
Wed, 15 Feb 2012 17:49:03 +0100 | |
changeset 46484 | 50fca9d09528 |
parent 46295 | 2548a85b0e02 |
child 46487 | e641f8a9f0b7 |
permissions | -rw-r--r-- |
30184
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
17818
diff
changeset
|
1 |
|
104 | 2 |
\chapter{Tactics} \label{tactics} |
30184
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
17818
diff
changeset
|
3 |
\index{tactics|(} |
104 | 4 |
|
5 |
\section{Other basic tactics} |
|
6 |
||
7 |
\subsection{Inserting premises and facts}\label{cut_facts_tac} |
|
323 | 8 |
\index{tactics!for inserting facts}\index{assumptions!inserting} |
104 | 9 |
\begin{ttbox} |
10 |
cut_facts_tac : thm list -> int -> tactic |
|
286 | 11 |
cut_inst_tac : (string*string)list -> thm -> int -> tactic |
104 | 12 |
\end{ttbox} |
2039
79c86b966257
Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents:
1212
diff
changeset
|
13 |
These tactics add assumptions to a subgoal. |
323 | 14 |
\begin{ttdescription} |
104 | 15 |
\item[\ttindexbold{cut_facts_tac} {\it thms} {\it i}] |
16 |
adds the {\it thms} as new assumptions to subgoal~$i$. Once they have |
|
286 | 17 |
been inserted as assumptions, they become subject to tactics such as {\tt |
18 |
eresolve_tac} and {\tt rewrite_goals_tac}. Only rules with no premises |
|
19 |
are inserted: Isabelle cannot use assumptions that contain $\Imp$ |
|
20 |
or~$\Forall$. Sometimes the theorems are premises of a rule being |
|
21 |
derived, returned by~{\tt goal}; instead of calling this tactic, you |
|
22 |
could state the goal with an outermost meta-quantifier. |
|
23 |
||
24 |
\item[\ttindexbold{cut_inst_tac} {\it insts} {\it thm} {\it i}] |
|
25 |
instantiates the {\it thm} with the instantiations {\it insts}, as |
|
7491 | 26 |
described in {\S}\ref{res_inst_tac}. It adds the resulting theorem as a |
286 | 27 |
new assumption to subgoal~$i$. |
104 | 28 |
|
323 | 29 |
\end{ttdescription} |
104 | 30 |
|
31 |
||
32 |
\subsection{Composition: resolution without lifting} |
|
323 | 33 |
\index{tactics!for composition} |
104 | 34 |
\begin{ttbox} |
35 |
compose_tac: (bool * thm * int) -> int -> tactic |
|
36 |
\end{ttbox} |
|
332 | 37 |
{\bf Composing} two rules means resolving them without prior lifting or |
104 | 38 |
renaming of unknowns. This low-level operation, which underlies the |
39 |
resolution tactics, may occasionally be useful for special effects. |
|
40 |
A typical application is \ttindex{res_inst_tac}, which lifts and instantiates a |
|
41 |
rule, then passes the result to {\tt compose_tac}. |
|
323 | 42 |
\begin{ttdescription} |
104 | 43 |
\item[\ttindexbold{compose_tac} ($flag$, $rule$, $m$) $i$] |
44 |
refines subgoal~$i$ using $rule$, without lifting. The $rule$ is taken to |
|
45 |
have the form $\List{\psi@1; \ldots; \psi@m} \Imp \psi$, where $\psi$ need |
|
323 | 46 |
not be atomic; thus $m$ determines the number of new subgoals. If |
104 | 47 |
$flag$ is {\tt true} then it performs elim-resolution --- it solves the |
48 |
first premise of~$rule$ by assumption and deletes that assumption. |
|
323 | 49 |
\end{ttdescription} |
104 | 50 |
|
51 |
||
4276 | 52 |
\section{*Managing lots of rules} |
104 | 53 |
These operations are not intended for interactive use. They are concerned |
54 |
with the processing of large numbers of rules in automatic proof |
|
55 |
strategies. Higher-order resolution involving a long list of rules is |
|
56 |
slow. Filtering techniques can shorten the list of rules given to |
|
2039
79c86b966257
Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents:
1212
diff
changeset
|
57 |
resolution, and can also detect whether a subgoal is too flexible, |
104 | 58 |
with too many rules applicable. |
59 |
||
60 |
\subsection{Combined resolution and elim-resolution} \label{biresolve_tac} |
|
61 |
\index{tactics!resolution} |
|
62 |
\begin{ttbox} |
|
63 |
biresolve_tac : (bool*thm)list -> int -> tactic |
|
64 |
bimatch_tac : (bool*thm)list -> int -> tactic |
|
65 |
subgoals_of_brl : bool*thm -> int |
|
66 |
lessb : (bool*thm) * (bool*thm) -> bool |
|
67 |
\end{ttbox} |
|
68 |
{\bf Bi-resolution} takes a list of $\it (flag,rule)$ pairs. For each |
|
69 |
pair, it applies resolution if the flag is~{\tt false} and |
|
70 |
elim-resolution if the flag is~{\tt true}. A single tactic call handles a |
|
71 |
mixture of introduction and elimination rules. |
|
72 |
||
323 | 73 |
\begin{ttdescription} |
104 | 74 |
\item[\ttindexbold{biresolve_tac} {\it brls} {\it i}] |
75 |
refines the proof state by resolution or elim-resolution on each rule, as |
|
76 |
indicated by its flag. It affects subgoal~$i$ of the proof state. |
|
77 |
||
78 |
\item[\ttindexbold{bimatch_tac}] |
|
79 |
is like {\tt biresolve_tac}, but performs matching: unknowns in the |
|
7491 | 80 |
proof state are never updated (see~{\S}\ref{match_tac}). |
104 | 81 |
|
82 |
\item[\ttindexbold{subgoals_of_brl}({\it flag},{\it rule})] |
|
4597
a0bdee64194c
Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents:
4317
diff
changeset
|
83 |
returns the number of new subgoals that bi-res\-o\-lu\-tion would yield for the |
104 | 84 |
pair (if applied to a suitable subgoal). This is $n$ if the flag is |
85 |
{\tt false} and $n-1$ if the flag is {\tt true}, where $n$ is the number |
|
86 |
of premises of the rule. Elim-resolution yields one fewer subgoal than |
|
87 |
ordinary resolution because it solves the major premise by assumption. |
|
88 |
||
89 |
\item[\ttindexbold{lessb} ({\it brl1},{\it brl2})] |
|
90 |
returns the result of |
|
91 |
\begin{ttbox} |
|
332 | 92 |
subgoals_of_brl{\it brl1} < subgoals_of_brl{\it brl2} |
104 | 93 |
\end{ttbox} |
323 | 94 |
\end{ttdescription} |
104 | 95 |
Note that \hbox{\tt sort lessb {\it brls}} sorts a list of $\it |
96 |
(flag,rule)$ pairs by the number of new subgoals they will yield. Thus, |
|
97 |
those that yield the fewest subgoals should be tried first. |
|
98 |
||
99 |
||
323 | 100 |
\subsection{Discrimination nets for fast resolution}\label{filt_resolve_tac} |
104 | 101 |
\index{discrimination nets|bold} |
102 |
\index{tactics!resolution} |
|
103 |
\begin{ttbox} |
|
104 |
net_resolve_tac : thm list -> int -> tactic |
|
105 |
net_match_tac : thm list -> int -> tactic |
|
106 |
net_biresolve_tac: (bool*thm) list -> int -> tactic |
|
107 |
net_bimatch_tac : (bool*thm) list -> int -> tactic |
|
108 |
filt_resolve_tac : thm list -> int -> int -> tactic |
|
109 |
could_unify : term*term->bool |
|
8136 | 110 |
filter_thms : (term*term->bool) -> int*term*thm list -> thm{\ts}list |
104 | 111 |
\end{ttbox} |
323 | 112 |
The module {\tt Net} implements a discrimination net data structure for |
104 | 113 |
fast selection of rules \cite[Chapter 14]{charniak80}. A term is |
114 |
classified by the symbol list obtained by flattening it in preorder. |
|
115 |
The flattening takes account of function applications, constants, and free |
|
116 |
and bound variables; it identifies all unknowns and also regards |
|
323 | 117 |
\index{lambda abs@$\lambda$-abstractions} |
104 | 118 |
$\lambda$-abstractions as unknowns, since they could $\eta$-contract to |
119 |
anything. |
|
120 |
||
121 |
A discrimination net serves as a polymorphic dictionary indexed by terms. |
|
122 |
The module provides various functions for inserting and removing items from |
|
123 |
nets. It provides functions for returning all items whose term could match |
|
124 |
or unify with a target term. The matching and unification tests are |
|
125 |
overly lax (due to the identifications mentioned above) but they serve as |
|
126 |
useful filters. |
|
127 |
||
128 |
A net can store introduction rules indexed by their conclusion, and |
|
129 |
elimination rules indexed by their major premise. Isabelle provides |
|
323 | 130 |
several functions for `compiling' long lists of rules into fast |
104 | 131 |
resolution tactics. When supplied with a list of theorems, these functions |
132 |
build a discrimination net; the net is used when the tactic is applied to a |
|
332 | 133 |
goal. To avoid repeatedly constructing the nets, use currying: bind the |
104 | 134 |
resulting tactics to \ML{} identifiers. |
135 |
||
323 | 136 |
\begin{ttdescription} |
104 | 137 |
\item[\ttindexbold{net_resolve_tac} {\it thms}] |
138 |
builds a discrimination net to obtain the effect of a similar call to {\tt |
|
139 |
resolve_tac}. |
|
140 |
||
141 |
\item[\ttindexbold{net_match_tac} {\it thms}] |
|
142 |
builds a discrimination net to obtain the effect of a similar call to {\tt |
|
143 |
match_tac}. |
|
144 |
||
145 |
\item[\ttindexbold{net_biresolve_tac} {\it brls}] |
|
146 |
builds a discrimination net to obtain the effect of a similar call to {\tt |
|
147 |
biresolve_tac}. |
|
148 |
||
149 |
\item[\ttindexbold{net_bimatch_tac} {\it brls}] |
|
150 |
builds a discrimination net to obtain the effect of a similar call to {\tt |
|
151 |
bimatch_tac}. |
|
152 |
||
153 |
\item[\ttindexbold{filt_resolve_tac} {\it thms} {\it maxr} {\it i}] |
|
154 |
uses discrimination nets to extract the {\it thms} that are applicable to |
|
155 |
subgoal~$i$. If more than {\it maxr\/} theorems are applicable then the |
|
156 |
tactic fails. Otherwise it calls {\tt resolve_tac}. |
|
157 |
||
158 |
This tactic helps avoid runaway instantiation of unknowns, for example in |
|
159 |
type inference. |
|
160 |
||
161 |
\item[\ttindexbold{could_unify} ({\it t},{\it u})] |
|
323 | 162 |
returns {\tt false} if~$t$ and~$u$ are `obviously' non-unifiable, and |
104 | 163 |
otherwise returns~{\tt true}. It assumes all variables are distinct, |
164 |
reporting that {\tt ?a=?a} may unify with {\tt 0=1}. |
|
165 |
||
166 |
\item[\ttindexbold{filter_thms} $could\; (limit,prem,thms)$] |
|
167 |
returns the list of potentially resolvable rules (in {\it thms\/}) for the |
|
168 |
subgoal {\it prem}, using the predicate {\it could\/} to compare the |
|
169 |
conclusion of the subgoal with the conclusion of each rule. The resulting list |
|
170 |
is no longer than {\it limit}. |
|
323 | 171 |
\end{ttdescription} |
104 | 172 |
|
173 |
\index{tactics|)} |
|
5371 | 174 |
|
175 |
||
176 |
%%% Local Variables: |
|
177 |
%%% mode: latex |
|
178 |
%%% TeX-master: "ref" |
|
179 |
%%% End: |