doc-src/Ref/tactic.tex
author wenzelm
Fri, 27 Jan 2012 21:29:37 +0100
changeset 46271 e1b5460f1725
parent 46257 3ba3681d8930
child 46274 67139209b548
permissions -rw-r--r--
updated subgoal_tac;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30184
37969710e61f removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents: 17818
diff changeset
     1
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     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
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     4
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     5
\section{Other basic tactics}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     6
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     7
\subsection{Inserting premises and facts}\label{cut_facts_tac}
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
     8
\index{tactics!for inserting facts}\index{assumptions!inserting}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     9
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    10
cut_facts_tac : thm list -> int -> tactic
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    11
cut_inst_tac  : (string*string)list -> thm -> int -> tactic
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    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
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    14
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    15
\item[\ttindexbold{cut_facts_tac} {\it thms} {\it i}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    16
  adds the {\it thms} as new assumptions to subgoal~$i$.  Once they have
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    17
  been inserted as assumptions, they become subject to tactics such as {\tt
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    18
    eresolve_tac} and {\tt rewrite_goals_tac}.  Only rules with no premises
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    19
  are inserted: Isabelle cannot use assumptions that contain $\Imp$
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    20
  or~$\Forall$.  Sometimes the theorems are premises of a rule being
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    21
  derived, returned by~{\tt goal}; instead of calling this tactic, you
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    22
  could state the goal with an outermost meta-quantifier.
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    23
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    24
\item[\ttindexbold{cut_inst_tac} {\it insts} {\it thm} {\it i}]
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    25
  instantiates the {\it thm} with the instantiations {\it insts}, as
7491
95a4af0e10a7 added ftac, eatac, datac, fatac
oheimb
parents: 6618
diff changeset
    26
  described in {\S}\ref{res_inst_tac}.  It adds the resulting theorem as a
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    27
  new assumption to subgoal~$i$. 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    28
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    29
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    30
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    31
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    32
\subsection{Definitions and meta-level rewriting} \label{sec:rewrite_goals}
2039
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    33
\index{tactics!meta-rewriting|bold}\index{meta-rewriting|bold}
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    34
\index{definitions}
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    35
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    36
Definitions in Isabelle have the form $t\equiv u$, where $t$ is typically a
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    37
constant or a constant applied to a list of variables, for example $\it
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    38
sqr(n)\equiv n\times n$.  Conditional definitions, $\phi\Imp t\equiv u$,
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    39
are also supported.  {\bf Unfolding} the definition ${t\equiv u}$ means using
2039
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    40
it as a rewrite rule, replacing~$t$ by~$u$ throughout a theorem.  {\bf
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    41
Folding} $t\equiv u$ means replacing~$u$ by~$t$.  Rewriting continues until
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    42
no rewrites are applicable to any subterm.
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    43
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    44
There are rules for unfolding and folding definitions; Isabelle does not do
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    45
this automatically.  The corresponding tactics rewrite the proof state,
46257
3ba3681d8930 removed obscure/outdated material;
wenzelm
parents: 30184
diff changeset
    46
yielding a single next state.
2039
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    47
\begin{ttbox} 
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    48
rewrite_goals_tac : thm list -> tactic
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    49
fold_goals_tac    : thm list -> tactic
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    50
\end{ttbox}
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    51
\begin{ttdescription}
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    52
\item[\ttindexbold{rewrite_goals_tac} {\it defs}]  
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    53
unfolds the {\it defs} throughout the subgoals of the proof state, while
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    54
leaving the main goal unchanged.  Use \ttindex{SELECT_GOAL} to restrict it to a
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    55
particular subgoal.
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    56
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    57
\item[\ttindexbold{fold_goals_tac} {\it defs}]  
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    58
folds the {\it defs} throughout the subgoals of the proof state, while
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    59
leaving the main goal unchanged.
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    60
\end{ttdescription}
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    61
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    62
\begin{warn}
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    63
  These tactics only cope with definitions expressed as meta-level
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    64
  equalities ($\equiv$).  More general equivalences are handled by the
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    65
  simplifier, provided that it is set up appropriately for your logic
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    66
  (see Chapter~\ref{chap:simplification}).
7264fa2ff2ec several minor updates;
wenzelm
parents: 4276
diff changeset
    67
\end{warn}
2039
79c86b966257 Documented defer_tac and moved back the obsolete tactics like fold_tac
paulson
parents: 1212
diff changeset
    68
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    69
\subsection{Theorems useful with tactics}
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    70
\index{theorems!of pure theory}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    71
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    72
asm_rl: thm 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    73
cut_rl: thm 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    74
\end{ttbox}
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    75
\begin{ttdescription}
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    76
\item[\tdx{asm_rl}] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    77
is $\psi\Imp\psi$.  Under elim-resolution it does proof by assumption, and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    78
\hbox{\tt eresolve_tac (asm_rl::{\it thms}) {\it i}} is equivalent to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    79
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    80
assume_tac {\it i}  ORELSE  eresolve_tac {\it thms} {\it i}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    81
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    82
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    83
\item[\tdx{cut_rl}] 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    84
is $\List{\psi\Imp\theta,\psi}\Imp\theta$.  It is useful for inserting
46271
e1b5460f1725 updated subgoal_tac;
wenzelm
parents: 46257
diff changeset
    85
assumptions; it underlies {\tt forward_tac}, {\tt cut_facts_tac}.
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
    86
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    87
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    88
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    89
\section{Obscure tactics}
1212
7059356e18e0 added rotate_tac
nipkow
parents: 457
diff changeset
    90
2612
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    91
\subsection{Manipulating assumptions}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    92
\index{assumptions!rotating}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    93
\begin{ttbox} 
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    94
thin_tac   : string -> int -> tactic
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    95
rotate_tac : int -> int -> tactic
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    96
\end{ttbox}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    97
\begin{ttdescription}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    98
\item[\ttindexbold{thin_tac} {\it formula} $i$]  
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
    99
\index{assumptions!deleting}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   100
deletes the specified assumption from subgoal $i$.  Often the assumption
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   101
can be abbreviated, replacing subformul{\ae} by unknowns; the first matching
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   102
assumption will be deleted.  Removing useless assumptions from a subgoal
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   103
increases its readability and can make search tactics run faster.
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   104
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   105
\item[\ttindexbold{rotate_tac} $n$ $i$]  
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   106
\index{assumptions!rotating}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   107
rotates the assumptions of subgoal $i$ by $n$ positions: from right to left
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   108
if $n$ is positive, and from left to right if $n$ is negative.  This is 
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   109
sometimes necessary in connection with \ttindex{asm_full_simp_tac}, which 
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   110
processes assumptions from left to right.
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   111
\end{ttdescription}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   112
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   113
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   114
\subsection{Tidying the proof state}
3400
80c979e0d42f Documented the new distinct_subgoals_tac
paulson
parents: 3108
diff changeset
   115
\index{duplicate subgoals!removing}
2612
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   116
\index{parameters!removing unused}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   117
\index{flex-flex constraints}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   118
\begin{ttbox} 
3400
80c979e0d42f Documented the new distinct_subgoals_tac
paulson
parents: 3108
diff changeset
   119
distinct_subgoals_tac : tactic
80c979e0d42f Documented the new distinct_subgoals_tac
paulson
parents: 3108
diff changeset
   120
prune_params_tac      : tactic
80c979e0d42f Documented the new distinct_subgoals_tac
paulson
parents: 3108
diff changeset
   121
flexflex_tac          : tactic
2612
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   122
\end{ttbox}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   123
\begin{ttdescription}
9695
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 9568
diff changeset
   124
\item[\ttindexbold{distinct_subgoals_tac}] removes duplicate subgoals from a
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 9568
diff changeset
   125
  proof state.  (These arise especially in ZF, where the subgoals are
ec7d7f877712 proper setup of iman.sty/extra.sty/ttbox.sty;
wenzelm
parents: 9568
diff changeset
   126
  essentially type constraints.)
3400
80c979e0d42f Documented the new distinct_subgoals_tac
paulson
parents: 3108
diff changeset
   127
2612
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   128
\item[\ttindexbold{prune_params_tac}]  
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   129
  removes unused parameters from all subgoals of the proof state.  It works
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   130
  by rewriting with the theorem $(\Forall x. V)\equiv V$.  This tactic can
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   131
  make the proof state more readable.  It is used with
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   132
  \ttindex{rule_by_tactic} to simplify the resulting theorem.
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   133
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   134
\item[\ttindexbold{flexflex_tac}]  
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   135
  removes all flex-flex pairs from the proof state by applying the trivial
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   136
  unifier.  This drastic step loses information, and should only be done as
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   137
  the last step of a proof.
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   138
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   139
  Flex-flex constraints arise from difficult cases of higher-order
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   140
  unification.  To prevent this, use \ttindex{res_inst_tac} to instantiate
7491
95a4af0e10a7 added ftac, eatac, datac, fatac
oheimb
parents: 6618
diff changeset
   141
  some variables in a rule~({\S}\ref{res_inst_tac}).  Normally flex-flex
2612
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   142
  constraints can be ignored; they often disappear as unknowns get
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   143
  instantiated.
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   144
\end{ttdescription}
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   145
28232396b60e Documented thin_tac
paulson
parents: 2039
diff changeset
   146
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   147
\subsection{Composition: resolution without lifting}
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   148
\index{tactics!for composition}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   149
\begin{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   150
compose_tac: (bool * thm * int) -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   151
\end{ttbox}
332
01b87a921967 final Springer copy
lcp
parents: 323
diff changeset
   152
{\bf Composing} two rules means resolving them without prior lifting or
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   153
renaming of unknowns.  This low-level operation, which underlies the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   154
resolution tactics, may occasionally be useful for special effects.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   155
A typical application is \ttindex{res_inst_tac}, which lifts and instantiates a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   156
rule, then passes the result to {\tt compose_tac}.
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   157
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   158
\item[\ttindexbold{compose_tac} ($flag$, $rule$, $m$) $i$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   159
refines subgoal~$i$ using $rule$, without lifting.  The $rule$ is taken to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   160
have the form $\List{\psi@1; \ldots; \psi@m} \Imp \psi$, where $\psi$ need
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   161
not be atomic; thus $m$ determines the number of new subgoals.  If
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   162
$flag$ is {\tt true} then it performs elim-resolution --- it solves the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   163
first premise of~$rule$ by assumption and deletes that assumption.
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   164
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   165
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   166
4276
a770eae2cdb0 changed Pure/Sequence interface;
wenzelm
parents: 3950
diff changeset
   167
\section{*Managing lots of rules}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   168
These operations are not intended for interactive use.  They are concerned
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   169
with the processing of large numbers of rules in automatic proof
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   170
strategies.  Higher-order resolution involving a long list of rules is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   171
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
   172
resolution, and can also detect whether a subgoal is too flexible,
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   173
with too many rules applicable.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   174
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   175
\subsection{Combined resolution and elim-resolution} \label{biresolve_tac}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   176
\index{tactics!resolution}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   177
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   178
biresolve_tac   : (bool*thm)list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   179
bimatch_tac     : (bool*thm)list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   180
subgoals_of_brl : bool*thm -> int
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   181
lessb           : (bool*thm) * (bool*thm) -> bool
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   182
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   183
{\bf Bi-resolution} takes a list of $\it (flag,rule)$ pairs.  For each
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   184
pair, it applies resolution if the flag is~{\tt false} and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   185
elim-resolution if the flag is~{\tt true}.  A single tactic call handles a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   186
mixture of introduction and elimination rules.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   187
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   188
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   189
\item[\ttindexbold{biresolve_tac} {\it brls} {\it i}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   190
refines the proof state by resolution or elim-resolution on each rule, as
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   191
indicated by its flag.  It affects subgoal~$i$ of the proof state.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   192
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   193
\item[\ttindexbold{bimatch_tac}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   194
is like {\tt biresolve_tac}, but performs matching: unknowns in the
7491
95a4af0e10a7 added ftac, eatac, datac, fatac
oheimb
parents: 6618
diff changeset
   195
proof state are never updated (see~{\S}\ref{match_tac}).
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   196
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   197
\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
   198
returns the number of new subgoals that bi-res\-o\-lu\-tion would yield for the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   199
pair (if applied to a suitable subgoal).  This is $n$ if the flag is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   200
{\tt false} and $n-1$ if the flag is {\tt true}, where $n$ is the number
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   201
of premises of the rule.  Elim-resolution yields one fewer subgoal than
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   202
ordinary resolution because it solves the major premise by assumption.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   203
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   204
\item[\ttindexbold{lessb} ({\it brl1},{\it brl2})] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   205
returns the result of 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   206
\begin{ttbox}
332
01b87a921967 final Springer copy
lcp
parents: 323
diff changeset
   207
subgoals_of_brl{\it brl1} < subgoals_of_brl{\it brl2}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   208
\end{ttbox}
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   209
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   210
Note that \hbox{\tt sort lessb {\it brls}} sorts a list of $\it
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   211
(flag,rule)$ pairs by the number of new subgoals they will yield.  Thus,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   212
those that yield the fewest subgoals should be tried first.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   213
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   214
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   215
\subsection{Discrimination nets for fast resolution}\label{filt_resolve_tac}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   216
\index{discrimination nets|bold}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   217
\index{tactics!resolution}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   218
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   219
net_resolve_tac  : thm list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   220
net_match_tac    : thm list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   221
net_biresolve_tac: (bool*thm) list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   222
net_bimatch_tac  : (bool*thm) list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   223
filt_resolve_tac : thm list -> int -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   224
could_unify      : term*term->bool
8136
8c65f3ca13f2 fixed many bad line & page breaks
paulson
parents: 7491
diff changeset
   225
filter_thms      : (term*term->bool) -> int*term*thm list -> thm{\ts}list
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   226
\end{ttbox}
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   227
The module {\tt Net} implements a discrimination net data structure for
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   228
fast selection of rules \cite[Chapter 14]{charniak80}.  A term is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   229
classified by the symbol list obtained by flattening it in preorder.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   230
The flattening takes account of function applications, constants, and free
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   231
and bound variables; it identifies all unknowns and also regards
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   232
\index{lambda abs@$\lambda$-abstractions}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   233
$\lambda$-abstractions as unknowns, since they could $\eta$-contract to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   234
anything.  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   235
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   236
A discrimination net serves as a polymorphic dictionary indexed by terms.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   237
The module provides various functions for inserting and removing items from
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   238
nets.  It provides functions for returning all items whose term could match
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   239
or unify with a target term.  The matching and unification tests are
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   240
overly lax (due to the identifications mentioned above) but they serve as
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   241
useful filters.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   242
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   243
A net can store introduction rules indexed by their conclusion, and
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   244
elimination rules indexed by their major premise.  Isabelle provides
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   245
several functions for `compiling' long lists of rules into fast
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   246
resolution tactics.  When supplied with a list of theorems, these functions
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   247
build a discrimination net; the net is used when the tactic is applied to a
332
01b87a921967 final Springer copy
lcp
parents: 323
diff changeset
   248
goal.  To avoid repeatedly constructing the nets, use currying: bind the
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   249
resulting tactics to \ML{} identifiers.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   250
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   251
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   252
\item[\ttindexbold{net_resolve_tac} {\it thms}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   253
builds a discrimination net to obtain the effect of a similar call to {\tt
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   254
resolve_tac}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   255
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   256
\item[\ttindexbold{net_match_tac} {\it thms}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   257
builds a discrimination net to obtain the effect of a similar call to {\tt
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   258
match_tac}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   259
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   260
\item[\ttindexbold{net_biresolve_tac} {\it brls}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   261
builds a discrimination net to obtain the effect of a similar call to {\tt
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   262
biresolve_tac}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   263
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   264
\item[\ttindexbold{net_bimatch_tac} {\it brls}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   265
builds a discrimination net to obtain the effect of a similar call to {\tt
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   266
bimatch_tac}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   267
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   268
\item[\ttindexbold{filt_resolve_tac} {\it thms} {\it maxr} {\it i}] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   269
uses discrimination nets to extract the {\it thms} that are applicable to
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   270
subgoal~$i$.  If more than {\it maxr\/} theorems are applicable then the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   271
tactic fails.  Otherwise it calls {\tt resolve_tac}.  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   272
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   273
This tactic helps avoid runaway instantiation of unknowns, for example in
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   274
type inference.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   275
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   276
\item[\ttindexbold{could_unify} ({\it t},{\it u})] 
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   277
returns {\tt false} if~$t$ and~$u$ are `obviously' non-unifiable, and
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   278
otherwise returns~{\tt true}.  It assumes all variables are distinct,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   279
reporting that {\tt ?a=?a} may unify with {\tt 0=1}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   280
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   281
\item[\ttindexbold{filter_thms} $could\; (limit,prem,thms)$] 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   282
returns the list of potentially resolvable rules (in {\it thms\/}) for the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   283
subgoal {\it prem}, using the predicate {\it could\/} to compare the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   284
conclusion of the subgoal with the conclusion of each rule.  The resulting list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   285
is no longer than {\it limit}.
323
361a71713176 penultimate Springer draft
lcp
parents: 286
diff changeset
   286
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   287
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   288
\index{tactics|)}
5371
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   289
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   290
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   291
%%% Local Variables: 
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   292
%%% mode: latex
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   293
%%% TeX-master: "ref"
e27558a68b8d emacs local vars;
wenzelm
parents: 4607
diff changeset
   294
%%% End: