src/Pure/Thy/export_theory.ML
author wenzelm
Sat Mar 30 20:54:47 2019 +0100 (6 months ago)
changeset 70015 c8e08d8ffb93
parent 69996 8f2d3a27aff0
child 70384 8ce08b154aa1
permissions -rw-r--r--
clarified signature: more explicit type Path.binding;
tuned;
wenzelm@68154
     1
(*  Title:      Pure/Thy/export_theory.ML
wenzelm@68154
     2
    Author:     Makarius
wenzelm@68154
     3
wenzelm@69023
     4
Export foundational theory content and locale/class structure.
wenzelm@68154
     5
*)
wenzelm@68154
     6
wenzelm@68154
     7
signature EXPORT_THEORY =
wenzelm@68154
     8
sig
wenzelm@68201
     9
  val setup_presentation: (Thy_Info.presentation_context -> theory -> unit) -> unit
wenzelm@68201
    10
  val export_body: theory -> string -> XML.body -> unit
wenzelm@68154
    11
end;
wenzelm@68154
    12
wenzelm@68154
    13
structure Export_Theory: EXPORT_THEORY =
wenzelm@68154
    14
struct
wenzelm@68154
    15
wenzelm@69077
    16
(* approximative syntax *)
wenzelm@69076
    17
wenzelm@69077
    18
val get_syntax = Syntax.get_approx o Proof_Context.syn_of;
wenzelm@69077
    19
fun get_syntax_type ctxt = get_syntax ctxt o Lexicon.mark_type;
wenzelm@69077
    20
fun get_syntax_const ctxt = get_syntax ctxt o Lexicon.mark_const;
wenzelm@69077
    21
fun get_syntax_fixed ctxt = get_syntax ctxt o Lexicon.mark_fixed;
wenzelm@69076
    22
wenzelm@69077
    23
fun get_syntax_param ctxt loc x =
wenzelm@69076
    24
  let val thy = Proof_Context.theory_of ctxt in
wenzelm@69076
    25
    if Class.is_class thy loc then
wenzelm@69076
    26
      (case AList.lookup (op =) (Class.these_params thy [loc]) x of
wenzelm@69076
    27
        NONE => NONE
wenzelm@69077
    28
      | SOME (_, (c, _)) => get_syntax_const ctxt c)
wenzelm@69077
    29
    else get_syntax_fixed ctxt x
wenzelm@69076
    30
  end;
wenzelm@69076
    31
wenzelm@69077
    32
val encode_syntax =
wenzelm@69077
    33
  XML.Encode.variant
wenzelm@69077
    34
   [fn NONE => ([], []),
wenzelm@69077
    35
    fn SOME (Syntax.Prefix delim) => ([delim], []),
wenzelm@69077
    36
    fn SOME (Syntax.Infix {assoc, delim, pri}) =>
wenzelm@69077
    37
      let
wenzelm@69077
    38
        val ass =
wenzelm@69077
    39
          (case assoc of
wenzelm@69077
    40
            Printer.No_Assoc => 0
wenzelm@69077
    41
          | Printer.Left_Assoc => 1
wenzelm@69077
    42
          | Printer.Right_Assoc => 2);
wenzelm@69077
    43
        open XML.Encode Term_XML.Encode;
wenzelm@69077
    44
      in ([], triple int string int (ass, delim, pri)) end];
wenzelm@69076
    45
wenzelm@69076
    46
wenzelm@69023
    47
(* standardization of variables: only frees and named bounds *)
wenzelm@68725
    48
wenzelm@68725
    49
local
wenzelm@69023
    50
wenzelm@69023
    51
fun declare_names (Abs (_, _, b)) = declare_names b
wenzelm@69023
    52
  | declare_names (t $ u) = declare_names t #> declare_names u
wenzelm@69023
    53
  | declare_names (Const (c, _)) = Name.declare (Long_Name.base_name c)
wenzelm@69023
    54
  | declare_names (Free (x, _)) = Name.declare x
wenzelm@69023
    55
  | declare_names _ = I;
wenzelm@69023
    56
wenzelm@69023
    57
fun variant_abs bs (Abs (x, T, t)) =
wenzelm@69023
    58
      let
wenzelm@69023
    59
        val names = fold Name.declare bs (declare_names t Name.context);
wenzelm@69023
    60
        val x' = #1 (Name.variant x names);
wenzelm@69023
    61
        val t' = variant_abs (x' :: bs) t;
