src/Tools/isac/xmlsrc/thy-hierarchy.sml
author Walther Neuper <neuper@ist.tugraz.at>
Tue, 28 Sep 2010 09:06:56 +0200
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38015 67ba02dffacc
child 38060 356e0272d565
permissions -rw-r--r--
tuned error and writeln

# raise error --> error
# writeln in atomtyp, atomty, atomt and xmlsrc
neuper@37906
     1
(*.export theory-data to xml
neuper@37906
     2
   author: Walther Neuper 0601
neuper@37906
     3
   (c) isac-team
neuper@37906
     4
neuper@37906
     5
   FIXME.WN0602: re-engineer this file for analogy to pbl-met-hierarchy
neuper@37906
     6
   as follows:
neuper@37906
     7
   # 'fun collect_thydata': unit -> string list * thydata list
neuper@37906
     8
                                    ^^^^^^^^^^^ hierarchy-key
neuper@37906
     9
   # 'fun thys2file': from this ^^^ datastructure (^^^^^^^^^^^ for free!)
neuper@37906
    10
   # map 'fun store_pbt' (NEW!) over ^^^ into 'thy_data ptyp'
neuper@37906
    11
   # from 'thy_data ptyp' create 'thy_hierarchy'
neuper@37906
    12
neuper@37906
    13
use"xmlsrc/thy-hierarchy.sml";
neuper@37906
    14
use"thy-hierarchy.sml";
neuper@37906
    15
.*)
neuper@37906
    16
neuper@37906
    17
neuper@37906
    18
(**.collect data and build intermediate structure for hierarchy:
neuper@37906
    19
    theorems, rulesets and Calc's, (TODO rew_ord's etc) defined in isac 
neuper@37906
    20
    and Isabelle-thms used in rulesets;
neuper@37906
    21
    this code binds ref-var's and must be after IsacKnowledge .**)
neuper@37906
    22
neuper@37906
    23
(*.collect all theorems defined in in a theory and insert the guh.*)
neuper@38002
    24
fun makeHthm (part:string, thyID:thyID) (thmID:thmID, thm:term) =
neuper@37906
    25
    let val theID = [part, thyID, "Theorems"] @ [strip_thy thmID] : theID
neuper@37906
    26
    in (theID, Hthm {guh = theID2guh theID, coursedesign = [], 
neuper@37906
    27
		     mathauthors = ["isac-team"], thm = thm})
neuper@37906
    28
    end;
neuper@37906
    29
fun makeHrls (part:string) (rls':rls', thy_rls as (thyID, rls): thyID * rls) =
neuper@37906
    30
    let val theID = [part, thyID,"Rulesets"] @ [rls'] : theID
neuper@37906
    31
    in (theID, Hrls {guh = theID2guh theID, coursedesign=[], 
neuper@37906
    32
		     mathauthors=["isac-team"], thy_rls = thy_rls})
neuper@37906
    33
    end;
neuper@37906
    34
fun makeHcal (part:string, thyID:thyID) (calID, cal) =
neuper@37906
    35
    let val theID = [part, thyID,"Operations"] @ [calID] : theID
neuper@37906
    36
    in (theID, Hcal {guh = theID2guh theID, coursedesign=[], 
neuper@37906
    37
		     mathauthors=["isac-team"], calc = cal})
neuper@37906
    38
    end;
neuper@37906
    39
fun makeHord (part:string, thyID:thyID) (ordID, ord) =
neuper@37906
    40
    let val theID = [part, thyID,"TODO-Orders"] @ [ordID] : theID
neuper@37906
    41
    in (theID, Hord  {guh = theID2guh theID, coursedesign=[], 
neuper@37906
    42
		      mathauthors=["isac-team"], ord = ord})
neuper@37906
    43
    end;
neuper@37906
    44
neuper@37906
    45
neuper@37906
    46
fun collect_thms' (part, thy') =
neuper@37906
    47
    let val thy = assoc_thy (thyID2theory' thy')
