| author | wenzelm | 
| Fri, 24 Sep 2021 22:23:26 +0200 | |
| changeset 74362 | 0135a0c77b64 | 
| parent 74264 | 04214caeb9ac | 
| child 74561 | 8e6c973003c8 | 
| permissions | -rw-r--r-- | 
| 68154 | 1 | (* Title: Pure/Thy/export_theory.ML | 
| 2 | Author: Makarius | |
| 3 | ||
| 69023 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 4 | Export foundational theory content and locale/class structure. | 
| 68154 | 5 | *) | 
| 6 | ||
| 7 | signature EXPORT_THEORY = | |
| 8 | sig | |
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 9 | val other_name_space: (theory -> Name_Space.T) -> theory -> theory | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 10 | val export_enabled: Thy_Info.presentation_context -> bool | 
| 68201 | 11 | val export_body: theory -> string -> XML.body -> unit | 
| 68154 | 12 | end; | 
| 13 | ||
| 14 | structure Export_Theory: EXPORT_THEORY = | |
| 15 | struct | |
| 16 | ||
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 17 | (* other name spaces *) | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 18 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 19 | fun err_dup_kind kind = error ("Duplicate name space kind " ^ quote kind);
 | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 20 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 21 | structure Data = Theory_Data | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 22 | ( | 
| 74264 
04214caeb9ac
simplified: uniqueness check happens in export_consumer;
 wenzelm parents: 
74261diff
changeset | 23 | type T = (theory -> Name_Space.T) Inttab.table; | 
| 
04214caeb9ac
simplified: uniqueness check happens in export_consumer;
 wenzelm parents: 
74261diff
changeset | 24 | val empty = Inttab.empty; | 
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 25 | val extend = I; | 
| 74264 
04214caeb9ac
simplified: uniqueness check happens in export_consumer;
 wenzelm parents: 
74261diff
changeset | 26 | val merge = Inttab.merge (K true); | 
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 27 | ); | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 28 | |
| 74264 
04214caeb9ac
simplified: uniqueness check happens in export_consumer;
 wenzelm parents: 
74261diff
changeset | 29 | val other_name_spaces = map #2 o Inttab.dest o Data.get; | 
| 
04214caeb9ac
simplified: uniqueness check happens in export_consumer;
 wenzelm parents: 
