doc-src/Ref/classical.tex
author wenzelm
Wed, 29 Apr 1998 11:43:53 +0200
changeset 4872 33e7cdc20681
parent 4666 b7c4e4ade1aa
child 4881 d80faf83c82f
permissions -rw-r--r--
Theory.require;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
     1
%% $Id$
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
     2
\chapter{The Classical Reasoner}\label{chap:classical}
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
     3
\index{classical reasoner|(}
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
     4
\newcommand\ainfer[2]{\begin{array}{r@{\,}l}#2\\ \hline#1\end{array}}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
     5
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
     6
Although Isabelle is generic, many users will be working in some
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
     7
extension of classical first-order logic.  Isabelle's set theory~{\tt
4398
wenzelm
parents: 4317
diff changeset
     8
  ZF} is built upon theory~\texttt{FOL}, while {\HOL}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
     9
conceptually contains first-order logic as a fragment.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    10
Theorem-proving in predicate logic is undecidable, but many
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    11
researchers have developed strategies to assist in this task.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    12
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
    13
Isabelle's classical reasoner is an \ML{} functor that accepts certain
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    14
information about a logic and delivers a suite of automatic tactics.  Each
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    15
tactic takes a collection of rules and executes a simple, non-clausal proof
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    16
procedure.  They are slow and simplistic compared with resolution theorem
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    17
provers, but they can save considerable time and effort.  They can prove
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    18
theorems such as Pelletier's~\cite{pelletier86} problems~40 and~41 in
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    19
seconds:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    20
\[ (\exists y. \forall x. J(y,x) \bimp \neg J(x,x))  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    21
   \imp  \neg (\forall x. \exists y. \forall z. J(z,y) \bimp \neg J(z,x)) \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    22
\[ (\forall z. \exists y. \forall x. F(x,y) \bimp F(x,z) \conj \neg F(x,x))
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    23
   \imp \neg (\exists z. \forall x. F(x,z))  
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    24
\]
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    25
%
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    26
The tactics are generic.  They are not restricted to first-order logic, and
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    27
have been heavily used in the development of Isabelle's set theory.  Few
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    28
interactive proof assistants provide this much automation.  The tactics can
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    29
be traced, and their components can be called directly; in this manner,
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    30
any proof can be viewed interactively.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    31
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    32
The simplest way to apply the classical reasoner (to subgoal~$i$) is to type
2479
57109c1a653d Updated account of implicit simpsets and clasets
paulson
parents: 1869
diff changeset
    33
\begin{ttbox}
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
    34
by (Blast_tac \(i\));
2479
57109c1a653d Updated account of implicit simpsets and clasets
paulson
parents: 1869
diff changeset
    35
\end{ttbox}
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    36
This command quickly proves most simple formulas of the predicate calculus or
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    37
set theory.  To attempt to prove \emph{all} subgoals using a combination of
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    38
rewriting and classical reasoning, try
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
    39
\begin{ttbox}
4507
f313d8fb8f49 Auto_tac now has type tactic, not unit->tactic
paulson
parents: 4398
diff changeset
    40
by Auto_tac;
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
    41
\end{ttbox}
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    42
To do all obvious logical steps, even if they do not prove the
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
    43
subgoal, type one of the following:
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    44
\begin{ttbox}
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
    45
by (Clarify_tac \(i\));        \emph{\textrm{applies to one subgoal}}
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
    46
by Safe_tac;               \emph{\textrm{applies to all subgoals}}
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    47
\end{ttbox}
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    48
You need to know how the classical reasoner works in order to use it
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
    49
effectively.  There are many tactics to choose from, including {\tt
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
    50
  Fast_tac} and \texttt{Best_tac}.
2479
57109c1a653d Updated account of implicit simpsets and clasets
paulson
parents: 1869
diff changeset
    51
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    52
We shall first discuss the underlying principles, then present the
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    53
classical reasoner.  Finally, we shall see how to instantiate it for
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    54
new logics.  The logics \FOL, \ZF, {\HOL} and {\HOLCF} have it already
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    55
installed.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    56
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    57
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    58
\section{The sequent calculus}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    59
\index{sequent calculus}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    60
Isabelle supports natural deduction, which is easy to use for interactive
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    61
proof.  But natural deduction does not easily lend itself to automation,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    62
and has a bias towards intuitionism.  For certain proofs in classical
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    63
logic, it can not be called natural.  The {\bf sequent calculus}, a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    64
generalization of natural deduction, is easier to automate.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    65
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    66
A {\bf sequent} has the form $\Gamma\turn\Delta$, where $\Gamma$
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    67
and~$\Delta$ are sets of formulae.%
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    68
\footnote{For first-order logic, sequents can equivalently be made from
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    69
  lists or multisets of formulae.} The sequent
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    70
\[ P@1,\ldots,P@m\turn Q@1,\ldots,Q@n \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    71
is {\bf valid} if $P@1\conj\ldots\conj P@m$ implies $Q@1\disj\ldots\disj
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    72
Q@n$.  Thus $P@1,\ldots,P@m$ represent assumptions, each of which is true,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    73
while $Q@1,\ldots,Q@n$ represent alternative goals.  A sequent is {\bf
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    74
basic} if its left and right sides have a common formula, as in $P,Q\turn
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    75
Q,R$; basic sequents are trivially valid.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    76
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    77
Sequent rules are classified as {\bf right} or {\bf left}, indicating which
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    78
side of the $\turn$~symbol they operate on.  Rules that operate on the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    79
right side are analogous to natural deduction's introduction rules, and
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    80
left rules are analogous to elimination rules.  
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    81
Recall the natural deduction rules for
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    82
  first-order logic, 
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    83
\iflabelundefined{fol-fig}{from {\it Introduction to Isabelle}}%
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    84
                          {Fig.\ts\ref{fol-fig}}.
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
    85
The sequent calculus analogue of~$({\imp}I)$ is the rule
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    86
$$
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    87
\ainfer{\Gamma &\turn \Delta, P\imp Q}{P,\Gamma &\turn \Delta,Q}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    88
\eqno({\imp}R)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    89
$$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    90
This breaks down some implication on the right side of a sequent; $\Gamma$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    91
and $\Delta$ stand for the sets of formulae that are unaffected by the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    92
inference.  The analogue of the pair~$({\disj}I1)$ and~$({\disj}I2)$ is the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    93
single rule 
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    94
$$
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    95
\ainfer{\Gamma &\turn \Delta, P\disj Q}{\Gamma &\turn \Delta,P,Q}
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    96
\eqno({\disj}R)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
    97
$$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    98
This breaks down some disjunction on the right side, replacing it by both
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
    99
disjuncts.  Thus, the sequent calculus is a kind of multiple-conclusion logic.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   100
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   101
To illustrate the use of multiple formulae on the right, let us prove
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   102
the classical theorem $(P\imp Q)\disj(Q\imp P)$.  Working backwards, we
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   103
reduce this formula to a basic sequent:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   104
\[ \infer[(\disj)R]{\turn(P\imp Q)\disj(Q\imp P)}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   105
   {\infer[(\imp)R]{\turn(P\imp Q), (Q\imp P)\;}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   106
    {\infer[(\imp)R]{P \turn Q, (Q\imp P)\qquad}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   107
                    {P, Q \turn Q, P\qquad\qquad}}}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   108
\]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   109
This example is typical of the sequent calculus: start with the desired
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   110
theorem and apply rules backwards in a fairly arbitrary manner.  This yields a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   111
surprisingly effective proof procedure.  Quantifiers add few complications,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   112
since Isabelle handles parameters and schematic variables.  See Chapter~10
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   113
of {\em ML for the Working Programmer}~\cite{paulson91} for further
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   114
discussion.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   115
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   116
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   117
\section{Simulating sequents by natural deduction}
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   118
Isabelle can represent sequents directly, as in the object-logic~\texttt{LK}\@.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   119
But natural deduction is easier to work with, and most object-logics employ
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   120
it.  Fortunately, we can simulate the sequent $P@1,\ldots,P@m\turn
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   121
Q@1,\ldots,Q@n$ by the Isabelle formula
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   122
\[ \List{P@1;\ldots;P@m; \neg Q@2;\ldots; \neg Q@n}\Imp Q@1, \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   123
where the order of the assumptions and the choice of~$Q@1$ are arbitrary.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   124
Elim-resolution plays a key role in simulating sequent proofs.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   125
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   126
We can easily handle reasoning on the left.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   127
As discussed in
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   128
\iflabelundefined{destruct}{{\it Introduction to Isabelle}}{\S\ref{destruct}}, 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   129
elim-resolution with the rules $(\disj E)$, $(\bot E)$ and $(\exists E)$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   130
achieves a similar effect as the corresponding sequent rules.  For the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   131
other connectives, we use sequent-style elimination rules instead of
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   132
destruction rules such as $({\conj}E1,2)$ and $(\forall E)$.  But note that
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   133
the rule $(\neg L)$ has no effect under our representation of sequents!
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   134
$$
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   135
\ainfer{\neg P,\Gamma &\turn \Delta}{\Gamma &\turn \Delta,P}\eqno({\neg}L)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   136
$$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   137
What about reasoning on the right?  Introduction rules can only affect the
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   138
formula in the conclusion, namely~$Q@1$.  The other right-side formulae are
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   139
represented as negated assumptions, $\neg Q@2$, \ldots,~$\neg Q@n$.  
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   140
\index{assumptions!negated}
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   141
In order to operate on one of these, it must first be exchanged with~$Q@1$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   142
Elim-resolution with the {\bf swap} rule has this effect:
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   143
$$ \List{\neg P; \; \neg R\Imp P} \Imp R   \eqno(swap)  $$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   144
To ensure that swaps occur only when necessary, each introduction rule is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   145
converted into a swapped form: it is resolved with the second premise
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   146
of~$(swap)$.  The swapped form of~$({\conj}I)$, which might be
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   147
called~$({\neg\conj}E)$, is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   148
\[ \List{\neg(P\conj Q); \; \neg R\Imp P; \; \neg R\Imp Q} \Imp R. \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   149
Similarly, the swapped form of~$({\imp}I)$ is
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   150
\[ \List{\neg(P\imp Q); \; \List{\neg R;P}\Imp Q} \Imp R  \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   151
Swapped introduction rules are applied using elim-resolution, which deletes
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   152
the negated formula.  Our representation of sequents also requires the use
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   153
of ordinary introduction rules.  If we had no regard for readability, we
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   154
could treat the right side more uniformly by representing sequents as
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   155
\[ \List{P@1;\ldots;P@m; \neg Q@1;\ldots; \neg Q@n}\Imp \bot. \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   156
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   157
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   158
\section{Extra rules for the sequent calculus}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   159
As mentioned, destruction rules such as $({\conj}E1,2)$ and $(\forall E)$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   160
must be replaced by sequent-style elimination rules.  In addition, we need
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   161
rules to embody the classical equivalence between $P\imp Q$ and $\neg P\disj
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   162
Q$.  The introduction rules~$({\disj}I1,2)$ are replaced by a rule that
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   163
simulates $({\disj}R)$:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   164
\[ (\neg Q\Imp P) \Imp P\disj Q \]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   165
The destruction rule $({\imp}E)$ is replaced by
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   166
\[ \List{P\imp Q;\; \neg P\Imp R;\; Q\Imp R} \Imp R. \]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   167
Quantifier replication also requires special rules.  In classical logic,
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   168
$\exists x{.}P$ is equivalent to $\neg\forall x{.}\neg P$; the rules
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   169
$(\exists R)$ and $(\forall L)$ are dual:
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   170
\[ \ainfer{\Gamma &\turn \Delta, \exists x{.}P}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   171
          {\Gamma &\turn \Delta, \exists x{.}P, P[t/x]} \; (\exists R)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   172
   \qquad
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   173
   \ainfer{\forall x{.}P, \Gamma &\turn \Delta}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   174
          {P[t/x], \forall x{.}P, \Gamma &\turn \Delta} \; (\forall L)
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   175
\]
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   176
Thus both kinds of quantifier may be replicated.  Theorems requiring
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   177
multiple uses of a universal formula are easy to invent; consider 
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   178
\[ (\forall x.P(x)\imp P(f(x))) \conj P(a) \imp P(f^n(a)), \]
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   179
for any~$n>1$.  Natural examples of the multiple use of an existential
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   180
formula are rare; a standard one is $\exists x.\forall y. P(x)\imp P(y)$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   181
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   182
Forgoing quantifier replication loses completeness, but gains decidability,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   183
since the search space becomes finite.  Many useful theorems can be proved
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   184
without replication, and the search generally delivers its verdict in a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   185
reasonable time.  To adopt this approach, represent the sequent rules
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   186
$(\exists R)$, $(\exists L)$ and $(\forall R)$ by $(\exists I)$, $(\exists
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   187
E)$ and $(\forall I)$, respectively, and put $(\forall E)$ into elimination
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   188
form:
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   189
$$ \List{\forall x{.}P(x); P(t)\Imp Q} \Imp Q    \eqno(\forall E@2) $$
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   190
Elim-resolution with this rule will delete the universal formula after a
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   191
single use.  To replicate universal quantifiers, replace the rule by
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   192
$$
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   193
\List{\forall x{.}P(x);\; \List{P(t); \forall x{.}P(x)}\Imp Q} \Imp Q.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   194
\eqno(\forall E@3)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   195
$$
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   196
To replicate existential quantifiers, replace $(\exists I)$ by
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   197
\[ \List{\neg(\exists x{.}P(x)) \Imp P(t)} \Imp \exists x{.}P(x). \]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   198
All introduction rules mentioned above are also useful in swapped form.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   199
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   200
Replication makes the search space infinite; we must apply the rules with
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   201
care.  The classical reasoner distinguishes between safe and unsafe
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   202
rules, applying the latter only when there is no alternative.  Depth-first
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   203
search may well go down a blind alley; best-first search is better behaved
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   204
in an infinite search space.  However, quantifier replication is too
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   205
expensive to prove any but the simplest theorems.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   206
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   207
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   208
\section{Classical rule sets}
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   209
\index{classical sets}
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   210
Each automatic tactic takes a {\bf classical set} --- a collection of
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   211
rules, classified as introduction or elimination and as {\bf safe} or {\bf
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   212
unsafe}.  In general, safe rules can be attempted blindly, while unsafe
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   213
rules must be used with care.  A safe rule must never reduce a provable
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   214
goal to an unprovable set of subgoals.  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   215
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   216
The rule~$({\disj}I1)$ is unsafe because it reduces $P\disj Q$ to~$P$.  Any
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   217
rule is unsafe whose premises contain new unknowns.  The elimination
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   218
rule~$(\forall E@2)$ is unsafe, since it is applied via elim-resolution,
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   219
which discards the assumption $\forall x{.}P(x)$ and replaces it by the
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   220
weaker assumption~$P(\Var{t})$.  The rule $({\exists}I)$ is unsafe for
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   221
similar reasons.  The rule~$(\forall E@3)$ is unsafe in a different sense:
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   222
since it keeps the assumption $\forall x{.}P(x)$, it is prone to looping.
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   223
In classical first-order logic, all rules are safe except those mentioned
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   224
above.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   225
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   226
The safe/unsafe distinction is vague, and may be regarded merely as a way
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   227
of giving some rules priority over others.  One could argue that
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   228
$({\disj}E)$ is unsafe, because repeated application of it could generate
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   229
exponentially many subgoals.  Induction rules are unsafe because inductive
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   230
proofs are difficult to set up automatically.  Any inference is unsafe that
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   231
instantiates an unknown in the proof state --- thus \ttindex{match_tac}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   232
must be used, rather than \ttindex{resolve_tac}.  Even proof by assumption
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   233
is unsafe if it instantiates unknowns shared with other subgoals --- thus
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   234
\ttindex{eq_assume_tac} must be used, rather than \ttindex{assume_tac}.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   235
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   236
\subsection{Adding rules to classical sets}
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   237
Classical rule sets belong to the abstract type \mltydx{claset}, which
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   238
supports the following operations (provided the classical reasoner is
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   239
installed!):
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   240
\begin{ttbox} 
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   241
empty_cs    : claset
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   242
print_cs    : claset -> unit
4665
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   243
rep_cs      : claset -> {safeEs: thm list, safeIs: thm list,
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   244
                         hazEs: thm list,  hazIs: thm list, 
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   245
                         swrappers: (string * wrapper) list, 
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   246
                         uwrappers: (string * wrapper) list,
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   247
                         safe0_netpair: netpair, safep_netpair: netpair,
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   248
                           haz_netpair: netpair,   dup_netpair: netpair}
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   249
addSIs      : claset * thm list -> claset                 \hfill{\bf infix 4}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   250
addSEs      : claset * thm list -> claset                 \hfill{\bf infix 4}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   251
addSDs      : claset * thm list -> claset                 \hfill{\bf infix 4}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   252
addIs       : claset * thm list -> claset                 \hfill{\bf infix 4}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   253
addEs       : claset * thm list -> claset                 \hfill{\bf infix 4}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   254
addDs       : claset * thm list -> claset                 \hfill{\bf infix 4}
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   255
delrules    : claset * thm list -> claset                 \hfill{\bf infix 4}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   256
\end{ttbox}
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   257
The add operations ignore any rule already present in the claset with the same
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   258
classification (such as Safe Introduction).  They print a warning if the rule
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   259
has already been added with some other classification, but add the rule
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   260
anyway.  Calling \texttt{delrules} deletes all occurrences of a rule from the
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   261
claset, but see the warning below concerning destruction rules.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   262
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   263
\item[\ttindexbold{empty_cs}] is the empty classical set.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   264
4665
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   265
\item[\ttindexbold{print_cs} $cs$] displays the printable contents of~$cs$,
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   266
  which is the rules. All other parts are non-printable.
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   267
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   268
\item[\ttindexbold{rep_cs} $cs$] decomposes $cs$ as a record of its internal 
4666
b7c4e4ade1aa added minimal description of rep_cs: corrections
oheimb
parents: 4665
diff changeset
   269
  components, namely the safe introduction and elimination rules, the unsafe
b7c4e4ade1aa added minimal description of rep_cs: corrections
oheimb
parents: 4665
diff changeset
   270
  introduction and elimination rules, the lists of safe and unsafe wrappers
b7c4e4ade1aa added minimal description of rep_cs: corrections
oheimb
parents: 4665
diff changeset
   271
  (see \ref{sec:modifying-search}), and the internalized forms of the rules.
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   272
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   273
\item[$cs$ addSIs $rules$] \indexbold{*addSIs}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   274
adds safe introduction~$rules$ to~$cs$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   275
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   276
\item[$cs$ addSEs $rules$] \indexbold{*addSEs}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   277
adds safe elimination~$rules$ to~$cs$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   278
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   279
\item[$cs$ addSDs $rules$] \indexbold{*addSDs}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   280
adds safe destruction~$rules$ to~$cs$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   281
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   282
\item[$cs$ addIs $rules$] \indexbold{*addIs}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   283
adds unsafe introduction~$rules$ to~$cs$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   284
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   285
\item[$cs$ addEs $rules$] \indexbold{*addEs}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   286
adds unsafe elimination~$rules$ to~$cs$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   287
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   288
\item[$cs$ addDs $rules$] \indexbold{*addDs}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   289
adds unsafe destruction~$rules$ to~$cs$.
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   290
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   291
\item[$cs$ delrules $rules$] \indexbold{*delrules}
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   292
deletes~$rules$ from~$cs$.  It prints a warning for those rules that are not
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   293
in~$cs$.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   294
\end{ttdescription}
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   295
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   296
\begin{warn}
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   297
  If you added $rule$ using \texttt{addSDs} or \texttt{addDs}, then you must delete
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   298
  it as follows:
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   299
\begin{ttbox}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   300
\(cs\) delrules [make_elim \(rule\)]
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   301
\end{ttbox}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   302
\par\noindent
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   303
This is necessary because the operators \texttt{addSDs} and \texttt{addDs} convert
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   304
the destruction rules to elimination rules by applying \ttindex{make_elim},
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   305
and then insert them using \texttt{addSEs} and \texttt{addEs}, respectively.
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   306
\end{warn}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   307
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   308
Introduction rules are those that can be applied using ordinary resolution.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   309
The classical set automatically generates their swapped forms, which will
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   310
be applied using elim-resolution.  Elimination rules are applied using
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   311
elim-resolution.  In a classical set, rules are sorted by the number of new
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   312
subgoals they will yield; rules that generate the fewest subgoals will be
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   313
tried first (see \S\ref{biresolve_tac}).
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   314
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   315
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   316
\subsection{Modifying the search step}
4665
ef6a546d6b69 added minimal description of rep_cs
oheimb
parents: 4649
diff changeset
   317
\label{sec:modifying-search}
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   318
For a given classical set, the proof strategy is simple.  Perform as many safe
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   319
inferences as possible; or else, apply certain safe rules, allowing
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   320
instantiation of unknowns; or else, apply an unsafe rule.  The tactics also
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   321
eliminate assumptions of the form $x=t$ by substitution if they have been set
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   322
up to do so (see \texttt{hyp_subst_tacs} in~\S\ref{sec:classical-setup} below).
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   323
They may perform a form of Modus Ponens: if there are assumptions $P\imp Q$
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   324
and~$P$, then replace $P\imp Q$ by~$Q$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   325
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   326
The classical reasoning tactics --- except \texttt{blast_tac}! --- allow
4649
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   327
you to modify this basic proof strategy by applying two lists of arbitrary 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   328
{\bf wrapper tacticals} to it. 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   329
The first wrapper list, which is considered to contain safe wrappers only, 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   330
affects \ttindex{safe_step_tac} and all the tactics that call it.  
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   331
The second one, which may contain unsafe wrappers, affects \ttindex{step_tac}, 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   332
\ttindex{slow_step_tac} and the tactics that call them.
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   333
A wrapper transforms each step of the search, for example 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   334
by invoking other tactics before or alternatively to the original step tactic. 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   335
All members of a wrapper list are applied in turn to the respective step tactic.
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   336
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   337
Initially the two wrapper lists are empty, which means no modification of the
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   338
step tactics. Safe and unsafe wrappers are added to a claset 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   339
with the functions given below, supplying them with wrapper names. 
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   340
These names may be used to selectively delete wrappers.
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   341
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   342
\begin{ttbox} 
4649
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   343
type wrapper = (int -> tactic) -> (int -> tactic);
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   344
addSbefore   : claset * (string * (int -> tactic)) -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   345
addSaltern   : claset * (string * (int -> tactic)) -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   346
addSWrapper  : claset * (string * wrapper        ) -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   347
delSWrapper  : claset *  string                    -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   348
addbefore    : claset * (string * (int -> tactic)) -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   349
addaltern    : claset * (string * (int -> tactic)) -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   350
addWrapper   : claset * (string * wrapper        ) -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   351
delWrapper   : claset *  string                    -> claset \hfill{\bf infix 4}
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   352
2632
1612b99395d4 corrected minor mistakes
oheimb
parents: 2631
diff changeset
   353
addss        : claset * simpset -> claset                 \hfill{\bf infix 4}
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   354
\end{ttbox}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   355
%
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   356
\index{simplification!from classical reasoner} The wrapper tacticals
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   357
underly the operator addss, which combines each search step by
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   358
simplification.  Strictly speaking, \texttt{addss} is not part of the
4597
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4561
diff changeset
   359
classical reasoner.  It should be defined when the simplifier is
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4561
diff changeset
   360
installed:
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4561
diff changeset
   361
\begin{ttbox}
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4561
diff changeset
   362
infix 4 addss;
4649
89ad3eb863a1 changed wrapper mechanism of classical reasoner
oheimb
parents: 4597
diff changeset
   363
fun cs addss ss = cs addbefore asm_full_simp_tac ss;
4597
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4561
diff changeset
   364
\end{ttbox}
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   365
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   366
\begin{ttdescription}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   367
\item[$cs$ addss $ss$] \indexbold{*addss}
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3224
diff changeset
   368
adds the simpset~$ss$ to the classical set.  The assumptions and goal will be
2631
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   369
simplified, in a safe way, after the safe steps of the search.
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   370
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   371
\item[$cs$ addSbefore $tac$] \indexbold{*addSbefore}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   372
changes the safe wrapper tactical to apply the given tactic {\em before}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   373
each safe step of the search.
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   374
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   375
\item[$cs$ addSaltern $tac$] \indexbold{*addSaltern}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   376
changes the safe wrapper tactical to apply the given tactic when a safe step 
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   377
of the search would fail.
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   378
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   379
\item[$cs$ setSWrapper $tactical$] \indexbold{*setSWrapper}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   380
specifies a new safe wrapper tactical.  
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   381
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   382
\item[$cs$ compSWrapper $tactical$] \indexbold{*compSWrapper}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   383
composes the $tactical$ with the existing safe wrapper tactical, 
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   384
to combine their effects. 
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   385
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   386
\item[$cs$ addbefore $tac$] \indexbold{*addbefore}
2631
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   387
changes the (unsafe) wrapper tactical to apply the given tactic, which should
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   388
be safe, {\em before} each step of the search.
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   389
2631
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   390
\item[$cs$ addaltern $tac$] \indexbold{*addaltern}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   391
changes the (unsafe) wrapper tactical to apply the given tactic 
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   392
{\em alternatively} after each step of the search.
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   393
2631
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   394
\item[$cs$ setWrapper $tactical$] \indexbold{*setWrapper}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   395
specifies a new (unsafe) wrapper tactical.  
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   396
2631
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   397
\item[$cs$ compWrapper $tactical$] \indexbold{*compWrapper}
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   398
composes the $tactical$ with the existing (unsafe) wrapper tactical, 
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   399
to combine their effects. 
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   400
\end{ttdescription}
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   401
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   402
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   403
\section{The classical tactics}
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   404
\index{classical reasoner!tactics} If installed, the classical module provides
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   405
powerful theorem-proving tactics.  Most of them have capitalized analogues
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   406
that use the default claset; see \S\ref{sec:current-claset}.
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   407
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   408
\subsection{Semi-automatic tactics}
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   409
\begin{ttbox} 
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   410
clarify_tac      : claset -> int -> tactic
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   411
clarify_step_tac : claset -> int -> tactic
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   412
\end{ttbox}
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   413
Use these when the automatic tactics fail.  They perform all the obvious
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   414
logical inferences that do not split the subgoal.  The result is a
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   415
simpler subgoal that can be tackled by other means, such as by
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   416
instantiating quantifiers yourself.
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   417
\begin{ttdescription}
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   418
\item[\ttindexbold{clarify_tac} $cs$ $i$] performs a series of safe steps on
4597
a0bdee64194c Fixed a lot of overfull and underfull lines (hboxes)
paulson
parents: 4561
diff changeset
   419
subgoal~$i$ by repeatedly calling \texttt{clarify_step_tac}.
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   420
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   421
\item[\ttindexbold{clarify_step_tac} $cs$ $i$] performs a safe step on
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   422
  subgoal~$i$.  No splitting step is applied; for example, the subgoal $A\conj
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   423
  B$ is left as a conjunction.  Proof by assumption, Modus Ponens, etc., may be
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   424
  performed provided they do not instantiate unknowns.  Assumptions of the
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   425
  form $x=t$ may be eliminated.  The user-supplied safe wrapper tactical is
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   426
  applied.
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   427
\end{ttdescription}
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   428
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   429
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   430
\subsection{The tableau prover}
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   431
The tactic \texttt{blast_tac} searches for a proof using a fast tableau prover,
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   432
coded directly in \ML.  It then reconstructs the proof using Isabelle
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   433
tactics.  It is faster and more powerful than the other classical
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   434
reasoning tactics, but has major limitations too.
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   435
\begin{itemize}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   436
\item It does not use the wrapper tacticals described above, such as
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   437
  \ttindex{addss}.
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   438
\item It ignores types, which can cause problems in \HOL.  If it applies a rule
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   439
  whose types are inappropriate, then proof reconstruction will fail.
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   440
\item It does not perform higher-order unification, as needed by the rule {\tt
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   441
    rangeI} in {\HOL} and \texttt{RepFunI} in {\ZF}.  There are often
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   442
    alternatives to such rules, for example {\tt
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   443
    range_eqI} and \texttt{RepFun_eqI}.
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   444
\item The message {\small\tt Function Var's argument not a bound variable\ }
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   445
relates to the lack of higher-order unification.  Function variables
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   446
may only be applied to parameters of the subgoal.
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   447
\item Its proof strategy is more general than \texttt{fast_tac}'s but can be
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   448
  slower.  If \texttt{blast_tac} fails or seems to be running forever, try {\tt
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   449
  fast_tac} and the other tactics described below.
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   450
\end{itemize}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   451
%
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   452
\begin{ttbox} 
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   453
blast_tac        : claset -> int -> tactic
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   454
Blast.depth_tac  : claset -> int -> int -> tactic
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   455
Blast.trace      : bool ref \hfill{\bf initially false}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   456
\end{ttbox}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   457
The two tactics differ on how they bound the number of unsafe steps used in a
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   458
proof.  While \texttt{blast_tac} starts with a bound of zero and increases it
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   459
successively to~20, \texttt{Blast.depth_tac} applies a user-supplied search bound.
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   460
\begin{ttdescription}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   461
\item[\ttindexbold{blast_tac} $cs$ $i$] tries to prove
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   462
  subgoal~$i$ using iterative deepening to increase the search bound.
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   463
  
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   464
\item[\ttindexbold{Blast.depth_tac} $cs$ $lim$ $i$] tries
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   465
  to prove subgoal~$i$ using a search bound of $lim$.  Often a slow
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   466
  proof using \texttt{blast_tac} can be made much faster by supplying the
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   467
  successful search bound to this tactic instead.
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   468
  
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3720
diff changeset
   469
\item[set \ttindexbold{Blast.trace};] \index{tracing!of classical prover}
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   470
  causes the tableau prover to print a trace of its search.  At each step it
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   471
  displays the formula currently being examined and reports whether the branch
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   472
  has been closed, extended or split.
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   473
\end{ttdescription}
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   474
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   475
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   476
\subsection{An automatic tactic}
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   477
\begin{ttbox} 
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   478
auto_tac      : claset * simpset -> tactic
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   479
auto          : unit -> unit
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   480
\end{ttbox}
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   481
The auto-tactic attempts to prove all subgoals using a combination of
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   482
simplification and classical reasoning.  It is intended for situations where
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   483
there are a lot of mostly trivial subgoals; it proves all the easy ones,
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   484
leaving the ones it cannot prove.  (Unfortunately, attempting to prove the
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   485
hard ones may take a long time.)  It must be supplied both a simpset and a
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   486
claset; therefore it is most easily called as \texttt{Auto_tac}, which uses
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   487
the default claset and simpset (see \S\ref{sec:current-claset} below).  For
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   488
interactive use, the shorthand \texttt{auto();} abbreviates 
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   489
\begin{ttbox}
4507
f313d8fb8f49 Auto_tac now has type tactic, not unit->tactic
paulson
parents: 4398
diff changeset
   490
by Auto_tac;
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   491
\end{ttbox}
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   492
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   493
\subsection{Other classical tactics}
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   494
\begin{ttbox} 
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   495
fast_tac      : claset -> int -> tactic
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   496
best_tac      : claset -> int -> tactic
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   497
slow_tac      : claset -> int -> tactic
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   498
slow_best_tac : claset -> int -> tactic
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   499
\end{ttbox}
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   500
These tactics attempt to prove a subgoal using sequent-style reasoning.
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   501
Unlike \texttt{blast_tac}, they construct proofs directly in Isabelle.  Their
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   502
effect is restricted (by \texttt{SELECT_GOAL}) to one subgoal; they either prove
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   503
this subgoal or fail.  The \texttt{slow_} versions conduct a broader
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   504
search.%
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   505
\footnote{They may, when backtracking from a failed proof attempt, undo even
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   506
  the step of proving a subgoal by assumption.}
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   507
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   508
The best-first tactics are guided by a heuristic function: typically, the
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   509
total size of the proof state.  This function is supplied in the functor call
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   510
that sets up the classical reasoner.
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   511
\begin{ttdescription}
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   512
\item[\ttindexbold{fast_tac} $cs$ $i$] applies \texttt{step_tac} using
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   513
depth-first search, to prove subgoal~$i$.
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   514
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   515
\item[\ttindexbold{best_tac} $cs$ $i$] applies \texttt{step_tac} using
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   516
best-first search, to prove subgoal~$i$.
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   517
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   518
\item[\ttindexbold{slow_tac} $cs$ $i$] applies \texttt{slow_step_tac} using
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   519
depth-first search, to prove subgoal~$i$.
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   520
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   521
\item[\ttindexbold{slow_best_tac} $cs$ $i$] applies \texttt{slow_step_tac} using
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   522
best-first search, to prove subgoal~$i$.
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   523
\end{ttdescription}
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   524
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   525
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   526
\subsection{Depth-limited automatic tactics}
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   527
\begin{ttbox} 
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   528
depth_tac  : claset -> int -> int -> tactic
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   529
deepen_tac : claset -> int -> int -> tactic
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   530
\end{ttbox}
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   531
These work by exhaustive search up to a specified depth.  Unsafe rules are
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   532
modified to preserve the formula they act on, so that it be used repeatedly.
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   533
They can prove more goals than \texttt{fast_tac} can but are much
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   534
slower, for example if the assumptions have many universal quantifiers.
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   535
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   536
The depth limits the number of unsafe steps.  If you can estimate the minimum
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   537
number of unsafe steps needed, supply this value as~$m$ to save time.
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   538
\begin{ttdescription}
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   539
\item[\ttindexbold{depth_tac} $cs$ $m$ $i$] 
3089
32dad29d4666 Documented blast_tac
paulson
parents: 2632
diff changeset
   540
tries to prove subgoal~$i$ by exhaustive search up to depth~$m$.
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   541
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   542
\item[\ttindexbold{deepen_tac} $cs$ $m$ $i$] 
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   543
tries to prove subgoal~$i$ by iterative deepening.  It calls \texttt{depth_tac}
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   544
repeatedly with increasing depths, starting with~$m$.
332
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   545
\end{ttdescription}
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   546
01b87a921967 final Springer copy
lcp
parents: 319
diff changeset
   547
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   548
\subsection{Single-step tactics}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   549
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   550
safe_step_tac : claset -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   551
safe_tac      : claset        -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   552
inst_step_tac : claset -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   553
step_tac      : claset -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   554
slow_step_tac : claset -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   555
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   556
The automatic proof procedures call these tactics.  By calling them
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   557
yourself, you can execute these procedures one step at a time.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   558
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   559
\item[\ttindexbold{safe_step_tac} $cs$ $i$] performs a safe step on
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   560
  subgoal~$i$.  The safe wrapper tactical is applied to a tactic that may
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   561
  include proof by assumption or Modus Ponens (taking care not to instantiate
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   562
  unknowns), or substitution.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   563
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   564
\item[\ttindexbold{safe_tac} $cs$] repeatedly performs safe steps on all 
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   565
subgoals.  It is deterministic, with at most one outcome.  
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   566
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   567
\item[\ttindexbold{inst_step_tac} $cs$ $i$] is like \texttt{safe_step_tac},
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   568
but allows unknowns to be instantiated.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   569
1099
f4335b56f772 Covers wrapper tacticals: setwrapper, ..., addss
lcp
parents: 875
diff changeset
   570
\item[\ttindexbold{step_tac} $cs$ $i$] is the basic step of the proof
2631
5e5c78ba955e description of safe vs. unsafe wrapper and the functions involved
oheimb
parents: 2479
diff changeset
   571
  procedure.  The (unsafe) wrapper tactical is applied to a tactic that tries
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   572
 \texttt{safe_tac}, \texttt{inst_step_tac}, or applies an unsafe rule from~$cs$.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   573
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   574
\item[\ttindexbold{slow_step_tac}] 
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   575
  resembles \texttt{step_tac}, but allows backtracking between using safe
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   576
  rules with instantiation (\texttt{inst_step_tac}) and using unsafe rules.
875
a0b71a4bbe5e documented slow_tac, slow_best_tac, depth_tac, deepen_tac
lcp
parents: 332
diff changeset
   577
  The resulting search space is larger.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   578
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   579
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   580
\subsection{The current claset}\label{sec:current-claset}
4561
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   581
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   582
Each theory is equipped with an implicit \emph{current
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   583
  claset}\index{claset!current}.  This is a default set of classical
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   584
rules.  The underlying idea is quite similar to that of a current
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   585
simpset described in \S\ref{sec:simp-for-dummies}; please read that
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   586
section, including its warnings.  The implicit claset can be accessed
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   587
as follows:
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   588
\begin{ttbox}
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   589
claset        : unit -> claset
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   590
claset_ref    : unit -> claset ref
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   591
claset_of     : theory -> claset
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   592
claset_ref_of : theory -> claset ref
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   593
print_claset  : theory -> unit
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   594
\end{ttbox}
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   595
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   596
The tactics
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   597
\begin{ttbox}
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   598
Blast_tac        : int -> tactic
4507
f313d8fb8f49 Auto_tac now has type tactic, not unit->tactic
paulson
parents: 4398
diff changeset
   599
Auto_tac         :        tactic
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   600
Fast_tac         : int -> tactic
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   601
Best_tac         : int -> tactic
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   602
Deepen_tac       : int -> int -> tactic
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   603
Clarify_tac      : int -> tactic
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   604
Clarify_step_tac : int -> tactic
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   605
Safe_tac         :        tactic
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   606
Safe_step_tac    : int -> tactic
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   607
Step_tac         : int -> tactic
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   608
\end{ttbox}
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   609
\indexbold{*Blast_tac}\indexbold{*Auto_tac}
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   610
\indexbold{*Best_tac}\indexbold{*Fast_tac}%
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   611
\indexbold{*Deepen_tac}
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   612
\indexbold{*Clarify_tac}\indexbold{*Clarify_step_tac}
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   613
\indexbold{*Safe_tac}\indexbold{*Safe_step_tac}
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   614
\indexbold{*Step_tac}
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   615
make use of the current claset.  For example, \texttt{Blast_tac} is defined as 
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   616
\begin{ttbox}
4561
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   617
fun Blast_tac i st = blast_tac (claset()) i st;
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   618
\end{ttbox}
4561
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   619
and gets the current claset, only after it is applied to a proof
19f1a01570bf updated to Isabelle98;
wenzelm
parents: 4507
diff changeset
   620
state.  The functions
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   621
\begin{ttbox}
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   622
AddSIs, AddSEs, AddSDs, AddIs, AddEs, AddDs: thm list -> unit
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   623
\end{ttbox}
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   624
\indexbold{*AddSIs} \indexbold{*AddSEs} \indexbold{*AddSDs}
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   625
\indexbold{*AddIs} \indexbold{*AddEs} \indexbold{*AddDs}
3485
f27a30a18a17 Now there are TWO spaces after each full stop, so that the Emacs sentence
paulson
parents: 3224
diff changeset
   626
are used to add rules to the current claset.  They work exactly like their
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   627
lower case counterparts, such as \texttt{addSIs}.  Calling
1869
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   628
\begin{ttbox}
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   629
Delrules : thm list -> unit
065bd29adc7a Added section about current claset.
berghofe
parents: 1099
diff changeset
   630
\end{ttbox}
3224
4ea2aa9f93a5 Documented auto_tac
paulson
parents: 3108
diff changeset
   631
deletes rules from the current claset. 
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   632
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   633
\subsection{Other useful tactics}
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   634
\index{tactics!for contradiction}
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   635
\index{tactics!for Modus Ponens}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   636
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   637
contr_tac    :             int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   638
mp_tac       :             int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   639
eq_mp_tac    :             int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   640
swap_res_tac : thm list -> int -> tactic
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   641
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   642
These can be used in the body of a specialized search.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   643
\begin{ttdescription}
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   644
\item[\ttindexbold{contr_tac} {\it i}]\index{assumptions!contradictory}
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   645
  solves subgoal~$i$ by detecting a contradiction among two assumptions of
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   646
  the form $P$ and~$\neg P$, or fail.  It may instantiate unknowns.  The
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   647
  tactic can produce multiple outcomes, enumerating all possible
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   648
  contradictions.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   649
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   650
\item[\ttindexbold{mp_tac} {\it i}] 
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   651
is like \texttt{contr_tac}, but also attempts to perform Modus Ponens in
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   652
subgoal~$i$.  If there are assumptions $P\imp Q$ and~$P$, then it replaces
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   653
$P\imp Q$ by~$Q$.  It may instantiate unknowns.  It fails if it can do
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   654
nothing.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   655
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   656
\item[\ttindexbold{eq_mp_tac} {\it i}] 
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   657
is like \texttt{mp_tac} {\it i}, but may not instantiate unknowns --- thus, it
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   658
is safe.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   659
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   660
\item[\ttindexbold{swap_res_tac} {\it thms} {\it i}] refines subgoal~$i$ of
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   661
the proof state using {\it thms}, which should be a list of introduction
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   662
rules.  First, it attempts to prove the goal using \texttt{assume_tac} or
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   663
\texttt{contr_tac}.  It then attempts to apply each rule in turn, attempting
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   664
resolution and also elim-resolution with the swapped form.
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   665
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   666
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   667
\subsection{Creating swapped rules}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   668
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   669
swapify   : thm list -> thm list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   670
joinrules : thm list * thm list -> (bool * thm) list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   671
\end{ttbox}
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   672
\begin{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   673
\item[\ttindexbold{swapify} {\it thms}] returns a list consisting of the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   674
swapped versions of~{\it thms}, regarded as introduction rules.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   675
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   676
\item[\ttindexbold{joinrules} ({\it intrs}, {\it elims})]
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   677
joins introduction rules, their swapped versions, and elimination rules for
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   678
use with \ttindex{biresolve_tac}.  Each rule is paired with~\texttt{false}
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   679
(indicating ordinary resolution) or~\texttt{true} (indicating
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   680
elim-resolution).
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   681
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   682
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   683
3716
2885b760a4b4 Clarify_tac and some textual improvements
paulson
parents: 3485
diff changeset
   684
\section{Setting up the classical reasoner}\label{sec:classical-setup}
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   685
\index{classical reasoner!setting up}
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   686
Isabelle's classical object-logics, including \texttt{FOL} and \texttt{HOL}, have
286
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   687
the classical reasoner already set up.  When defining a new classical logic,
e7efbf03562b first draft of Springer book
lcp
parents: 104
diff changeset
   688
you should set up the reasoner yourself.  It consists of the \ML{} functor
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   689
\ttindex{ClassicalFun}, which takes the argument
3720
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   690
signature \texttt{
a5b9e0ade194 Safe_tac, Safe_step_tac, and minor corrections including \tt -> \texttt
paulson
parents: 3716
diff changeset
   691
                  CLASSICAL_DATA}:
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   692
\begin{ttbox} 
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   693
signature CLASSICAL_DATA =
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   694
  sig
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   695
  val mp             : thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   696
  val not_elim       : thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   697
  val swap           : thm
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   698
  val sizef          : thm -> int
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   699
  val hyp_subst_tacs : (int -> tactic) list
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   700
  end;
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   701
\end{ttbox}
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   702
Thus, the functor requires the following items:
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   703
\begin{ttdescription}
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   704
\item[\tdxbold{mp}] should be the Modus Ponens rule
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   705
$\List{\Var{P}\imp\Var{Q};\; \Var{P}} \Imp \Var{Q}$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   706
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   707
\item[\tdxbold{not_elim}] should be the contradiction rule
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   708
$\List{\neg\Var{P};\; \Var{P}} \Imp \Var{R}$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   709
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   710
\item[\tdxbold{swap}] should be the swap rule
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   711
$\List{\neg \Var{P}; \; \neg \Var{R}\Imp \Var{P}} \Imp \Var{R}$.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   712
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   713
\item[\ttindexbold{sizef}] is the heuristic function used for best-first
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   714
search.  It should estimate the size of the remaining subgoals.  A good
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   715
heuristic function is \ttindex{size_of_thm}, which measures the size of the
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   716
proof state.  Another size function might ignore certain subgoals (say,
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   717
those concerned with type checking).  A heuristic function might simply
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   718
count the subgoals.
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   719
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   720
\item[\ttindexbold{hyp_subst_tacs}] is a list of tactics for substitution in
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   721
the hypotheses, typically created by \ttindex{HypsubstFun} (see
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   722
Chapter~\ref{substitution}).  This list can, of course, be empty.  The
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   723
tactics are assumed to be safe!
308
f4cecad9b6a0 modifications towards final draft
lcp
parents: 286
diff changeset
   724
\end{ttdescription}
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   725
The functor is not at all sensitive to the formalization of the
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   726
object-logic.  It does not even examine the rules, but merely applies
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   727
them according to its fixed strategy.  The functor resides in {\tt
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3089
diff changeset
   728
  Provers/classical.ML} in the Isabelle sources.
104
d8205bb279a7 Initial revision
lcp
parents:
diff changeset
   729
319
f143f7686cd6 penultimate Springer draft
lcp
parents: 308
diff changeset
   730
\index{classical reasoner|)}