test/Tools/isac/xmlsrc/thy-hierarchy.sml
author Mathias Lehnfeld <s1210629013@students.fh-hagenberg.at>
Mon, 27 Jan 2014 21:49:27 +0100
changeset 55359 73dc85c025ab
parent 52156 aa0884017d48
child 55397 71f7fd375e7d
permissions -rw-r--r--
cleanup, naming: 'KEStore_Elems' in Tests now 'Test_KEStore_Elems', 'store_pbts' now 'add_pbts'
akargl@42176
     1
(* Title: tests for sml/xmlsrc/thy-hierarchy.sml
akargl@42176
     2
   Authors: Walther Neuper 060113
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
neuper@37906
     5
CAUTION with testing *2file functions -- they are actually writing to ~/tmp
neuper@37906
     6
*)
neuper@37906
     7
akargl@42176
     8
val thy = @{theory "Isac"};
neuper@37906
     9
neuper@37906
    10
"-----------------------------------------------------------------";
neuper@37906
    11
"table of contents -----------------------------------------------";
neuper@37906
    12
"-----------------------------------------------------------------";
neuper@37906
    13
"----------- assoc_rls -------------------------------------------";
neuper@37906
    14
"----------- thm_hier --------------------------------------------";
neuper@37906
    15
"----------- fun thydata2xml -------------------------------------";
neuper@37906
    16
"----------- write xml to tmp ------------------------------------";
neuper@37906
    17
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
    18
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@42407
    19
"----------- thes2file: thy_containing_rls : rls '...' not in ! --";
neuper@42411
    20
"----------- fun store_thm ---------------------------------------";
neuper@42429
    21
"----------- fun insert_fillpats ---------------------------------";
neuper@42453
    22
"----------- fun insert_errpatIDs --------------------------------";
neuper@37906
    23
"-----------------------------------------------------------------";
neuper@37906
    24
"-----------------------------------------------------------------";
neuper@37906
    25
"-----------------------------------------------------------------";
neuper@37906
    26
neuper@37906
    27
neuper@37906
    28
"----------- assoc_rls -------------------------------------------";
neuper@37906
    29
"----------- assoc_rls -------------------------------------------";
neuper@37906
    30
"----------- assoc_rls -------------------------------------------";
neuper@37906
    31
val al = [(1,11),(2,22),(3,33)];
neuper@37906
    32
overwrite (al, (2,2222));
neuper@37906
    33
(*val it = [(1, 11), (2, 2222), (3, 33)] : (int * int) list*)
neuper@37906
    34
neuper@37906
    35
val al = [("e_rls",("Atools",e_rls)),("e_rrls",("Atools",e_rrls))];
neuper@37906
    36
val bl = [("e_rls",e_rls),("e_rrls",e_rrls)];
neuper@37906
    37
val b = ("e_rls",("Atools",e_rrls));
neuper@37906
    38
overwrite (al, b);
neuper@37906
    39
overwritelthy thy (al, bl);
neuper@37906
    40
s1210629013@55359
    41
case assoc' ((Test_KEStore_Elems.get_rlss (Thy_Info.get_theory "Isac")),"e_rls") of
neuper@42407
    42
  SOME ("Tools", Rls _) => ()
neuper@52156
    43
| _ => error "e_rls not in Theory_Data" 
neuper@42407
    44
neuper@37906
    45
assoc_rls "e_rls";
neuper@37906
    46
neuper@37906
    47
neuper@37906
    48
"----------- thm_hier --------------------------------------------";
neuper@37906
    49
"----------- thm_hier --------------------------------------------";
neuper@37906
    50
"----------- thm_hier --------------------------------------------";
neuper@37906
    51
(curry op:: "xxx") ["yyy","yyy","yyy"];
neuper@37906
    52
map (curry op:: "xxx") [["yyy1"],["yyy2"],["yyy3"]];
neuper@37906
    53
neuper@37906
    54
val thy' = "Integrate";
neuper@37906
    55
val thy = assoc_thy (thyID2theory' thy');
neuper@42407
    56
neuper@42407
    57
"WN120406.GOON --- restarted with 'isolate response' below, because it was very slow ?!?" ^
neuper@42407
    58
"slow probably only because of print_depth 999 and large output";
neuper@42407
    59
neuper@42400
    60
val thm = prop_of @{thm integral_var};
neuper@37906
    61
neuper@42407
    62