wenzelm@69023
    62
      in Abs (x', T, t') end
wenzelm@69023
    63
  | variant_abs bs (t $ u) = variant_abs bs t $ variant_abs bs u
wenzelm@69023
    64
  | variant_abs _ t = t;
wenzelm@69023
    65
wenzelm@69023
    66
in
wenzelm@69023
    67
wenzelm@69023
    68
fun standard_vars used =
wenzelm@69023
    69
  let
wenzelm@69023
    70
    fun zero_var_indexes tm =
wenzelm@69023
    71
      Term_Subst.instantiate (Term_Subst.zero_var_indexes_inst used [tm]) tm;
wenzelm@68725
    72
wenzelm@69023
    73
    fun unvarifyT ty = ty |> Term.map_atyps
wenzelm@69023
    74
      (fn TVar ((a, _), S) => TFree (a, S)
wenzelm@69023
    75
        | T as TFree (a, _) =>
wenzelm@69023
    76
            if Name.is_declared used a then T
wenzelm@69023
    77
            else raise TYPE (Logic.bad_fixed a, [ty], []));
wenzelm@69023
    78
wenzelm@69023
    79
    fun unvarify tm = tm |> Term.map_aterms
wenzelm@69023
    80
      (fn Var ((x, _), T) => Free (x, T)
wenzelm@69023
    81
        | t as Free (x, _) =>
wenzelm@69023
    82
            if Name.is_declared used x then t
wenzelm@69023
    83
            else raise TERM (Logic.bad_fixed x, [tm])
wenzelm@69023
    84
        | t => t);
wenzelm@69023
    85
wenzelm@69023
    86
  in zero_var_indexes #> map_types unvarifyT #> unvarify #> variant_abs [] end;
wenzelm@69023
    87
wenzelm@69023
    88
val standard_vars_global = standard_vars Name.context;
wenzelm@69023
    89
wenzelm@68725
    90
end;
wenzelm@68725
    91
wenzelm@68725
    92
wenzelm@69023
    93
(* free variables: not declared in the context *)
wenzelm@69023
    94
wenzelm@69023
    95
val is_free = not oo Name.is_declared;
wenzelm@69023
    96
wenzelm@69023
    97
fun add_frees used =
wenzelm@69023
    98
  fold_aterms (fn Free (x, T) => is_free used x ? insert (op =) (x, T) | _ => I);
wenzelm@69023
    99
wenzelm@69023
   100
fun add_tfrees used =
wenzelm@69023
   101
  (fold_types o fold_atyps) (fn TFree (a, S) => is_free used a ? insert (op =) (a, S) | _ => I);
wenzelm@69023
   102
wenzelm@69023
   103
wenzelm@69992
   104
(* spec rules *)
wenzelm@69992
   105
wenzelm@69992
   106
fun primrec_types ctxt const =
wenzelm@69992
   107
  Spec_Rules.retrieve ctxt (Const const)
wenzelm@69996
   108
  |> get_first
wenzelm@69996
   109
    (fn (Spec_Rules.Equational (Spec_Rules.Primrec types), _) => SOME (types, false)
wenzelm@69996
   110
      | (Spec_Rules.Equational (Spec_Rules.Primcorec types), _) => SOME (types, true)
wenzelm@69996
   111
      | _ => NONE)
wenzelm@69996
   112
  |> the_default ([], false);
wenzelm@69992
   113
wenzelm@69992
   114
wenzelm@69087
   115
(* locales content *)
wenzelm@69019
   116
wenzelm@69034
   117
fun locale_content thy loc =
wenzelm@69019
   118
  let
wenzelm@69083
   119
    val ctxt = Locale.init loc thy;
wenzelm@69083
   120
    val args =
wenzelm@69083
   121
      Locale.params_of thy loc
wenzelm@69083
   122
      |> map (fn ((x, T), _) => ((x, T), get_syntax_param ctxt loc x));
wenzelm@69029
   123
    val axioms =
wenzelm@69029
   124
      let
wenzelm@69083
   125
        val (asm, defs) = Locale.specification_of thy loc;
wenzelm@69083
   126
        val cprops = map (Thm.cterm_of ctxt) (the_list asm @ defs);
wenzelm@69029
   127
        val (intro1, intro2) = Locale.intros_of thy loc;
wenzelm@69083
   128
        val intros_tac = Method.try_intros_tac ctxt (the_list intro1 @ the_list intro2) [];
