doc-src/IsarRef/Thy/Spec.thy
changeset 30526 7f9a9ec1c94d
parent 30461 00323c45ea83
child 30546 b3b1f4184ae4
equal deleted inserted replaced
30525:8a5a0aa30e1c 30526:7f9a9ec1c94d
   798     @{command_def "ML_prf"} & : & @{text "proof \<rightarrow> proof"} \\
   798     @{command_def "ML_prf"} & : & @{text "proof \<rightarrow> proof"} \\
   799     @{command_def "ML_val"} & : & @{text "any \<rightarrow>"} \\
   799     @{command_def "ML_val"} & : & @{text "any \<rightarrow>"} \\
   800     @{command_def "ML_command"} & : & @{text "any \<rightarrow>"} \\
   800     @{command_def "ML_command"} & : & @{text "any \<rightarrow>"} \\
   801     @{command_def "setup"} & : & @{text "theory \<rightarrow> theory"} \\
   801     @{command_def "setup"} & : & @{text "theory \<rightarrow> theory"} \\
   802     @{command_def "local_setup"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
   802     @{command_def "local_setup"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
       
   803     @{command_def "attribute_setup"} & : & @{text "theory \<rightarrow> theory"} \\
   803   \end{matharray}
   804   \end{matharray}
   804 
   805 
   805   \begin{mldecls}
   806   \begin{mldecls}
   806     @{index_ML bind_thms: "string * thm list -> unit"} \\
   807     @{index_ML bind_thms: "string * thm list -> unit"} \\
   807     @{index_ML bind_thm: "string * thm -> unit"} \\
   808     @{index_ML bind_thm: "string * thm -> unit"} \\
   809 
   810 
   810   \begin{rail}
   811   \begin{rail}
   811     'use' name
   812     'use' name
   812     ;
   813     ;
   813     ('ML' | 'ML\_prf' | 'ML\_val' | 'ML\_command' | 'setup' | 'local\_setup') text
   814     ('ML' | 'ML\_prf' | 'ML\_val' | 'ML\_command' | 'setup' | 'local\_setup') text
       
   815     ;
       
   816     'attribute\_setup' name '=' text text
   814     ;
   817     ;
   815   \end{rail}
   818   \end{rail}
   816 
   819 
   817   \begin{description}
   820   \begin{description}
   818 
   821 
   853   \item @{command "local_setup"} is similar to @{command "setup"} for
   856   \item @{command "local_setup"} is similar to @{command "setup"} for
   854   a local theory context, and an ML expression of type @{ML_type
   857   a local theory context, and an ML expression of type @{ML_type
   855   "local_theory -> local_theory"}.  This allows to
   858   "local_theory -> local_theory"}.  This allows to
   856   invoke local theory specification packages without going through
   859   invoke local theory specification packages without going through
   857   concrete outer syntax, for example.
   860   concrete outer syntax, for example.
       
   861 
       
   862   \item @{command "attribute_setup"}~@{text "name = text description"}
       
   863   defines an attribute in the current theory.  The given @{text
       
   864   "text"} has to be an ML expression of type
       
   865   @{ML_type "attribute context_parser"}, cf.\ basic parsers defined in
       
   866   structure @{ML_struct Args} and @{ML_struct Attrib}.
       
   867 
       
   868   In principle, attributes can operate both on a given theorem and the
       
   869   implicit context, although in practice only one is modified and the
       
   870   other serves as parameter.  Here are examples for these two cases:
       
   871 
       
   872   \end{description}
       
   873 *}
       
   874 
       
   875     attribute_setup my_rule = {*
       
   876       Attrib.thms >> (fn ths =>
       
   877         Thm.rule_attribute (fn context: Context.generic => fn th: thm =>
       
   878           let val th' = th OF ths
       
   879           in th' end)) *}  "my rule"
       
   880 
       
   881     attribute_setup my_declatation = {*
       
   882       Attrib.thms >> (fn ths =>
       
   883         Thm.declaration_attribute (fn th: thm => fn context: Context.generic =>
       
   884           let val context' = context
       
   885           in context' end)) *}  "my declaration"
       
   886 
       
   887 text {*
       
   888   \begin{description}
   858 
   889 
   859   \item @{ML bind_thms}~@{text "(name, thms)"} stores a list of
   890   \item @{ML bind_thms}~@{text "(name, thms)"} stores a list of
   860   theorems produced in ML both in the theory context and the ML
   891   theorems produced in ML both in the theory context and the ML
   861   toplevel, associating it with the provided name.  Theorems are put
   892   toplevel, associating it with the provided name.  Theorems are put
   862   into a global ``standard'' format before being stored.
   893   into a global ``standard'' format before being stored.