474 \isamarkupsection{Tacticals \label{sec:tacticals}% |
474 \isamarkupsection{Tacticals \label{sec:tacticals}% |
475 } |
475 } |
476 \isamarkuptrue% |
476 \isamarkuptrue% |
477 % |
477 % |
478 \begin{isamarkuptext}% |
478 \begin{isamarkuptext}% |
479 A \emph{tactical} is a functional combinator for building up complex |
479 A \emph{tactical} is a functional combinator for building up |
480 tactics from simpler ones. Typical tactical perform sequential |
480 complex tactics from simpler ones. Common tacticals perform |
481 composition, disjunction (choice), iteration, or goal addressing. |
481 sequential composition, disjunctive choice, iteration, or goal |
482 Various search strategies may be expressed via tacticals. |
482 addressing. Various search strategies may be expressed via |
483 |
483 tacticals. |
484 \medskip FIXME |
484 |
485 |
485 \medskip The chapter on tacticals in old \cite{isabelle-ref} is |
486 \medskip The chapter on tacticals in \cite{isabelle-ref} is still |
486 still applicable for further details.% |
487 applicable, despite a few outdated details.% |
487 \end{isamarkuptext}% |
488 \end{isamarkuptext}% |
488 \isamarkuptrue% |
489 \isamarkuptrue% |
489 % |
|
490 \isamarkupsubsection{Combining tactics% |
|
491 } |
|
492 \isamarkuptrue% |
|
493 % |
|
494 \begin{isamarkuptext}% |
|
495 Sequential composition and alternative choices are the most |
|
496 basic ways to combine tactics, similarly to ``\verb|,|'' and |
|
497 ``\verb||\verb,|,\verb||'' in Isar method notation. This corresponds to |
|
498 \isa{THEN} and \isa{ORELSE} in ML, but there are further |
|
499 possibilities for fine-tuning alternation of tactics such as \isa{APPEND}. Further details become visible in ML due to explicit |
|
500 subgoal addressing.% |
|
501 \end{isamarkuptext}% |
|
502 \isamarkuptrue% |
|
503 % |
|
504 \isadelimmlref |
|
505 % |
|
506 \endisadelimmlref |
|
507 % |
|
508 \isatagmlref |
|
509 % |
|
510 \begin{isamarkuptext}% |
|
511 \begin{mldecls} |
|
512 \indexdef{}{ML}{THEN}\verb|op THEN: tactic * tactic -> tactic| \\ |
|
513 \indexdef{}{ML}{ORELSE}\verb|op ORELSE: tactic * tactic -> tactic| \\ |
|
514 \indexdef{}{ML}{APPEND}\verb|op APPEND: tactic * tactic -> tactic| \\ |
|
515 \indexdef{}{ML}{EVERY}\verb|EVERY: tactic list -> tactic| \\ |
|
516 \indexdef{}{ML}{FIRST}\verb|FIRST: tactic list -> tactic| \\[0.5ex] |
|
517 |
|
518 \indexdef{}{ML}{THEN'}\verb|op THEN': ('a -> tactic) * ('a -> tactic) -> 'a -> tactic| \\ |
|
519 \indexdef{}{ML}{ORELSE'}\verb|op ORELSE': ('a -> tactic) * ('a -> tactic) -> 'a -> tactic| \\ |
|
520 \indexdef{}{ML}{APPEND'}\verb|op APPEND': ('a -> tactic) * ('a -> tactic) -> 'a -> tactic| \\ |
|
521 \indexdef{}{ML}{EVERY'}\verb|EVERY': ('a -> tactic) list -> 'a -> tactic| \\ |
|
522 \indexdef{}{ML}{FIRST'}\verb|FIRST': ('a -> tactic) list -> 'a -> tactic| \\ |
|
523 \indexdef{}{ML}{EVERY1}\verb|EVERY1: (int -> tactic) list -> tactic| \\ |
|
524 \indexdef{}{ML}{FIRST1}\verb|FIRST1: (int -> tactic) list -> tactic| \\[0.5ex] |
|
525 \end{mldecls} |
|
526 |
|
527 \begin{description} |
|
528 |
|
529 \item \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ THEN\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}} is the sequential composition of |
|
530 \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} and \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}}. Applied to a proof state, it |
|
531 returns all states reachable in two steps by applying \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} |
|
532 followed by \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}}. First, it applies \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} to the |
|
533 proof state, getting a sequence of possible next states; then, it |
|
534 applies \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}} to each of these and concatenates the results |
|
535 to produce again one flat sequence of states. |
|
536 |
|
537 \item \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ ORELSE\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}} makes a choice between \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} and \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}}. Applied to a state, it tries \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} and returns the result if non-empty; if \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} fails |
|
538 then it uses \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}}. This is a deterministic choice: if |
|
539 \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} succeeds then \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}} is excluded from the |
|
540 result. |
|
541 |
|
542 \item \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ APPEND\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}} concatenates the possible results |
|
543 of \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}} and \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}}. Unlike \isa{ORELSE} there |
|
544 is \emph{no commitment} to either tactic, so \isa{APPEND} helps |
|
545 to avoid incompleteness during search, at the cost of potential |
|
546 inefficiencies. |
|
547 |
|
548 \item \isa{EVERY\ {\isaliteral{5B}{\isacharbrackleft}}tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{5D}{\isacharbrackright}}} abbreviates \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ THEN\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ THEN\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub n}. Note that \isa{EVERY\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5D}{\isacharbrackright}}} is the same as \verb|all_tac|: it always succeeds. |
|
549 |
|
550 \item \isa{FIRST\ {\isaliteral{5B}{\isacharbrackleft}}tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}{\isaliteral{2C}{\isacharcomma}}\ {\isaliteral{5C3C646F74733E}{\isasymdots}}{\isaliteral{2C}{\isacharcomma}}\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub n{\isaliteral{5D}{\isacharbrackright}}} abbreviates \isa{tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ ORELSE\ {\isaliteral{5C3C646F74733E}{\isasymdots}}\ ORELSE\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub n}. Note that \isa{FIRST\ {\isaliteral{5B}{\isacharbrackleft}}{\isaliteral{5D}{\isacharbrackright}}} is the same as |
|
551 \verb|no_tac|: it always fails. |
|
552 |
|
553 \item \isa{THEN{\isaliteral{27}{\isacharprime}}}, \isa{ORELSE{\isaliteral{27}{\isacharprime}}}, and \isa{APPEND{\isaliteral{27}{\isacharprime}}} are |
|
554 lifted versions of \isa{THEN}, \isa{ORELSE}, and \isa{APPEND}, for tactics with explicit subgoal addressing. This means |
|
555 \isa{{\isaliteral{28}{\isacharparenleft}}tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ THEN{\isaliteral{27}{\isacharprime}}\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}{\isaliteral{29}{\isacharparenright}}\ i} is the same as \isa{{\isaliteral{28}{\isacharparenleft}}tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{1}}\ i\ THEN\ tac\isaliteral{5C3C5E7375623E}{}\isactrlsub {\isadigit{2}}\ i{\isaliteral{29}{\isacharparenright}}} etc. |
|
556 |
|
557 \item \isa{EVERY{\isaliteral{27}{\isacharprime}}} and \isa{FIRST{\isaliteral{27}{\isacharprime}}} are lifted versions of |
|
558 \isa{EVERY{\isaliteral{27}{\isacharprime}}} and \isa{FIRST{\isaliteral{27}{\isacharprime}}}, for tactics with explicit |
|
559 subgoal addressing. |
|
560 |
|
561 \item \isa{EVERY{\isadigit{1}}} and \isa{FIRST{\isadigit{1}}} are convenience versions |
|
562 of \isa{EVERY{\isaliteral{27}{\isacharprime}}} and \isa{FIRST{\isaliteral{27}{\isacharprime}}}, applied to subgoal 1. |
|
563 |
|
564 \end{description}% |
|
565 \end{isamarkuptext}% |
|
566 \isamarkuptrue% |
|
567 % |
|
568 \endisatagmlref |
|
569 {\isafoldmlref}% |
|
570 % |
|
571 \isadelimmlref |
|
572 % |
|
573 \endisadelimmlref |
490 % |
574 % |
491 \isadelimtheory |
575 \isadelimtheory |
492 % |
576 % |
493 \endisadelimtheory |
577 \endisadelimtheory |
494 % |
578 % |