21 not be atomic; thus $m$ determines the number of new subgoals. If |
21 not be atomic; thus $m$ determines the number of new subgoals. If |
22 $flag$ is {\tt true} then it performs elim-resolution --- it solves the |
22 $flag$ is {\tt true} then it performs elim-resolution --- it solves the |
23 first premise of~$rule$ by assumption and deletes that assumption. |
23 first premise of~$rule$ by assumption and deletes that assumption. |
24 \end{ttdescription} |
24 \end{ttdescription} |
25 |
25 |
26 |
|
27 \section{*Managing lots of rules} |
|
28 These operations are not intended for interactive use. They are concerned |
|
29 with the processing of large numbers of rules in automatic proof |
|
30 strategies. Higher-order resolution involving a long list of rules is |
|
31 slow. Filtering techniques can shorten the list of rules given to |
|
32 resolution, and can also detect whether a subgoal is too flexible, |
|
33 with too many rules applicable. |
|
34 |
|
35 |
|
36 \subsection{Discrimination nets for fast resolution}\label{filt_resolve_tac} |
|
37 \index{discrimination nets|bold} |
|
38 \index{tactics!resolution} |
|
39 \begin{ttbox} |
|
40 net_resolve_tac : thm list -> int -> tactic |
|
41 net_match_tac : thm list -> int -> tactic |
|
42 net_biresolve_tac: (bool*thm) list -> int -> tactic |
|
43 net_bimatch_tac : (bool*thm) list -> int -> tactic |
|
44 filt_resolve_tac : thm list -> int -> int -> tactic |
|
45 could_unify : term*term->bool |
|
46 filter_thms : (term*term->bool) -> int*term*thm list -> thm{\ts}list |
|
47 \end{ttbox} |
|
48 The module {\tt Net} implements a discrimination net data structure for |
|
49 fast selection of rules \cite[Chapter 14]{charniak80}. A term is |
|
50 classified by the symbol list obtained by flattening it in preorder. |
|
51 The flattening takes account of function applications, constants, and free |
|
52 and bound variables; it identifies all unknowns and also regards |
|
53 \index{lambda abs@$\lambda$-abstractions} |
|
54 $\lambda$-abstractions as unknowns, since they could $\eta$-contract to |
|
55 anything. |
|
56 |
|
57 A discrimination net serves as a polymorphic dictionary indexed by terms. |
|
58 The module provides various functions for inserting and removing items from |
|
59 nets. It provides functions for returning all items whose term could match |
|
60 or unify with a target term. The matching and unification tests are |
|
61 overly lax (due to the identifications mentioned above) but they serve as |
|
62 useful filters. |
|
63 |
|
64 A net can store introduction rules indexed by their conclusion, and |
|
65 elimination rules indexed by their major premise. Isabelle provides |
|
66 several functions for `compiling' long lists of rules into fast |
|
67 resolution tactics. When supplied with a list of theorems, these functions |
|
68 build a discrimination net; the net is used when the tactic is applied to a |
|
69 goal. To avoid repeatedly constructing the nets, use currying: bind the |
|
70 resulting tactics to \ML{} identifiers. |
|
71 |
|
72 \begin{ttdescription} |
|
73 \item[\ttindexbold{net_resolve_tac} {\it thms}] |
|
74 builds a discrimination net to obtain the effect of a similar call to {\tt |
|
75 resolve_tac}. |
|
76 |
|
77 \item[\ttindexbold{net_match_tac} {\it thms}] |
|
78 builds a discrimination net to obtain the effect of a similar call to {\tt |
|
79 match_tac}. |
|
80 |
|
81 \item[\ttindexbold{net_biresolve_tac} {\it brls}] |
|
82 builds a discrimination net to obtain the effect of a similar call to {\tt |
|
83 biresolve_tac}. |
|
84 |
|
85 \item[\ttindexbold{net_bimatch_tac} {\it brls}] |
|
86 builds a discrimination net to obtain the effect of a similar call to {\tt |
|
87 bimatch_tac}. |
|
88 |
|
89 \item[\ttindexbold{filt_resolve_tac} {\it thms} {\it maxr} {\it i}] |
|
90 uses discrimination nets to extract the {\it thms} that are applicable to |
|
91 subgoal~$i$. If more than {\it maxr\/} theorems are applicable then the |
|
92 tactic fails. Otherwise it calls {\tt resolve_tac}. |
|
93 |
|
94 This tactic helps avoid runaway instantiation of unknowns, for example in |
|
95 type inference. |
|
96 |
|
97 \item[\ttindexbold{could_unify} ({\it t},{\it u})] |
|
98 returns {\tt false} if~$t$ and~$u$ are `obviously' non-unifiable, and |
|
99 otherwise returns~{\tt true}. It assumes all variables are distinct, |
|
100 reporting that {\tt ?a=?a} may unify with {\tt 0=1}. |
|
101 |
|
102 \item[\ttindexbold{filter_thms} $could\; (limit,prem,thms)$] |
|
103 returns the list of potentially resolvable rules (in {\it thms\/}) for the |
|
104 subgoal {\it prem}, using the predicate {\it could\/} to compare the |
|
105 conclusion of the subgoal with the conclusion of each rule. The resulting list |
|
106 is no longer than {\it limit}. |
|
107 \end{ttdescription} |
|
108 |
|
109 \index{tactics|)} |
|
110 |
|
111 |
|
112 %%% Local Variables: |
26 %%% Local Variables: |
113 %%% mode: latex |
27 %%% mode: latex |
114 %%% TeX-master: "ref" |
28 %%% TeX-master: "ref" |
115 %%% End: |
29 %%% End: |