701 scripts, provided that goals are only stated within the current |
701 scripts, provided that goals are only stated within the current |
702 theory. Robust programs would not count on that, of course. |
702 theory. Robust programs would not count on that, of course. |
703 \end{warn} |
703 \end{warn} |
704 |
704 |
705 |
705 |
706 \section{Forward simplification rules} |
706 \section{Forward rules and conversions} |
707 \index{simplification!forward rules} |
707 \index{simplification!forward rules}\index{simplification!conversions} |
708 \begin{ttbox}\index{*simplify}\index{*asm_simplify}\index{*full_simplify}\index{*asm_full_simplify} |
708 \begin{ttbox}\index{*simplify}\index{*asm_simplify}\index{*full_simplify}\index{*asm_full_simplify}\index{*Simplifier.rewrite}\index{*Simplifier.asm_rewrite}\index{*Simplifier.full_rewrite}\index{*Simplifier.asm_full_rewrite} |
709 simplify : simpset -> thm -> thm |
709 simplify : simpset -> thm -> thm |
710 asm_simplify : simpset -> thm -> thm |
710 asm_simplify : simpset -> thm -> thm |
711 full_simplify : simpset -> thm -> thm |
711 full_simplify : simpset -> thm -> thm |
712 asm_full_simplify : simpset -> thm -> thm |
712 asm_full_simplify : simpset -> thm -> thm\medskip |
713 \end{ttbox} |
713 Simplifier.rewrite : simpset -> cterm -> thm |
714 |
714 Simplifier.asm_rewrite : simpset -> cterm -> thm |
715 These functions provide \emph{forward} rules for simplification. |
715 Simplifier.full_rewrite : simpset -> cterm -> thm |
716 Their effect is analogous to the corresponding tactics described in |
716 Simplifier.asm_full_rewrite : simpset -> cterm -> thm |
717 \S\ref{simp-tactics}, but affect the whole theorem instead of just a |
717 \end{ttbox} |
718 certain subgoal. Also note that the looper~/ solver process as |
718 |
719 described in \S\ref{sec:simp-looper} and \S\ref{sec:simp-solver} is |
719 The first four of these functions provide \emph{forward} rules for |
720 omitted in forward simplification. |
720 simplification. Their effect is analogous to the corresponding |
|
721 tactics described in \S\ref{simp-tactics}, but affect the whole |
|
722 theorem instead of just a certain subgoal. Also note that the |
|
723 looper~/ solver process as described in \S\ref{sec:simp-looper} and |
|
724 \S\ref{sec:simp-solver} is omitted in forward simplification. |
|
725 |
|
726 The latter four are \emph{conversions}, establishing proven equations |
|
727 of the form $t \equiv u$ where the l.h.s.\ $t$ has been given as |
|
728 argument. |
721 |
729 |
722 \begin{warn} |
730 \begin{warn} |
723 Forward simplification should be used rarely in ordinary proof |
731 Forward simplification rules and conversions should be used rarely |
724 scripts. It as mainly intended to provide an internal interface to |
732 in ordinary proof scripts. The main intention is to provide an |
725 the simplifier for special utilities. |
733 internal interface to the simplifier for special utilities. |
726 \end{warn} |
734 \end{warn} |
727 |
735 |
728 |
736 |
729 \section{Examples of using the simplifier} |
737 \section{Examples of using the simplifier} |
730 \index{examples!of simplification} Assume we are working within {\tt |
738 \index{examples!of simplification} Assume we are working within {\tt |
814 \begin{ttbox} |
822 \begin{ttbox} |
815 set trace_simp; |
823 set trace_simp; |
816 by (Asm_simp_tac 1); |
824 by (Asm_simp_tac 1); |
817 \ttbreak |
825 \ttbreak |
818 {\out Adding rewrite rule:} |
826 {\out Adding rewrite rule:} |
819 {\out .x + Suc(n) == Suc(.x + n)} |
827 {\out .x + Suc n == Suc (.x + n)} |
820 \ttbreak |
828 \ttbreak |
|
829 {\out Applying instance of rewrite rule:} |
|
830 {\out ?m + Suc ?n == Suc (?m + ?n)} |
821 {\out Rewriting:} |
831 {\out Rewriting:} |
822 {\out Suc(.x) + Suc(n) == Suc(.x + Suc(n))} |
832 {\out Suc .x + Suc n == Suc (Suc .x + n)} |
823 \ttbreak |
833 \ttbreak |
|
834 {\out Applying instance of rewrite rule:} |
|
835 {\out Suc ?m + ?n == Suc (?m + ?n)} |
824 {\out Rewriting:} |
836 {\out Rewriting:} |
825 {\out .x + Suc(n) == Suc(.x + n)} |
837 {\out Suc .x + n == Suc (.x + n)} |
826 \ttbreak |
838 \ttbreak |
|
839 {\out Applying instance of rewrite rule:} |
|
840 {\out Suc ?m + ?n == Suc (?m + ?n)} |
827 {\out Rewriting:} |
841 {\out Rewriting:} |
828 {\out Suc(.x) + n == Suc(.x + n)} |
842 {\out Suc .x + n == Suc (.x + n)} |
829 \ttbreak |
843 \ttbreak |
|
844 {\out Applying instance of rewrite rule:} |
|
845 {\out ?x = ?x == True} |
830 {\out Rewriting:} |
846 {\out Rewriting:} |
831 {\out Suc(Suc(.x + n)) = Suc(Suc(.x + n)) == True} |
847 {\out Suc (Suc (.x + n)) = Suc (Suc (.x + n)) == True} |
832 \ttbreak |
848 \ttbreak |
833 {\out Level 3} |
849 {\out Level 3} |
834 {\out m + Suc(n) = Suc(m + n)} |
850 {\out m + Suc(n) = Suc(m + n)} |
835 {\out No subgoals!} |
851 {\out No subgoals!} |
836 \end{ttbox} |
852 \end{ttbox} |
1422 \begin{ttbox} |
1438 \begin{ttbox} |
1423 by (simp_tac (simpset() addsplits [expand_if]) 1); |
1439 by (simp_tac (simpset() addsplits [expand_if]) 1); |
1424 \end{ttbox} |
1440 \end{ttbox} |
1425 |
1441 |
1426 |
1442 |
1427 \subsection{Theory data for implicit simpsets} |
1443 \subsection{Theory setup}\index{simplification!setting up the theory} |
1428 \begin{ttbox}\indexbold{*simpset_thy_data} |
1444 \begin{ttbox}\indexbold{*Simplifier.setup}\index{*setup!simplifier} |
1429 simpset_thy_data: string * (object * (object -> object) * |
1445 Simplifier.setup: (theory -> theory) list |
1430 (object * object -> object) * (Sign.sg -> object -> unit)) |
1446 \end{ttbox} |
1431 \end{ttbox} |
1447 |
1432 |
1448 Advanced theory related features of the simplifier (e.g.\ implicit |
1433 Theory data for implicit simpsets has to be set up explicitly. The |
1449 simpset support) have to be set up explicitly. The simplifier already |
1434 simplifier already provides an appropriate data kind definition |
1450 provides a suitable setup function definition. This has to be |
1435 record. This has to be installed into the base theory of any new |
1451 installed into the base theory of any new object-logic via a |
1436 object-logic as \ttindexbold{thy_data} within the \texttt{ML} section. |
1452 \texttt{setup} declaration. |
1437 |
1453 |
1438 This is done at the end of \texttt{IFOL.thy} as follows: |
1454 For example, this is done in \texttt{FOL/IFOL.thy} as follows: |
1439 \begin{ttbox} |
1455 \begin{ttbox} |
1440 ML val thy_data = [Simplifier.simpset_thy_data]; |
1456 setup Simplifier.setup |
1441 \end{ttbox} |
1457 \end{ttbox} |
1442 |
1458 |
1443 |
1459 |
1444 \index{simplification|)} |
1460 \index{simplification|)} |
|
1461 |
|
1462 |
|
1463 %%% Local Variables: |
|
1464 %%% mode: latex |
|
1465 %%% TeX-master: "ref" |
|
1466 %%% End: |