src/Pure/Thy/export_theory.ML
changeset 70386 6af87375b95f
parent 70384 8ce08b154aa1
child 70529 2ecbbe6b35db
equal deleted inserted replaced
70385:68d2c533db9c 70386:6af87375b95f
   288           in triple (list (pair string sort)) (list (pair string typ)) term end
   288           in triple (list (pair string sort)) (list (pair string typ)) term end
   289       end;
   289       end;
   290 
   290 
   291     fun encode_axiom used t = encode_prop used ([], t);
   291     fun encode_axiom used t = encode_prop used ([], t);
   292 
   292 
   293     val encode_fact_single = encode_prop Name.context o prop_of;
   293     val encode_fact = encode_prop Name.context;
   294     val encode_fact_multi = XML.Encode.list (encode_prop Name.context) o map prop_of;
   294     val encode_fact_single = encode_fact o prop_of;
       
   295     val encode_fact_multi = XML.Encode.list encode_fact o map prop_of;
   295 
   296 
   296     val _ =
   297     val _ =
   297       export_entities "axioms" (fn _ => fn t => SOME (encode_axiom Name.context t))
   298       export_entities "axioms" (fn _ => fn t => SOME (encode_axiom Name.context t))
   298         Theory.axiom_space (Theory.axioms_of thy);
   299         Theory.axiom_space (Theory.axioms_of thy);
   299     val _ =
   300     val _ =
   319         Sign.class_space (map (rpair ()) (Graph.keys (Sorts.classes_of (#2 (#classes rep_tsig)))));
   320         Sign.class_space (map (rpair ()) (Graph.keys (Sorts.classes_of (#2 (#classes rep_tsig)))));
   320 
   321 
   321 
   322 
   322     (* sort algebra *)
   323     (* sort algebra *)
   323 
   324 
   324     val {classrel, arities} =
   325     local
   325       Sorts.dest_algebra (map (#2 o #classes o Type.rep_tsig o Sign.tsig_of) parents)
   326       val prop = encode_axiom Name.context o Logic.varify_global;
   326         (#2 (#classes rep_tsig));
   327 
   327 
   328       val encode_classrel =
   328     val encode_prop0 =
   329         let open XML.Encode
   329       encode_axiom Name.context o Logic.varify_global;
   330         in list (pair prop (pair string string)) end;
   330 
   331 
   331     val encode_classrel =
   332       val encode_arities =
   332       let open XML.Encode
   333         let open XML.Encode Term_XML.Encode
   333       in list (pair encode_prop0 (pair string string)) end;
   334         in list (pair prop (triple string (list sort) string)) end;
   334 
   335     in
   335     val encode_arities =
   336       val export_classrel =
   336       let open XML.Encode Term_XML.Encode
   337         maps (fn (c, cs) => map (pair c) cs) #> map (`Logic.mk_classrel) #> encode_classrel;
   337       in list (pair encode_prop0 (triple string (list sort) string)) end;
   338 
   338 
   339       val export_arities = map (`Logic.mk_arity) #> encode_arities;
   339     val export_classrel =
   340 
   340       maps (fn (c, cs) => map (pair c) cs) #> map (`Logic.mk_classrel) #> encode_classrel;
   341       val {classrel, arities} =
   341 
   342         Sorts.dest_algebra (map (#2 o #classes o Type.rep_tsig o Sign.tsig_of) parents)
   342     val export_arities = map (`Logic.mk_arity) #> encode_arities;
   343           (#2 (#classes rep_tsig));
       
   344 
       
   345     end;
   343 
   346 
   344     val _ = if null classrel then () else export_body thy "classrel" (export_classrel classrel);
   347     val _ = if null classrel then () else export_body thy "classrel" (export_classrel classrel);
   345     val _ = if null arities then () else export_body thy "arities" (export_arities arities);
   348     val _ = if null arities then () else export_body thy "arities" (export_arities arities);
   346 
   349 
   347 
   350