74261diff
changeset | 30 | fun other_name_space get_space thy = Data.map (Inttab.update (serial (), get_space)) thy; | 
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 31 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 32 | val _ = Theory.setup | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 33 | (other_name_space Thm.oracle_space #> | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 34 | other_name_space Global_Theory.fact_space #> | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 35 | other_name_space (Bundle.bundle_space o Context.Theory) #> | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 36 | other_name_space (Attrib.attribute_space o Context.Theory) #> | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 37 | other_name_space (Method.method_space o Context.Theory)); | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 38 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 39 | |
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 40 | (* approximative syntax *) | 
| 69076 | 41 | |
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 42 | val get_syntax = Syntax.get_approx o Proof_Context.syn_of; | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 43 | fun get_syntax_type ctxt = get_syntax ctxt o Lexicon.mark_type; | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 44 | fun get_syntax_const ctxt = get_syntax ctxt o Lexicon.mark_const; | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 45 | fun get_syntax_fixed ctxt = get_syntax ctxt o Lexicon.mark_fixed; | 
| 69076 | 46 | |
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 47 | fun get_syntax_param ctxt loc x = | 
| 69076 | 48 | let val thy = Proof_Context.theory_of ctxt in | 
| 49 | if Class.is_class thy loc then | |
| 50 | (case AList.lookup (op =) (Class.these_params thy [loc]) x of | |
| 51 | NONE => NONE | |
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 52 | | SOME (_, (c, _)) => get_syntax_const ctxt c) | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 53 | else get_syntax_fixed ctxt x | 
| 69076 | 54 | end; | 
| 55 | ||
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 56 | val encode_syntax = | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 57 | XML.Encode.variant | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 58 | [fn NONE => ([], []), | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 59 | fn SOME (Syntax.Prefix delim) => ([delim], []), | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 60 |     fn SOME (Syntax.Infix {assoc, delim, pri}) =>
 | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 61 | let | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 62 | val ass = | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 63 | (case assoc of | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 64 | Printer.No_Assoc => 0 | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 65 | | Printer.Left_Assoc => 1 | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 66 | | Printer.Right_Assoc => 2); | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 67 | open XML.Encode Term_XML.Encode; | 
| 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 68 | in ([], triple int string int (ass, delim, pri)) end]; | 
| 69076 | 69 | |
| 70 | ||
| 69023 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 71 | (* free variables: not declared in the context *) | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 72 | |
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 73 | val is_free = not oo Name.is_declared; | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 74 | |
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 75 | fun add_frees used = | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 76 | fold_aterms (fn Free (x, T) => is_free used x ? insert (op =) (x, T) | _ => I); | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 77 | |
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 78 | fun add_tfrees used = | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 79 | (fold_types o fold_atyps) (fn TFree (a, S) => is_free used a ? insert (op =) (a, S) | _ => I); | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 80 | |
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 81 | |
| 71209 | 82 | (* locales *) | 
| 69019 | 83 | |
| 69034 | 84 | fun locale_content thy loc = | 
| 69019 | 85 | let | 
| 69083 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 86 | val ctxt = Locale.init loc thy; | 
| 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 87 | val args = | 
| 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 88 | Locale.params_of thy loc | 
| 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 89 | |> map (fn ((x, T), _) => ((x, T), get_syntax_param ctxt loc x)); | 
| 69029 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 90 | val axioms = | 
| 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 91 | let | 
| 69083 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 92 | val (asm, defs) = Locale.specification_of thy loc; | 
| 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 93 | val cprops = map (Thm.cterm_of ctxt) (the_list asm @ defs); | 
| 69029 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 94 | val (intro1, intro2) = Locale.intros_of thy loc; | 
| 69083 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 95 | val intros_tac = Method.try_intros_tac ctxt (the_list intro1 @ the_list intro2) []; | 
| 69029 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 96 | val res = | 
| 69083 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 97 | Goal.init (Conjunction.mk_conjunction_balanced cprops) | 
| 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 98 | |> (ALLGOALS Goal.conjunction_tac THEN intros_tac) | 
| 69029 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 99 | |> try Seq.hd; | 
| 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 100 | in | 
| 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 101 | (case res of | 
| 69083 
6f8ae6ddc26b
more direct locale goal: avoid renaming of type_parameters;
 wenzelm parents: 
69077diff
changeset | 102 | SOME goal => Thm.prems_of goal | 
| 69029 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 103 |         | NONE => raise Fail ("Cannot unfold locale " ^ quote loc))
 | 
| 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 104 | end; | 
| 74235 | 105 | val typargs = build_rev (fold Term.add_tfrees (map (Free o #1) args @ axioms)); | 
| 69029 
aec64b88e708
clarified locale content: proper args with types for interpretation/axioms and typargs derived from the result;
 wenzelm parents: 
69028diff
changeset | 106 |   in {typargs = typargs, args = args, axioms = axioms} end;
 | 
| 69019 | 107 | |
| 69087 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 108 | fun get_locales thy = | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 109 | Locale.get_locales thy |> map_filter (fn loc => | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 110 | if Experiment.is_experiment thy loc then NONE else SOME (loc, ())); | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 111 | |
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 112 | fun get_dependencies prev_thys thy = | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 113 | Locale.dest_dependencies prev_thys thy |> map_filter (fn dep => | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 114 | if Experiment.is_experiment thy (#source dep) orelse | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 115 | Experiment.is_experiment thy (#target dep) then NONE | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 116 | else | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 117 | let | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 118 | val (type_params, params) = Locale.parameters_of thy (#source dep); | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 119 | val typargs = fold (Term.add_tfreesT o #2 o #1) params type_params; | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 120 | val substT = | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 121 | typargs |> map_filter (fn v => | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 122 | let | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 123 | val T = TFree v; | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 124 | val T' = Morphism.typ (#morphism dep) T; | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 125 | in if T = T' then NONE else SOME (v, T') end); | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 126 | val subst = | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 127 | params |> map_filter (fn (v, _) => | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 128 | let | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 129 | val t = Free v; | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 130 | val t' = Morphism.term (#morphism dep) t; | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 131 | in if t aconv t' then NONE else SOME (v, t') end); | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 132 | in SOME (dep, (substT, subst)) end); | 
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 133 | |
| 69019 | 134 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 135 | (* presentation *) | 
| 68154 | 136 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 137 | fun export_enabled (context: Thy_Info.presentation_context) = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 138 | Options.bool (#options context) "export_theory"; | 
| 68154 | 139 | |
| 70990 | 140 | fun export_body thy name body = | 
| 70994 | 141 | if XML.is_empty_body body then () | 
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 142 |   else Export.export thy (Path.binding0 (Path.make ("theory" :: space_explode "/" name))) body;
 | 
| 68165 | 143 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 144 | val _ = (Theory.setup o Thy_Info.add_presentation) (fn context => fn thy => | 
| 68201 | 145 | let | 
| 68264 | 146 | val rep_tsig = Type.rep_tsig (Sign.tsig_of thy); | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 147 | val consts = Sign.consts_of thy; | 
| 69003 | 148 | val thy_ctxt = Proof_Context.init_global thy; | 
| 68997 | 149 | |
| 71249 | 150 | val pos_properties = Thy_Info.adjust_pos_properties context; | 
| 151 | ||
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 152 | val enabled = export_enabled context; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 153 | |
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 154 | |
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 155 | (* strict parents *) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 156 | |
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 157 | val parents = Theory.parents_of thy; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 158 | val _ = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 159 | Export.export thy \<^path_binding>\<open>theory/parents\<close> | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 160 | (XML.Encode.string (cat_lines (map Context.theory_long_name parents))); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 161 | |
| 68264 | 162 | |
| 71218 | 163 | (* spec rules *) | 
| 164 | ||
| 165 |     fun spec_rule_content {pos, name, rough_classification, terms, rules} =
 | |
| 166 | let | |
| 167 | val spec = | |
| 168 | terms @ map Thm.plain_prop_of rules | |
| 169 | |> Term_Subst.zero_var_indexes_list | |
| 170 | |> map Logic.unvarify_global; | |
| 171 | in | |
| 71249 | 172 |        {props = pos_properties pos,
 | 
| 71218 | 173 | name = name, | 
| 174 | rough_classification = rough_classification, | |
| 74235 | 175 | typargs = build_rev (fold Term.add_tfrees spec), | 
| 176 | args = build_rev (fold Term.add_frees spec), | |
| 71218 | 177 | terms = map (fn t => (t, Term.type_of t)) (take (length terms) spec), | 
| 178 | rules = drop (length terms) spec} | |
| 179 | end; | |
| 180 | ||
| 181 | ||
| 68201 | 182 | (* entities *) | 
| 68154 | 183 | |
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 184 | fun make_entity_markup name xname pos serial = | 
| 71249 | 185 | let val props = pos_properties pos @ Markup.serial_properties serial; | 
| 68997 | 186 | in (Markup.entityN, (Markup.nameN, name) :: (Markup.xnameN, xname) :: props) end; | 
| 68154 | 187 | |
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 188 | fun entity_markup space name = | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 189 | let | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 190 | val xname = Name_Space.extern_shortest thy_ctxt space name; | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 191 |         val {serial, pos, ...} = Name_Space.the_entry space name;
 | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 192 | in make_entity_markup name xname pos serial end; | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 193 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 194 | fun export_entities export_name get_space decls export = | 
| 70601 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 195 | let | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 196 | val parent_spaces = map get_space parents; | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 197 | val space = get_space thy; | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 198 | in | 
| 74234 | 199 | build (decls |> fold (fn (name, decl) => | 
| 70601 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 200 | if exists (fn space => Name_Space.declared space name) parent_spaces then I | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 201 | else | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 202 | (case export name decl of | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 203 | NONE => I | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 204 | | SOME make_body => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 205 | let | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 206 | val i = #serial (Name_Space.the_entry space name); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 207 | val body = if enabled then make_body () else []; | 
| 74234 | 208 | in cons (i, XML.Elem (entity_markup space name, body)) end))) | 
| 70601 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 209 | |> sort (int_ord o apply2 #1) |> map #2 | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 210 | |> export_body thy export_name | 
| 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 211 | end; | 
| 68165 | 212 | |
| 213 | ||
| 68201 | 214 | (* types *) | 
| 68165 | 215 | |
| 68201 | 216 | val encode_type = | 
| 217 | let open XML.Encode Term_XML.Encode | |
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 218 | in triple encode_syntax (list string) (option typ) end; | 
| 68165 | 219 | |
| 68201 | 220 | val _ = | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 221 | export_entities "types" Sign.type_space (Name_Space.dest_table (#types rep_tsig)) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 222 | (fn c => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 223 | (fn Type.LogicalType n => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 224 | SOME (fn () => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 225 | encode_type (get_syntax_type thy_ctxt c, Name.invent Name.context Name.aT n, NONE)) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 226 | | Type.Abbreviation (args, U, false) => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 227 | SOME (fn () => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 228 | encode_type (get_syntax_type thy_ctxt c, args, SOME U)) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 229 | | _ => NONE)); | 
| 68201 | 230 | |
| 68173 | 231 | |
| 68201 | 232 | (* consts *) | 
| 233 | ||
| 70784 
799437173553
Term_XML.Encode/Decode.term uses Const "typargs";
 wenzelm parents: 
70605diff
changeset | 234 | val encode_term = Term_XML.Encode.term consts; | 
| 
799437173553
Term_XML.Encode/Decode.term uses Const "typargs";
 wenzelm parents: 
70605diff
changeset | 235 | |
| 68201 | 236 | val encode_const = | 
| 71222 
2bc39c80a95d
clarified export of consts: recursion is accessible via spec_rules;
 wenzelm parents: 
71218diff
changeset | 237 | let open XML.Encode Term_XML.Encode | 
| 
2bc39c80a95d
clarified export of consts: recursion is accessible via spec_rules;
 wenzelm parents: 
71218diff
changeset | 238 | in pair encode_syntax (pair (list string) (pair typ (pair (option encode_term) bool))) end; | 
| 68165 | 239 | |
| 68201 | 240 | val _ = | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 241 | export_entities "consts" Sign.const_space (#constants (Consts.dest consts)) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 242 | (fn c => fn (T, abbrev) => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 243 | SOME (fn () => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 244 | let | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 245 | val syntax = get_syntax_const thy_ctxt c; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 246 | val U = Logic.unvarifyT_global T; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 247 | val U0 = Type.strip_sorts U; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 248 | val trim_abbrev = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 249 | Proofterm.standard_vars_term Name.context #> map_types Type.strip_sorts; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 250 | val abbrev' = Option.map trim_abbrev abbrev; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 251 | val args = map (#1 o dest_TFree) (Consts.typargs consts (c, U0)); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 252 | val propositional = Object_Logic.is_propositional thy_ctxt (Term.body_type U0); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 253 | in encode_const (syntax, (args, (U0, (abbrev', propositional)))) end)); | 
| 68201 | 254 | |
| 68208 | 255 | |
| 70579 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 256 | (* axioms *) | 
| 68208 | 257 | |
| 70534 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 258 | fun standard_prop used extra_shyps raw_prop raw_proof = | 
| 68727 | 259 | let | 
| 70541 
f3fbc7f3559d
more careful treatment of hidden type variable names: smash before zero_var_indexes to get standard enumeration;
 wenzelm parents: 
70540diff
changeset | 260 | val (prop, proof) = Proofterm.standard_vars used (raw_prop, raw_proof); | 
| 69023 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 261 | val args = rev (add_frees used prop []); | 
| 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 262 | val typargs = rev (add_tfrees used prop []); | 
| 70534 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 263 | val used_typargs = fold (Name.declare o #1) typargs used; | 
| 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 264 | val sorts = Name.invent used_typargs Name.aT (length extra_shyps) ~~ extra_shyps; | 
| 70541 
f3fbc7f3559d
more careful treatment of hidden type variable names: smash before zero_var_indexes to get standard enumeration;
 wenzelm parents: 
70540diff
changeset | 265 | in ((sorts @ typargs, args, prop), proof) end; | 
| 70534 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 266 | |
| 71202 | 267 | fun standard_prop_of thm = | 
| 268 | standard_prop Name.context (Thm.extra_shyps thm) (Thm.full_prop_of thm); | |
| 269 | ||
| 70534 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 270 | val encode_prop = | 
| 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 271 | let open XML.Encode Term_XML.Encode | 
| 70784 
799437173553
Term_XML.Encode/Decode.term uses Const "typargs";
 wenzelm parents: 
70605diff
changeset | 272 | in triple (list (pair string sort)) (list (pair string typ)) encode_term end; | 
| 70534 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 273 | |
| 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 274 | fun encode_axiom used prop = | 
| 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 275 | encode_prop (#1 (standard_prop used [] prop NONE)); | 
| 68208 | 276 | |
| 70579 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 277 | val _ = | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 278 | export_entities "axioms" Theory.axiom_space (Theory.all_axioms_of thy) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 279 | (fn _ => fn prop => SOME (fn () => encode_axiom Name.context prop)); | 
| 70579 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 280 | |
| 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 281 | |
| 70914 
05c4c6a99b3f
option to export standardized proof terms (not scalable);
 wenzelm parents: 
70909diff
changeset | 282 | (* theorems and proof terms *) | 
| 
05c4c6a99b3f
option to export standardized proof terms (not scalable);
 wenzelm parents: 
70909diff
changeset | 283 | |
| 70895 
2a318149b01b
proof boxes based on proof digest (not proof term): thus it works with prune_proofs;
 wenzelm parents: 
70892diff
changeset | 284 | val clean_thm = Thm.check_hyps (Context.Theory thy) #> Thm.strip_shyps; | 
| 71660 
4269db8981b8
avoid vacous type variable, due to "potentially redundant" shyps in Thm.unconstrainT;
 wenzelm parents: 
71249diff
changeset | 285 | val prep_thm = clean_thm #> Thm.unconstrainT #> Thm.strip_shyps; | 
| 69023 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 286 | |
| 70892 
aadb5c23af24
clarified proof_boxes (requires prune_proofs=false);
 wenzelm parents: 
70884diff
changeset | 287 | val lookup_thm_id = Global_Theory.lookup_thm_id thy; | 
| 
aadb5c23af24
clarified proof_boxes (requires prune_proofs=false);
 wenzelm parents: 
70884diff
changeset | 288 | |
| 70915 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 289 | fun expand_name thm_id (header: Proofterm.thm_header) = | 
| 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 290 | if #serial header = #serial thm_id then "" | 
| 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 291 | else | 
| 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 292 | (case lookup_thm_id (Proofterm.thm_header_id header) of | 
| 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 293 | NONE => "" | 
| 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 294 | | SOME thm_name => Thm_Name.print thm_name); | 
| 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 295 | |
| 70579 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 296 | fun entity_markup_thm (serial, (name, i)) = | 
| 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 297 | let | 
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 298 | val space = Global_Theory.fact_space thy; | 
| 70579 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 299 | val xname = Name_Space.extern_shortest thy_ctxt space name; | 
| 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 300 |         val {pos, ...} = Name_Space.the_entry space name;
 | 
| 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 301 | in make_entity_markup (Thm_Name.print (name, i)) (Thm_Name.print (xname, i)) pos serial end; | 
| 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 302 | |
| 70915 
bd4d37edfee4
clarified expand_proof/expand_name: allow more detailed control via thm_header;
 wenzelm parents: 
70914diff
changeset | 303 | fun encode_thm thm_id raw_thm = | 
| 70597 | 304 | let | 
| 70605 | 305 | val deps = map (Thm_Name.print o #2) (Thm_Deps.thm_deps thy [raw_thm]); | 
| 71202 | 306 | val thm = prep_thm raw_thm; | 
| 70914 
05c4c6a99b3f
option to export standardized proof terms (not scalable);
 wenzelm parents: 
70909diff
changeset | 307 | |
| 
05c4c6a99b3f
option to export standardized proof terms (not scalable);
 wenzelm parents: 
70909diff
changeset | 308 | val proof0 = | 
| 70983 | 309 | if Proofterm.export_standard_enabled () then | 
| 71088 | 310 | Proof_Syntax.standard_proof_of | 
| 311 |               {full = true, expand_name = SOME o expand_name thm_id} thm
 | |
| 70914 
05c4c6a99b3f
option to export standardized proof terms (not scalable);
 wenzelm parents: 
70909diff
changeset | 312 | else if Proofterm.export_enabled () then Thm.reconstruct_proof_of thm | 
| 
05c4c6a99b3f
option to export standardized proof terms (not scalable);
 wenzelm parents: 
70909diff
changeset | 313 | else MinProof; | 
| 71202 | 314 | val (prop, SOME proof) = standard_prop_of thm (SOME proof0); | 
| 71018 
d32ed8927a42
more robust expose_proofs corresponding to register_proofs/consolidate_theory;
 wenzelm parents: 
71015diff
changeset | 315 | val _ = Thm.expose_proofs thy [thm]; | 
| 70597 | 316 | in | 
| 71015 
bb49abc2ecbb
determine proof boxes from exported proof (NB: thm_boxes is not sufficient due to OfClass proofs);
 wenzelm parents: 
70994diff
changeset | 317 | (prop, deps, proof) |> | 
| 70843 
cc987440d776
more compact XML: separate environment for free variables;
 wenzelm parents: 
70829diff
changeset | 318 | let | 
| 
cc987440d776
more compact XML: separate environment for free variables;
 wenzelm parents: 
70829diff
changeset | 319 | open XML.Encode Term_XML.Encode; | 
| 
cc987440d776
more compact XML: separate environment for free variables;
 wenzelm parents: 
70829diff
changeset | 320 | val encode_proof = Proofterm.encode_standard_proof consts; | 
| 71015 
bb49abc2ecbb
determine proof boxes from exported proof (NB: thm_boxes is not sufficient due to OfClass proofs);
 wenzelm parents: 
70994diff
changeset | 321 | in triple encode_prop (list string) encode_proof end | 
| 70597 | 322 | end; | 
| 68208 | 323 | |
| 70992 
e7dfc505de1b
more direct output of XML material -- bypass Buffer.T;
 wenzelm parents: 
70991diff
changeset | 324 | fun export_thm (thm_id, thm_name) = | 
| 70601 
79831e40e2be
more scalable: avoid huge intermediate XML elems;
 wenzelm parents: 
70597diff
changeset | 325 | let | 
| 70904 | 326 | val markup = entity_markup_thm (#serial thm_id, thm_name); | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 327 | val body = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 328 | if enabled then | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 329 | Global_Theory.get_thm_name thy (thm_name, Position.none) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 330 | |> encode_thm thm_id | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 331 | else []; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 332 | in XML.Elem (markup, body) end; | 
| 70579 
5a8e3e4b3760
clarified export of axioms and theorems (identified derivations instead of projected facts);
 wenzelm parents: 
70541diff
changeset | 333 | |
| 70992 
e7dfc505de1b
more direct output of XML material -- bypass Buffer.T;
 wenzelm parents: 
70991diff
changeset | 334 | val _ = export_body thy "thms" (map export_thm (Global_Theory.dest_thm_names thy)); | 
| 68232 | 335 | |
| 68264 | 336 | |
| 337 | (* type classes *) | |
| 338 | ||
| 339 | val encode_class = | |
| 340 | let open XML.Encode Term_XML.Encode | |
| 70534 
fb876ebbf5a7
export facts with reconstructed proof term (if possible), but its PThm boxes need to be collected separately;
 wenzelm parents: 
70529diff
changeset | 341 | in pair (list (pair string typ)) (list (encode_axiom Name.context)) end; | 
| 68264 | 342 | |
| 343 | val _ = | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 344 | export_entities "classes" Sign.class_space | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 345 | (map (rpair ()) (Graph.keys (Sorts.classes_of (#2 (#classes rep_tsig))))) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 346 | (fn name => fn () => SOME (fn () => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 347 | (case try (Axclass.get_info thy) name of | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 348 | NONE => ([], []) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 349 |           | SOME {params, axioms, ...} => (params, map (Thm.plain_prop_of o clean_thm) axioms))
 | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 350 | |> encode_class)); | 
| 68264 | 351 | |
| 68295 | 352 | |
| 353 | (* sort algebra *) | |
| 354 | ||
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 355 | val _ = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 356 | if enabled then | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 357 | let | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 358 | val prop = encode_axiom Name.context o Logic.varify_global; | 
| 68295 | 359 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 360 | val encode_classrel = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 361 | let open XML.Encode | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 362 | in list (pair prop (pair string string)) end; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 363 | |
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 364 | val encode_arities = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 365 | let open XML.Encode Term_XML.Encode | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 366 | in list (pair prop (triple string (list sort) string)) end; | 
| 70384 
8ce08b154aa1
clarified export of sort algebra: avoid logical operations in Isabelle/Scala;
 wenzelm parents: 
70015diff
changeset | 367 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 368 | val export_classrel = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 369 | maps (fn (c, cs) => map (pair c) cs) #> map (`Logic.mk_classrel) #> encode_classrel; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 370 | |
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 371 | val export_arities = map (`Logic.mk_arity) #> encode_arities; | 
| 68295 | 372 | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 373 |           val {classrel, arities} =
 | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 374 | Sorts.dest_algebra (map (#2 o #classes o Type.rep_tsig o Sign.tsig_of) parents) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 375 | (#2 (#classes rep_tsig)); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 376 | in | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 377 | if null classrel then () else export_body thy "classrel" (export_classrel classrel); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 378 | if null arities then () else export_body thy "arities" (export_arities arities) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 379 | end | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 380 | else (); | 
| 68295 | 381 | |
| 68862 | 382 | |
| 383 | (* locales *) | |
| 384 | ||
| 69023 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 385 | fun encode_locale used = | 
| 69076 | 386 | let open XML.Encode Term_XML.Encode in | 
| 69077 
11529ae45786
more approximative prefix syntax, including binder;
 wenzelm parents: 
69076diff
changeset | 387 | triple (list (pair string sort)) (list (pair (pair string typ) encode_syntax)) | 
| 69076 | 388 | (list (encode_axiom used)) | 
| 389 | end; | |
| 69023 
cef000855cf4
clarified standardization of variables, with proper treatment of local variables;
 wenzelm parents: 
69019diff
changeset | 390 | |
| 68862 | 391 | val _ = | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 392 | export_entities "locales" Locale.locale_space (get_locales thy) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 393 | (fn loc => fn () => SOME (fn () => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 394 | let | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 395 |             val {typargs, args, axioms} = locale_content thy loc;
 | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 396 | val used = fold Name.declare (map #1 typargs @ map (#1 o #1) args) Name.context; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 397 | in encode_locale used (typargs, args, axioms) end | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 398 | handle ERROR msg => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 399 |             cat_error msg ("The error(s) above occurred in locale " ^
 | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 400 | quote (Locale.markup_name thy_ctxt loc)))); | 
| 68862 | 401 | |
| 68900 
1145b25c53de
more robust: parents are strict in Export_Theory.read_theory and thus approximate "commit" of exports;
 wenzelm parents: 
68864diff
changeset | 402 | |
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 403 | (* locale dependencies *) | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 404 | |
| 69087 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 405 | fun encode_locale_dependency (dep: Locale.locale_dependency, subst) = | 
| 
06017b2c4552
suppress aux. locales from command 'experiment' -- avoid crash of theory Dict_Construction.Test_Dict_Construction (AFP);
 wenzelm parents: 
69086diff
changeset | 406 | (#source dep, (#target dep, (#prefix dep, subst))) |> | 
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 407 | let | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 408 | open XML.Encode Term_XML.Encode; | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 409 | val encode_subst = | 
| 70784 
799437173553
Term_XML.Encode/Decode.term uses Const "typargs";
 wenzelm parents: 
70605diff
changeset | 410 | pair (list (pair (pair string sort) typ)) (list (pair (pair string typ) (term consts))); | 
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 411 | in pair string (pair string (pair (list (pair string bool)) encode_subst)) end; | 
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 412 | |
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 413 | val _ = | 
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 414 | if enabled then | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 415 | get_dependencies parents thy |> map_index (fn (i, dep) => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 416 | let | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 417 | val xname = string_of_int (i + 1); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 418 | val name = Long_Name.implode [Context.theory_name thy, xname]; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 419 | val markup = make_entity_markup name xname (#pos (#1 dep)) (#serial (#1 dep)); | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 420 | val body = encode_locale_dependency dep; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 421 | in XML.Elem (markup, body) end) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 422 | |> export_body thy "locale_dependencies" | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 423 | else (); | 
| 69069 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 424 | |
| 
b9aca3b9619f
export locale dependencies, with approx. morphism as type/term substitution;
 wenzelm parents: 
69034diff
changeset | 425 | |
| 70920 | 426 | (* constdefs *) | 
| 427 | ||
| 428 | val _ = | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 429 | if enabled then | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 430 | let | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 431 | val constdefs = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 432 | Defs.dest_constdefs (map Theory.defs_of (Theory.parents_of thy)) (Theory.defs_of thy) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 433 | |> sort_by #1; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 434 | val encode = | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 435 | let open XML.Encode | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 436 | in list (pair string string) end; | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 437 | in if null constdefs then () else export_body thy "constdefs" (encode constdefs) end | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 438 | else (); | 
| 70920 | 439 | |
| 440 | ||
| 71202 | 441 | (* spec rules *) | 
| 442 | ||
| 71208 
5e0050eb64f2
clarified export of spec rules: more like locale;
 wenzelm parents: 
71207diff
changeset | 443 | val encode_specs = | 
| 
5e0050eb64f2
clarified export of spec rules: more like locale;
 wenzelm parents: 
71207diff
changeset | 444 | let open XML.Encode Term_XML.Encode in | 
| 
5e0050eb64f2
clarified export of spec rules: more like locale;
 wenzelm parents: 
71207diff
changeset | 445 |         list (fn {props, name, rough_classification, typargs, args, terms, rules} =>
 | 
| 
5e0050eb64f2
clarified export of spec rules: more like locale;
 wenzelm parents: 
71207diff
changeset | 446 | pair properties (pair string (pair Spec_Rules.encode_rough_classification | 
| 
5e0050eb64f2
clarified export of spec rules: more like locale;
 wenzelm parents: 
71207diff
changeset | 447 | (pair (list (pair string sort)) (pair (list (pair string typ)) | 
| 71211 | 448 | (pair (list (pair encode_term typ)) (list encode_term)))))) | 
| 71208 
5e0050eb64f2
clarified export of spec rules: more like locale;
 wenzelm parents: 
71207diff
changeset | 449 | (props, (name, (rough_classification, (typargs, (args, (terms, rules))))))) | 
| 71202 | 450 | end; | 
| 451 | ||
| 452 | val _ = | |
| 74114 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 453 | if enabled then | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 454 | (case Spec_Rules.dest_theory thy of | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 455 | [] => () | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 456 | | spec_rules => | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 457 | export_body thy "spec_rules" (encode_specs (map spec_rule_content spec_rules))) | 
| 
700e5bd59c7d
clarified export of formal entities: name space info is always present, but content depends on option "export_theory";
 wenzelm parents: 
71660diff
changeset | 458 | else (); | 
| 68900 
1145b25c53de
more robust: parents are strict in Export_Theory.read_theory and thus approximate "commit" of exports;
 wenzelm parents: 
68864diff
changeset | 459 | |
| 74261 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 460 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 461 | (* other entities *) | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 462 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 463 | fun export_other get_space = | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 464 | let | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 465 | val space = get_space thy; | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 466 | val export_name = "other/" ^ Name_Space.kind_of space; | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 467 | val decls = Name_Space.get_names space |> map (rpair ()); | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 468 | in export_entities export_name get_space decls (fn _ => fn () => SOME (K [])) end; | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 469 | |
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 470 | val other_spaces = other_name_spaces thy; | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 471 | val other_kinds = map (fn get_space => Name_Space.kind_of (get_space thy)) other_spaces; | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 472 | val _ = | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 473 | if null other_kinds then () | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 474 | else | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 475 | Export.export thy \<^path_binding>\<open>theory/other_kinds\<close> | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 476 | (XML.Encode.string (cat_lines other_kinds)); | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 477 | val _ = List.app export_other other_spaces; | 
| 
d28a51dd9da6
export other entities, e.g. relevant for formal document output;
 wenzelm parents: 
74235diff
changeset | 478 | |
| 68295 | 479 | in () end); | 
| 68165 | 480 | |
| 481 | end; |