(*-.-.-.-.-.-WN120406 isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
neuper@42407
    63
neuper@37906
    64
"collect_thms thy'------------------------------------------------";
neuper@42400
    65
(apfst single) ("Integrate.integral_var", thm);
neuper@42400
    66
(strip_thy o #1) ("Integrate.integral_var", thm);
neuper@37906
    67
neuper@37906
    68
(*cannot get this as arg from arg        ^^^^^^^^^^^^^^^^*)
neuper@42400
    69
    ("Integrate.integral_var", @{thm integral_var});
neuper@37906
    70
(*thus new fun....*)
neuper@37906
    71
neuper@42400
    72
makeHthm ("IsacKnowledge", thy') ("Integrate.integral_var", thm);
neuper@42400
    73
(makeHthm ("IsacKnowledge", thy')) ("Integrate.integral_var", thm);
neuper@42400
    74
map (makeHthm ("IsacKnowledge", thy')) (Theory.axioms_of thy);
neuper@42400
    75
collect_thms' ("IsacKnowledge", thy');
neuper@37906
    76
neuper@37906
    77
"collect_rlss thy'------------------------------------------------";
neuper@37906
    78
makeHrls "IsacKnowledge" ("integration_rules", (thy', integration_rules));
neuper@37906
    79
neuper@37906
    80
val thy' = "Test";
neuper@37906
    81
val rlss = filter ((curry op= thy') o 
neuper@37906
    82
			   ((#1 o #2):(rls' * (theory' * rls)) -> theory')) 
s1210629013@55359
    83
			  (Test_KEStore_Elems.get_rlss (Thy_Info.get_theory "Isac"));
neuper@37906
    84
collect_rlss ("IsacKnowledge",thy');
neuper@37906
    85
neuper@37906
    86
"collect_thy thy-------------------------------------------------";
neuper@42400
    87
val thy' = "ListC";
neuper@37906
    88
val thy = assoc_thy (thyID2theory' thy');
neuper@37906
    89
((collect_thms' ("IsacKnowledge",thy')) @ 
neuper@37906
    90
 (collect_rlss ("IsacKnowledge",thy')) @ 
neuper@37906
    91
 (collect_cals ("IsacKnowledge",thy')) @ 
neuper@37906
    92
 (collect_ords ("IsacKnowledge",thy')));
neuper@37906
    93
collect_thy "IsacKnowledge" thy';
neuper@37906
    94
neuper@37906
    95
"collect_thydata -------------------------------------------------";
neuper@42400
    96
(*map rearrange_inv (! isab_thm_thy); dropped WN120321*)
neuper@42400
    97
val xxx = hd (! isab_thm_thy);
neuper@42400
    98
(single) xxx;
neuper@42400
    99
(apfst ((curry op:: "Isabelle") o single)) xxx;
neuper@37906
   100
neuper@42400
   101
map (apfst ( (curry op:: "Isabelle") o single) );
neuper@42400
   102
map (apfst ((curry op:: "Isabelle") o single)) (! isab_thm_thy);
neuper@37906
   103
neuper@37906
   104
"thy_hierarchy ---------------------------------------------------";
neuper@42400
   105
val theID = ["IsacScripts", "ListC", "Theorems", "append_Cons"]:theID;
neuper@37906
   106
val thydat as (theID, thydata) = 
akargl@42176
   107
    (theID, Hthm {guh = theID2guh theID, mathauthors = [],
neuper@42400
   108
     coursedesign = [], thm = prop_of @{thm append_Cons}});
neuper@42400
   109
neuper@37906
   110
val th = [] : thehier;
neuper@37906
   111
val theID' = cut_theID th theID;
neuper@37906
   112
val th = fill_parents th theID' theID;
neuper@37906
   113
(* val th =
neuper@37906
   114
   [Ptyp ("IsacScripts",
neuper@37906
   115
            [Html {guh = "thy_ListG-thm-append_Cons", html = "", ...}],
neuper@37906
   116
            [Ptyp ("ListG", ...)])] : thehier *)
neuper@37906
   117
(*show_thes*)(writeln o format_pblIDl o (scan [])) th;
neuper@37906
   118
writeln (hierarchy_guh th);
neuper@37906
   119
neuper@42400
   120
"~~~~~ fun collect_thydata, args:"; val () = ();
neuper@42400
   121
    val isab_thms = (! isab_thm_thy):  (thmDeriv * term) list
neuper@42400
   122
val xxx = hd (! isab_thm_thy);
neuper@42400
   123
(collect_isab "Isabelle") xxx;
neuper@42400
   124
(map (collect_isab "Isabelle") (! isab_thm_thy));
neuper@42400
   125
(* = [(["Isabelle", "HOL", "Theorems", "refl"],
neuper@42400
   126
           Hthm {guh = "thy_isab_HOL-thm-refl", thm = Const ("HOL.Trueprop...", ..., 
neuper@42400
   127
             mathauthors = ["Isabelle team, TU Munich"], coursedesign = []}),
neuper@42400
   128
          (["Isabelle", "Fun", "Theorems", ...],
neuper@42400
   129
           Hthm {guh = "thy_isab_Fun-thm-o_apply", thm = Const (......, 
neuper@42400
   130
             mathauthors = ["Isabelle team, TU Munich"], coursedesign = []}),
neuper@42400
   131
          (["Isabelle", "ListC", ...], ...), (["Isabelle", ...], ...), ([...], ...), ...]:
neuper@42400
   132
   (theID * thydata) list*)
neuper@42400
   133
neuper@42400
   134
(! progthys);
neuper@42400
   135
val xxx = hd (map Context.theory_name (! progthys)): theory';
neuper@42400
   136
(collect_thy "IsacScripts") xxx;
neuper@42400
   137
((flat o (map (collect_thy "IsacScripts"))) (map Context.theory_name (! progthys)));
neuper@42400
   138
(* = [(["IsacScripts", "Script", "Theorems", "arity_type_ID"],
neuper@42400
   139
           Hthm {guh = "thy_scri_Script-thm-arity_type_ID", thm = Const ("HOL.type_class..., 
neuper@42400
   140
             mathauthors = ["isac-team"], coursedesign = []}),
neuper@42400
   141
          (["IsacScripts", "Script", "Theorems", ...], 
neuper@42400
   142
               Hthm {guh = "thy_scri_Script-thm-arity_type_arg", thm = Const (...) $ Const (...), 
neuper@42400
   143
                 mathauthors = ["isac-team"], coursedesign = []}),
neuper@42400
   144
          (["IsacScripts", "Tools", ...], ...), (["IsacScripts", ...], ...), ([...], ...), ...]:
neuper@42400
   145
   (theID * thydata) list*)
neuper@42400
   146
neuper@42400
   147
print_depth 5;
neuper@42400
   148
((flat o (map (collect_thy "IsacKnowledge"))) (map Context.theory_name (! knowthys)));
neuper@42400
   149
(* = [(["IsacKnowledge", "Inverse_Z_Transform", "Theorems", ...],
neuper@42400
   150
           Hthm {guh = "thy_isac_Inverse_Z_Transform-thm-rule1", thm =
neuper@42400
   151
                 Const (...) $ (Const (...) $ Const (... $ Bound 0 $ Const (...))))))),
neuper@42400
   152
                 mathauthors = ["isac-team"], coursedesign = []}),
neuper@42400
   153
          (["IsacKnowledge", "Inverse_Z_Transform", ...], ...), 
neuper@42400
   154
          (["IsacKnowledge", ...], ...), ([...], ...), ...]:
neuper@42400
   155
   (theID * thydata) list*)
neuper@42400
   156
"~~~~~ from collect_thydata return val:"; val () = ();
neuper@42400
   157
neuper@37906
   158
val th = [] : thehier;
neuper@37906
   159
val thydats = collect_thydata ();
neuper@37906
   160
val th1 = the_hier th thydats (**** insert: not found [".. from fill_parents*);
neuper@37906
   161
(*show_thes*)(writeln o format_pblIDl o (scan [])) th1;
neuper@37906
   162
neuper@37906
   163
writeln (hierarchy_guh th);
neuper@42400
   164
(*writeln (hierarchy_guh th);
neuper@42400
   165
*)
neuper@37906
   166
writeln (hierarchy_guh th1);
neuper@42400
   167
(* <NODE>
neuper@42400
   168
    <ID> Isabelle </ID>
neuper@42400
   169
    <NO> 1 </NO>
neuper@42400
   170
    <CONTENTREF> thy_isab_Isabelle-part </CONTENTREF>
neuper@42400
   171
  </NODE>*)
neuper@37906
   172
neuper@37906
   173
"thy_hierarchy2file ----------------------------------------------";
neuper@37906
   174
show_thes();
neuper@37906
   175
(*
neuper@42451
   176
val path = "../../tmp/";
neuper@37906
   177
thy_hierarchy2file path;
neuper@37906
   178
*)
neuper@37906
   179
neuper@37906
   180
get_the ["IsacKnowledge"];
neuper@42400
   181
(*------------------------ WN120320
neuper@37906
   182
get_the ["IsacKnowledge", "Test"];
neuper@37906
   183
get_the ["IsacKnowledge", "Test", "Theorems"];
neuper@37906
   184
get_the ["IsacKnowledge", "Test", "Theorems", "exp_pow"];
neuper@37906
   185
get_the ["IsacKnowledge", "Test", "Rulesets"];
neuper@42400
   186
WN120320 ----------------------- *)
neuper@37906
   187
neuper@37906
   188
(* FIXXXXXXXXXME.WN060713 guh -- theID
neuper@37906
   189
case get_the ["IsacKnowledge", "Test", "Rulesets", "Test_simplify"] of
neuper@37906
   190
    Hrls {guh = "thy_Test-rls-Test_simplify",thy_rls = ("Test", _),
neuper@37906
   191
          mathauthors = _,coursedesign = _} => ()
neuper@38031
   192
  | _ => error "thy-hierarchy.sml: [IsacKnowledge,Test,Rulesets]";
neuper@37906
   193
*)
neuper@42407
   194
-.-.-.-.-.-.-WN120406 isolate response.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.*)
neuper@37906
   195
neuper@37906
   196
neuper@37906
   197
"----------- fun thydata2xml -------------------------------------";
neuper@37906
   198
"----------- fun thydata2xml -------------------------------------";
neuper@37906
   199
"----------- fun thydata2xml -------------------------------------";
neuper@42400
   200
(*========== inhibit exn AK110725 ================================================
neuper@37906
   201
val theID = ["IsacScripts", "ListG", "Theorems", "append_Cons"];
neuper@37906
   202
val thmdata = get_the theID;
neuper@37906
   203
writeln(thydata2xml (theID, thmdata));
neuper@37906
   204
neuper@37906
   205
val theID = ["IsacKnowledge", "Poly", "Rulesets", "norm_Poly"];
neuper@37906
   206
val rlsdata = get_the theID;
neuper@37906
   207
writeln(thydata2xml (theID, rlsdata));
akargl@42176
   208
========== inhibit exn AK110725 ================================================*)
neuper@37906
   209
neuper@37906
   210
(*FIXXXXXXXME.WN060714 in rls make Calc : calc -> rule [add scriptop!]
neuper@37906
   211
  see sml/../datatypes.sml !
neuper@38058
   212
val (thy', rls') = ("DiffApp", "Tools.rhs");
neuper@37906
   213
thy_containing_rls thy' rls';
neuper@37906
   214
print_depth 99; map #1 startsearch; print_depth 3;
neuper@37906
   215
*)
neuper@37906
   216
neuper@37906
   217
(*
neuper@42451
   218
val path = "../../tmp/";
neuper@37906
   219
thes2file path;
neuper@37906
   220
*)
neuper@37906
   221
neuper@37906
   222
"----------- write xml to tmp ------------------------------------";
neuper@37906
   223
"----------- write xml to tmp ------------------------------------";
neuper@37906
   224
"----------- write xml to tmp ------------------------------------";
neuper@37906
   225
(*
neuper@42451
   226
val path = "../../tmp/"; 
neuper@37906
   227
neuper@37906
   228
pbl_hierarchy2file (path ^ "pbl/");
neuper@37906
   229
pbls2file          (path ^ "pbl/");
neuper@37906
   230
neuper@37906
   231
met_hierarchy2file (path ^ "met/");
neuper@37906
   232
mets2file          (path ^ "met/");
neuper@37906
   233
neuper@37906
   234
thy_hierarchy2file (path ^ "thy/");
neuper@37906
   235
thes2file          (path ^ "thy/");
neuper@37906
   236
*)
neuper@37906
   237
neuper@37906
   238
neuper@37906
   239
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
   240
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
   241
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
   242
(*
neuper@38059
   243
store_isa ["Isabelle"] ["THIS SHOULD not BE OVERWRITTEN below"];
neuper@37906
   244
print_depth 99; get_the ["Isabelle"]; print_depth 3;
neuper@37906
   245
print_depth 5; thehier;  print_depth 3;
neuper@37906
   246
neuper@38059
   247
thehier := the_hier (! thehier) (collect_thydata ());
neuper@37906
   248
print_depth 99; get_the ["Isabelle"]; print_depth 3;
neuper@37906
   249
print_depth 5; thehier;  print_depth 3;
neuper@37906
   250
*)
neuper@37906
   251
neuper@37906
   252
case get_the ["IsacKnowledge", "Biegelinie", "Theorems"] of
neuper@37906
   253
   Html {mathauthors =
neuper@37906
   254
	 ["Walther Neuper 2005 supported by a grant from NMI Austria"],...}=>()
neuper@38031
   255
 | _ => error "thy-hierarchy.sml: store_isa overwritten";
neuper@37906
   256
neuper@37906
   257
case get_the ["IsacKnowledge","Biegelinie","Theorems","Belastung_Querkraft"] of
neuper@37906
   258
   Hthm {mathauthors =
neuper@37906
   259
	 ["Walther Neuper 2005 supported by a grant from NMI Austria"],...}=>()
neuper@38031
   260
 | _ => error "thy-hierarchy.sml: store_isa overwritten";
neuper@37906
   261
neuper@37906
   262
(*
neuper@37906
   263
print_depth 7; 
neuper@37906
   264
get_the ["IsacKnowledge","Biegelinie","Theorems","Belastung_Querkraft"];
neuper@37906
   265
print_depth 3;
neuper@37906
   266
*)
neuper@37906
   267
neuper@37906
   268
(*WN060728 strange behaviour:
neuper@37906
   269
### fun the_hier reports these not overwritten ?!?...(stored twice ?!?) ...
neuper@37906
   270
neuper@37906
   271
val it = () : unit
neuper@48763
   272
*** insert: preserved ["Isabelle","RealDef","Theorems","mult_assoc"]
neuper@37967
   273
*** insert: preserved ["Isabelle","RealDef","Theorems","add_assoc"]
neuper@37906
   274
*** insert: preserved ["Isabelle","RealBin","Theorems","real_mult_minus1"]
neuper@37906
   275
*** insert: preserved ["Isabelle","RealBin","Theorems","real_mult_2"]
neuper@48763
   276
*** insert: preserved ["Isabelle","RealDef","Theorems","mult_assoc"]
neuper@37906
   277
*** insert: preserved ["Isabelle","RealDef","Theorems","real_mult_minus_eq1"]
neuper@37967
   278
*** insert: preserved ["Isabelle","RealDef","Theorems","add_assoc"]
neuper@37906
   279
*** insert: preserved ["Isabelle","RealDef","Theorems","real_minus_divide_eq"]
neuper@37906
   280
*** insert: preserved ["IsacScripts","ListG","Theorems","induct"]
neuper@37906
   281
*** insert: preserved ["IsacScripts","ListG","Theorems","simps_1"]
neuper@37906
   282
*** insert: preserved ["IsacScripts","ListG","Theorems","simps_2"]
neuper@37906
   283
val it = () : unit
neuper@37906
   284
neuper@37906
   285
### but those store_*d in Biegelinie.ML are NOT reported !?!?!?!?!?!?!
neuper@37906
   286
### however, '*** insert: not found' is NOT reported below, too....
neuper@37906
   287
neuper@37906
   288
----------------------------------
neuper@37906
   289
*** insert: not found ... IS OK :
neuper@37906
   290
comes from fill_parents
neuper@37906
   291
----------------------------------
neuper@37906
   292
neuper@37906
   293
val it = () : unit
neuper@48764
   294
*** insert: not found ["Isabelle","NatDef","Theorems","order_refl"]
neuper@48764
   295
*** insert: not found ["Isabelle","NatDef","Theorems","order_refl"]*)
neuper@37906
   296
neuper@37906
   297
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
   298
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
   299
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
   300
writeln "what to do when you get,e.g. \n\
neuper@37906
   301
\### thes2file: id = [\"IsacKnowledge\",\"Integrate\",\"Rulesets\"]\n\
neuper@37906
   302
\### thes2file: id = [\"IsacKnowledge\",\"Integrate\",\"Rulesets\",\"integration_rules\"]\n\
neuper@37906
   303
\### thes2file: id = [\"IsacKnowledge\",\"Integrate\",\"Rulesets\",\"add_new_c\"]\n\
neuper@37906
   304
\Exception- Match raised";
neuper@37906
   305
neuper@38059
   306
val ptyp = hd (! thehier);
neuper@37906
   307
val theID = ["IsacKnowledge","Integrate","Rulesets","add_new_c"];
akargl@42176
   308
(*========== inhibit exn AK110725 ================================================
neuper@37906
   309
val thydata = get_the theID;
akargl@42176
   310
neuper@37906
   311
(* creates a file ...
neuper@37906
   312
thydata2file "~/tmp/"[] theID thydata (*reports Exception- Match in question*);
neuper@37906
   313
*)
akargl@42176
   314
neuper@37906
   315
thydata2xml (theID, thydata) (*reports Exception- Match in question*);
akargl@42176
   316
neuper@37906
   317
val (theID:theID, Hrls {guh, coursedesign, mathauthors, thy_rls}) = 
neuper@37906
   318
    (theID, thydata);
neuper@37906
   319
rls2xml i thy_rls (*reports Exception- Match in question*);
neuper@37906
   320
val (j, (thyID, Seq data)) = (i, thy_rls);
neuper@37906
   321
(* evaluate this local fun ...
neuper@37906
   322
rls2xm j (thyID, "Seq", data) (*reports Exception- Match in question*);
neuper@37906
   323
*)
neuper@37906
   324
val (j, (thyID, seqrls, {id, preconds, rew_ord=(ord,_), erls,
neuper@37906
   325
			 srls, calc, rules, scr})) = 
neuper@37906
   326
    (j, (thyID, "Seq", data));
neuper@37906
   327
rules2xml (j+2*i) thyID rules (*reports Exception- Match in question*);
akargl@42176
   328
============ inhibit exn AK110725 ==============================================*)
neuper@42407
   329
neuper@42407
   330
"----------- thes2file: thy_containing_rls : rls '...' not in ! --";
neuper@42407
   331
"----------- thes2file: thy_containing_rls : rls '...' not in ! --";
neuper@42407
   332
"----------- thes2file: thy_containing_rls : rls '...' not in ! --";
neuper@42407
   333
val TESTdump = Unsynchronized.ref 
neuper@42407
   334
  ("path": path, ["ids"]: theID, []: pos, thydata2file, Ptyp ("xxx", [], []): thydata ptyp);
neuper@42407
   335
neuper@42407
   336
fun TESTthenode (pa:path) ids po wfn (Ptyp (id, [n], ns)) TESTids = 
neuper@42407
   337
    let val po' = lev_on po
neuper@42407
   338
    in 
neuper@42407
   339
      if (ids@[id]) = TESTids
neuper@42407
   340
      then
neuper@42407
   341
        (TESTdump := (pa, ids, po', wfn, (Ptyp (id, [n], ns))); 
neuper@42407
   342
          error "stopped before error, created TESTdump") (* this exn creates right signature*)
neuper@42407
   343
      else
neuper@42407
   344
        wfn pa po' (ids @ [id]) n; TESTthenodes pa (ids @ [id]) ((lev_dn po'): pos) wfn ns TESTids
neuper@42407
   345
    end
neuper@42407
   346
and TESTthenodes _ _ _ _ [] _ = ()
neuper@42407
   347
  | TESTthenodes pa ids po wfn (n::ns) TESTids =
neuper@42407
   348
      (TESTthenode pa ids po wfn n TESTids; TESTthenodes pa ids (lev_on po) wfn ns TESTids);
neuper@42407
   349
neuper@42407
   350
(* /--- side effects from previous test files ---\*)
neuper@42407
   351
    val i = indentation;
neuper@42407
   352
    val j = indentation;
neuper@42407
   353
(* \--- side effects from previous test files ---/*)
neuper@42451
   354
"~~~~~ fun thes2file, args:"; val (p : path) = ("../../tmp/");
neuper@42407
   355
(* recursively descend into thehier just before the error: *)
neuper@42407
   356
(TESTthenodes p [] [0] thydata2file (! thehier)
neuper@42407
   357
  ["IsacKnowledge","Poly","Rulesets","norm_Poly"] 
neuper@42407
   358
handle _(* "stopped before error, created TESTdump" *) => ());
neuper@42407
   359
val (pa, ids, po', wfn, (Ptyp (id, [n], ns))) = ! TESTdump;
neuper@42407
   360
neuper@42407
   361
"~~~~~ fun thydata2file, args:"; val ((xmldata:path), (pos:pos), (theID:theID), thydata) =
neuper@42407
   362
  (pa, po', (ids@[id]), n);
neuper@42407
   363
"~~~~~ fun thydata2xml, args:"; val (theID, Hrls {guh, coursedesign, mathauthors, thy_rls}) =
neuper@42407
   364
  (theID:theID, thydata);
neuper@42407
   365
"~~~~~ fun rls2xml, args:"; val (j, (thyID, Seq data)) = (i, thy_rls);
neuper@42407
   366
"~~~~~ fun rls2xm, args:"; val (j, (thyID, seqrls, {id, preconds, rew_ord=(ord,_), erls,
neuper@42451
   367
		      srls, calc, errpatts, rules, scr})) = (j, (thyID, "Seq", data));
neuper@42407
   368
"~~~~~ fun rules2xml, args:"; val (j, thyID, (r::rs)) = ((j+2*i), thyID, rules);
neuper@42407
   369
"~~~~~ fun rule2xml, args:"; val (j, thyID, (Rls_ rls)) = (j, thyID, r);
neuper@42407
   370
val rls' = (#id o rep_rls) rls;
neuper@42407
   371
"~~~~~ fun thy_containing_rls, args:"; val (thy', rls') = (thyID, rls');
neuper@42407
   372
infix mem; (*from Isabelle2002*)
neuper@42407
   373
fun x mem [] = false
neuper@42407
   374
  | x mem (y :: ys) = x = y orelse x mem ys;
neuper@42407
   375
neuper@42407
   376
    val rls' = strip_thy rls'
neuper@42407
   377
    val thy' = thyID2theory' thy'
neuper@42407
   378
    val dropthys =
neuper@42407
   379
      takewhile [] (not o (curry op= thy') o (#1:theory' * theory -> theory'))
neuper@42407
   380
        (rev (!theory'));
neuper@42407
   381
neuper@42407
   382
if map #1 dropthys = ["Isac", "Inverse_Z_Transform", "DiophantEq", "AlgEin", "Biegelinie",
neuper@42407
   383
  "Vect", "PolyMinus", "Frontend", "Partial_Fractions", "DiffApp", "Test", "EqSystem", "Integrate",
neuper@42407
   384
  "Diff", "LogExp", "Trig", "Calculus", "PolyEq", "RootRatEq", "RootRat", "RatEq", "RootEq",
neuper@42407
   385
  "LinEq", "Root", "Equation", "Rational"]
neuper@42407
   386
then () else error "thy_containing_rls changed ancestors_rls for (Poly, discard_minus)";
neuper@42407
   387
neuper@42407
   388
    val dropthys' = map (get_thy o (#1 : (theory' * theory) -> theory')) dropthys: string list;
neuper@42407
   389
		    val ancestors_rls = 
neuper@42407
   390
		      filter_out ((curry ((op mem) o swap) dropthys') o ((#1 o #2): rls'*(theory' * rls)->theory'))
s1210629013@55359
   391
		        (rev (Test_KEStore_Elems.get_rlss (Thy_Info.get_theory "Isac")));
neuper@42407
   392
neuper@42407
   393
case assoc (ancestors_rls, rls') of
neuper@42407
   394
  SOME ("Poly", Rls {id = "discard_minus", ...}) => ()
neuper@42407
   395
| _ => error "thy_containing_rls changed 2";
neuper@42407
   396
neuper@42411
   397
"----------- fun store_thm ---------------------------------------";
neuper@42411
   398
"----------- fun store_thm ---------------------------------------";
neuper@42411
   399
"----------- fun store_thm ---------------------------------------";
neuper@42411
   400
store_thm @{theory "Biegelinie"} "IsacKnowledge"
neuper@42411
   401
  ("Belastung_Querkraft", prop_of @{thm Belastung_Querkraft})
neuper@42411
   402
	    ["Walther Neuper 2005 supported by a grant from NMI Austria"];
neuper@42407
   403
neuper@42411
   404
"~~~~~ fun store_thm, args:"; val (thy, part, (thmID : thmID, thm), (mathauthors : authors)) =
neuper@42411
   405
  (@{theory "Biegelinie"}, "IsacKnowledge",
neuper@42411
   406
    ("Belastung_Querkraft", prop_of @{thm Belastung_Querkraft}),
neuper@42411
   407
	      ["Walther Neuper 2005 supported by a grant from NMI Austria"]);
neuper@42411
   408
    val guh = thm2guh (part, theory2thyID thy) thmID
neuper@42411
   409
    val theID = guh2theID guh;
neuper@42411
   410
if guh = "thy_isac_Biegelinie-thm-Belastung_Querkraft" andalso
neuper@42411
   411
  theID = ["IsacKnowledge", "Biegelinie", "Theorems", "Belastung_Querkraft"]
neuper@42411
   412
then () else error "store_thm: guh | theID changed";
neuper@42411
   413
neuper@42429
   414
"----------- fun insert_fillpats ---------------------------------";
neuper@42429
   415
"----------- fun insert_fillpats ---------------------------------";
neuper@42429
   416
"----------- fun insert_fillpats ---------------------------------";
neuper@42456
   417
(* vv--- this intermediate save/restore does not work and affects other tests ---vv
neuper@42456
   418
         see test/../calcelems.sml --- Unsynchronized.ref doesn't work any more ---
neuper@42456
   419
neuper@42456
   420
val path = ["IsacKnowledge", "Diff", "Theorems", "diff_sin_chain"]: theID;
neuper@42456
   421
neuper@42456
   422
(*save   *) val Hthm {guh, coursedesign, mathauthors, thm, fillpats = save_fillpats} = get_the path;
neuper@42456
   423
neuper@42456
   424
val test_fillpats = [
neuper@42429
   425
  ("fill-d_d-arg",
neuper@42429
   426
    parse_patt thy "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv _", "chain-rule-diff-both"),
neuper@42456
   427
  ("test-fillpatt", e_term, "test-errpat")]: fillpat list;
neuper@42429
   428
neuper@42456
   429
insert_fillpats path test_fillpats;
neuper@42456
   430
val Hthm {fillpats, ...} = get_the path;
neuper@42429
   431
case fillpats of
neuper@42456
   432
  [("fill-d_d-arg", _, "chain-rule-diff-both"), ("test-fillpatt", _, "test-errpat")] => ()
neuper@42429
   433
| _ => error "insert_fillpats changed"
neuper@42429
   434
neuper@42456
   435
(*restore*) insert_fillpats path save_fillpats;
neuper@42456
   436
^^^^^--- this intermediate save/restore does not work and affects other tests ---^^*)
neuper@42456
   437
neuper@42453
   438
"----------- fun insert_errpatIDs --------------------------------";
neuper@42453
   439
"----------- fun insert_errpatIDs --------------------------------";
neuper@42453
   440
"----------- fun insert_errpatIDs --------------------------------";
neuper@42456
   441
(* vv--- this intermediate save/restore does not work and affects other tests ---vv
neuper@42456
   442
         see test/../calcelems.sml --- Unsynchronized.ref doesn't work any more ---
neuper@42456
   443
neuper@42455
   444
(* isolate test: 10 secs *) val original = (! thehier);
neuper@42455
   445
neuper@42453
   446
(* still ununsed; planned for stepToErrorpattern *)
neuper@42455
   447
val path = ["IsacKnowledge", "Diff", "Rulesets", "norm_diff"]: theID;
neuper@42455
   448
val errpattIDs = ["chain-rule-diff-both", "test-errpatID"];
neuper@42453
   449
neuper@42455
   450
insert_errpatIDs path errpattIDs;
neuper@42453
   451
neuper@42455
   452
val Hrls {guh, coursedesign, mathauthors, thy_rls = (thyID, rls)} = get_the path
neuper@42453
   453
val Rls {id, preconds, rew_ord, erls, srls, calc, rules, scr, errpatts} = rls;
neuper@42453
   454
neuper@42455
   455
if errpattIDs = ["chain-rule-diff-both", "test-errpatID"] then ()
neuper@42453
   456
else error "insert_errpatIDs to norm_diff changed";
neuper@42453
   457
neuper@42455
   458
(* isolate test: 10 secs *) thehier := original;
neuper@42456
   459
^^^^^--- this intermediate save/restore does not work and affects other tests ---^^*)
neuper@42455
   460
neuper@42456
   461
insert_fillpats ["IsacKnowledge", "Diff", "Theorems", "diff_sin_chain"]
neuper@42456
   462
 ([("fill-d_d-arg",
neuper@42456
   463
     parse_patt thy "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv _", "chain-rule-diff-both"),
neuper@42456
   464
   ("fill-both-args",
neuper@42456
   465
     parse_patt thy "d_d ?bdv (sin _) = cos ?u * d_d ?bdv _", "chain-rule-diff-both"),
neuper@42456
   466
   ("fill-d_d",
neuper@42456
   467
     parse_patt thy "d_d ?bdv (sin ?u) = cos ?u * _ ?bdv ?u", "chain-rule-diff-both"),
neuper@42456
   468
   ("fill-inner-deriv",
neuper@42456
   469
     parse_patt thy "d_d ?bdv (sin ?u) = cos ?u * _", "chain-rule-diff-both"),
neuper@42456
   470
   ("fill-all",
neuper@42456
   471
     parse_patt thy "d_d ?bdv (sin ?u) = _", "chain-rule-diff-both")]: fillpat list);
neuper@42456
   472