doc-src/Ref/tctical.tex
changeset 8149 941afb897532
parent 6569 66c941ea1f01
child 13104 df7aac8543c9
equal deleted inserted replaced
8148:5ef0b624aadb 8149:941afb897532
    65 
    65 
    66 
    66 
    67 \subsection{Repetition tacticals}
    67 \subsection{Repetition tacticals}
    68 \index{tacticals!repetition}
    68 \index{tacticals!repetition}
    69 \begin{ttbox} 
    69 \begin{ttbox} 
    70 TRY           : tactic -> tactic
    70 TRY             : tactic -> tactic
    71 REPEAT_DETERM : tactic -> tactic
    71 REPEAT_DETERM   : tactic -> tactic
    72 REPEAT        : tactic -> tactic
    72 REPEAT_DETERM_N : int -> tactic -> tactic
    73 REPEAT1       : tactic -> tactic
    73 REPEAT          : tactic -> tactic
    74 trace_REPEAT  : bool ref \hfill{\bf initially false}
    74 REPEAT1         : tactic -> tactic
       
    75 DETERM_UNTIL    : (thm -> bool) -> tactic -> tactic
       
    76 trace_REPEAT    : bool ref \hfill{\bf initially false}
    75 \end{ttbox}
    77 \end{ttbox}
    76 \begin{ttdescription}
    78 \begin{ttdescription}
    77 \item[\ttindexbold{TRY} {\it tac}] 
    79 \item[\ttindexbold{TRY} {\it tac}] 
    78 applies {\it tac\/} to the proof state and returns the resulting sequence,
    80 applies {\it tac\/} to the proof state and returns the resulting sequence,
    79 if non-empty; otherwise it returns the original state.  Thus, it applies
    81 if non-empty; otherwise it returns the original state.  Thus, it applies
    81 
    83 
    82 \item[\ttindexbold{REPEAT_DETERM} {\it tac}] 
    84 \item[\ttindexbold{REPEAT_DETERM} {\it tac}] 
    83 applies {\it tac\/} to the proof state and, recursively, to the head of the
    85 applies {\it tac\/} to the proof state and, recursively, to the head of the
    84 resulting sequence.  It returns the first state to make {\it tac\/} fail.
    86 resulting sequence.  It returns the first state to make {\it tac\/} fail.
    85 It is deterministic, discarding alternative outcomes.
    87 It is deterministic, discarding alternative outcomes.
       
    88 
       
    89 \item[\ttindexbold{REPEAT_DETERM_N} {\it n} {\it tac}] 
       
    90 is like \hbox{\tt REPEAT_DETERM {\it tac}} but the number of repititions
       
    91 is bound by {\it n} (unless negative).
    86 
    92 
    87 \item[\ttindexbold{REPEAT} {\it tac}] 
    93 \item[\ttindexbold{REPEAT} {\it tac}] 
    88 applies {\it tac\/} to the proof state and, recursively, to each element of
    94 applies {\it tac\/} to the proof state and, recursively, to each element of
    89 the resulting sequence.  The resulting sequence consists of those states
    95 the resulting sequence.  The resulting sequence consists of those states
    90 that make {\it tac\/} fail.  Thus, it applies {\it tac\/} as many times as
    96 that make {\it tac\/} fail.  Thus, it applies {\it tac\/} as many times as
    94 
   100 
    95 \item[\ttindexbold{REPEAT1} {\it tac}] 
   101 \item[\ttindexbold{REPEAT1} {\it tac}] 
    96 is like \hbox{\tt REPEAT {\it tac}} but it always applies {\it tac\/} at
   102 is like \hbox{\tt REPEAT {\it tac}} but it always applies {\it tac\/} at
    97 least once, failing if this is impossible.
   103 least once, failing if this is impossible.
    98 
   104 
       
   105 \item[\ttindexbold{DETERM_UNTIL} {\it p} {\it tac}] 
       
   106 applies {\it tac\/} to the proof state and, recursively, to the head of the
       
   107 resulting sequence, until the predicate {\it p} (applied on the proof state)
       
   108 yields {\it true}. It fails if {\it tac\/} fails on any of the intermediate 
       
   109 states. It is deterministic, discarding alternative outcomes.
       
   110 
    99 \item[set \ttindexbold{trace_REPEAT};] 
   111 \item[set \ttindexbold{trace_REPEAT};] 
   100 enables an interactive tracing mode for the tacticals {\tt REPEAT_DETERM}
   112 enables an interactive tracing mode for the tacticals {\tt REPEAT_DETERM}
   101 and {\tt REPEAT}.  To view the tracing options, type {\tt h} at the prompt.
   113 and {\tt REPEAT}.  To view the tracing options, type {\tt h} at the prompt.
   102 \end{ttdescription}
   114 \end{ttdescription}
   103 
   115 
   250 
   262 
   251 \subsection{Auxiliary tacticals for searching}
   263 \subsection{Auxiliary tacticals for searching}
   252 \index{tacticals!conditional}
   264 \index{tacticals!conditional}
   253 \index{tacticals!deterministic}
   265 \index{tacticals!deterministic}
   254 \begin{ttbox} 
   266 \begin{ttbox} 
   255 COND        : (thm->bool) -> tactic -> tactic -> tactic
   267 COND                : (thm->bool) -> tactic -> tactic -> tactic
   256 IF_UNSOLVED : tactic -> tactic
   268 IF_UNSOLVED         : tactic -> tactic
   257 SOLVE       : tactic -> tactic
   269 SOLVE               : tactic -> tactic
   258 DETERM      : tactic -> tactic
   270 DETERM              : tactic -> tactic
       
   271 DETERM_UNTIL_SOLVED : tactic -> tactic
   259 \end{ttbox}
   272 \end{ttbox}
   260 \begin{ttdescription}
   273 \begin{ttdescription}
   261 \item[\ttindexbold{COND} {\it p} $tac@1$ $tac@2$] 
   274 \item[\ttindexbold{COND} {\it p} $tac@1$ $tac@2$] 
   262 applies $tac@1$ to the proof state if it satisfies~$p$, and applies $tac@2$
   275 applies $tac@1$ to the proof state if it satisfies~$p$, and applies $tac@2$
   263 otherwise.  It is a conditional tactical in that only one of $tac@1$ and
   276 otherwise.  It is a conditional tactical in that only one of $tac@1$ and
   275 
   288 
   276 \item[\ttindexbold{DETERM} {\it tac}] 
   289 \item[\ttindexbold{DETERM} {\it tac}] 
   277 applies {\it tac\/} to the proof state and returns the head of the
   290 applies {\it tac\/} to the proof state and returns the head of the
   278 resulting sequence.  {\tt DETERM} limits the search space by making its
   291 resulting sequence.  {\tt DETERM} limits the search space by making its
   279 argument deterministic.
   292 argument deterministic.
       
   293 
       
   294 \item[\ttindexbold{DETERM_UNTIL_SOLVED} {\it tac}] 
       
   295 forces repeated deterministic application of {\it tac\/} to the proof state 
       
   296 until the goal is solved completely.
   280 \end{ttdescription}
   297 \end{ttdescription}
   281 
   298 
   282 
   299 
   283 \subsection{Predicates and functions useful for searching}
   300 \subsection{Predicates and functions useful for searching}
   284 \index{theorems!size of}
   301 \index{theorems!size of}