src/Pure/Thy/export_theory.ML
changeset 71249 877316c54ed3
parent 71222 2bc39c80a95d
child 71660 4269db8981b8
equal deleted inserted replaced
71248:adf5e53d2b2b 71249:877316c54ed3
   119   else Export.export thy (Path.binding0 (Path.make ["theory", name])) body;
   119   else Export.export thy (Path.binding0 (Path.make ["theory", name])) body;
   120 
   120 
   121 
   121 
   122 (* presentation *)
   122 (* presentation *)
   123 
   123 
   124 val _ = setup_presentation (fn {adjust_pos, ...} => fn thy =>
   124 val _ = setup_presentation (fn context => fn thy =>
   125   let
   125   let
   126     val parents = Theory.parents_of thy;
   126     val parents = Theory.parents_of thy;
   127     val rep_tsig = Type.rep_tsig (Sign.tsig_of thy);
   127     val rep_tsig = Type.rep_tsig (Sign.tsig_of thy);
   128 
   128 
   129     val thy_ctxt = Proof_Context.init_global thy;
   129     val thy_ctxt = Proof_Context.init_global thy;
   130 
   130 
       
   131     val pos_properties = Thy_Info.adjust_pos_properties context;
       
   132 
   131 
   133 
   132     (* spec rules *)
   134     (* spec rules *)
   133 
       
   134     fun position_properties pos =
       
   135       Position.offset_properties_of (adjust_pos pos) @ Position.id_properties_of pos;
       
   136 
   135 
   137     fun spec_rule_content {pos, name, rough_classification, terms, rules} =
   136     fun spec_rule_content {pos, name, rough_classification, terms, rules} =
   138       let
   137       let
   139         val spec =
   138         val spec =
   140           terms @ map Thm.plain_prop_of rules
   139           terms @ map Thm.plain_prop_of rules
   141           |> Term_Subst.zero_var_indexes_list
   140           |> Term_Subst.zero_var_indexes_list
   142           |> map Logic.unvarify_global;
   141           |> map Logic.unvarify_global;
   143       in
   142       in
   144        {props = position_properties pos,
   143        {props = pos_properties pos,
   145         name = name,
   144         name = name,
   146         rough_classification = rough_classification,
   145         rough_classification = rough_classification,
   147         typargs = rev (fold Term.add_tfrees spec []),
   146         typargs = rev (fold Term.add_tfrees spec []),
   148         args = rev (fold Term.add_frees spec []),
   147         args = rev (fold Term.add_frees spec []),
   149         terms = map (fn t => (t, Term.type_of t)) (take (length terms) spec),
   148         terms = map (fn t => (t, Term.type_of t)) (take (length terms) spec),
   152 
   151 
   153 
   152 
   154     (* entities *)
   153     (* entities *)
   155 
   154 
   156     fun make_entity_markup name xname pos serial =
   155     fun make_entity_markup name xname pos serial =
   157       let val props = position_properties pos @ Markup.serial_properties serial;
   156       let val props = pos_properties pos @ Markup.serial_properties serial;
   158       in (Markup.entityN, (Markup.nameN, name) :: (Markup.xnameN, xname) :: props) end;
   157       in (Markup.entityN, (Markup.nameN, name) :: (Markup.xnameN, xname) :: props) end;
   159 
   158 
   160     fun entity_markup space name =
   159     fun entity_markup space name =
   161       let
   160       let
   162         val xname = Name_Space.extern_shortest thy_ctxt space name;
   161         val xname = Name_Space.extern_shortest thy_ctxt space name;