doc-src/Ref/tactic.tex
changeset 4317 7264fa2ff2ec
parent 4276 a770eae2cdb0
child 4597 a0bdee64194c
equal deleted inserted replaced
4316:86ac9153e660 4317:7264fa2ff2ec
     4 abbreviation for functions from theorems to theorem sequences, where
     4 abbreviation for functions from theorems to theorem sequences, where
     5 the theorems represent states of a backward proof.  Tactics seldom
     5 the theorems represent states of a backward proof.  Tactics seldom
     6 need to be coded from scratch, as functions; instead they are
     6 need to be coded from scratch, as functions; instead they are
     7 expressed using basic tactics and tacticals.
     7 expressed using basic tactics and tacticals.
     8 
     8 
     9 This chapter only presents the primitive tactics.  Substantial proofs require
     9 This chapter only presents the primitive tactics.  Substantial proofs
    10 the power of simplification (Chapter~\ref{chap:simplification}) and classical
    10 require the power of automatic tools like simplification
    11 reasoning (Chapter~\ref{chap:classical}).
    11 (Chapter~\ref{chap:simplification}) and classical tableau reasoning
       
    12 (Chapter~\ref{chap:classical}).
    12 
    13 
    13 \section{Resolution and assumption tactics}
    14 \section{Resolution and assumption tactics}
    14 {\bf Resolution} is Isabelle's basic mechanism for refining a subgoal using
    15 {\bf Resolution} is Isabelle's basic mechanism for refining a subgoal using
    15 a rule.  {\bf Elim-resolution} is particularly suited for elimination
    16 a rule.  {\bf Elim-resolution} is particularly suited for elimination
    16 rules, while {\bf destruct-resolution} is particularly suited for
    17 rules, while {\bf destruct-resolution} is particularly suited for
   249   The tactic fails if subgoal~$i$ does not exist or if the proof state
   250   The tactic fails if subgoal~$i$ does not exist or if the proof state
   250   contains type unknowns. 
   251   contains type unknowns. 
   251 \end{ttdescription}
   252 \end{ttdescription}
   252 
   253 
   253 
   254 
   254 \subsection{Definitions and meta-level rewriting}
   255 \subsection{Definitions and meta-level rewriting} \label{sec:rewrite_goals}
   255 \index{tactics!meta-rewriting|bold}\index{meta-rewriting|bold}
   256 \index{tactics!meta-rewriting|bold}\index{meta-rewriting|bold}
   256 \index{definitions}
   257 \index{definitions}
   257 
   258 
   258 Definitions in Isabelle have the form $t\equiv u$, where $t$ is typically a
   259 Definitions in Isabelle have the form $t\equiv u$, where $t$ is typically a
   259 constant or a constant applied to a list of variables, for example $\it
   260 constant or a constant applied to a list of variables, for example $\it
   260 sqr(n)\equiv n\times n$.  (Conditional definitions, $\phi\Imp t\equiv u$,
   261 sqr(n)\equiv n\times n$.  Conditional definitions, $\phi\Imp t\equiv u$,
   261 are not supported.)  {\bf Unfolding} the definition ${t\equiv u}$ means using
   262 are also supported.  {\bf Unfolding} the definition ${t\equiv u}$ means using
   262 it as a rewrite rule, replacing~$t$ by~$u$ throughout a theorem.  {\bf
   263 it as a rewrite rule, replacing~$t$ by~$u$ throughout a theorem.  {\bf
   263 Folding} $t\equiv u$ means replacing~$u$ by~$t$.  Rewriting continues until
   264 Folding} $t\equiv u$ means replacing~$u$ by~$t$.  Rewriting continues until
   264 no rewrites are applicable to any subterm.
   265 no rewrites are applicable to any subterm.
   265 
   266 
   266 There are rules for unfolding and folding definitions; Isabelle does not do
   267 There are rules for unfolding and folding definitions; Isabelle does not do
   289 
   290 
   290 \item[\ttindexbold{fold_tac} {\it defs}]  
   291 \item[\ttindexbold{fold_tac} {\it defs}]  
   291 folds the {\it defs} throughout the proof state.
   292 folds the {\it defs} throughout the proof state.
   292 \end{ttdescription}
   293 \end{ttdescription}
   293 
   294 
       
   295 \begin{warn}
       
   296   These tactics only cope with definitions expressed as meta-level
       
   297   equalities ($\equiv$).  More general equivalences are handled by the
       
   298   simplifier, provided that it is set up appropriately for your logic
       
   299   (see Chapter~\ref{chap:simplification}).
       
   300 \end{warn}
   294 
   301 
   295 \subsection{Theorems useful with tactics}
   302 \subsection{Theorems useful with tactics}
   296 \index{theorems!of pure theory}
   303 \index{theorems!of pure theory}
   297 \begin{ttbox} 
   304 \begin{ttbox} 
   298 asm_rl: thm 
   305 asm_rl: thm 
   354 
   361 
   355 \item[\ttindexbold{Logic.set_rename_prefix} {\it prefix};] 
   362 \item[\ttindexbold{Logic.set_rename_prefix} {\it prefix};] 
   356 sets the prefix for uniform renaming to~{\it prefix}.  The default prefix
   363 sets the prefix for uniform renaming to~{\it prefix}.  The default prefix
   357 is {\tt"k"}.
   364 is {\tt"k"}.
   358 
   365 
   359 \item[\ttindexbold{Logic.auto_rename} := true;] 
   366 \item[set \ttindexbold{Logic.auto_rename};] 
   360 makes Isabelle generate uniform names for parameters. 
   367 makes Isabelle generate uniform names for parameters. 
   361 \end{ttdescription}
   368 \end{ttdescription}
   362 
   369 
   363 
   370 
   364 \subsection{Manipulating assumptions}
   371 \subsection{Manipulating assumptions}
   557 conclusion of the subgoal with the conclusion of each rule.  The resulting list
   564 conclusion of the subgoal with the conclusion of each rule.  The resulting list
   558 is no longer than {\it limit}.
   565 is no longer than {\it limit}.
   559 \end{ttdescription}
   566 \end{ttdescription}
   560 
   567 
   561 
   568 
   562 \section{*Programming tools for proof strategies}
   569 \section{Programming tools for proof strategies}
   563 Do not consider using the primitives discussed in this section unless you
   570 Do not consider using the primitives discussed in this section unless you
   564 really need to code tactics from scratch.
   571 really need to code tactics from scratch.
   565 
   572 
   566 \subsection{Operations on type {\tt tactic}}
   573 \subsection{Operations on type {\tt tactic}}
   567 \index{tactics!primitives for coding} A tactic maps theorems to sequences of
   574 \index{tactics!primitives for coding} A tactic maps theorems to sequences of
   624 a value:
   631 a value:
   625 \begin{ttbox}
   632 \begin{ttbox}
   626 datatype 'a option = None  |  Some of 'a;
   633 datatype 'a option = None  |  Some of 'a;
   627 \end{ttbox}
   634 \end{ttbox}
   628 The {\tt Seq} structure is supposed to be accessed via fully qualified
   635 The {\tt Seq} structure is supposed to be accessed via fully qualified
   629 names and should not be \texttt{open}ed.
   636 names and should not be \texttt{open}.
   630 
   637 
   631 \subsection{Basic operations on sequences}
   638 \subsection{Basic operations on sequences}
   632 \begin{ttbox} 
   639 \begin{ttbox} 
   633 Seq.empty   : 'a seq
   640 Seq.empty   : 'a seq
   634 Seq.make    : (unit -> ('a * 'a seq) option) -> 'a seq
   641 Seq.make    : (unit -> ('a * 'a seq) option) -> 'a seq