src/Tools/isac/xmlsrc/thy-hierarchy.sml
branchisac-update-Isa09-2
changeset 38060 356e0272d565
parent 38031 460c24a6a6ba
child 42400 dcacb8077a98
equal deleted inserted replaced
38059:1c76b4b60f52 38060:356e0272d565
   101        ((flat o (map (collect_thy "IsacScripts"))) scri_thys) @
   101        ((flat o (map (collect_thy "IsacScripts"))) scri_thys) @
   102        ((flat o (map (collect_thy "IsacKnowledge"))) isac_thys)
   102        ((flat o (map (collect_thy "IsacKnowledge"))) isac_thys)
   103 	 : (theID * thydata) list
   103 	 : (theID * thydata) list
   104     end; 
   104     end; 
   105 
   105 
   106 fun show_thes () = (writeln o format_pblIDl o (scan [])) (!thehier);
   106 fun show_thes () = (writeln o format_pblIDl o (scan [])) (! thehier);
   107 
   107 
   108 
   108 
   109 
   109 
   110 (***.create the xml-format for the hierarchy.***)
   110 (***.create the xml-format for the hierarchy.***)
   111 
   111 
   157 (*.create the hierarchy from a list (generated automatically);
   157 (*.create the hierarchy from a list (generated automatically);
   158    thus, missing parents of list-elems are inserted 
   158    thus, missing parents of list-elems are inserted 
   159    (causing msgs '*** insert: not found');
   159    (causing msgs '*** insert: not found');
   160    elemes already store_*d in some *.ML are NOT overwritten.*)
   160    elemes already store_*d in some *.ML are NOT overwritten.*)
   161 fun the_hier th ([]: (theID * thydata) list) = th
   161 fun the_hier th ([]: (theID * thydata) list) = th
   162 (* val (th, (theID, thydata)::ths) = (!thehier, collect_thydata ());
   162 (* val (th, (theID, thydata)::ths) = (! thehier, collect_thydata ());
   163    *)
   163    *)
   164   | the_hier th ((theID, thydata)::ths) =
   164   | the_hier th ((theID, thydata)::ths) =
   165     if can_insert theID th 
   165     if can_insert theID th 
   166     then let val th' = if exist_the theID th
   166     then let val th' = if exist_the theID th
   167 		       then (writeln ("*** insert: preserved "^strs2str theID);
   167 		       then (writeln ("*** insert: preserved "^strs2str theID);
   203     str2file (path ^ "thy_hierarchy.xml") 
   203     str2file (path ^ "thy_hierarchy.xml") 
   204 	     ("<NODE>\n" ^
   204 	     ("<NODE>\n" ^
   205 	      "  <ID> theory hierarchy </ID>\n" ^
   205 	      "  <ID> theory hierarchy </ID>\n" ^
   206 	      "  <NO> 1 </NO>\n" ^
   206 	      "  <NO> 1 </NO>\n" ^
   207 	      "  <CONTENTREF> thy_ROOT </CONTENTREF>\n" ^
   207 	      "  <CONTENTREF> thy_ROOT </CONTENTREF>\n" ^
   208 	     (hierarchy_guh (!thehier)) ^
   208 	     (hierarchy_guh (! thehier)) ^
   209 	     "</NODE>");
   209 	     "</NODE>");
   210 
   210 
   211 
   211 
   212 (**.create the xml-files for the theory-data from the hierarchy.**)
   212 (**.create the xml-files for the theory-data from the hierarchy.**)
   213 
   213 
   276 fun thenode (pa:path) ids po wfn (Ptyp (id,[n],ns)) = 
   276 fun thenode (pa:path) ids po wfn (Ptyp (id,[n],ns)) = 
   277     let val po' = lev_on po
   277     let val po' = lev_on po
   278     in wfn pa po' (ids@[id]) n;
   278     in wfn pa po' (ids@[id]) n;
   279     thenodes pa (ids@[id]) ((lev_dn po'):pos) wfn ns end
   279     thenodes pa (ids@[id]) ((lev_dn po'):pos) wfn ns end
   280 (* val (pa,   ids,            po,  wfn,            (n::ns)) =
   280 (* val (pa,   ids,            po,  wfn,            (n::ns)) =
   281        (path, []:string list, [0], thydata2file, (!thehier));
   281        (path, []:string list, [0], thydata2file, (! thehier));
   282    *)
   282    *)
   283 and thenodes _ _ _ _ [] = ()
   283 and thenodes _ _ _ _ [] = ()
   284   | thenodes pa ids po wfn (n::ns) = (thenode pa ids po wfn n;
   284   | thenodes pa ids po wfn (n::ns) = (thenode pa ids po wfn n;
   285 				 thenodes pa ids (lev_on po) wfn ns);
   285 				 thenodes pa ids (lev_on po) wfn ns);
   286 
   286 
   287 (*..analoguous to 'fun mets2file'*)
   287 (*..analoguous to 'fun mets2file'*)
   288 fun thes2file (p : path) = 
   288 fun thes2file (p : path) = 
   289     thenodes p [] [0] thydata2file (!thehier);
   289     thenodes p [] [0] thydata2file (! thehier);
   290 
   290 
   291 
   291 
   292 (***.store a single theory element in the hierarchy.***)
   292 (***.store a single theory element in the hierarchy.***)
   293 
   293 
   294 (*.for mathauthors only, other html is added to xml exported from here.*)
   294 (*.for mathauthors only, other html is added to xml exported from here.*)
   304 	val the = Html {guh = guh, 
   304 	val the = Html {guh = guh, 
   305 			coursedesign = [], 
   305 			coursedesign = [], 
   306 			mathauthors = mathauthors,
   306 			mathauthors = mathauthors,
   307 			html = ""}
   307 			html = ""}
   308     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   308     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   309 	thehier := insrt theID the theID (!thehier) end;
   309 	thehier := insrt theID the theID (! thehier) end;
   310 				 
   310 				 
   311 fun store_thy thy (mathauthors : authors) =
   311 fun store_thy thy (mathauthors : authors) =
   312     let val guh = thy2guh ["IsacKnowledge", theory2thyID thy]
   312     let val guh = thy2guh ["IsacKnowledge", theory2thyID thy]
   313 	val theID = guh2theID guh
   313 	val theID = guh2theID guh
   314 	val the = Html {guh = guh, 
   314 	val the = Html {guh = guh, 
   315 			coursedesign = [], 
   315 			coursedesign = [], 
   316 			mathauthors = mathauthors,
   316 			mathauthors = mathauthors,
   317 			html = ""}
   317 			html = ""}
   318     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   318     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   319 	thehier := insrt theID the theID (!thehier) end;
   319 	thehier := insrt theID the theID (! thehier) end;
   320 				 
   320 				 
   321 fun store_thm thy (thmID : thmID, thm) (mathauthors : authors) =
   321 fun store_thm thy (thmID : thmID, thm) (mathauthors : authors) =
   322     let val guh = thm2guh ("IsacKnowledge", theory2thyID thy) thmID
   322     let val guh = thm2guh ("IsacKnowledge", theory2thyID thy) thmID
   323 	val theID = guh2theID guh
   323 	val theID = guh2theID guh
   324 	val the = Hthm {guh = guh, 
   324 	val the = Hthm {guh = guh, 
   325 			coursedesign = [], (*done at xml exported from here*)
   325 			coursedesign = [], (*done at xml exported from here*)
   326 			mathauthors=mathauthors,
   326 			mathauthors=mathauthors,
   327 			thm = thm}
   327 			thm = thm}
   328     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   328     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   329 	thehier := insrt theID the theID (!thehier) end;
   329 	thehier := insrt theID the theID (! thehier) end;
   330 
   330 
   331 fun store_rls thy rls (mathauthors : authors) =
   331 fun store_rls thy rls (mathauthors : authors) =
   332     let val guh = rls2guh ("IsacKnowledge", theory2thyID thy) 
   332     let val guh = rls2guh ("IsacKnowledge", theory2thyID thy) 
   333 			  ((#id o rep_rls)  rls)
   333 			  ((#id o rep_rls)  rls)
   334 	val theID = guh2theID guh
   334 	val theID = guh2theID guh
   335 	val the = Hrls {guh = guh,
   335 	val the = Hrls {guh = guh,
   336 			coursedesign = [], 
   336 			coursedesign = [], 
   337 			mathauthors = mathauthors,
   337 			mathauthors = mathauthors,
   338 			thy_rls=(theory2thyID thy, rls)}
   338 			thy_rls=(theory2thyID thy, rls)}
   339     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   339     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   340 	thehier := insrt theID the theID (!thehier) end;
   340 	thehier := insrt theID the theID (! thehier) end;
   341 
   341 
   342 fun store_cal thy cal (mathauthors : authors) =
   342 fun store_cal thy cal (mathauthors : authors) =
   343     let val guh = cal2guh ("IsacKnowledge", theory2thyID thy)
   343     let val guh = cal2guh ("IsacKnowledge", theory2thyID thy)
   344 			  ("TODO store_cal")
   344 			  ("TODO store_cal")
   345 	val theID = guh2theID guh
   345 	val theID = guh2theID guh
   346 	val the = Hcal {guh = guh,
   346 	val the = Hcal {guh = guh,
   347 			coursedesign = [],
   347 			coursedesign = [],
   348 			mathauthors = mathauthors,
   348 			mathauthors = mathauthors,
   349 			calc = cal}
   349 			calc = cal}
   350     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   350     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   351 	thehier := insrt theID the theID (!thehier) end;
   351 	thehier := insrt theID the theID (! thehier) end;
   352 
   352 
   353 fun store_ord thy ord (mathauthors : authors) =
   353 fun store_ord thy ord (mathauthors : authors) =
   354     let val guh = ord2guh ("IsacKnowledge", theory2thyID thy)
   354     let val guh = ord2guh ("IsacKnowledge", theory2thyID thy)
   355 			  ("TODO store_ord")
   355 			  ("TODO store_ord")
   356 	val theID = guh2theID guh
   356 	val theID = guh2theID guh
   357 	val the = Hord {guh = guh,
   357 	val the = Hord {guh = guh,
   358 			coursedesign = [],
   358 			coursedesign = [],
   359 			mathauthors = mathauthors,
   359 			mathauthors = mathauthors,
   360 			ord = ord}
   360 			ord = ord}
   361     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   361     in (*needs no (!check_guhs_unique) because guh is generated automatically*)
   362 	thehier := insrt theID the theID (!thehier) end;
   362 	thehier := insrt theID the theID (! thehier) end;