doc-src/IsarImplementation/Thy/document/Tactic.tex
changeset 46263 a87e06a18a5c
parent 46262 912b42e64fde
child 46264 f575281fb551
equal deleted inserted replaced
46262:912b42e64fde 46263:a87e06a18a5c
   726 {\isafoldML}%
   726 {\isafoldML}%
   727 %
   727 %
   728 \isadelimML
   728 \isadelimML
   729 %
   729 %
   730 \endisadelimML
   730 \endisadelimML
   731 \isanewline
   731 %
       
   732 \isamarkupsubsection{Scanning for a subgoal by number%
       
   733 }
       
   734 \isamarkuptrue%
       
   735 %
       
   736 \begin{isamarkuptext}%
       
   737 Tactics with explicit subgoal addressing
       
   738   \verb|int -> tactic| can be used together with tacticals that
       
   739   act like ``subgoal quantifiers'': guided by success of the body
       
   740   tactic a certain range of subgoals is covered.  Thus the body tactic
       
   741   is applied to all subgoals, for example.
       
   742 
       
   743   Suppose that the goal state has \isa{n\ {\isaliteral{5C3C67653E}{\isasymge}}\ {\isadigit{0}}} subgoals.  Many of
       
   744   these tacticals address subgoal ranges counting downwards from
       
   745   \isa{n} towards \isa{{\isadigit{1}}}.  This has the fortunate effect that
       
   746   newly emerging subgoals are concatenated in the result, without
       
   747   interfering each other.  Nonetheless, there might be situations
       
   748   where a different order is desired, but it has to be achieved by
       
   749   other means.%
       
   750 \end{isamarkuptext}%
       
   751 \isamarkuptrue%
       
   752 %
       
   753 \isadelimmlref
       
   754 %
       
   755 \endisadelimmlref
       
   756 %
       
   757 \isatagmlref
       
   758 %
       
   759 \begin{isamarkuptext}%
       
   760 \begin{mldecls}
       
   761   \indexdef{}{ML}{ALLGOALS}\verb|ALLGOALS: (int -> tactic) -> tactic| \\
       
   762   \indexdef{}{ML}{TRYALL}\verb|TRYALL: (int -> tactic) -> tactic| \\
       
   763   \indexdef{}{ML}{SOMEGOAL}\verb|SOMEGOAL: (int -> tactic) -> tactic| \\
       
   764   \indexdef{}{ML}{FIRSTGOAL}\verb|FIRSTGOAL: (int -> tactic) -> tactic| \\
       
   765   \indexdef{}{ML}{REPEAT\_SOME}\verb|REPEAT_SOME: (int -> tactic) -> tactic| \\
       
   766   \indexdef{}{ML}{REPEAT\_FIRST}\verb|REPEAT_FIRST: (int -> tactic) -> tactic| \\
       
   767   \indexdef{}{ML}{trace\_goalno\_tac}\verb|trace_goalno_tac: (int -> tactic) -> int -> tactic| \\
       
   768   \end{mldecls}
       
   769 
       
   770   \begin{description}
       
   771 
       
   772   \item \verb|ALLGOALS|~\isa{tac} is equivalent to \isa{tac\ n}~\verb|THEN|~\isa{{\isaliteral{5C3C646F74733E}{\isasymdots}}}~\verb|THEN|~\isa{tac\ {\isadigit{1}}}.  It
       
   773   applies the \isa{tac} to all the subgoals, counting downwards.
       
   774 
       
   775   \item \verb|TRYALL|~\isa{tac} is equivalent to \verb|TRY|~\isa{{\isaliteral{28}{\isacharparenleft}}tac\ n{\isaliteral{29}{\isacharparenright}}}~\verb|THEN|~\isa{{\isaliteral{5C3C646F74733E}{\isasymdots}}}~\verb|THEN|~\verb|TRY|~\isa{{\isaliteral{28}{\isacharparenleft}}tac\ {\isadigit{1}}{\isaliteral{29}{\isacharparenright}}}.  It attempts to apply \isa{tac} to all the subgoals.
       
   776 
       
   777   \item \verb|SOMEGOAL|~\isa{tac} is equivalent to \isa{tac\ n}~\verb|ORELSE|~\isa{{\isaliteral{5C3C646F74733E}{\isasymdots}}}~\verb|ORELSE|~\isa{tac\ {\isadigit{1}}}.  It
       
   778   applies \isa{tac} to one subgoal, counting downwards.
       
   779 
       
   780   \item \verb|FIRSTGOAL|~\isa{tac} is equivalent to \isa{tac\ {\isadigit{1}}}~\verb|ORELSE|~\isa{{\isaliteral{5C3C646F74733E}{\isasymdots}}}~\verb|ORELSE|~\isa{tac\ n}.  It
       
   781   applies \isa{tac} to one subgoal, counting upwards.
       
   782 
       
   783   \item \verb|REPEAT_SOME|~\isa{tac} applies \isa{tac} once or
       
   784   more to a subgoal, counting downwards.
       
   785 
       
   786   \item \verb|REPEAT_FIRST|~\isa{tac} applies \isa{tac} once or
       
   787   more to a subgoal, counting upwards.
       
   788 
       
   789   \item \verb|trace_goalno_tac|~\isa{tac\ i} applies \isa{tac\ i}
       
   790   to the proof state.  If the resulting sequence is non-empty, then it
       
   791   is returned, with the side-effect of printing the selected subgoal.
       
   792   Otherwise, it fails and prints nothing.  It indicates that ``the
       
   793   tactic worked for subgoal \isa{i}'' and is mainly used with \verb|SOMEGOAL| and \verb|FIRSTGOAL|.
       
   794 
       
   795   \end{description}%
       
   796 \end{isamarkuptext}%
       
   797 \isamarkuptrue%
       
   798 %
       
   799 \endisatagmlref
       
   800 {\isafoldmlref}%
       
   801 %
       
   802 \isadelimmlref
       
   803 %
       
   804 \endisadelimmlref
   732 %
   805 %
   733 \isadelimtheory
   806 \isadelimtheory
   734 \isanewline
       
   735 %
   807 %
   736 \endisadelimtheory
   808 \endisadelimtheory
   737 %
   809 %
   738 \isatagtheory
   810 \isatagtheory
   739 \isacommand{end}\isamarkupfalse%
   811 \isacommand{end}\isamarkupfalse%