doc-src/Ref/classical.tex
changeset 3716 2885b760a4b4
parent 3485 f27a30a18a17
child 3720 a5b9e0ade194
equal deleted inserted replaced
3715:6e074b41c735 3716:2885b760a4b4
    27 have been heavily used in the development of Isabelle's set theory.  Few
    27 have been heavily used in the development of Isabelle's set theory.  Few
    28 interactive proof assistants provide this much automation.  The tactics can
    28 interactive proof assistants provide this much automation.  The tactics can
    29 be traced, and their components can be called directly; in this manner,
    29 be traced, and their components can be called directly; in this manner,
    30 any proof can be viewed interactively.
    30 any proof can be viewed interactively.
    31 
    31 
    32 The simplest way to apply the classical reasoner (to subgoal~$i$) is as
    32 The simplest way to apply the classical reasoner (to subgoal~$i$) is to type
    33 follows:
       
    34 \begin{ttbox}
    33 \begin{ttbox}
    35 by (Blast_tac \(i\));
    34 by (Blast_tac \(i\));
    36 \end{ttbox}
    35 \end{ttbox}
    37 If the subgoal is a simple formula of the predicate calculus or set theory,
    36 This command quickly proves most simple formulas of the predicate calculus or
    38 then it should be proved quickly.  To attempt to prove \emph{all} subgoals
    37 set theory.  To attempt to prove \emph{all} subgoals using a combination of
    39 using a combination of rewriting and classical reasoning, try
    38 rewriting and classical reasoning, try
    40 \begin{ttbox}
    39 \begin{ttbox}
    41 by (Auto_tac());
    40 by (Auto_tac());
    42 \end{ttbox}
    41 \end{ttbox}
    43 To use the classical reasoner effectively, you need to know how it works.  It
    42 To do all obvious logical steps, even if they do not prove the
    44 provides many tactics to choose from, including {\tt Fast_tac} and {\tt
    43 subgoal, type
    45   Best_tac}.
    44 \begin{ttbox}
       
    45 by (Clarify_tac \(i\));
       
    46 \end{ttbox}
       
    47 You need to know how the classical reasoner works in order to use it
       
    48 effectively.  There are many tactics to choose from, including {\tt
       
    49   Fast_tac} and {\tt Best_tac}.
    46 
    50 
    47 We shall first discuss the underlying principles, then present the
    51 We shall first discuss the underlying principles, then present the
    48 classical reasoner.  Finally, we shall see how to instantiate it for
    52 classical reasoner.  Finally, we shall see how to instantiate it for
    49 new logics.  The logics \FOL, \ZF, {\HOL} and {\HOLCF} have it already
    53 new logics.  The logics \FOL, \ZF, {\HOL} and {\HOLCF} have it already
    50 installed.
    54 installed.
   295 subgoals they will yield; rules that generate the fewest subgoals will be
   299 subgoals they will yield; rules that generate the fewest subgoals will be
   296 tried first (see \S\ref{biresolve_tac}).
   300 tried first (see \S\ref{biresolve_tac}).
   297 
   301 
   298 
   302 
   299 \subsection{Modifying the search step}
   303 \subsection{Modifying the search step}
   300 For a given classical set, the proof strategy is simple.  Perform as many
   304 For a given classical set, the proof strategy is simple.  Perform as many safe
   301 safe inferences as possible; or else, apply certain safe rules, allowing
   305 inferences as possible; or else, apply certain safe rules, allowing
   302 instantiation of unknowns; or else, apply an unsafe rule.  The tactics may
   306 instantiation of unknowns; or else, apply an unsafe rule.  The tactics also
   303 also apply {\tt hyp_subst_tac}, if they have been set up to do so (see
   307 eliminate assumptions of the form $x=t$ by substitution if they have been set
   304 below).  They may perform a form of Modus Ponens: if there are assumptions
   308 up to do so (see {\tt hyp_subst_tacs} in~\S\ref{sec:classical-setup} below).
   305 $P\imp Q$ and~$P$, then replace $P\imp Q$ by~$Q$.
   309 They may perform a form of Modus Ponens: if there are assumptions $P\imp Q$
       
   310 and~$P$, then replace $P\imp Q$ by~$Q$.
   306 
   311 
   307 The classical reasoning tactics --- except {\tt blast_tac}! --- allow
   312 The classical reasoning tactics --- except {\tt blast_tac}! --- allow
   308 you to modify this basic proof strategy by applying two arbitrary {\bf
   313 you to modify this basic proof strategy by applying two arbitrary {\bf
   309   wrapper tacticals} to it.  This affects each step of the search.
   314   wrapper tacticals} to it.  This affects each step of the search.
   310 Usually they are the identity tacticals, but they could apply another
   315 Usually they are the identity tacticals, but they could apply another
   373 to combine their effects. 
   378 to combine their effects. 
   374 \end{ttdescription}
   379 \end{ttdescription}
   375 
   380 
   376 
   381 
   377 \section{The classical tactics}
   382 \section{The classical tactics}
   378 \index{classical reasoner!tactics}
   383 \index{classical reasoner!tactics} If installed, the classical module provides
   379 If installed, the classical module provides several tactics (and other
   384 powerful theorem-proving tactics.  Most of them have capitalized analogues
   380 operations) for simulating the classical sequent calculus.
   385 that use the default claset; see \S\ref{sec:current-claset}.
       
   386 
       
   387 \subsection{Semi-automatic tactics}
       
   388 \begin{ttbox} 
       
   389 clarify_tac      : claset -> int -> tactic
       
   390 clarify_step_tac : claset -> int -> tactic
       
   391 \end{ttbox}
       
   392 Use these when the automatic tactics fail.  They perform all the obvious
       
   393 logical inferences that do not split the subgoal.  The result is a
       
   394 simpler subgoal that can be tackled by other means, such as by
       
   395 instantiating quantifiers yourself.
       
   396 \begin{ttdescription}
       
   397 \item[\ttindexbold{clarify_tac} $cs$ $i$] performs a series of safe steps on
       
   398 subgoal~$i$, using \texttt{clarify_step_tac}.
       
   399 
       
   400 \item[\ttindexbold{clarify_step_tac} $cs$ $i$] performs a safe step on
       
   401   subgoal~$i$.  No splitting step is applied; for example, the subgoal $A\conj
       
   402   B$ is left as a conjunction.  Proof by assumption, Modus Ponens, etc., may be
       
   403   performed provided they do not instantiate unknowns.  Assumptions of the
       
   404   form $x=t$ may be eliminated.  The user-supplied safe wrapper tactical is
       
   405   applied.
       
   406 \end{ttdescription}
       
   407 
   381 
   408 
   382 \subsection{The tableau prover}
   409 \subsection{The tableau prover}
   383 The tactic {\tt blast_tac} searches for a proof using a fast tableau prover,
   410 The tactic {\tt blast_tac} searches for a proof using a fast tableau prover,
   384 coded directly in \ML.  It then reconstructs the proof using Isabelle
   411 coded directly in \ML.  It then reconstructs the proof using Isabelle
   385 tactics.  It is faster and more powerful than the other classical
   412 tactics.  It is faster and more powerful than the other classical
   473 \item[\ttindexbold{slow_best_tac} $cs$ $i$] applies {\tt slow_step_tac} using
   500 \item[\ttindexbold{slow_best_tac} $cs$ $i$] applies {\tt slow_step_tac} using
   474 best-first search, to prove subgoal~$i$.
   501 best-first search, to prove subgoal~$i$.
   475 \end{ttdescription}
   502 \end{ttdescription}
   476 
   503 
   477 
   504 
   478 \subsection{Depth-limited tactics}
   505 \subsection{Depth-limited automatic tactics}
   479 \begin{ttbox} 
   506 \begin{ttbox} 
   480 depth_tac  : claset -> int -> int -> tactic
   507 depth_tac  : claset -> int -> int -> tactic
   481 deepen_tac : claset -> int -> int -> tactic
   508 deepen_tac : claset -> int -> int -> tactic
   482 \end{ttbox}
   509 \end{ttbox}
   483 These work by exhaustive search up to a specified depth.  Unsafe rules are
   510 These work by exhaustive search up to a specified depth.  Unsafe rules are
   507 \end{ttbox}
   534 \end{ttbox}
   508 The automatic proof procedures call these tactics.  By calling them
   535 The automatic proof procedures call these tactics.  By calling them
   509 yourself, you can execute these procedures one step at a time.
   536 yourself, you can execute these procedures one step at a time.
   510 \begin{ttdescription}
   537 \begin{ttdescription}
   511 \item[\ttindexbold{safe_step_tac} $cs$ $i$] performs a safe step on
   538 \item[\ttindexbold{safe_step_tac} $cs$ $i$] performs a safe step on
   512 subgoal~$i$.  The safe wrapper tactical is applied to a tactic that may include 
   539   subgoal~$i$.  The safe wrapper tactical is applied to a tactic that may
   513 proof by assumption or Modus Ponens (taking care not to instantiate unknowns), 
   540   include proof by assumption or Modus Ponens (taking care not to instantiate
   514 or {\tt hyp_subst_tac}.
   541   unknowns), or substitution.
   515 
   542 
   516 \item[\ttindexbold{safe_tac} $cs$] repeatedly performs safe steps on all 
   543 \item[\ttindexbold{safe_tac} $cs$] repeatedly performs safe steps on all 
   517 subgoals.  It is deterministic, with at most one outcome.  If the automatic
   544 subgoals.  It is deterministic, with at most one outcome.  
   518 tactics fail, try using {\tt safe_tac} to open up your formula; then you
       
   519 can replicate certain quantifiers explicitly by applying appropriate rules.
       
   520 
   545 
   521 \item[\ttindexbold{inst_step_tac} $cs$ $i$] is like {\tt safe_step_tac},
   546 \item[\ttindexbold{inst_step_tac} $cs$ $i$] is like {\tt safe_step_tac},
   522 but allows unknowns to be instantiated.
   547 but allows unknowns to be instantiated.
   523 
   548 
   524 \item[\ttindexbold{step_tac} $cs$ $i$] is the basic step of the proof
   549 \item[\ttindexbold{step_tac} $cs$ $i$] is the basic step of the proof
   537 underlying idea is quite similar to that of a current simpset described in
   562 underlying idea is quite similar to that of a current simpset described in
   538 \S\ref{sec:simp-for-dummies}; please read that section, including its
   563 \S\ref{sec:simp-for-dummies}; please read that section, including its
   539 warnings.  Just like simpsets, clasets can be associated with theories.  The
   564 warnings.  Just like simpsets, clasets can be associated with theories.  The
   540 tactics
   565 tactics
   541 \begin{ttbox}
   566 \begin{ttbox}
   542 Blast_tac    : int -> tactic
   567 Blast_tac        : int -> tactic
   543 Auto_tac     : unit -> tactic
   568 Auto_tac         : unit -> tactic
   544 Fast_tac     : int -> tactic
   569 Fast_tac         : int -> tactic
   545 Best_tac     : int -> tactic
   570 Best_tac         : int -> tactic
   546 Deepen_tac   : int -> int -> tactic
   571 Deepen_tac       : int -> int -> tactic
   547 Step_tac     : int -> tactic
   572 Clarify_tac      : int -> tactic
       
   573 Clarify_step_tac : int -> tactic
       
   574 Step_tac         : int -> tactic
   548 \end{ttbox}
   575 \end{ttbox}
   549 \indexbold{*Blast_tac}\indexbold{*Auto_tac}
   576 \indexbold{*Blast_tac}\indexbold{*Auto_tac}
   550 \indexbold{*Best_tac}\indexbold{*Fast_tac}%
   577 \indexbold{*Best_tac}\indexbold{*Fast_tac}%
   551 \indexbold{*Deepen_tac}\indexbold{*Step_tac}
   578 \indexbold{*Deepen_tac}\indexbold{*Clarify_tac}
       
   579 \indexbold{*Clarify_step_tac}\indexbold{*Step_tac}
   552 make use of the current claset.  E.g. {\tt Blast_tac} is defined as follows:
   580 make use of the current claset.  E.g. {\tt Blast_tac} is defined as follows:
   553 \begin{ttbox}
   581 \begin{ttbox}
   554 fun Blast_tac i = fast_tac (!claset) i;
   582 fun Blast_tac i = fast_tac (!claset) i;
   555 \end{ttbox}
   583 \end{ttbox}
   556 where \ttindex{!claset} is the current claset.
   584 where \ttindex{!claset} is the current claset.
   616 (indicating ordinary resolution) or~{\tt true} (indicating
   644 (indicating ordinary resolution) or~{\tt true} (indicating
   617 elim-resolution).
   645 elim-resolution).
   618 \end{ttdescription}
   646 \end{ttdescription}
   619 
   647 
   620 
   648 
   621 \section{Setting up the classical reasoner}
   649 \section{Setting up the classical reasoner}\label{sec:classical-setup}
   622 \index{classical reasoner!setting up}
   650 \index{classical reasoner!setting up}
   623 Isabelle's classical object-logics, including {\tt FOL} and {\tt HOL}, have
   651 Isabelle's classical object-logics, including {\tt FOL} and {\tt HOL}, have
   624 the classical reasoner already set up.  When defining a new classical logic,
   652 the classical reasoner already set up.  When defining a new classical logic,
   625 you should set up the reasoner yourself.  It consists of the \ML{} functor
   653 you should set up the reasoner yourself.  It consists of the \ML{} functor
   626 \ttindex{ClassicalFun}, which takes the argument
   654 \ttindex{ClassicalFun}, which takes the argument