equal
deleted
inserted
replaced
522 now the proof: |
522 now the proof: |
523 *} |
523 *} |
524 |
524 |
525 text_raw{* |
525 text_raw{* |
526 \begin{figure}[t] |
526 \begin{figure}[t] |
|
527 \begin{minipage}{\textwidth} |
527 \begin{isabelle} |
528 \begin{isabelle} |
528 *} |
529 *} |
529 ML{*fun sp_tac {prems, params, asms, concl, context, schematics} = |
530 ML{*fun sp_tac {prems, params, asms, concl, context, schematics} = |
530 let |
531 let |
531 val str_of_params = str_of_cterms context params |
532 val str_of_params = str_of_cterms context params |
542 in |
543 in |
543 no_tac |
544 no_tac |
544 end*} |
545 end*} |
545 text_raw{* |
546 text_raw{* |
546 \end{isabelle} |
547 \end{isabelle} |
|
548 \end{minipage} |
547 \caption{A function that prints out the various parameters provided by the tactic |
549 \caption{A function that prints out the various parameters provided by the tactic |
548 @{ML SUBPROOF}. It uses the functions defined in Section~\ref{sec:printing} for |
550 @{ML SUBPROOF}. It uses the functions defined in Section~\ref{sec:printing} for |
549 extracting strings from @{ML_type cterm}s and @{ML_type thm}s.\label{fig:sptac}} |
551 extracting strings from @{ML_type cterm}s and @{ML_type thm}s.\label{fig:sptac}} |
550 \end{figure} |
552 \end{figure} |
551 *} |
553 *} |
1118 (FIXME: What about splitters? @{ML addsplits}, @{ML delsplits}) |
1120 (FIXME: What about splitters? @{ML addsplits}, @{ML delsplits}) |
1119 *} |
1121 *} |
1120 |
1122 |
1121 text_raw {* |
1123 text_raw {* |
1122 \begin{figure}[t] |
1124 \begin{figure}[t] |
|
1125 \begin{minipage}{\textwidth} |
1123 \begin{isabelle}*} |
1126 \begin{isabelle}*} |
1124 ML{*fun print_ss ctxt ss = |
1127 ML{*fun print_ss ctxt ss = |
1125 let |
1128 let |
1126 val {simps, congs, procs, ...} = MetaSimplifier.dest_ss ss |
1129 val {simps, congs, procs, ...} = MetaSimplifier.dest_ss ss |
1127 |
1130 |
1142 |> implode |
1145 |> implode |
1143 |> warning |
1146 |> warning |
1144 end*} |
1147 end*} |
1145 text_raw {* |
1148 text_raw {* |
1146 \end{isabelle} |
1149 \end{isabelle} |
|
1150 \end{minipage} |
1147 \caption{The function @{ML MetaSimplifier.dest_ss} returns a record containing |
1151 \caption{The function @{ML MetaSimplifier.dest_ss} returns a record containing |
1148 all printable information stored in a simpset. We are here only interested in the |
1152 all printable information stored in a simpset. We are here only interested in the |
1149 simplifcation rules, congruence rules and simprocs.\label{fig:printss}} |
1153 simplifcation rules, congruence rules and simprocs.\label{fig:printss}} |
1150 \end{figure} *} |
1154 \end{figure} *} |
1151 |
1155 |
1453 moment we are \emph{not} interested in actually rewriting anything. We want |
1457 moment we are \emph{not} interested in actually rewriting anything. We want |
1454 that the simproc is triggered by the pattern @{term "Suc n"}. This can be |
1458 that the simproc is triggered by the pattern @{term "Suc n"}. This can be |
1455 done by adding the simproc to the current simpset as follows |
1459 done by adding the simproc to the current simpset as follows |
1456 *} |
1460 *} |
1457 |
1461 |
1458 simproc_setup fail_sp ("Suc n") = {* K fail_sp_aux *} |
1462 simproc_setup %gray fail_sp ("Suc n") = {* K fail_sp_aux *} |
1459 |
1463 |
1460 text {* |
1464 text {* |
1461 where the second argument specifies the pattern and the right-hand side |
1465 where the second argument specifies the pattern and the right-hand side |
1462 contains the code of the simproc (we have to use @{ML K} since we ignoring |
1466 contains the code of the simproc (we have to use @{ML K} since we ignoring |
1463 an argument about morphisms\footnote{FIXME: what does the morphism do?}). |
1467 an argument about morphisms\footnote{FIXME: what does the morphism do?}). |
1537 Simprocs are applied from inside to outside and from left to right. You can |
1541 Simprocs are applied from inside to outside and from left to right. You can |
1538 see this in the proof |
1542 see this in the proof |
1539 *} |
1543 *} |
1540 |
1544 |
1541 lemma shows "Suc (Suc 0) = (Suc 1)" |
1545 lemma shows "Suc (Suc 0) = (Suc 1)" |
1542 apply(tactic {* simp_tac (HOL_basic_ss addsimprocs [fail_sp']) 1*}) |
1546 apply(tactic {* simp_tac (HOL_basic_ss addsimprocs [fail_sp']) 1*}) |
1543 (*<*)oops(*>*) |
1547 (*<*)oops(*>*) |
1544 |
1548 |
1545 text {* |
1549 text {* |
1546 The simproc @{ML fail_sp'} prints out the sequence |
1550 The simproc @{ML fail_sp'} prints out the sequence |
1547 |
1551 |
1589 a theorem if the term is not @{term "Suc 0"}. The result you can see |
1593 a theorem if the term is not @{term "Suc 0"}. The result you can see |
1590 in the following proof |
1594 in the following proof |
1591 *} |
1595 *} |
1592 |
1596 |
1593 lemma shows "P (Suc (Suc (Suc 0))) (Suc 0)" |
1597 lemma shows "P (Suc (Suc (Suc 0))) (Suc 0)" |
1594 apply(tactic {* simp_tac (HOL_basic_ss addsimprocs [plus_one_sp]) 1*}) |
1598 apply(tactic {* simp_tac (HOL_basic_ss addsimprocs [plus_one_sp]) 1*}) |
1595 txt{* |
1599 txt{* |
1596 where the simproc produces the goal state |
1600 where the simproc produces the goal state |
1597 |
1601 |
|
1602 \begin{minipage}{\textwidth} |
1598 @{subgoals[display]} |
1603 @{subgoals[display]} |
|
1604 \end{minipage} |
1599 *} |
1605 *} |
1600 (*<*)oops(*>*) |
1606 (*<*)oops(*>*) |
1601 |
1607 |
1602 text {* |
1608 text {* |
1603 As usual with rewriting you have to worry about looping: you already have |
1609 As usual with rewriting you have to worry about looping: you already have |
1692 text {* |
1698 text {* |
1693 Now in the lemma |
1699 Now in the lemma |
1694 *} |
1700 *} |
1695 |
1701 |
1696 lemma "P (Suc (Suc 2)) (Suc 99) (0::nat) (Suc 4 + Suc 0) (Suc (0 + 0))" |
1702 lemma "P (Suc (Suc 2)) (Suc 99) (0::nat) (Suc 4 + Suc 0) (Suc (0 + 0))" |
1697 apply(tactic {* simp_tac (HOL_ss addsimprocs [nat_number_sp]) 1*}) |
1703 apply(tactic {* simp_tac (HOL_ss addsimprocs [nat_number_sp]) 1*}) |
1698 txt {* |
1704 txt {* |
1699 you obtain the more legible goal state |
1705 you obtain the more legible goal state |
1700 |
1706 |
|
1707 \begin{minipage}{\textwidth} |
1701 @{subgoals [display]} |
1708 @{subgoals [display]} |
|
1709 \end{minipage} |
1702 *} |
1710 *} |
1703 (*<*)oops(*>*) |
1711 (*<*)oops(*>*) |
1704 |
1712 |
1705 text {* |
1713 text {* |
1706 where the simproc rewrites all @{term "Suc"}s except in the last argument. There it cannot |
1714 where the simproc rewrites all @{term "Suc"}s except in the last argument. There it cannot |
2023 "if True \<and> P then P else True \<and> False \<Longrightarrow> |
2031 "if True \<and> P then P else True \<and> False \<Longrightarrow> |
2024 (if True \<and> Q then True \<and> Q else P) \<longrightarrow> True \<and> (True \<and> Q)" |
2032 (if True \<and> Q then True \<and> Q else P) \<longrightarrow> True \<and> (True \<and> Q)" |
2025 apply(tactic {* true1_tac 1 *}) |
2033 apply(tactic {* true1_tac 1 *}) |
2026 txt {* where the tactic yields the goal state |
2034 txt {* where the tactic yields the goal state |
2027 |
2035 |
2028 @{subgoals [display]}*} |
2036 \begin{minipage}{\textwidth} |
|
2037 @{subgoals [display]} |
|
2038 \end{minipage}*} |
2029 (*<*)oops(*>*) |
2039 (*<*)oops(*>*) |
2030 |
2040 |
2031 text {* |
2041 text {* |
2032 As you can see, the premises are rewritten according to @{ML if_true1_conv}, while |
2042 As you can see, the premises are rewritten according to @{ML if_true1_conv}, while |
2033 the conclusion according to @{ML all_true1_conv}. |
2043 the conclusion according to @{ML all_true1_conv}. |