test/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 37967 bd4f7a35e892
child 38050 4c52ad406c20
permissions -rw-r--r--
tuned error and writeln

# raise error --> error
# writeln in atomtyp, atomty, atomt and xmlsrc
neuper@37906
     1
(* tests for sml/xmlsrc/thy-hierarchy.sml
neuper@37906
     2
   authors: Walther Neuper 060113
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
neuper@37906
     5
use"../smltest/xmlsrc/thy-hierarchy.sml";
neuper@37906
     6
use"thy-hierarchy.sml";
neuper@37906
     7
neuper@37906
     8
CAUTION with testing *2file functions -- they are actually writing to ~/tmp
neuper@37906
     9
*)
neuper@37906
    10
neuper@37906
    11
val thy = Isac.thy;
neuper@37906
    12
neuper@37906
    13
"-----------------------------------------------------------------";
neuper@37906
    14
"table of contents -----------------------------------------------";
neuper@37906
    15
"-----------------------------------------------------------------";
neuper@37906
    16
"----------- assoc_rls -------------------------------------------";
neuper@37906
    17
"----------- thm_hier --------------------------------------------";
neuper@37906
    18
"----------- fun thydata2xml -------------------------------------";
neuper@37906
    19
"----------- write xml to tmp ------------------------------------";
neuper@37906
    20
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
    21
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
    22
"-----------------------------------------------------------------";
neuper@37906
    23
"-----------------------------------------------------------------";
neuper@37906
    24
"-----------------------------------------------------------------";
neuper@37906
    25
neuper@37906
    26
neuper@37906
    27
"----------- assoc_rls -------------------------------------------";
neuper@37906
    28
"----------- assoc_rls -------------------------------------------";
neuper@37906
    29
"----------- assoc_rls -------------------------------------------";
neuper@37906
    30
val al = [(1,11),(2,22),(3,33)];
neuper@37906
    31
overwrite (al, (2,2222));
neuper@37906
    32
(*val it = [(1, 11), (2, 2222), (3, 33)] : (int * int) list*)
neuper@37906
    33
neuper@37906
    34
val al = [("e_rls",("Atools",e_rls)),("e_rrls",("Atools",e_rrls))];
neuper@37906
    35
val bl = [("e_rls",e_rls),("e_rrls",e_rrls)];
neuper@37906
    36
val b = ("e_rls",("Atools",e_rrls));
neuper@37906
    37
overwrite (al, b);
neuper@37906
    38
overwritelthy thy (al, bl);
neuper@37906
    39
neuper@37906
    40
assoc' (!ruleset',"e_rls");
neuper@37906
    41
assoc_rls "e_rls";
neuper@37906
    42
neuper@37906
    43
neuper@37906
    44
"----------- thm_hier --------------------------------------------";
neuper@37906
    45
"----------- thm_hier --------------------------------------------";
neuper@37906
    46
"----------- thm_hier --------------------------------------------";
neuper@37906
    47
(curry op:: "xxx") ["yyy","yyy","yyy"];
neuper@37906
    48
map (curry op:: "xxx") [["yyy1"],["yyy2"],["yyy3"]];
neuper@37906
    49
neuper@37906
    50
val thy' = "Integrate";
neuper@37906
    51
val thy = assoc_thy (thyID2theory' thy');
neuper@37906
    52
neuper@37906
    53
"collect_thms thy'------------------------------------------------";
neuper@37936
    54
(PureThy.all_thms_of thy);
neuper@37906
    55
neuper@37906
    56
(apfst single) ("Integrate.integral_var", integral_var);
neuper@37906
    57
neuper@37906
    58
