523 \end{readmore} |
523 \end{readmore} |
524 |
524 |
525 Often proofs on the ML-level involve elaborate operations on assumptions and |
525 Often proofs on the ML-level involve elaborate operations on assumptions and |
526 @{text "\<And>"}-quantified variables. To do such operations using the basic tactics |
526 @{text "\<And>"}-quantified variables. To do such operations using the basic tactics |
527 shown so far is very unwieldy and brittle. Some convenience and |
527 shown so far is very unwieldy and brittle. Some convenience and |
528 safety is provided by the functions @{ML [index] FOCUS} and @{ML [index] SUBPROOF}. |
528 safety is provided by the functions @{ML [index] FOCUS in Subgoal} and |
529 These tactics fix the parameters |
529 @{ML [index] SUBPROOF}. These tactics fix the parameters |
530 and bind the various components of a goal state to a record. |
530 and bind the various components of a goal state to a record. |
531 To see what happens, assume the function defined in Figure~\ref{fig:sptac}, which |
531 To see what happens, assume the function defined in Figure~\ref{fig:sptac}, which |
532 takes a record and just prints out the content of this record (using the |
532 takes a record and just prints out the content of this record (using the |
533 string transformation functions from in Section~\ref{sec:printing}). Consider |
533 string transformation functions from in Section~\ref{sec:printing}). Consider |
534 now the proof: |
534 now the proof: |
545 let |
545 let |
546 val string_of_params = string_of_cterms context (map snd params) |
546 val string_of_params = string_of_cterms context (map snd params) |
547 val string_of_asms = string_of_cterms context asms |
547 val string_of_asms = string_of_cterms context asms |
548 val string_of_concl = string_of_cterm context concl |
548 val string_of_concl = string_of_cterm context concl |
549 val string_of_prems = string_of_thms_no_vars context prems |
549 val string_of_prems = string_of_thms_no_vars context prems |
550 val string_of_schms = string_of_cterms context (snd schematics) |
550 val string_of_schms = string_of_cterms context (map fst (snd schematics)) |
551 |
551 |
552 val _ = (writeln ("params: " ^ string_of_params); |
552 val _ = (writeln ("params: " ^ string_of_params); |
553 writeln ("schematics: " ^ string_of_schms); |
553 writeln ("schematics: " ^ string_of_schms); |
554 writeln ("assumptions: " ^ string_of_asms); |
554 writeln ("assumptions: " ^ string_of_asms); |
555 writeln ("conclusion: " ^ string_of_concl); |
555 writeln ("conclusion: " ^ string_of_concl); |
556 writeln ("premises: " ^ string_of_prems)) |
556 writeln ("premises: " ^ string_of_prems)) |
557 in |
557 in |
558 all_tac |
558 all_tac |
559 end*} |
559 end*} |
|
560 |
560 text_raw{* |
561 text_raw{* |
561 \end{isabelle} |
562 \end{isabelle} |
562 \end{minipage} |
563 \end{minipage} |
563 \caption{A function that prints out the various parameters provided by |
564 \caption{A function that prints out the various parameters provided by |
564 @{ML FOCUS} and @{ML SUBPROOF}. It uses the functions defined in Section~\ref{sec:printing} for |
565 @{ML FOCUS in Subgoal} and @{ML SUBPROOF}. It uses the functions defined |
565 extracting strings from @{ML_type cterm}s and @{ML_type thm}s.\label{fig:sptac}} |
566 in Section~\ref{sec:printing} for extracting strings from @{ML_type cterm}s |
|
567 and @{ML_type thm}s.\label{fig:sptac}} |
566 \end{figure} |
568 \end{figure} |
567 *} |
569 *} |
568 |
570 |
569 lemma shows "\<And>x y. A x y \<Longrightarrow> B y x \<longrightarrow> C (?z y) x" |
571 lemma shows "\<And>x y. A x y \<Longrightarrow> B y x \<longrightarrow> C (?z y) x" |
570 apply(tactic {* FOCUS foc_tac @{context} 1 *}) |
572 apply(tactic {* Subgoal.FOCUS foc_tac @{context} 1 *}) |
571 |
573 |
572 txt {* |
574 txt {* |
573 The tactic produces the following printout: |
575 The tactic produces the following printout: |
574 |
576 |
575 \begin{quote}\small |
577 \begin{quote}\small |
580 conclusion: & @{term "B y x \<longrightarrow> C (z y) x"}\\ |
582 conclusion: & @{term "B y x \<longrightarrow> C (z y) x"}\\ |
581 premises: & @{term "A x y"} |
583 premises: & @{term "A x y"} |
582 \end{tabular} |
584 \end{tabular} |
583 \end{quote} |
585 \end{quote} |
584 |
586 |
|
587 (FIXME: find out how nowadays the schmetics are handled) |
|
588 |
585 Notice in the actual output the brown colour of the variables @{term x} and |
589 Notice in the actual output the brown colour of the variables @{term x} and |
586 @{term y}. Although they are parameters in the original goal, they are fixed inside |
590 @{term y}. Although they are parameters in the original goal, they are fixed inside |
587 the subproof. By convention these fixed variables are printed in brown colour. |
591 the subproof. By convention these fixed variables are printed in brown colour. |
588 Similarly the schematic variable @{term z}. The assumption, or premise, |
592 Similarly the schematic variable @{term z}. The assumption, or premise, |
589 @{prop "A x y"} is bound as @{ML_type cterm} to the record-variable |
593 @{prop "A x y"} is bound as @{ML_type cterm} to the record-variable |
611 (*<*)oops(*>*) |
615 (*<*)oops(*>*) |
612 |
616 |
613 text {* |
617 text {* |
614 Now also @{term "B y x"} is an assumption bound to @{text asms} and @{text prems}. |
618 Now also @{term "B y x"} is an assumption bound to @{text asms} and @{text prems}. |
615 |
619 |
616 The difference between @{ML SUBPROOF} and @{ML FOCUS} is that the former |
620 The difference between @{ML SUBPROOF} and @{ML FOCUS in Subgoal} is that the former |
617 expects that the goal is solved completely, which the latter does not. One |
621 expects that the goal is solved completely, which the latter does not. One |
618 convenience of both @{ML FOCUS} and @{ML SUBPROOF} is that we can apply the |
622 convenience of both @{ML FOCUS in Subgoal} and @{ML SUBPROOF} is that we can apply the |
619 assumptions using the usual tactics, because the parameter @{text prems} |
623 assumptions using the usual tactics, because the parameter @{text prems} |
620 contains them as theorems. With this you can easily implement a tactic that |
624 contains them as theorems. With this you can easily implement a tactic that |
621 behaves almost like @{ML atac}: |
625 behaves almost like @{ML atac}: |
622 *} |
626 *} |
623 |
627 |
655 done |
659 done |
656 |
660 |
657 |
661 |
658 text {* |
662 text {* |
659 \begin{readmore} |
663 \begin{readmore} |
660 The functions @{ML FOCUS} and @{ML SUBPROOF} are defined in |
664 The functions @{ML FOCUS in Subgoal} and @{ML SUBPROOF} are defined in |
661 @{ML_file "Pure/subgoal.ML"} and also described in |
665 @{ML_file "Pure/subgoal.ML"} and also described in |
662 \isccite{sec:results}. |
666 \isccite{sec:results}. |
663 \end{readmore} |
667 \end{readmore} |
664 |
668 |
665 Similar but less powerful functions than @{ML FOCUS} are @{ML [index] SUBGOAL} |
669 Similar but less powerful functions than @{ML FOCUS in Subgoal} are |
666 and @{ML [index] CSUBGOAL}. They allow you to inspect a given subgoal (the former |
670 @{ML [index] SUBGOAL} and @{ML [index] CSUBGOAL}. They allow you to |
|
671 inspect a given subgoal (the former |
667 presents the subgoal as a @{ML_type term}, while the latter as a @{ML_type |
672 presents the subgoal as a @{ML_type term}, while the latter as a @{ML_type |
668 cterm}). With this you can implement a tactic that applies a rule according |
673 cterm}). With this you can implement a tactic that applies a rule according |
669 to the topmost logic connective in the subgoal (to illustrate this we only |
674 to the topmost logic connective in the subgoal (to illustrate this we only |
670 analyse a few connectives). The code of the tactic is as |
675 analyse a few connectives). The code of the tactic is as |
671 follows. |
676 follows. |
1051 |
1056 |
1052 text {* |
1057 text {* |
1053 will solve all trivial subgoals involving @{term True} or @{term "False"}. |
1058 will solve all trivial subgoals involving @{term True} or @{term "False"}. |
1054 |
1059 |
1055 (FIXME: say something about @{ML [index] COND} and COND') |
1060 (FIXME: say something about @{ML [index] COND} and COND') |
1056 |
|
1057 (FIXME: say something about @{ML [index] FOCUS}) |
|
1058 |
1061 |
1059 \begin{readmore} |
1062 \begin{readmore} |
1060 Most tactic combinators described in this section are defined in @{ML_file "Pure/tactical.ML"}. |
1063 Most tactic combinators described in this section are defined in @{ML_file "Pure/tactical.ML"}. |
1061 Some combinators for the purpose of proof search are implemented in @{ML_file "Pure/search.ML"}. |
1064 Some combinators for the purpose of proof search are implemented in @{ML_file "Pure/search.ML"}. |
|
1065 The function @{ML FOCUS in Subgoal} and @{ML SUBPROOF} are defined in @{ML_file "Pure/subgoal.ML"} |
1062 \end{readmore} |
1066 \end{readmore} |
1063 |
1067 |
1064 *} |
1068 *} |
1065 |
1069 |
1066 section {* Simplifier Tactics *} |
1070 section {* Simplifier Tactics *} |