src/Pure/Isar/bundle.ML
changeset 63282 7c509ddf29a5
parent 63278 6c963f1fc388
child 63352 4eaf35781b23
equal deleted inserted replaced
63281:06b021ff8920 63282:7c509ddf29a5
    13   val bundle: binding * Attrib.thms ->
    13   val bundle: binding * Attrib.thms ->
    14     (binding * typ option * mixfix) list -> local_theory -> local_theory
    14     (binding * typ option * mixfix) list -> local_theory -> local_theory
    15   val bundle_cmd: binding * (Facts.ref * Token.src list) list ->
    15   val bundle_cmd: binding * (Facts.ref * Token.src list) list ->
    16     (binding * string option * mixfix) list -> local_theory -> local_theory
    16     (binding * string option * mixfix) list -> local_theory -> local_theory
    17   val init: binding -> theory -> local_theory
    17   val init: binding -> theory -> local_theory
       
    18   val unbundle: string list -> local_theory -> local_theory
       
    19   val unbundle_cmd: (xstring * Position.T) list -> local_theory -> local_theory
    18   val includes: string list -> Proof.context -> Proof.context
    20   val includes: string list -> Proof.context -> Proof.context
    19   val includes_cmd: (xstring * Position.T) list -> Proof.context -> Proof.context
    21   val includes_cmd: (xstring * Position.T) list -> Proof.context -> Proof.context
    20   val include_: string list -> Proof.state -> Proof.state
    22   val include_: string list -> Proof.state -> Proof.state
    21   val include_cmd: (xstring * Position.T) list -> Proof.state -> Proof.state
    23   val include_cmd: (xstring * Position.T) list -> Proof.state -> Proof.state
    22   val including: string list -> Proof.state -> Proof.state
    24   val including: string list -> Proof.state -> Proof.state
   188 
   190 
   189 end;
   191 end;
   190 
   192 
   191 
   193 
   192 
   194 
   193 (** include bundles **)
   195 (** activate bundles **)
   194 
   196 
   195 local
   197 local
   196 
   198 
   197 fun gen_includes get args ctxt =
   199 fun gen_activate notes get args ctxt =
   198   let val decls = maps (get ctxt) args in
   200   let val decls = maps (get ctxt) args in
   199     ctxt
   201     ctxt
   200     |> Context_Position.set_visible false
   202     |> Context_Position.set_visible false
   201     |> Attrib.local_notes "" [((Binding.empty, []), decls)] |> #2
   203     |> notes [((Binding.empty, []), decls)] |> #2
   202     |> Context_Position.restore_visible ctxt
   204     |> Context_Position.restore_visible ctxt
   203   end;
   205   end;
       
   206 
       
   207 fun gen_includes get = gen_activate (Attrib.local_notes "") get;
   204 
   208 
   205 fun gen_context get prep_decl raw_incls raw_elems gthy =
   209 fun gen_context get prep_decl raw_incls raw_elems gthy =
   206   let
   210   let
   207     val (after_close, lthy) =
   211     val (after_close, lthy) =
   208       gthy |> Context.cases (pair Local_Theory.exit o Named_Target.theory_init)
   212       gthy |> Context.cases (pair Local_Theory.exit o Named_Target.theory_init)
   215       (Local_Theory.background_naming_of lthy) (Local_Theory.operations_of lthy) after_close
   219       (Local_Theory.background_naming_of lthy) (Local_Theory.operations_of lthy) after_close
   216   end;
   220   end;
   217 
   221 
   218 in
   222 in
   219 
   223 
       
   224 val unbundle = gen_activate Local_Theory.notes get_bundle;
       
   225 val unbundle_cmd = gen_activate Local_Theory.notes get_bundle_cmd;
       
   226 
   220 val includes = gen_includes get_bundle;
   227 val includes = gen_includes get_bundle;
   221 val includes_cmd = gen_includes get_bundle_cmd;
   228 val includes_cmd = gen_includes get_bundle_cmd;
   222 
   229 
   223 fun include_ bs = Proof.assert_forward #> Proof.map_context (includes bs) #> Proof.reset_facts;
   230 fun include_ bs = Proof.assert_forward #> Proof.map_context (includes bs) #> Proof.reset_facts;
   224 fun include_cmd bs =
   231 fun include_cmd bs =