src/Pure/Isar/specification.ML
changeset 58848 fd0c85d7da38
parent 58028 e4250d370657
child 58993 302104d8366b
equal deleted inserted replaced
58847:c44aff8ac894 58848:fd0c85d7da38
    72     bool -> local_theory -> Proof.state
    72     bool -> local_theory -> Proof.state
    73   val schematic_theorem_cmd: string -> Method.text option ->
    73   val schematic_theorem_cmd: string -> Method.text option ->
    74     (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
    74     (thm list list -> local_theory -> local_theory) -> Attrib.binding ->
    75     (xstring * Position.T) list -> Element.context list -> Element.statement ->
    75     (xstring * Position.T) list -> Element.context list -> Element.statement ->
    76     bool -> local_theory -> Proof.state
    76     bool -> local_theory -> Proof.state
    77   val add_theorem_hook: (bool -> Proof.state -> Proof.state) -> Context.generic -> Context.generic
       
    78 end;
    77 end;
    79 
    78 
    80 structure Specification: SPECIFICATION =
    79 structure Specification: SPECIFICATION =
    81 struct
    80 struct
    82 
    81 
   369           |> fold_map assume_case (obtains ~~ propp)
   368           |> fold_map assume_case (obtains ~~ propp)
   370           |-> (fn ths =>
   369           |-> (fn ths =>
   371             Proof_Context.note_thmss "" [((Binding.name Obtain.thatN, []), [(ths, [])])] #>
   370             Proof_Context.note_thmss "" [((Binding.name Obtain.thatN, []), [(ths, [])])] #>
   372             #2 #> pair ths);
   371             #2 #> pair ths);
   373       in ((more_atts, prems, stmt, SOME facts), goal_ctxt) end);
   372       in ((more_atts, prems, stmt, SOME facts), goal_ctxt) end);
   374 
       
   375 structure Theorem_Hook = Generic_Data
       
   376 (
       
   377   type T = ((bool -> Proof.state -> Proof.state) * stamp) list;
       
   378   val empty = [];
       
   379   val extend = I;
       
   380   fun merge data : T = Library.merge (eq_snd op =) data;
       
   381 );
       
   382 
   373 
   383 fun gen_theorem schematic bundle_includes prep_att prep_stmt
   374 fun gen_theorem schematic bundle_includes prep_att prep_stmt
   384     kind before_qed after_qed (name, raw_atts) raw_includes raw_elems raw_concl int lthy =
   375     kind before_qed after_qed (name, raw_atts) raw_includes raw_elems raw_concl int lthy =
   385   let
   376   let
   386     val _ = Local_Theory.assert lthy;
   377     val _ = Local_Theory.assert lthy;
   417     |> snd
   408     |> snd
   418     |> Proof.theorem before_qed after_qed' (map snd stmt)
   409     |> Proof.theorem before_qed after_qed' (map snd stmt)
   419     |> (case facts of NONE => I | SOME ths => Proof.refine_insert ths)
   410     |> (case facts of NONE => I | SOME ths => Proof.refine_insert ths)
   420     |> tap (fn state => not schematic andalso Proof.schematic_goal state andalso
   411     |> tap (fn state => not schematic andalso Proof.schematic_goal state andalso
   421         error "Illegal schematic goal statement")
   412         error "Illegal schematic goal statement")
   422     |> fold_rev (fn (f, _) => f int) (Theorem_Hook.get (Context.Proof goal_ctxt))
       
   423   end;
   413   end;
   424 
   414 
   425 in
   415 in
   426 
   416 
   427 val theorem =
   417 val theorem =
   432 val schematic_theorem =
   422 val schematic_theorem =
   433   gen_theorem true Bundle.includes (K I) Expression.cert_statement;
   423   gen_theorem true Bundle.includes (K I) Expression.cert_statement;
   434 val schematic_theorem_cmd =
   424 val schematic_theorem_cmd =
   435   gen_theorem true Bundle.includes_cmd Attrib.check_src Expression.read_statement;
   425   gen_theorem true Bundle.includes_cmd Attrib.check_src Expression.read_statement;
   436 
   426 
   437 fun add_theorem_hook f = Theorem_Hook.map (cons (f, stamp ()));
   427 end;
   438 
   428 
   439 end;
   429 end;
   440 
       
   441 end;