doc-src/IsarImplementation/Thy/Isar.thy
changeset 39861 b8d89db3e238
parent 39851 7219a771ab63
child 39864 f3b4fde34cd1
equal deleted inserted replaced
39860:788e902f3c59 39861:b8d89db3e238
   165 example_proof
   165 example_proof
   166   have A and B and C
   166   have A and B and C
   167     ML_val {* Thm.nprems_of (#goal @{Isar.goal}) *}
   167     ML_val {* Thm.nprems_of (#goal @{Isar.goal}) *}
   168     oops
   168     oops
   169 
   169 
   170 text {* \noindent Here we see 3 individual subgoals in the same way as
   170 text {* Here we see 3 individual subgoals in the same way as regular
   171   regular proof methods would do.
   171   proof methods would do.  *}
   172 *}
       
   173 
   172 
   174 
   173 
   175 section {* Proof methods *}
   174 section {* Proof methods *}
   176 
   175 
   177 text {* A @{text "method"} is a function @{text "context \<rightarrow> thm\<^sup>* \<rightarrow> goal
   176 text {* A @{text "method"} is a function @{text "context \<rightarrow> thm\<^sup>* \<rightarrow> goal
   227   \quad@{text "body"} \\
   226   \quad@{text "body"} \\
   228   @{command qed}~@{text "(terminal_method)"} \\
   227   @{command qed}~@{text "(terminal_method)"} \\
   229   \end{tabular}
   228   \end{tabular}
   230   \medskip
   229   \medskip
   231 
   230 
   232   \noindent The goal configuration consists of @{text "facts\<^sub>1"} and
   231   The goal configuration consists of @{text "facts\<^sub>1"} and @{text
   233   @{text "facts\<^sub>2"} appended in that order, and various @{text "props"}
   232   "facts\<^sub>2"} appended in that order, and various @{text "props"} being
   234   being claimed here.  The @{text "initial_method"} is invoked with
   233   claimed here.  The @{text "initial_method"} is invoked with facts
   235   facts and goals together and refines the problem to something that
   234   and goals together and refines the problem to something that is
   236   is handled recursively in the proof @{text "body"}.  The @{text
   235   handled recursively in the proof @{text "body"}.  The @{text
   237   "terminal_method"} has another chance to finish-off any remaining
   236   "terminal_method"} has another chance to finish-off any remaining
   238   subgoals, but it does not see the facts of the initial step.
   237   subgoals, but it does not see the facts of the initial step.
   239 
   238 
   240   \medskip The second pattern illustrates unstructured proof scripts:
   239   \medskip The second pattern illustrates unstructured proof scripts:
   241 
   240 
   247   \quad@{command using}~@{text "facts\<^sub>3"}~@{command apply}~@{text "method\<^sub>3"} \\
   246   \quad@{command using}~@{text "facts\<^sub>3"}~@{command apply}~@{text "method\<^sub>3"} \\
   248   \quad@{command done} \\
   247   \quad@{command done} \\
   249   \end{tabular}
   248   \end{tabular}
   250   \medskip
   249   \medskip
   251 
   250 
   252   \noindent The @{text "method\<^sub>1"} operates on the original claim
   251   The @{text "method\<^sub>1"} operates on the original claim together while
   253   together while using @{text "facts\<^sub>1"}.  Since the @{command apply}
   252   using @{text "facts\<^sub>1"}.  Since the @{command apply} command
   254   command structurally resets the facts, the @{text "method\<^sub>2"} will
   253   structurally resets the facts, the @{text "method\<^sub>2"} will operate on
   255   operate on the remaining goal state without facts.  The @{text
   254   the remaining goal state without facts.  The @{text "method\<^sub>3"} will
   256   "method\<^sub>3"} will see again a collection of @{text "facts\<^sub>3"} that has
   255   see again a collection of @{text "facts\<^sub>3"} that has been inserted
   257   been inserted into the script explicitly.
   256   into the script explicitly.
   258 
   257 
   259   \medskip Empirically, Isar proof methods can be categorized as
   258   \medskip Empirically, Isar proof methods can be categorized as
   260   follows.
   259   follows.
   261 
   260 
   262   \begin{enumerate}
   261   \begin{enumerate}
   444     Named_Thms
   443     Named_Thms
   445       (val name = "my_simp" val description = "my_simp rule")
   444       (val name = "my_simp" val description = "my_simp rule")
   446 *}
   445 *}
   447 setup My_Simps.setup
   446 setup My_Simps.setup
   448 
   447 
   449 text {* \medskip\noindent This provides ML access to a list of
   448 text {* This provides ML access to a list of theorems in canonical
   450   theorems in canonical declaration order via @{ML My_Simps.get}.  The
   449   declaration order via @{ML My_Simps.get}.  The user can add or
   451   user can add or delete rules via the attribute @{attribute my_simp}.
   450   delete rules via the attribute @{attribute my_simp}.  The actual
   452   The actual proof method is now defined as before, but we append the
   451   proof method is now defined as before, but we append the explicit
   453   explicit arguments and the rules from the context.
   452   arguments and the rules from the context.  *}
   454 *}
       
   455 
   453 
   456 method_setup my_simp' = {*
   454 method_setup my_simp' = {*
   457   Attrib.thms >> (fn thms => fn ctxt =>
   455   Attrib.thms >> (fn thms => fn ctxt =>
   458     SIMPLE_METHOD' (fn i =>
   456     SIMPLE_METHOD' (fn i =>
   459       CHANGED (asm_full_simp_tac
   457       CHANGED (asm_full_simp_tac