neuper@38002
    48
    in map (makeHthm (part, thy')) (Theory.axioms_of thy) end;
neuper@37906
    49
    
neuper@37906
    50
(*.collect all rulesets defined in in a theory and insert the guh.*)
neuper@37906
    51
fun collect_rlss (part, thy') = 
neuper@37906
    52
    let val rlss = filter ((curry op= thy') o 
neuper@37906
    53
			   ((#1 o #2):(rls' * (theory' * rls)) -> theory')) 
neuper@37906
    54
			  (!ruleset')
neuper@37906
    55
    in map (makeHrls part) rlss end;
neuper@37906
    56
neuper@37906
    57
(*.collect all calcs defined in in a theory.*)
neuper@37906
    58
fun collect_cals (part, thy') =
neuper@37906
    59
    let val cals = [] (*FIXXXXXXXXXXME.WN060713 add thyID: (thyID, cal)*)
neuper@37906
    60
    in map (makeHcal (part, thy')) cals end;
neuper@37906
    61
neuper@37906
    62
neuper@37906
    63
(*.collect all rew_ord's defined in in a theory.*)
neuper@37906
    64
fun collect_ords (part, thy') =
neuper@37906
    65
    let val thy = assoc_thy (thyID2theory' thy')
neuper@37906
    66
    in [(*TODO.WN060120 rew_ord, Calc*)]:(theID * thydata) list end;
neuper@37906
    67
neuper@37906
    68
(*.collect all data for a thy TODO.WN060120 rew_ord, Calc.*)
neuper@37906
    69
(* val thy' = nth 1 scri_thys;
neuper@37906
    70
   *)
neuper@37906
    71
fun collect_thy part(*IsacScripts|IsacKnowledge*) (thy': theory') =
neuper@37906
    72
    ((collect_thms' (part, thy')) @ (collect_rlss (part, thy')) @ 
neuper@37906
    73
     (collect_cals (part, thy')) @ (collect_ords (part, thy')))
neuper@37906
    74
    : (theID * thydata) list;
neuper@37906
    75
neuper@37906
    76
(*.collect theorems defined in Isabelle (before Isac is evaluated above).*)
neuper@37906
    77
fun collect_isab isa (thyID, (thmID, thm)) =
neuper@37906
    78
    let val theID = [isa, thyID, "Theorems", thmID]
neuper@37906
    79
    in (theID:theID, Hthm {guh = theID2guh theID, 
neuper@37906
    80
		     mathauthors = ["Isabelle team, TU Munich"],
neuper@37906
    81
		     coursedesign = [],
neuper@37906
    82
		     thm = thm}) end;
neuper@37906
    83
neuper@37906
    84
val isabelle_page = (["Isabelle"] : theID,
neuper@37906
    85
		     Html {guh = theID2guh ["Isabelle"],
neuper@37906
    86
			   html = "",
neuper@37906
    87
			   mathauthors = ["Isabelle team, TU Munich"],
neuper@37906
    88
			   coursedesign = []});
neuper@37906
    89
neuper@37906
    90
(*.create a list with all thydata=thyelements=the;
neuper@37906
    91
   this list is used by 'fun the_hier' to create the hierarchy .*)
neuper@37906
    92
fun collect_thydata () =
neuper@37906
    93
    let val isab_thms = map rearrange_inv (!isab_thm_thy)
neuper@37940
    94
	val scri_thys = 
neuper@37940
    95
            subtract op = ["e_domID"] (map (get_thy o #1) (!script_thys))
neuper@37940
    96
	val isac_thys = 
neuper@37940
    97
            subtract op = ["e_domID"] 
neuper@37940
    98
            (subtract op = scri_thys (map (get_thy o #1) (!theory')))
neuper@37906
    99
    in [isabelle_page] @
neuper@37906
   100
       (map (collect_isab "Isabelle") isab_thms) @
neuper@37906
   101
       ((flat o (map (collect_thy "IsacScripts"))) scri_thys) @
neuper@37906
   102
       ((flat o (map (collect_thy "IsacKnowledge"))) isac_thys)
neuper@37906
   103
	 : (theID * thydata) list
neuper@37906
   104
    end; 
neuper@37906
   105
neuper@38031
   106
fun show_thes () = (writeln o format_pblIDl o (scan [])) (!thehier);
neuper@37906
   107
neuper@37906
   108
neuper@37906
   109
neuper@37906
   110
(***.create the xml-format for the hierarchy.***)
neuper@37906
   111
neuper@37906
   112
(**.make a hierarchy from (theID * thydata) list created by 'fun collect_thy';
neuper@37906
   113
    use the same mechanism as for pbl_hierarchy and met_hierarchy;
neuper@37906
   114
    but check, if a thydata is already there (for auto-gen. Isabelle).**)
neuper@37906
   115
neuper@37906
   116
(*.for preserving elements created by 'fun store_thy'.*)
neuper@37906
   117
fun exist_the (theID:theID) (thy_hie:thehier) =
neuper@37906
   118
    let fun node theID ids (Ptyp (id,_,ns)) =
neuper@37906
   119
	    if theID = ids @ [id] then true
neuper@37906
   120
	    else nodes theID (ids @ [id]) ns
neuper@37906
   121
	and nodes _ _ [] = false
neuper@37906
   122
	  | nodes theID ids (n::ns) = if node theID ids n then true
neuper@37906
   123
				      else  nodes theID ids ns
neuper@37906
   124
    in nodes theID [] thy_hie end;
neuper@37906
   125
neuper@37906
   126
(*.insrt requires a parent; see 'fun fill_parents'.*)
neuper@37906
   127
fun can_insert (theID:theID) (thy_hie:thehier) = 
neuper@37906
   128
    (insrt theID e_thydata theID thy_hie; true)
neuper@37906
   129
    handle _ => false;
neuper@37906
   130
neuper@37906
   131
(*.cut 'theID', the ID of theory elements from tail to head
neuper@37906
   132
   until insertion into the hierarchy of theory elements 'th' is possible
neuper@37906
   133
   (the hierarchy requires the parentnode to exist for insertion).*)
neuper@37906
   134
fun cut_theID th ([]:theID) = 
neuper@38031
   135
    error "could not insert into thy-hierarchy"
neuper@37906
   136
  | cut_theID th theID  = 
neuper@37906
   137
    if can_insert theID th
neuper@37906
   138
    then theID else cut_theID th (drop_last theID);
neuper@37906
   139
neuper@37906
   140
(*.insert empty parents 'Html' into the hierarchy of theory elements 'th'
neuper@37906
   141
   until the actual node can be inserted with key 'theID'.*)
neuper@37906
   142
(* val (th, cutID, theID) = (th, theID, theID);
neuper@37906
   143
   val (th, cutID, theID) = (th', cutID_, theID);
neuper@37906
   144
   *)
neuper@37906
   145
fun fill_parents th cutID theID =
neuper@37906
   146
    let val cutID' = cut_theID th cutID
neuper@37906
   147
    in if cutID' = theID
neuper@37906
   148
       then th
neuper@37906
   149
       else let val th' = insrt cutID' (Html {guh=theID2guh theID,
neuper@37906
   150
					      coursedesign=["isac team 2006"],
neuper@37906
   151
					      mathauthors=[],
neuper@37906
   152
					      html=""}) cutID' th
neuper@37906
   153
		val cutID_ = cutID' @ [nth ((length cutID') + 1) theID]
neuper@37906
   154
	    in fill_parents th' cutID_ theID end
neuper@37906
   155
    end;
neuper@37906
   156
neuper@37906
   157
(*.create the hierarchy from a list (generated automatically);
neuper@37906
   158
   thus, missing parents of list-elems are inserted 
neuper@37906
   159
   (causing msgs '*** insert: not found');
neuper@37906
   160
   elemes already store_*d in some *.ML are NOT overwritten.*)
neuper@37906
   161
fun the_hier th ([]: (theID * thydata) list) = th
neuper@37906
   162
(* val (th, (theID, thydata)::ths) = (!thehier, collect_thydata ());
neuper@37906
   163
   *)
neuper@37906
   164
  | the_hier th ((theID, thydata)::ths) =
neuper@37906
   165
    if can_insert theID th 
neuper@37906
   166
    then let val th' = if exist_the theID th
neuper@38031
   167
		       then (writeln ("*** insert: preserved "^strs2str theID);
neuper@37906
   168
			     th)
neuper@37906
   169
		       else insrt theID thydata theID th
neuper@37906
   170
	 in the_hier th' ths end
neuper@37906
   171
    else let val th' = fill_parents th theID theID (*..*** insert: not found*)
neuper@37906
   172
	     val th' = insrt theID thydata theID th'
neuper@37906
   173
	 in the_hier th' ths end;
neuper@37906
   174
neuper@37906
   175
neuper@37906
   176
(*these files shall contain 'invisible' html
neuper@37906
   177
val thydatafilename = "thy_datafile.xml"; (*for "Theorems"|...*)
neuper@37906
   178
fun partfilename str = "thy_" ^ str ^ ".xml"; (*for "Isabelle"|...*)*)
neuper@37906
   179
neuper@37906
   180
(*.create an xml-hierarchy where the filname is created from the guh.*)
neuper@37906
   181
(*ad DTD: a NODE contains an ID and zero or more NODEs*)
neuper@37906
   182
fun hierarchy_guh h =
neuper@37906
   183
    let val i = indentation
neuper@37906
   184
	val j = indentation
neuper@37906
   185
	fun node i p theID (Ptyp (id,_,ns)) = 
neuper@37906
   186
	    let val p' = lev_on p
neuper@37906
   187
		val theID' = theID @ [id]
neuper@37906
   188
	    in (indt i) ^ "<NODE>\n" ^ 
neuper@37906
   189
	       (indt (i+j)) ^ "<ID> " ^ id ^ " </ID>\n" ^ 
neuper@37906
   190
	       (indt (i+j)) ^ "<NO> " (*on this level*) ^ 
neuper@37906
   191
	       (string_of_int o last_elem) p' ^ " </NO>\n" ^ 
neuper@37906
   192
	       (indt (i+j)) ^ "<CONTENTREF> " ^ theID2guh theID' ^
neuper@37906
   193
	       " </CONTENTREF>\n" ^
neuper@37906
   194
	       (nodes (i+j) (lev_dn p') theID' ns) ^ 
neuper@37906
   195
	       (indt i) ^ "</NODE>\n"
neuper@37906
   196
	    end
neuper@37906
   197
	and nodes _ _ _ [] = ""
neuper@37906
   198
	  | nodes i p theID (n::ns) = (node i p theID n) 
neuper@37906
   199
				      ^ (nodes i (lev_on p) theID ns);
neuper@37906
   200
    in nodes j [0] [] h end;
neuper@37906
   201
neuper@37906
   202
fun thy_hierarchy2file (path:path) = 
neuper@37906
   203
    str2file (path ^ "thy_hierarchy.xml") 
neuper@37906
   204
	     ("<NODE>\n" ^
neuper@37906
   205
	      "  <ID> theory hierarchy </ID>\n" ^
neuper@37906
   206
	      "  <NO> 1 </NO>\n" ^
neuper@37906
   207
	      "  <CONTENTREF> thy_ROOT </CONTENTREF>\n" ^
neuper@37906
   208
	     (hierarchy_guh (!thehier)) ^
neuper@37906
   209
	     "</NODE>");
neuper@37906
   210
neuper@37906
   211
neuper@37906
   212
(**.create the xml-files for the theory-data from the hierarchy.**)
neuper@37906
   213
neuper@37906
   214
val i = indentation;
neuper@37906
   215
(*.analoguous to 'fun met2xml'.*)
neuper@37906
   216
fun thydata2xml (theID:theID, Html {guh, coursedesign, mathauthors, html}) =
neuper@37906
   217
    "<HTMLDATA>\n" ^
neuper@37906
   218
    indt i ^ "<GUH> "^ guh ^" </GUH>\n" ^
neuper@37906
   219
    id2xml i theID ^
neuper@37906
   220
    indt i ^ "<EXPLANATIONS> " ^ html ^ "</EXPLANATIONS>\n" ^
neuper@37906
   221
    authors2xml i "MATHAUTHORS" mathauthors ^
neuper@37906
   222
    authors2xml i "COURSEDESIGNS" coursedesign ^
neuper@37906
   223
    "</HTMLDATA>\n" : xml
neuper@37906
   224
  | thydata2xml (theID:theID, Hthm {guh, coursedesign, mathauthors, thm}) =
neuper@37906
   225
    "<THEOREMDATA>\n" ^
neuper@37906
   226
    indt i ^ "<GUH> "^ guh ^" </GUH>\n" ^
neuper@37906
   227
    id2xml i theID ^
neuper@38002
   228
    term2xml i thm ^
neuper@37906
   229
    indt i ^ "<PROOF>\n" ^
neuper@37906
   230
    extref2xml (i+i) "Proof of the theorem" 
neuper@37906
   231
	       ("http://www.ist.tugraz.at/projects/isac/www/\
neuper@37906
   232
		\kbase/thy/browser_info/HOL/HOL-Real/Isac/" ^
neuper@37906
   233
		nth 2 theID ^ ".html") ^
neuper@37906
   234
    indt i ^  "</PROOF>\n" ^
neuper@37906
   235
    indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n" ^
neuper@37906
   236
    authors2xml i "MATHAUTHORS" mathauthors ^
neuper@37906
   237
    authors2xml i "COURSEDESIGNS" coursedesign ^
neuper@37906
   238
    "</THEOREMDATA>\n"
neuper@37906
   239
(* val (theID:theID, Hrls {guh, coursedesign, mathauthors, thy_rls}) = 
neuper@37906
   240
       (theID, thydata);
neuper@37906
   241
   *)
neuper@37906
   242
  | thydata2xml (theID, Hrls {guh, coursedesign, mathauthors, thy_rls}) =
neuper@37906
   243
    "<RULESETDATA>\n" ^
neuper@37906
   244
    indt i ^ "<GUH> "^ guh ^" </GUH>\n" ^
neuper@37906
   245
    id2xml i theID ^
neuper@37906
   246
    rls2xml i thy_rls ^
neuper@37906
   247
    indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n" ^
neuper@37906
   248
    authors2xml i "MATHAUTHORS" mathauthors ^
neuper@37906
   249
    authors2xml i "COURSEDESIGNS" coursedesign ^
neuper@37906
   250
    "</RULESETDATA>\n"
neuper@37906
   251
(* val (theID:theID, Hcal {guh, coursedesign, mathauthors, calc}) = 
neuper@37906
   252
       (theID, rlsdata);
neuper@37906
   253
   *)
neuper@37906
   254
  | thydata2xml (theID, Hcal {guh, coursedesign, mathauthors, calc}) =
neuper@37906
   255
    "<RULESETDATA>\n" ^
neuper@37906
   256
    indt i ^ "<GUH> "^ guh ^" </GUH>\n" ^
neuper@37906
   257
    id2xml i theID ^
neuper@37906
   258
    calc2xml i (theID2thyID theID, calc) ^
neuper@37906
   259
    indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n" ^
neuper@37906
   260
    authors2xml i "MATHAUTHORS" mathauthors ^
neuper@37906
   261
    authors2xml i "COURSEDESIGNS" coursedesign ^
neuper@37906
   262
    "</RULESETDATA>\n"
neuper@37906
   263
  | thydata2xml (theID, _) =
neuper@38031
   264
    error ("thydata2xml: not implemented for "^ strs2str' theID);
neuper@37906
   265
neuper@37906
   266
(*.analoguous to 'fun met2file'.*)
neuper@37906
   267
fun thydata2file (xmldata:path) (pos:pos) (theID:theID) thydata =
neuper@38031
   268
    (writeln ("### thes2file: id = " ^ strs2str theID);
neuper@37906
   269
     str2file (xmldata ^ theID2filename theID)
neuper@37906
   270
	     (thydata2xml (theID:theID, thydata)));
neuper@37906
   271
neuper@37906
   272
(*.analoguous to 'fun node'; here we scan ??????????.*)
neuper@37906
   273
(* val (pa, ids, po, wfn, (Ptyp (id,[n],ns))) =
neuper@37906
   274
       (pa, ids, po, wfn,  n);
neuper@37906
   275
   *)
neuper@37906
   276
fun thenode (pa:path) ids po wfn (Ptyp (id,[n],ns)) = 
neuper@37906
   277
    let val po' = lev_on po
neuper@37906
   278
    in wfn pa po' (ids@[id]) n;
neuper@37906
   279
    thenodes pa (ids@[id]) ((lev_dn po'):pos) wfn ns end
neuper@37906
   280
(* val (pa,   ids,            po,  wfn,            (n::ns)) =
neuper@37906
   281
       (path, []:string list, [0], thydata2file, (!thehier));
neuper@37906
   282
   *)
neuper@37906
   283
and thenodes _ _ _ _ [] = ()
neuper@37906
   284
  | thenodes pa ids po wfn (n::ns) = (thenode pa ids po wfn n;
neuper@37906
   285
				 thenodes pa ids (lev_on po) wfn ns);
neuper@37906
   286
neuper@37906
   287
(*..analoguous to 'fun mets2file'*)
neuper@37906
   288
fun thes2file (p : path) = 
neuper@37906
   289
    thenodes p [] [0] thydata2file (!thehier);
neuper@37906
   290
neuper@37906
   291
neuper@37906
   292
(***.store a single theory element in the hierarchy.***)
neuper@37906
   293
neuper@37906
   294
(*.for mathauthors only, other html is added to xml exported from here.*)
neuper@37906
   295
(* val (theID, mathauthors) = 
neuper@37906
   296
       (["IsacKnowledge", theory2thyID Biegelinie.thy, "Theorems"],
neuper@37906
   297
	["Walther Neuper 2005 supported by a grant from NMI Austria"]);
neuper@37906
   298
   *)
neuper@37906
   299
fun store_isa (theID : theID) (mathauthors : authors) =
neuper@37906
   300
    let val guh = case theID of
neuper@37906
   301
		      [part] => part2guh theID
neuper@37906
   302
		    | [part, thyID, thypart] => thypart2guh theID
neuper@37906
   303
	val theID = guh2theID guh
neuper@37906
   304
	val the = Html {guh = guh, 
neuper@37906
   305
			coursedesign = [], 
neuper@37906
   306
			mathauthors = mathauthors,
neuper@37906
   307
			html = ""}
neuper@37906
   308
    in (*needs no (!check_guhs_unique) because guh is generated automatically*)
neuper@37906
   309
	thehier := insrt theID the theID (!thehier) end;
neuper@37906
   310
				 
neuper@37906
   311
fun store_thy thy (mathauthors : authors) =
neuper@37906
   312
    let val guh = thy2guh ["IsacKnowledge", theory2thyID thy]
neuper@37906
   313
	val theID = guh2theID guh
neuper@37906
   314
	val the = Html {guh = guh, 
neuper@37906
   315
			coursedesign = [], 
neuper@37906
   316
			mathauthors = mathauthors,
neuper@37906
   317
			html = ""}
neuper@37906
   318
    in (*needs no (!check_guhs_unique) because guh is generated automatically*)
neuper@37906
   319
	thehier := insrt theID the theID (!thehier) end;
neuper@37906
   320
				 
neuper@37906
   321
fun store_thm thy (thmID : thmID, thm) (mathauthors : authors) =
neuper@37906
   322
    let val guh = thm2guh ("IsacKnowledge", theory2thyID thy) thmID
neuper@37906
   323
	val theID = guh2theID guh
neuper@37906
   324
	val the = Hthm {guh = guh, 
neuper@37906
   325
			coursedesign = [], (*done at xml exported from here*)
neuper@37906
   326
			mathauthors=mathauthors,
neuper@37906
   327
			thm = thm}
neuper@37906
   328
    in (*needs no (!check_guhs_unique) because guh is generated automatically*)
neuper@37906
   329
	thehier := insrt theID the theID (!thehier) end;
neuper@37906
   330
neuper@37906
   331
fun store_rls thy rls (mathauthors : authors) =
neuper@37906
   332
    let val guh = rls2guh ("IsacKnowledge", theory2thyID thy) 
neuper@37906
   333
			  ((#id o rep_rls)  rls)
neuper@37906
   334
	val theID = guh2theID guh
neuper@37906
   335
	val the = Hrls {guh = guh,
neuper@37906
   336
			coursedesign = [], 
neuper@37906
   337
			mathauthors = mathauthors,
neuper@37906
   338
			thy_rls=(theory2thyID thy, rls)}
neuper@37906
   339
    in (*needs no (!check_guhs_unique) because guh is generated automatically*)
neuper@37906
   340
	thehier := insrt theID the theID (!thehier) end;
neuper@37906
   341
neuper@37906
   342
fun store_cal thy cal (mathauthors : authors) =
neuper@37906
   343
    let val guh = cal2guh ("IsacKnowledge", theory2thyID thy)
neuper@37906
   344
			  ("TODO store_cal")
neuper@37906
   345
	val theID = guh2theID guh
neuper@37906
   346
	val the = Hcal {guh = guh,
neuper@37906
   347
			coursedesign = [],
neuper@37906
   348
			mathauthors = mathauthors,
neuper@37906
   349
			calc = cal}
neuper@37906
   350
    in (*needs no (!check_guhs_unique) because guh is generated automatically*)
neuper@37906
   351
	thehier := insrt theID the theID (!thehier) end;
neuper@37906
   352
neuper@37906
   353
fun store_ord thy ord (mathauthors : authors) =
neuper@37906
   354
    let val guh = ord2guh ("IsacKnowledge", theory2thyID thy)
neuper@37906
   355
			  ("TODO store_ord")
neuper@37906
   356
	val theID = guh2theID guh
neuper@37906
   357
	val the = Hord {guh = guh,
neuper@37906
   358
			coursedesign = [],
neuper@37906
   359
			mathauthors = mathauthors,
neuper@37906
   360
			ord = ord}
neuper@37906
   361
    in (*needs no (!check_guhs_unique) because guh is generated automatically*)
neuper@37906
   362
	thehier := insrt theID the theID (!thehier) end;