(strip_thy o #1) ("Integrate.integral_var", integral_var);
neuper@37906
    59
neuper@37906
    60
(*cannot get this as arg from arg        ^^^^^^^^^^^^^^^^*)
neuper@37906
    61
    ("Integrate.integral_var", integral_var);
neuper@37906
    62
(*thus new fun....*)
neuper@37906
    63
neuper@37906
    64
makeHthm ("IsacKnowledge",thy') ("Integrate.integral_var", integral_var);
neuper@37906
    65
(makeHthm ("IsacKnowledge",thy')) ("Integrate.integral_var", integral_var);
neuper@37936
    66
map (makeHthm ("IsacKnowledge",thy')) (PureThy.all_thms_of thy);
neuper@37906
    67
collect_thms' ("IsacKnowledge",thy');
neuper@37906
    68
neuper@37906
    69
"collect_rlss thy'------------------------------------------------";
neuper@37906
    70
makeHrls "IsacKnowledge" ("integration_rules", (thy', integration_rules));
neuper@37906
    71
neuper@37906
    72
val thy' = "Test";
neuper@37906
    73
val rlss = filter ((curry op= thy') o 
neuper@37906
    74
			   ((#1 o #2):(rls' * (theory' * rls)) -> theory')) 
neuper@37906
    75
			  (!ruleset');
neuper@37906
    76
collect_rlss ("IsacKnowledge",thy');
neuper@37906
    77
neuper@37906
    78
"collect_thy thy-------------------------------------------------";
neuper@37906
    79
val thy' = "ListG.thy";
neuper@37906
    80
val thy = assoc_thy (thyID2theory' thy');
neuper@37906
    81
((collect_thms' ("IsacKnowledge",thy')) @ 
neuper@37906
    82
 (collect_rlss ("IsacKnowledge",thy')) @ 
neuper@37906
    83
 (collect_cals ("IsacKnowledge",thy')) @ 
neuper@37906
    84
 (collect_ords ("IsacKnowledge",thy')));
neuper@37906
    85
collect_thy "IsacKnowledge" thy';
neuper@37906
    86
neuper@37906
    87
"collect_thydata -------------------------------------------------";
neuper@37906
    88
(!isab_thm_thy);
neuper@37906
    89
map rearrange_inv (!isab_thm_thy);
neuper@37906
    90
(map ((apfst ((curry op:: "Isabelle") o single)) o rearrange_inv));
neuper@37906
    91
(map ((apfst ((curry op:: "Isabelle") o single)) o rearrange_inv)) 
neuper@37906
    92
    (!isab_thm_thy);
neuper@37906
    93
neuper@37906
    94
neuper@37906
    95
"thy_hierarchy ---------------------------------------------------";
neuper@37906
    96
val theID = ["IsacScripts", "ListG", "Theorems", "append_Cons"]:theID;
neuper@37906
    97
val thydat as (theID, thydata) = 
neuper@37906
    98
    (theID, Hthm {guh=theID2guh theID, mathauthors=[],
neuper@37906
    99
     coursedesign=[], thm=append_Cons});
neuper@37906
   100
neuper@37906
   101
val th = [] : thehier;
neuper@37906
   102
val theID' = cut_theID th theID;
neuper@37906
   103
val th = fill_parents th theID' theID;
neuper@37906
   104
(* val th =
neuper@37906
   105
   [Ptyp ("IsacScripts",
neuper@37906
   106
            [Html {guh = "thy_ListG-thm-append_Cons", html = "", ...}],
neuper@37906
   107
            [Ptyp ("ListG", ...)])] : thehier *)
neuper@37906
   108
(*show_thes*)(writeln o format_pblIDl o (scan [])) th;
neuper@37906
   109
writeln (hierarchy_guh th);
neuper@37906
   110
neuper@37906
   111
val th = [] : thehier;
neuper@37906
   112
val thydats = collect_thydata ();
neuper@37906
   113
val th1 = the_hier th thydats (**** insert: not found [".. from fill_parents*);
neuper@37906
   114
(*show_thes*)(writeln o format_pblIDl o (scan [])) th1;
neuper@37906
   115
neuper@37906
   116
writeln (hierarchy_guh th);
neuper@37906
   117
writeln (hierarchy_guh th1);
neuper@37906
   118
neuper@37906
   119
"thy_hierarchy2file ----------------------------------------------";
neuper@37906
   120
show_thes();
neuper@37906
   121
(*
neuper@37906
   122
val path = "/home/neuper/tmp/";
neuper@37906
   123
thy_hierarchy2file path;
neuper@37906
   124
*)
neuper@37906
   125
neuper@37906
   126
get_the ["IsacKnowledge"];
neuper@37906
   127
get_the ["IsacKnowledge", "Test"];
neuper@37906
   128
get_the ["IsacKnowledge", "Test", "Theorems"];
neuper@37906
   129
get_the ["IsacKnowledge", "Test", "Theorems", "exp_pow"];
neuper@37906
   130
neuper@37906
   131
get_the ["IsacKnowledge", "Test", "Rulesets"];
neuper@37906
   132
neuper@37906
   133
(* FIXXXXXXXXXME.WN060713 guh -- theID
neuper@37906
   134
case get_the ["IsacKnowledge", "Test", "Rulesets", "Test_simplify"] of
neuper@37906
   135
    Hrls {guh = "thy_Test-rls-Test_simplify",thy_rls = ("Test", _),
neuper@37906
   136
          mathauthors = _,coursedesign = _} => ()
neuper@38031
   137
  | _ => error "thy-hierarchy.sml: [IsacKnowledge,Test,Rulesets]";
neuper@37906
   138
*)
neuper@37906
   139
neuper@37906
   140
neuper@37906
   141
"----------- fun thydata2xml -------------------------------------";
neuper@37906
   142
"----------- fun thydata2xml -------------------------------------";
neuper@37906
   143
"----------- fun thydata2xml -------------------------------------";
neuper@37906
   144
val theID = ["IsacScripts", "ListG", "Theorems", "append_Cons"];
neuper@37906
   145
val thmdata = get_the theID;
neuper@37906
   146
writeln(thydata2xml (theID, thmdata));
neuper@37906
   147
neuper@37906
   148
val theID = ["IsacKnowledge", "Poly", "Rulesets", "norm_Poly"];
neuper@37906
   149
val rlsdata = get_the theID;
neuper@37906
   150
writeln(thydata2xml (theID, rlsdata));
neuper@37906
   151
neuper@37906
   152
(*FIXXXXXXXME.WN060714 in rls make Calc : calc -> rule [add scriptop!]
neuper@37906
   153
  see sml/../datatypes.sml !
neuper@37906
   154
val (thy', rls') = ("DiffApp.thy", "Tools.rhs");
neuper@37906
   155
thy_containing_rls thy' rls';
neuper@37906
   156
print_depth 99; map #1 startsearch; print_depth 3;
neuper@37906
   157
*)
neuper@37906
   158
neuper@37906
   159
(*
neuper@37906
   160
val path = "/home/neuper/tmp/";
neuper@37906
   161
thes2file path;
neuper@37906
   162
*)
neuper@37906
   163
neuper@37906
   164
"----------- write xml to tmp ------------------------------------";
neuper@37906
   165
"----------- write xml to tmp ------------------------------------";
neuper@37906
   166
"----------- write xml to tmp ------------------------------------";
neuper@37906
   167
(*
neuper@37906
   168
val path = "/home/neuper/tmp/"; 
neuper@37906
   169
neuper@37906
   170
pbl_hierarchy2file (path ^ "pbl/");
neuper@37906
   171
pbls2file          (path ^ "pbl/");
neuper@37906
   172
neuper@37906
   173
met_hierarchy2file (path ^ "met/");
neuper@37906
   174
mets2file          (path ^ "met/");
neuper@37906
   175
neuper@37906
   176
thy_hierarchy2file (path ^ "thy/");
neuper@37906
   177
thes2file          (path ^ "thy/");
neuper@37906
   178
*)
neuper@37906
   179
neuper@37906
   180
neuper@37906
   181
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
   182
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
   183
"----------- the_hier [] (collect_thyda.. NOT overwriting store_ -";
neuper@37906
   184
(*
neuper@37906
   185
store_isa ["Isabelle"] ["THIS SHOULD not BE OBERWRITTEN below"];
neuper@37906
   186
print_depth 99; get_the ["Isabelle"]; print_depth 3;
neuper@37906
   187
print_depth 5; thehier;  print_depth 3;
neuper@37906
   188
neuper@37906
   189
thehier := the_hier (!thehier) (collect_thydata ());
neuper@37906
   190
print_depth 99; get_the ["Isabelle"]; print_depth 3;
neuper@37906
   191
print_depth 5; thehier;  print_depth 3;
neuper@37906
   192
*)
neuper@37906
   193
neuper@37906
   194
case get_the ["IsacKnowledge", "Biegelinie", "Theorems"] of
neuper@37906
   195
   Html {mathauthors =
neuper@37906
   196
	 ["Walther Neuper 2005 supported by a grant from NMI Austria"],...}=>()
neuper@38031
   197
 | _ => error "thy-hierarchy.sml: store_isa overwritten";
neuper@37906
   198
neuper@37906
   199
case get_the ["IsacKnowledge","Biegelinie","Theorems","Belastung_Querkraft"] of
neuper@37906
   200
   Hthm {mathauthors =
neuper@37906
   201
	 ["Walther Neuper 2005 supported by a grant from NMI Austria"],...}=>()
neuper@38031
   202
 | _ => error "thy-hierarchy.sml: store_isa overwritten";
neuper@37906
   203
neuper@37906
   204
(*
neuper@37906
   205
print_depth 7; 
neuper@37906
   206
get_the ["IsacKnowledge","Biegelinie","Theorems","Belastung_Querkraft"];
neuper@37906
   207
print_depth 3;
neuper@37906
   208
*)
neuper@37906
   209
neuper@37906
   210
(*WN060728 strange behaviour:
neuper@37906
   211
### fun the_hier reports these not overwritten ?!?...(stored twice ?!?) ...
neuper@37906
   212
neuper@37906
   213
val it = () : unit
neuper@37906
   214
*** insert: preserved ["Isabelle","RealDef","Theorems","real_mult_assoc"]
neuper@37967
   215
*** insert: preserved ["Isabelle","RealDef","Theorems","add_assoc"]
neuper@37906
   216
*** insert: preserved ["Isabelle","RealBin","Theorems","real_mult_minus1"]
neuper@37906
   217
*** insert: preserved ["Isabelle","RealBin","Theorems","real_mult_2"]
neuper@37906
   218
*** insert: preserved ["Isabelle","RealDef","Theorems","real_mult_assoc"]
neuper@37906
   219
*** insert: preserved ["Isabelle","RealDef","Theorems","real_mult_minus_eq1"]
neuper@37967
   220
*** insert: preserved ["Isabelle","RealDef","Theorems","add_assoc"]
neuper@37906
   221
*** insert: preserved ["Isabelle","RealDef","Theorems","real_minus_divide_eq"]
neuper@37906
   222
*** insert: preserved ["IsacScripts","ListG","Theorems","induct"]
neuper@37906
   223
*** insert: preserved ["IsacScripts","ListG","Theorems","simps_1"]
neuper@37906
   224
*** insert: preserved ["IsacScripts","ListG","Theorems","simps_2"]
neuper@37906
   225
val it = () : unit
neuper@37906
   226
neuper@37906
   227
### but those store_*d in Biegelinie.ML are NOT reported !?!?!?!?!?!?!
neuper@37906
   228
### however, '*** insert: not found' is NOT reported below, too....
neuper@37906
   229
neuper@37906
   230
----------------------------------
neuper@37906
   231
*** insert: not found ... IS OK :
neuper@37906
   232
comes from fill_parents
neuper@37906
   233
----------------------------------
neuper@37906
   234
neuper@37906
   235
val it = () : unit
neuper@37967
   236
*** insert: not found ["Isabelle","NatDef","Theorems","real_le_refl"]
neuper@37967
   237
*** insert: not found ["Isabelle","NatDef","Theorems","real_le_refl"]*)
neuper@37906
   238
neuper@37906
   239
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
   240
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
   241
"----------- ### thes2file ... Exception- Match raised -----------";
neuper@37906
   242
writeln "what to do when you get,e.g. \n\
neuper@37906
   243
\### thes2file: id = [\"IsacKnowledge\",\"Integrate\",\"Rulesets\"]\n\
neuper@37906
   244
\### thes2file: id = [\"IsacKnowledge\",\"Integrate\",\"Rulesets\",\"integration_rules\"]\n\
neuper@37906
   245
\### thes2file: id = [\"IsacKnowledge\",\"Integrate\",\"Rulesets\",\"add_new_c\"]\n\
neuper@37906
   246
\Exception- Match raised";
neuper@37906
   247
neuper@37906
   248
val ptyp = hd (!thehier);
neuper@37906
   249
val theID = ["IsacKnowledge","Integrate","Rulesets","add_new_c"];
neuper@37906
   250
val thydata = get_the theID;
neuper@37906
   251
(* creates a file ...
neuper@37906
   252
thydata2file "~/tmp/"[] theID thydata (*reports Exception- Match in question*);
neuper@37906
   253
*)
neuper@37906
   254
thydata2xml (theID, thydata) (*reports Exception- Match in question*);
neuper@37906
   255
val (theID:theID, Hrls {guh, coursedesign, mathauthors, thy_rls}) = 
neuper@37906
   256
    (theID, thydata);
neuper@37906
   257
rls2xml i thy_rls (*reports Exception- Match in question*);
neuper@37906
   258
val (j, (thyID, Seq data)) = (i, thy_rls);
neuper@37906
   259
(* evaluate this local fun ...
neuper@37906
   260
rls2xm j (thyID, "Seq", data) (*reports Exception- Match in question*);
neuper@37906
   261
*)
neuper@37906
   262
val (j, (thyID, seqrls, {id, preconds, rew_ord=(ord,_), erls,
neuper@37906
   263
			 srls, calc, rules, scr})) = 
neuper@37906
   264
    (j, (thyID, "Seq", data));
neuper@37906
   265
rules2xml (j+2*i) thyID rules (*reports Exception- Match in question*);
neuper@37906
   266