signature BUNDLE = sig type name = bool * string type xname = (bool * Position.T) * (xstring * Position.T) val bundle_space: Context.generic -> Name_Space.T val check: Proof.context -> xstring * Position.T -> string val check_name: Proof.context -> xname -> name val get: Proof.context -> string -> Attrib.thms val extern: Proof.context -> string -> xstring val print_bundles: bool -> Proof.context -> unit val unbundle: name list -> local_theory -> local_theory val unbundle_cmd: xname list -> local_theory -> local_theory val includes: name list -> Proof.context -> Proof.context val includes_cmd: xname list -> Proof.context -> Proof.context val include_: name list -> Proof.state -> Proof.state val include_cmd: xname list -> Proof.state -> Proof.state val including: name list -> Proof.state -> Proof.state val including_cmd: xname list -> Proof.state -> Proof.state val bundle: {open_bundle: bool} -> binding * Attrib.thms ->
(binding * typ option * mixfix) list -> local_theory -> local_theory val bundle_cmd: {open_bundle: bool} -> binding * (Facts.ref * Token.src list) list ->
(binding * stringoption * mixfix) list -> local_theory -> local_theory val init: {open_bundle: bool} -> binding -> theory -> local_theory end;
structure Bundle: BUNDLE = struct
(** context data **)
structure Data = Generic_Data
( type T = Attrib.thms Name_Space.table * Attrib.thms option; val empty : T = (Name_Space.empty_table Markup.bundleN, NONE); fun merge ((tab1, target1), (tab2, target2)) =
(Name_Space.merge_tables (tab1, tab2), merge_options (target1, target2));
);
(* bundles *)
type name = bool * string; type xname = (bool * Position.T) * (xstring * Position.T);
val get_all_generic = #1 o Data.get; val get_all = get_all_generic o Context.Proof;
val bundle_space = Name_Space.space_of_table o #1 o Data.get;
fun check ctxt = #1 o Name_Space.check (Context.Proof ctxt) (get_all ctxt);
val reset_target = (Context.theory_map o Data.map o apsnd o K) NONE; val set_target = Context.theory_map o Data.map o apsnd o K o SOME o Attrib.trim_context_thms;
fun polarity_decls b =
[([Drule.dummy_thm],
[Attrib.internal \<^here> (K (Thm.declaration_attribute (K (Syntax.set_polarity_generic b))))])];
fun apply_bundle loc (add, bundle) ctxt = let val notes = if loc then Local_Theory.notes else Attrib.local_notes ""; val add0 = Syntax.get_polarity ctxt; val add1 = Syntax.effective_polarity ctxt add; val bundle' = if add1 then bundle else rev (map (apsnd rev) bundle); in
ctxt
|> Context_Position.set_visible false
|> notes [(Binding.empty_atts, polarity_decls add1 @ bundle' @ polarity_decls add0)] |> snd
|> Context_Position.restore_visible ctxt end;
local
fun gen_unbundle loc prep args ctxt = let val thy = Proof_Context.theory_of ctxt; val bundles = map (prep ctxt #> apsnd (get ctxt #> transfer_bundle thy)) args; in fold (apply_bundle loc) bundles ctxt end;
val unbundle = gen_unbundle true (K I); val unbundle_cmd = gen_unbundle true check_name;
val includes = gen_includes (K I); val includes_cmd = gen_includes check_name;
val include_ = gen_include (K I); val include_cmd = gen_include check_name;
val including = gen_including (K I); val including_cmd = gen_including check_name;
end;
(** define bundle **)
fun define_bundle (b, bundle) context = let val (name, bundles') = get_all_generic context
|> Name_Space.define context true (b, trim_context_bundle bundle); val context' = (Data.map o apfst o K) bundles' context; in (name, context') end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.