src/Pure/Isar/specification.ML
changeset 36317 506d732cb522
parent 36106 19deea200358
child 36323 655e2d74de3a
equal deleted inserted replaced
36316:f9b45eac4c60 36317:506d732cb522
    60     bool -> local_theory -> Proof.state
    60     bool -> local_theory -> Proof.state
    61   val theorem_cmd: string -> Method.text option ->
    61   val theorem_cmd: string -> Method.text option ->
    62     (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
    62     (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
    63     Element.context list -> Element.statement ->
    63     Element.context list -> Element.statement ->
    64     bool -> local_theory -> Proof.state
    64     bool -> local_theory -> Proof.state
       
    65   val schematic_theorem: string -> Method.text option ->
       
    66     (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
       
    67     Element.context_i list -> Element.statement_i ->
       
    68     bool -> local_theory -> Proof.state
       
    69   val schematic_theorem_cmd: string -> Method.text option ->
       
    70     (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
       
    71     Element.context list -> Element.statement ->
       
    72     bool -> local_theory -> Proof.state
    65   val add_theorem_hook: (bool -> Proof.state -> Proof.state) -> Context.generic -> Context.generic
    73   val add_theorem_hook: (bool -> Proof.state -> Proof.state) -> Context.generic -> Context.generic
    66 end;
    74 end;
    67 
    75 
    68 structure Specification: SPECIFICATION =
    76 structure Specification: SPECIFICATION =
    69 struct
    77 struct
   359   val empty = [];
   367   val empty = [];
   360   val extend = I;
   368   val extend = I;
   361   fun merge hooks : T = Library.merge (eq_snd op =) hooks;
   369   fun merge hooks : T = Library.merge (eq_snd op =) hooks;
   362 );
   370 );
   363 
   371 
   364 fun gen_theorem prep_att prep_stmt
   372 fun gen_theorem schematic prep_att prep_stmt
   365     kind before_qed after_qed (name, raw_atts) raw_elems raw_concl int lthy =
   373     kind before_qed after_qed (name, raw_atts) raw_elems raw_concl int lthy =
   366   let
   374   let
   367     val _ = Local_Theory.affirm lthy;
   375     val _ = Local_Theory.affirm lthy;
   368     val thy = ProofContext.theory_of lthy;
   376     val thy = ProofContext.theory_of lthy;
   369 
   377 
   395     goal_ctxt
   403     goal_ctxt
   396     |> ProofContext.note_thmss "" [((Binding.name Auto_Bind.assmsN, []), [(prems, [])])]
   404     |> ProofContext.note_thmss "" [((Binding.name Auto_Bind.assmsN, []), [(prems, [])])]
   397     |> snd
   405     |> snd
   398     |> Proof.theorem_i before_qed after_qed' (map snd stmt)
   406     |> Proof.theorem_i before_qed after_qed' (map snd stmt)
   399     |> (case facts of NONE => I | SOME ths => Proof.refine_insert ths)
   407     |> (case facts of NONE => I | SOME ths => Proof.refine_insert ths)
       
   408     |> tap (fn state => not schematic andalso Proof.schematic_goal state andalso
       
   409         error "Illegal schematic goal statement")
   400     |> Library.apply (map (fn (f, _) => f int) (rev (TheoremHook.get (Context.Proof goal_ctxt))))
   410     |> Library.apply (map (fn (f, _) => f int) (rev (TheoremHook.get (Context.Proof goal_ctxt))))
   401   end;
   411   end;
   402 
   412 
   403 in
   413 in
   404 
   414 
   405 val theorem = gen_theorem (K I) Expression.cert_statement;
   415 val theorem = gen_theorem false (K I) Expression.cert_statement;
   406 val theorem_cmd = gen_theorem Attrib.intern_src Expression.read_statement;
   416 val theorem_cmd = gen_theorem false Attrib.intern_src Expression.read_statement;
       
   417 
       
   418 val schematic_theorem = gen_theorem true (K I) Expression.cert_statement;
       
   419 val schematic_theorem_cmd = gen_theorem true Attrib.intern_src Expression.read_statement;
   407 
   420 
   408 fun add_theorem_hook f = TheoremHook.map (cons (f, stamp ()));
   421 fun add_theorem_hook f = TheoremHook.map (cons (f, stamp ()));
   409 
   422 
   410 end;
   423 end;
   411 
   424