wenzelm@69029
   129
        val res =
wenzelm@69083
   130
          Goal.init (Conjunction.mk_conjunction_balanced cprops)
wenzelm@69083
   131
          |> (ALLGOALS Goal.conjunction_tac THEN intros_tac)
wenzelm@69029
   132
          |> try Seq.hd;
wenzelm@69029
   133
      in
wenzelm@69029
   134
        (case res of
wenzelm@69083
   135
          SOME goal => Thm.prems_of goal
wenzelm@69029
   136
        | NONE => raise Fail ("Cannot unfold locale " ^ quote loc))
wenzelm@69029
   137
      end;
wenzelm@69076
   138
    val typargs = rev (fold Term.add_tfrees (map (Free o #1) args @ axioms) []);
wenzelm@69029
   139
  in {typargs = typargs, args = args, axioms = axioms} end;
wenzelm@69019
   140
wenzelm@69087
   141
fun get_locales thy =
wenzelm@69087
   142
  Locale.get_locales thy |> map_filter (fn loc =>
wenzelm@69087
   143
    if Experiment.is_experiment thy loc then NONE else SOME (loc, ()));
wenzelm@69087
   144
wenzelm@69087
   145
fun get_dependencies prev_thys thy =
wenzelm@69087
   146
  Locale.dest_dependencies prev_thys thy |> map_filter (fn dep =>
wenzelm@69087
   147
    if Experiment.is_experiment thy (#source dep) orelse
wenzelm@69087
   148
      Experiment.is_experiment thy (#target dep) then NONE
wenzelm@69087
   149
    else
wenzelm@69087
   150
      let
wenzelm@69087
   151
        val (type_params, params) = Locale.parameters_of thy (#source dep);
wenzelm@69087
   152
        val typargs = fold (Term.add_tfreesT o #2 o #1) params type_params;
wenzelm@69087
   153
        val substT =
wenzelm@69087
   154
          typargs |> map_filter (fn v =>
wenzelm@69087
   155
            let
wenzelm@69087
   156
              val T = TFree v;
wenzelm@69087
   157
              val T' = Morphism.typ (#morphism dep) T;
wenzelm@69087
   158
            in if T = T' then NONE else SOME (v, T') end);
wenzelm@69087
   159
        val subst =
wenzelm@69087
   160
          params |> map_filter (fn (v, _) =>
wenzelm@69087
   161
            let
wenzelm@69087
   162
              val t = Free v;
wenzelm@69087
   163
              val t' = Morphism.term (#morphism dep) t;
wenzelm@69087
   164
            in if t aconv t' then NONE else SOME (v, t') end);
wenzelm@69087
   165
      in SOME (dep, (substT, subst)) end);
wenzelm@69069
   166
wenzelm@69019
   167
wenzelm@68201
   168
(* general setup *)
wenzelm@68154
   169
wenzelm@68201
   170
fun setup_presentation f =
wenzelm@68201
   171
  Theory.setup (Thy_Info.add_presentation (fn context => fn thy =>
wenzelm@68201
   172
    if Options.bool (#options context) "export_theory" then f context thy else ()));
wenzelm@68154
   173
wenzelm@68201
   174
fun export_body thy name body =
wenzelm@70015
   175
  Export.export thy (Path.binding0 (Path.make ["theory", name]))
wenzelm@69784
   176
    (Buffer.chunks (YXML.buffer_body body Buffer.empty));
wenzelm@68165
   177
wenzelm@68154
   178
wenzelm@68201
   179
(* presentation *)
wenzelm@68201
   180
wenzelm@68201
   181
val _ = setup_presentation (fn {adjust_pos, ...} => fn thy =>
wenzelm@68201
   182
  let
wenzelm@68900
   183
    val parents = Theory.parents_of thy;
wenzelm@68264
   184
    val rep_tsig = Type.rep_tsig (Sign.tsig_of thy);
wenzelm@68264
   185
wenzelm@69003
   186
    val thy_ctxt = Proof_Context.init_global thy;
wenzelm@68997
   187
wenzelm@68264
   188
wenzelm@68201
   189
    (* entities *)
wenzelm@68154
   190
wenzelm@69069
   191
    fun make_entity_markup name xname pos serial =
wenzelm@68201
   192
      let
wenzelm@68201
   193
        val props =
wenzelm@68830
   194
          Position.offset_properties_of (adjust_pos pos) @
wenzelm@68830
   195
          Position.id_properties_of pos @
wenzelm@68830
   196
          Markup.serial_properties serial;
wenzelm@68997
   197
      in (Markup.entityN, (Markup.nameN, name) :: (Markup.xnameN, xname) :: props) end;
wenzelm@68154
   198
wenzelm@69069
   199
    fun entity_markup space name =
wenzelm@69069
   200
      let
wenzelm@69069
   201
        val xname = Name_Space.extern_shortest thy_ctxt space name;
wenzelm@69069
   202
        val {serial, pos, ...} = Name_Space.the_entry space name;
wenzelm@69069
   203
      in make_entity_markup name xname pos serial end;
wenzelm@69069
   204
wenzelm@68201
   205
    fun export_entities export_name export get_space decls =
wenzelm@68201
   206
      let val elems =
wenzelm@68201
   207
        let
wenzelm@68206
   208
          val parent_spaces = map get_space parents;
wenzelm@68201
   209
          val space = get_space thy;
wenzelm@68201
   210
        in
wenzelm@68201
   211
          (decls, []) |-> fold (fn (name, decl) =>
wenzelm@68201
   212
            if exists (fn space => Name_Space.declared space name) parent_spaces then I
wenzelm@68201
   213
            else
wenzelm@68201
   214
              (case export name decl of
wenzelm@68201
   215
                NONE => I
wenzelm@68724
   216
              | SOME body =>
wenzelm@68724
   217
                  cons (#serial (Name_Space.the_entry space name),
wenzelm@68724
   218
                    XML.Elem (entity_markup space name, body))))
wenzelm@68724
   219
          |> sort (int_ord o apply2 #1) |> map #2
wenzelm@68201
   220
        end;
wenzelm@68201
   221
      in if null elems then () else export_body thy export_name elems end;
wenzelm@68165
   222
wenzelm@68165
   223
wenzelm@68201
   224
    (* types *)
wenzelm@68165
   225
wenzelm@68201
   226
    val encode_type =
wenzelm@68201
   227
      let open XML.Encode Term_XML.Encode
wenzelm@69077
   228
      in triple encode_syntax (list string) (option typ) end;
wenzelm@68165
   229
wenzelm@69003
   230
    fun export_type c (Type.LogicalType n) =
wenzelm@69077
   231
          SOME (encode_type (get_syntax_type thy_ctxt c, Name.invent Name.context Name.aT n, NONE))
wenzelm@69003
   232
      | export_type c (Type.Abbreviation (args, U, false)) =
wenzelm@69077
   233
          SOME (encode_type (get_syntax_type thy_ctxt c, args, SOME U))
wenzelm@69003
   234
      | export_type _ _ = NONE;
wenzelm@68165
   235
wenzelm@68201
   236
    val _ =
wenzelm@69003
   237
      export_entities "types" export_type Sign.type_space
wenzelm@68264
   238
        (Name_Space.dest_table (#types rep_tsig));
wenzelm@68201
   239
wenzelm@68173
   240
wenzelm@68201
   241
    (* consts *)
wenzelm@68201
   242
wenzelm@68201
   243
    val encode_const =
wenzelm@69992
   244
      let open XML.Encode Term_XML.Encode in
wenzelm@69992
   245
        pair encode_syntax
wenzelm@69996
   246
          (pair (list string)
wenzelm@69996
   247
            (pair typ (pair (option term) (pair bool (pair (list string) bool)))))
wenzelm@69992
   248
      end;
wenzelm@68165
   249
wenzelm@68201
   250
    fun export_const c (T, abbrev) =
wenzelm@68201
   251
      let
wenzelm@69077
   252
        val syntax = get_syntax_const thy_ctxt c;
wenzelm@69992
   253
        val U = Logic.unvarifyT_global T;
wenzelm@69992
   254
        val U0 = Type.strip_sorts U;
wenzelm@69996
   255
        val recursion = primrec_types thy_ctxt (c, U);
wenzelm@69023
   256
        val abbrev' = abbrev |> Option.map (standard_vars_global #> map_types Type.strip_sorts);
wenzelm@69992
   257
        val args = map (#1 o dest_TFree) (Consts.typargs (Sign.consts_of thy) (c, U0));
wenzelm@69992
   258
        val propositional = Object_Logic.is_propositional thy_ctxt (Term.body_type U0);
wenzelm@69996
   259
      in encode_const (syntax, (args, (U0, (abbrev', (propositional, recursion))))) end;
wenzelm@68165
   260
wenzelm@68201
   261
    val _ =
wenzelm@69023
   262
      export_entities "consts" (SOME oo export_const) Sign.const_space
wenzelm@68201
   263
        (#constants (Consts.dest (Sign.consts_of thy)));
wenzelm@68201
   264
wenzelm@68208
   265
wenzelm@68232
   266
    (* axioms and facts *)
wenzelm@68208
   267
wenzelm@69023
   268
    fun prop_of raw_thm =
wenzelm@68727
   269
      let
wenzelm@68727
   270
        val thm = raw_thm
wenzelm@68727
   271
          |> Thm.transfer thy
wenzelm@68727
   272
          |> Thm.check_hyps (Context.Theory thy)
wenzelm@68727
   273
          |> Thm.strip_shyps;
wenzelm@68727
   274
        val prop = thm
wenzelm@69023
   275
          |> Thm.full_prop_of;
wenzelm@68727
   276
      in (Thm.extra_shyps thm, prop) end;
wenzelm@68539
   277
wenzelm@69023
   278
    fun encode_prop used (Ss, raw_prop) =
wenzelm@68208
   279
      let
wenzelm@69023
   280
        val prop = standard_vars used raw_prop;
wenzelm@69023
   281
        val args = rev (add_frees used prop []);
wenzelm@69023
   282
        val typargs = rev (add_tfrees used prop []);
wenzelm@69023
   283
        val used' = fold (Name.declare o #1) typargs used;
wenzelm@69023
   284
        val sorts = Name.invent used' Name.aT (length Ss) ~~ Ss;
wenzelm@68726
   285
      in
wenzelm@69023
   286
        (sorts @ typargs, args, prop) |>
wenzelm@68727
   287
          let open XML.Encode Term_XML.Encode
wenzelm@68727
   288
          in triple (list (pair string sort)) (list (pair string typ)) term end
wenzelm@68726
   289
      end;
wenzelm@68208
   290
wenzelm@69023
   291
    fun encode_axiom used t = encode_prop used ([], t);
wenzelm@69023
   292
wenzelm@69023
   293
    val encode_fact_single = encode_prop Name.context o prop_of;
wenzelm@69023
   294
    val encode_fact_multi = XML.Encode.list (encode_prop Name.context) o map prop_of;
wenzelm@68208
   295
wenzelm@68232
   296
    val _ =
wenzelm@69023
   297
      export_entities "axioms" (fn _ => fn t => SOME (encode_axiom Name.context t))
wenzelm@69023
   298
        Theory.axiom_space (Theory.axioms_of thy);
wenzelm@68235
   299
    val _ =
wenzelm@69023
   300
      export_entities "facts" (K (SOME o encode_fact_multi))
wenzelm@69023
   301
        (Facts.space_of o Global_Theory.facts_of)
wenzelm@68232
   302
        (Facts.dest_static true [] (Global_Theory.facts_of thy));
wenzelm@68232
   303
wenzelm@68264
   304
wenzelm@68264
   305
    (* type classes *)
wenzelm@68264
   306
wenzelm@68264
   307
    val encode_class =
wenzelm@68264
   308
      let open XML.Encode Term_XML.Encode
wenzelm@69023
   309
      in pair (list (pair string typ)) (list encode_fact_single) end;
wenzelm@68264
   310
wenzelm@68264
   311
    fun export_class name =
wenzelm@68264
   312
      (case try (Axclass.get_info thy) name of
wenzelm@68264
   313
        NONE => ([], [])
wenzelm@69023
   314
      | SOME {params, axioms, ...} => (params, axioms))
wenzelm@68264
   315
      |> encode_class |> SOME;
wenzelm@68264
   316
wenzelm@68264
   317
    val _ =
wenzelm@68264
   318
      export_entities "classes" (fn name => fn () => export_class name)
wenzelm@68264
   319
        Sign.class_space (map (rpair ()) (Graph.keys (Sorts.classes_of (#2 (#classes rep_tsig)))));
wenzelm@68264
   320
wenzelm@68295
   321
wenzelm@68295
   322
    (* sort algebra *)
wenzelm@68295
   323
wenzelm@68295
   324
    val {classrel, arities} =
wenzelm@68295
   325
      Sorts.dest_algebra (map (#2 o #classes o Type.rep_tsig o Sign.tsig_of) parents)
wenzelm@68295
   326
        (#2 (#classes rep_tsig));
wenzelm@68295
   327
wenzelm@68295
   328
    val encode_classrel =
wenzelm@68295
   329
      let open XML.Encode
wenzelm@68295
   330
      in list (pair string (list string)) end;
wenzelm@68295
   331
wenzelm@68295
   332
    val encode_arities =
wenzelm@68295
   333
      let open XML.Encode Term_XML.Encode
wenzelm@68295
   334
      in list (triple string (list sort) string) end;
wenzelm@68295
   335
wenzelm@68295
   336
    val _ = if null classrel then () else export_body thy "classrel" (encode_classrel classrel);
wenzelm@68295
   337
    val _ = if null arities then () else export_body thy "arities" (encode_arities arities);
wenzelm@68295
   338
wenzelm@68862
   339
wenzelm@68862
   340
    (* locales *)
wenzelm@68862
   341
wenzelm@69023
   342
    fun encode_locale used =
wenzelm@69076
   343
      let open XML.Encode Term_XML.Encode in
wenzelm@69077
   344
        triple (list (pair string sort)) (list (pair (pair string typ) encode_syntax))
wenzelm@69076
   345
          (list (encode_axiom used))
wenzelm@69076
   346
      end;
wenzelm@69023
   347
wenzelm@69029
   348
    fun export_locale loc =
wenzelm@68864
   349
      let
wenzelm@69034
   350
        val {typargs, args, axioms} = locale_content thy loc;
wenzelm@69076
   351
        val used = fold Name.declare (map #1 typargs @ map (#1 o #1) args) Name.context;
wenzelm@69027
   352
      in encode_locale used (typargs, args, axioms) end
wenzelm@69027
   353
      handle ERROR msg =>
wenzelm@69027
   354
        cat_error msg ("The error(s) above occurred in locale " ^
wenzelm@69027
   355
          quote (Locale.markup_name thy_ctxt loc));
wenzelm@68862
   356
wenzelm@68862
   357
    val _ =
wenzelm@69029
   358
      export_entities "locales" (fn loc => fn () => SOME (export_locale loc))
wenzelm@69087
   359
        Locale.locale_space (get_locales thy);
wenzelm@68862
   360
wenzelm@68900
   361
wenzelm@69069
   362
    (* locale dependencies *)
wenzelm@69069
   363
wenzelm@69087
   364
    fun encode_locale_dependency (dep: Locale.locale_dependency, subst) =
wenzelm@69087
   365
      (#source dep, (#target dep, (#prefix dep, subst))) |>
wenzelm@69069
   366
        let
wenzelm@69069
   367
          open XML.Encode Term_XML.Encode;
wenzelm@69069
   368
          val encode_subst =
wenzelm@69069
   369
            pair (list (pair (pair string sort) typ)) (list (pair (pair string typ) term));
wenzelm@69069
   370
        in pair string (pair string (pair (list (pair string bool)) encode_subst)) end;
wenzelm@69069
   371
wenzelm@69069
   372
    val _ =
wenzelm@69087
   373
      (case get_dependencies parents thy of
wenzelm@69069
   374
        [] => ()
wenzelm@69069
   375
      | deps =>
wenzelm@69069
   376
          deps |> map_index (fn (i, dep) =>
wenzelm@69069
   377
            let
wenzelm@69069
   378
              val xname = string_of_int (i + 1);
wenzelm@69069
   379
              val name = Long_Name.implode [Context.theory_name thy, xname];
wenzelm@69087
   380
              val markup = make_entity_markup name xname (#pos (#1 dep)) (#serial (#1 dep));
wenzelm@69069
   381
              val body = encode_locale_dependency dep;
wenzelm@69087
   382
            in XML.Elem (markup, body) end)
wenzelm@69069
   383
          |> export_body thy "locale_dependencies");
wenzelm@69069
   384
wenzelm@69069
   385
wenzelm@68900
   386
    (* parents *)
wenzelm@68900
   387
wenzelm@68900
   388
    val _ =
wenzelm@68900
   389
      export_body thy "parents"
wenzelm@68900
   390
        (XML.Encode.string (cat_lines (map Context.theory_long_name parents)));
wenzelm@68900
   391
wenzelm@68295
   392
  in () end);
wenzelm@68165
   393
wenzelm@68165
   394
end;