test/Tools/isac/Interpret/ptyps.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Tue, 13 Feb 2018 15:14:55 +0100
changeset 59367 fb6f5ef2c647
parent 59365 f771be3b6628
child 59377 9d7115bbdb01
permissions -rw-r--r--
Isabelle2015->17: "normalize" as identifier causes type clash now, etc

etc fixes:
# new negation "~ " --> "<not>"n noteq cf. 17bc5920c2fb
# session identifiers enforced now cf. 172b53399454
neuper@55356
     1
(* Title: tests for Interpret/ptyps.sml
neuper@42390
     2
   Author: Walther Neuper 010916
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
*)
neuper@37906
     5
neuper@55364
     6
"-----------------------------------------------------------------";
neuper@55364
     7
"table of contents -----------------------------------------------";
neuper@55364
     8
"-----------------------------------------------------------------";
neuper@55364
     9
"-ptyps.thy: store test-pbtyps by 'setup' ------------------------";
neuper@55364
    10
"----------- testdata for refin, refine_ori ----------------------";
neuper@55366
    11
(*"----------- refin test-pbtyps -------requires 'setup'------------";*)
neuper@55366
    12
"----------- refine_ori test-pbtyps --requires 'setup'------------";
neuper@55366
    13
"----------- refine test-pbtyps ------requires 'setup'------------";
neuper@55364
    14
"----------- Refine_Problem (aus subp-rooteq.sml) ----------------";
neuper@55364
    15
"----------- fun coll_guhs ---------------------------------------";
neuper@55364
    16
"----------- fun guh2kestoreID -----------------------------------";
wneuper@59269
    17
"----------- fun mark --------------------------------------------";
wneuper@59269
    18
"----------- fun coll --------------------------------------------";
wneuper@59269
    19
"----------- fun coll_variants -----------------------------------";
wneuper@59269
    20
"----------- fun add_id ------------------------------------------";
wneuper@59269
    21
"----------- fun filter_vat --------------------------------------";
wneuper@59269
    22
"----------- fun match_pbl ---------------------------------------";
wneuper@59269
    23
"----------- fun match_oris --------------------------------------";
neuper@55364
    24
"-----------------------------------------------------------------";
neuper@55364
    25
"-----------------------------------------------------------------";
neuper@55364
    26
"-----------------------------------------------------------------";
neuper@55356
    27
neuper@55364
    28
"----------- testdata for refin, refine_ori ----------------------";
neuper@55364
    29
"----------- testdata for refin, refine_ori ----------------------";
neuper@55364
    30
"----------- testdata for refin, refine_ori ----------------------";
neuper@55356
    31
show_ptyps();
neuper@55356
    32
val thy = @{theory "Isac"};
neuper@55356
    33
val ctxt = Proof_Context.init_global @{theory "Isac"};
neuper@55356
    34
neuper@55356
    35
(*case 1: no refinement *)
wneuper@59188
    36
val (d1,ts1) = split_dts ((Thm.term_of o the o (parse thy)) "fixedValues [aaa = 0]");
wneuper@59188
    37
val (d2,ts2) = split_dts ((Thm.term_of o the o (parse thy)) "errorBound (ddd = 0)");
neuper@55356
    38
val ori1 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]: ori list;
neuper@55356
    39
neuper@55356
    40
(*case 2: refined to pbt without children *)
wneuper@59188
    41
val (d2,ts2) = split_dts ((Thm.term_of o the o (parse thy)) "relations [aaa333]");
neuper@55356
    42
val ori2 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]:ori list;
neuper@55356
    43
neuper@55356
    44
(*case 3: refined to pbt with children *)
wneuper@59188
    45
val (d2,ts2) = split_dts ((Thm.term_of o the o (parse thy)) "valuesFor [aaa222]");
neuper@55356
    46
val ori3 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]:ori list;
neuper@55356
    47
neuper@55356
    48
(*case 4: refined to children (without child)*)
wneuper@59188
    49
val (d3,ts3) = split_dts ((Thm.term_of o the o (parse thy)) "boundVariable aaa222yyy");
neuper@55356
    50
val ori4 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2), (3,[1],"#Given",d3,ts3)]:ori list;
neuper@55356
    51
neuper@55364
    52
(*=================================================================
neuper@55364
    53
This test expects pbls at a certain position in the tree.
neuper@55364
    54
Since parallel evaluation (i.e. Theory_Data) this cannot be expected.
neuper@55364
    55
Solutions would be
neuper@55364
    56
* provide an access function for a branch (not only leaves)
neuper@55364
    57
* sort the tree of pbls.
neuper@55356
    58
"----------- refin test-pbtyps -----------------------------------";
neuper@55356
    59
"----------- refin test-pbtyps -----------------------------------";
neuper@55356
    60
"----------- refin test-pbtyps -----------------------------------";
neuper@55356
    61
(* fragile test setup: expects ptyps as fixed *)
neuper@55356
    62
val level_1 = case nth 9 (get_ptyps ()) of
neuper@55356
    63
Ptyp ("test", _, level_1) => level_1 | _ => error "refin broken: root-branch in ptyps changed?"
neuper@55356
    64
val level_2 = case nth 4 level_1 of
neuper@55356
    65
Ptyp ("refine", _, level_2) => level_2 | _ => error "refin broken: lev1-branch in ptyps changed?"
neuper@55356
    66
val pbla_branch = case level_2 of 
neuper@55356
    67
[Ptyp ("pbla", _, _)] => level_2 | _ => error "refin broken: lev2-branch in ptyps changed?";
neuper@55356
    68
neuper@55356
    69
(*case 1: no refinement *)
neuper@55356
    70
case refin [] ori1 (hd pbla_branch) of 
neuper@55356
    71
  SOME ["pbla"] => () | _ => error "refin case 1 broken";
neuper@55356
    72
neuper@55356
    73
(*case 2: refined to pbt without children *)
neuper@55356
    74
case refin [] ori2 (hd pbla_branch) of 
neuper@55356
    75
  SOME ["pbla", "pbla3"] => () | _ => error "refin case 2 broken";
neuper@55356
    76
neuper@55356
    77
(*case 3: refined to pbt with children *)
neuper@55356
    78
case refin [] ori3 (hd pbla_branch) of 
neuper@55356
    79
  SOME ["pbla", "pbla2"] => () | _ => error "refin case 3 broken";
neuper@55356
    80
neuper@55356
    81
(*case 4: refined to children (without child)*)
neuper@55356
    82
case refin [] ori4 (hd pbla_branch) of 
neuper@55356
    83
  SOME ["pbla", "pbla2", "pbla2y"] => () | _ => error "refin case 4 broken";
neuper@55356
    84
neuper@55356
    85
(*case 5: start refinement somewhere in ptyps*)
neuper@55356
    86
val [Ptyp ("pbla",_,[_, ppp as Ptyp ("pbla2",_,_), _])] = pbla_branch;
neuper@55356
    87
case refin ["pbla"] ori4 ppp of 
neuper@55356
    88
  SOME ["pbla", "pbla2", "pbla2y"] => () | _ => error "refin case 5 broken";
neuper@55364
    89
==================================================================*)
neuper@55356
    90
neuper@55356
    91
"----------- refine_ori test-pbtyps ------------------------------";
neuper@55356
    92
"----------- refine_ori test-pbtyps ------------------------------";
neuper@55356
    93
"----------- refine_ori test-pbtyps ------------------------------";
neuper@55356
    94
(*case 1: no refinement *)
neuper@55356
    95
case refine_ori ori1 ["pbla", "refine", "test"] of 
neuper@55356
    96
  NONE => () | _ => error "refine_ori case 1 broken";
neuper@55356
    97
neuper@55356
    98
(*case 2: refined to pbt without children *)
neuper@55356
    99
case refine_ori ori2 ["pbla", "refine", "test"] of 
neuper@55356
   100
  SOME ["pbla3", "pbla", "refine", "test"] => () | _ => error "refine_ori case 2 broken";
neuper@55356
   101
neuper@55356
   102
(*case 3: refined to pbt with children *)
neuper@55356
   103
case refine_ori ori3 ["pbla", "refine", "test"] of 
neuper@55356
   104
  SOME ["pbla2", "pbla", "refine", "test"] => () | _ => error "refine_ori case 3 broken";
neuper@55356
   105
neuper@55356
   106
(*case 4: refined to children (without child)*)
neuper@55356
   107
case refine_ori ori4 ["pbla", "refine", "test"] of 
neuper@55356
   108
  SOME ["pbla2y","pbla2","pbla", "refine", "test"] => () | _ => error "refine_ori case 4 broken";
neuper@55356
   109
neuper@55356
   110
(*case 5: start refinement somewhere in ptyps*)
neuper@55356
   111
case refine_ori ori4 ["pbla2","pbla", "refine", "test"] of 
neuper@55356
   112
  SOME ["pbla2y", "pbla2", "pbla", "refine", "test"] => () | _ => error "refine_ori case 5 broken";
neuper@55356
   113
neuper@55356
   114
"----------- refine test-pbtyps ----------------------------------";
neuper@55356
   115
"----------- refine test-pbtyps ----------------------------------";
neuper@55356
   116
"----------- refine test-pbtyps ----------------------------------";
neuper@55356
   117
val fmz1 = ["fixedValues [aaa=0]","errorBound (ddd=0)"];
neuper@55356
   118
val fmz2 = ["fixedValues [aaa=0]","relations aaa333"];
neuper@55356
   119
val fmz3 = ["fixedValues [aaa=0]","valuesFor [aaa222]"];
neuper@55356
   120
val fmz4 = ["fixedValues [aaa=0]","valuesFor [aaa222]",
neuper@55356
   121
	    "boundVariable aaa222yyy"];
neuper@55356
   122
neuper@55356
   123
(*case 1: no refinement *)
neuper@55356
   124
case refine fmz1 ["pbla", "refine", "test"] of
neuper@55356
   125
  [Matches (["pbla", "refine", "test"], _), 
neuper@55356
   126
   NoMatch (["pbla1", "pbla", "refine", "test"], _), 
neuper@55356
   127
   NoMatch (["pbla2", "pbla", "refine", "test"], _), 
neuper@55356
   128
   NoMatch (["pbla3", "pbla", "refine", "test"], _)] => ()
neuper@55356
   129
 | _ => error "--- refine test-pbtyps --- broken with case 1";
neuper@55356
   130
(* 
neuper@55356
   131
*** pass ["pbla"]
neuper@55356
   132
*** pass ["pbla","pbla1"]
neuper@55356
   133
*** pass ["pbla","pbla2"]
neuper@55356
   134
*** pass ["pbla","pbla3"]
neuper@55356
   135
val it =
neuper@55356
   136
  [Matches
neuper@55356
   137
     (["pbla"],
neuper@55356
   138
      {Find=[],
neuper@55356
   139
       Given=[Correct "fixedValues [aaa = #0]",
neuper@55356
   140
              Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
neuper@55356
   141
   NoMatch
neuper@55356
   142
     (["pbla1","pbla"],
neuper@55356
   143
      {Find=[],
neuper@55356
   144
       Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
neuper@55356
   145
              Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
neuper@55356
   146
   NoMatch
neuper@55356
   147
     (["pbla2","pbla"],
neuper@55356
   148
      {Find=[],
neuper@55356
   149
       Given=[Correct "fixedValues [aaa = #0]",Missing "valuesFor a2_",
neuper@55356
   150
              Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
neuper@55356
   151
   NoMatch
neuper@55356
   152
     (["pbla3","pbla"],
neuper@55356
   153
      {Find=[],
neuper@55356
   154
       Given=[Correct "fixedValues [aaa = #0]",Missing "relations a3_",
neuper@55356
   155
              Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]})]
neuper@55356
   156
  : match list*)
neuper@55356
   157
neuper@55356
   158
(*case 2: refined to pbt without children *)
neuper@55356
   159
case refine fmz2 ["pbla", "refine", "test"] of
neuper@55356
   160
  [Matches (["pbla", "refine", "test"], _),
neuper@55356
   161
   NoMatch (["pbla1", "pbla", "refine", "test"], _),
neuper@55356
   162
   NoMatch (["pbla2", "pbla", "refine", "test"], _),
neuper@55356
   163
   Matches (["pbla3", "pbla", "refine", "test"], _)] => ()
neuper@55356
   164
 | _ => error "--- refine test-pbtyps --- broken with case 2";
neuper@55356
   165
(* 
neuper@55356
   166
*** pass ["pbla"]
neuper@55356
   167
*** pass ["pbla","pbla1"]
neuper@55356
   168
*** pass ["pbla","pbla2"]
neuper@55356
   169
*** pass ["pbla","pbla3"]
neuper@55356
   170
val it =
neuper@55356
   171
  [Matches
neuper@55356
   172
     (["pbla"],
neuper@55356
   173
      {Find=[],
neuper@55356
   174
       Given=[Correct "fixedValues [aaa = #0]",Superfl "relations aaa333"],
neuper@55356
   175
       Relate=[],Where=[],With=[]}),
neuper@55356
   176
   NoMatch
neuper@55356
   177
     (["pbla1","pbla"],
neuper@55356
   178
      {Find=[],
neuper@55356
   179
       Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
neuper@55356
   180
              Superfl "relations aaa333"],Relate=[],Where=[],With=[]}),
neuper@55356
   181
   NoMatch
neuper@55356
   182
     (["pbla2","pbla"],
neuper@55356
   183
      {Find=[],
neuper@55356
   184
       Given=[Correct "fixedValues [aaa = #0]",Missing "valuesFor a2_",
neuper@55356
   185
              Superfl "relations aaa333"],Relate=[],Where=[],With=[]}),
neuper@55356
   186
   Matches
neuper@55356
   187
     (["pbla3","pbla"],
neuper@55356
   188
      {Find=[],
neuper@55356
   189
       Given=[Correct "fixedValues [aaa = #0]",Correct "relations aaa333"],
neuper@55356
   190
       Relate=[],Where=[],With=[]})] : match list*)
neuper@55356
   191
neuper@55356
   192
(*case 3: refined to pbt with children *)
neuper@55356
   193
case refine fmz3 ["pbla", "refine", "test"] of
neuper@55356
   194
  [Matches (["pbla", "refine", "test"], _),
neuper@55356
   195
   NoMatch (["pbla1", "pbla", "refine", "test"], _),
neuper@55356
   196
   Matches (["pbla2", "pbla", "refine", "test"], _),
neuper@55356
   197
   NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
neuper@55356
   198
   NoMatch (["pbla2y", "pbla2", "pbla", "refine", "test"], _),
neuper@55356
   199
   NoMatch (["pbla2z", "pbla2", "pbla", "refine", "test"], _),
neuper@55356
   200
   NoMatch (["pbla3", "pbla", "refine", "test"], _)] => ()
neuper@55356
   201
 | _ => error "--- refine test-pbtyps --- broken with case 3";
neuper@55356
   202
(* 
neuper@55356
   203
*** pass ["pbla"]
neuper@55356
   204
*** pass ["pbla","pbla1"]
neuper@55356
   205
*** pass ["pbla","pbla2"]
neuper@55356
   206
*** pass ["pbla","pbla2","pbla2x"]
neuper@55356
   207
*** pass ["pbla","pbla2","pbla2y"]
neuper@55356
   208
*** pass ["pbla","pbla2","pbla2z"]
neuper@55356
   209
*** pass ["pbla","pbla3"]
neuper@55356
   210
val it =
neuper@55356
   211
  [Matches
neuper@55356
   212
     (["pbla"],
neuper@55356
   213
      {Find=[],
neuper@55356
   214
       Given=[Correct "fixedValues [aaa = #0]",Superfl "valuesFor aaa222"],
neuper@55356
   215
       Relate=[],Where=[],With=[]}),
neuper@55356
   216
   NoMatch
neuper@55356
   217
     (["pbla1","pbla"],
neuper@55356
   218
      {Find=[],
neuper@55356
   219
       Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
neuper@55356
   220
              Superfl "valuesFor aaa222"],Relate=[],Where=[],With=[]}),
neuper@55356
   221
   Matches
neuper@55356
   222
     (["pbla2","pbla"],
neuper@55356
   223
      {Find=[],
neuper@55356
   224
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222"],
neuper@55356
   225
       Relate=[],Where=[],With=[]}),
neuper@55356
   226
   NoMatch
neuper@55356
   227
     (["pbla2x","pbla2","pbla"],
neuper@55356
   228
      {Find=[],
neuper@55356
   229
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   230
              Missing "functionOf a2x_"],Relate=[],Where=[],With=[]}),
neuper@55356
   231
   NoMatch
neuper@55356
   232
     (["pbla2y","pbla2","pbla"],
neuper@55356
   233
      {Find=[],
neuper@55356
   234
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   235
              Missing "boundVariable a2y_"],Relate=[],Where=[],With=[]}),
neuper@55356
   236
   NoMatch
neuper@55356
   237
     (["pbla2z","pbla2","pbla"],
neuper@55356
   238
      {Find=[],
neuper@55356
   239
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   240
              Missing "interval a2z_"],Relate=[],Where=[],With=[]}),
neuper@55356
   241
   NoMatch
neuper@55356
   242
     (["pbla3","pbla"],
neuper@55356
   243
      {Find=[],
neuper@55356
   244
       Given=[Correct "fixedValues [aaa = #0]",Missing "relations a3_",
neuper@55356
   245
              Superfl "valuesFor aaa222"],Relate=[],Where=[],With=[]})]
neuper@55356
   246
  : match list*)
neuper@55356
   247
neuper@55356
   248
(*case 4: refined to children (without child)*)
neuper@55356
   249
case refine fmz4 ["pbla", "refine", "test"] of
neuper@55356
   250
    [Matches (["pbla", "refine", "test"], _), 
neuper@55356
   251
     NoMatch (["pbla1", "pbla", "refine", "test"], _), 
neuper@55356
   252
     Matches (["pbla2", "pbla", "refine", "test"], _), 
neuper@55356
   253
     NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _), 
neuper@55356
   254
     Matches (["pbla2y", "pbla2", "pbla", "refine", "test"], _)] => ()
neuper@55356
   255
  | _ => error "--- refine test-pbtyps --- broken with case 4";
neuper@55356
   256
(* 
neuper@55356
   257
*** pass ["pbla"]
neuper@55356
   258
*** pass ["pbla","pbla1"]
neuper@55356
   259
*** pass ["pbla","pbla2"]
neuper@55356
   260
*** pass ["pbla","pbla2","pbla2x"]
neuper@55356
   261
*** pass ["pbla","pbla2","pbla2y"]
neuper@55356
   262
val it =
neuper@55356
   263
  [Matches
neuper@55356
   264
     (["pbla"],
neuper@55356
   265
      {Find=[],
neuper@55356
   266
       Given=[Correct "fixedValues [aaa = #0]",Superfl "valuesFor aaa222",
neuper@55356
   267
              Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
neuper@55356
   268
   NoMatch
neuper@55356
   269
     (["pbla1","pbla"],
neuper@55356
   270
      {Find=[],
neuper@55356
   271
       Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
neuper@55356
   272
              Superfl "valuesFor aaa222",Superfl "boundVariable aaa222yyy"],
neuper@55356
   273
       Relate=[],Where=[],With=[]}),
neuper@55356
   274
   Matches
neuper@55356
   275
     (["pbla2","pbla"],
neuper@55356
   276
      {Find=[],
neuper@55356
   277
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   278
              Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
neuper@55356
   279
   NoMatch
neuper@55356
   280
     (["pbla2x","pbla2","pbla"],
neuper@55356
   281
      {Find=[],
neuper@55356
   282
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   283
              Missing "functionOf a2x_",Superfl "boundVariable aaa222yyy"],
neuper@55356
   284
       Relate=[],Where=[],With=[]}),
neuper@55356
   285
   Matches
neuper@55356
   286
     (["pbla2y","pbla2","pbla"],
neuper@55356
   287
      {Find=[],
neuper@55356
   288
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   289
              Correct "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]})]
neuper@55356
   290
  : match list*)
neuper@55356
   291
neuper@55356
   292
(*case 5: start refinement somewhere in ptyps*)
neuper@55356
   293
case refine fmz4 ["pbla2","pbla", "refine", "test"] of
neuper@55356
   294
    [Matches (["pbla2", "pbla", "refine", "test"], _), 
neuper@55356
   295
     NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _), 
neuper@55356
   296
     Matches (["pbla2y", "pbla2", "pbla", "refine", "test"], _)] => ()
neuper@55356
   297
  | _ => error "--- refine test-pbtyps --- broken with case 5";
neuper@55356
   298
(* 
neuper@55356
   299
*** pass ["pbla","pbla2"]
neuper@55356
   300
*** pass ["pbla","pbla2","pbla2x"]
neuper@55356
   301
*** pass ["pbla","pbla2","pbla2y"]
neuper@55356
   302
val it =
neuper@55356
   303
  [Matches
neuper@55356
   304
     (["pbla2","pbla"],
neuper@55356
   305
      {Find=[],
neuper@55356
   306
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   307
              Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
neuper@55356
   308
   NoMatch
neuper@55356
   309
     (["pbla2x","pbla2","pbla"],
neuper@55356
   310
      {Find=[],
neuper@55356
   311
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   312
              Missing "functionOf a2x_",Superfl "boundVariable aaa222yyy"],
neuper@55356
   313
       Relate=[],Where=[],With=[]}),
neuper@55356
   314
   Matches
neuper@55356
   315
     (["pbla2y","pbla2","pbla"],
neuper@55356
   316
      {Find=[],
neuper@55356
   317
       Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
neuper@55356
   318
              Correct "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]})]
neuper@55356
   319
  : match list*)
neuper@55364
   320
neuper@37906
   321
"----------- Refine_Problem (aus subp-rooteq.sml) ----------------";
neuper@37906
   322
"----------- Refine_Problem (aus subp-rooteq.sml) ----------------";
neuper@37906
   323
"----------- Refine_Problem (aus subp-rooteq.sml) ----------------";
neuper@42390
   324
(*WN120313: attention: the 'nxt' in the comments are not correct!*)
neuper@42390
   325
val c = [];
neuper@42390
   326
val fmz = ["equality ((x+1)*(x+2)=x^^^2+(8::real))","solveFor x",
neuper@37906
   327
	   "errorBound (eps=0)","solutions L"];
neuper@38058
   328
val (dI',pI',mI') = ("Test",["sqroot-test","univariate","equation","test"],
neuper@37906
   329
		     ["Test","squ-equ-test-subpbl1"]);
neuper@37906
   330
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@42390
   331
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42390
   332
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42390
   333
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Add_Find", Add_Find "solutions L")*)
akargl@42188
   334
neuper@55279
   335
val nxt = ("Specify_Problem", 	  Specify_Problem ["LINEAR","univariate","equation","test"]);
neuper@42390
   336
(*=== specify a not-matching problem ------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
neuper@37906
   337
val (p,_,f,nxt,_,pt) = me nxt p c pt;
wneuper@59253
   338
val www = 
wneuper@59267
   339
case f of PpcKF (Problem [],
wneuper@59253
   340
  {Find = [Incompl "solutions"], With = [],
wneuper@59253
   341
   Given = [Correct "equality ((x + 1) * (x + 2) = x ^^^ 2 + 8)", Correct "solveFor x"],
wneuper@59253
   342
   Where = [False www],
wneuper@59267
   343
   Relate = [],...}) => www
wneuper@59253
   344
| _ => error "--- Refine_Problem broken 1";
wneuper@59365
   345
if www = "matches (x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\nmatches (?b * x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\nmatches (?a + x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\nmatches (?a + ?b * x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8)"
wneuper@59253
   346
then () else error "--- Refine_Problem broken 2";
neuper@37906
   347
(*ML> f; 
neuper@37906
   348
val it = Form' (PpcKF (0,EdUndef,0,Nundef,
neuper@55279
   349
        (Problem ["LINEAR","univariate","equation","test"],   <<<<<===== diff.to above WN120313
neuper@37906
   350
         {Find=[Incompl "solutions []"],
neuper@37906
   351
          Given=[Correct "equality ((x + #1) * (x + #2) = x ^^^ #2 + #8)",
neuper@37906
   352
                 Correct "solveFor x"],Relate=[],
neuper@37906
   353
          Where=[False "matches (x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)
neuper@37906
   354
                |\nmatches (?b * x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)
neuper@37906
   355
                |\nmatches (?a + x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)
neuper@37906
   356
        |\nmatches (?a + ?b * x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)"],
neuper@37906
   357
          With=[]}))) : mout
neuper@37906
   358
val nxt = ("Add_Find",Add_Find "solutions L") ????!!!!????*)
neuper@37906
   359
neuper@42390
   360
val (p,_,f,nxt,_,pt) = (me nxt p c pt) (*handle e => OldGoals.print_exn e*);
neuper@42390
   361
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   362
(*val nxt = ("Empty_Tac",Empty_Tac) 
neuper@55279
   363
... Refine_Problem ["LINEAR"..] fails internally 040312: works!?!*)
neuper@37906
   364
neuper@37906
   365
val nxt = ("Refine_Problem",Refine_Problem ["univariate","equation","test"]);
neuper@42390
   366
(*=== refine problem -----------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
neuper@37906
   367
val (p,_,f,nxt,_,pt) = me nxt p c pt;
wneuper@59367
   368
(*("Specify_Problem", Specify_Problem ["normalise", "univariate", ...])*)
neuper@37906
   369
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38058
   370
(*nxt = ("Specify_Theory", Specify_Theory "Test")*)
neuper@37906
   371
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   372
(*nxt = ("Specify_Method", Specify_Method ["Test", "squ-equ-test-subpbl1"]*)
neuper@37906
   373
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   374
(*nxt = ("Apply_Method", *)
neuper@37906
   375
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   376
(*nxt = ("Rewrite_Set", Rewrite_Set "norm_equation")*)
neuper@37906
   377
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   378
(*nxt = ("Rewrite_Set", Rewrite_Set "Test_simplify")*)
neuper@37906
   379
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@55279
   380
(*Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]*)
neuper@37906
   381
neuper@37906
   382
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@55279
   383
(*nxt = Model_Problem ["LINEAR","univariate","equation","test"]*)
neuper@37906
   384
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   385
(*nxt = ("Add_Given", Add_Given "equality (-6 + 3 * x = 0)"*)
neuper@37906
   386
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   387
(**)
neuper@42390
   388
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   389
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   390
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@55279
   391
(*nxt = Specify_Problem ["LINEAR","univariate","equation","test"])*)
neuper@37906
   392
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   393
(*xt = ("Specify_Method", Specify_Method ["Test", "solve_linear"])*)
neuper@37906
   394
val nxt = ("Refine_Problem",Refine_Problem ["univariate","equation","test"]);
neuper@37906
   395
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@55279
   396
(*("Specify_Problem", Specify_Problem ["LINEAR", "univariate", ...])*)
neuper@37906
   397
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   398
(*val nxt = ("Specify_Method",Specify_Method ("Test","solve_linear"))*)
neuper@37906
   399
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   400
(*val nxt = ("Apply_Method",Apply_Method ("Test","solve_linear"))*)
neuper@37906
   401
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   402
(*val nxt = ("Rewrite_Set_Inst",Rewrite_Set_Inst ([#],"isolate_bdv"))*)
neuper@37906
   403
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   404
(*val nxt = ("Rewrite_Set",Rewrite_Set "Test_simplify")*)
neuper@37906
   405
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@55279
   406
(*val nxt = ("Check_Postcond",Check_Postcond ["LINEAR","univariate","eq*)
neuper@37906
   407
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   408
(*val nxt = ("Check_elementwise",Check_elementwise "Assumptions")*)
neuper@37906
   409
val (p,_,f,nxt,_,pt) = me nxt p c pt;
wneuper@59367
   410
(*Check_Postcond ["normalise","univariate","equation","test"])*)
neuper@37906
   411
val (p,_,f,nxt,_,pt) = me nxt p c pt;
wneuper@59267
   412
val FormKF res = f;
neuper@42390
   413
wneuper@59253
   414
if res = "[x = 2]"
wneuper@59253
   415
then case nxt of ("End_Proof'", End_Proof') => ()
wneuper@59253
   416
  | _ => error "new behaviour in test:refine.sml:miniscript with mini-subpb 1"
wneuper@59253
   417
else error "new behaviour in test:refine.sml:miniscript with mini-subpb 2" 
neuper@37906
   418
neuper@37906
   419
"----------- fun coll_guhs ---------------------------------------";
neuper@37906
   420
"----------- fun coll_guhs ---------------------------------------";
neuper@37906
   421
"----------- fun coll_guhs ---------------------------------------";
neuper@37906
   422
val n = e_pbt;
neuper@37906
   423
(#guh : pbt -> guh) e_pbt;
neuper@37906
   424
neuper@37906
   425
fun XXXnode coll (Ptyp (_,[n],ns)) =
neuper@37906
   426
    [(#guh : pbt -> guh) n]
neuper@37906
   427
and XXXnodes coll [] = coll
neuper@37906
   428
  | XXXnodes coll (n::ns : pbt ptyp list) = (XXXnode coll n) @ 
neuper@37906
   429
					    (XXXnodes coll ns);
neuper@37906
   430
(*^^^ this works, but not this ...
neuper@37906
   431
fun node coll (Ptyp (_,[n],ns)) =
neuper@37906
   432
    [(#guh : 'a -> guh) n]
neuper@37906
   433
and nodes coll [] = coll
neuper@37906
   434
  | nodes coll (n::ns : 'a ptyp list) = (node coll n) @ (nodes coll ns);
neuper@37906
   435
neuper@37906
   436
Error:
neuper@37906
   437
Can't unify {guh: 'a, ...} with 'b (Cannot unify with explicit type variable)
neuper@37906
   438
   Found near #guh : 'a -> guh
neuper@37906
   439
neuper@37906
   440
i.e. there is no common fun for pbls and mets ?!?*)
neuper@37906
   441
s1210629013@55355
   442
coll_pblguhs (get_ptyps ());
s1210629013@55354
   443
sort string_ord (coll_pblguhs (get_ptyps ()));
neuper@37906
   444
show_pblguhs ();
neuper@37906
   445
sort_pblguhs ();
neuper@37906
   446
neuper@37906
   447
"----------- fun guh2kestoreID -----------------------------------";
neuper@37906
   448
"----------- fun guh2kestoreID -----------------------------------";
neuper@37906
   449
"----------- fun guh2kestoreID -----------------------------------";
neuper@37906
   450
"----- we assumed the problem-hierarchy containing 3 elements on toplevel";
akargl@42188
   451
(* ERROR: Exception Bind raised *)
neuper@37906
   452
val (Ptyp (id1,[n1 as {guh=guh1,...} : pbt], ns1)::
s1210629013@55354
   453
     Ptyp (id2,[n2 as {guh=guh2,...} : pbt], ns2):: _) = (get_ptyps ());
akargl@42188
   454
neuper@37906
   455
(*
neuper@55356
   456
nodes [] guh1 (get_ptyps ());
neuper@55356
   457
nodes [] guh2 (get_ptyps ());
neuper@37906
   458
*)
neuper@37906
   459
val (Ptyp (id1,[n1 as {guh=guh1,...} : pbt], ns1)
neuper@37906
   460
     ::
neuper@37906
   461
     Ptyp (id2,[n2 as {guh=guh2,...} : pbt], 
neuper@37906
   462
	   (Ptyp (id21,[n21 as {guh=guh21,...} : pbt], ns21)) :: _ )
neuper@37906
   463
     ::
neuper@37906
   464
     Ptyp (id3,[n3 as {guh=guh3,...} : pbt], ns3)
neuper@37906
   465
     ::
s1210629013@55354
   466
     _ ) = (get_ptyps ());
neuper@37906
   467
(*
neuper@55356
   468
nodes [] guh3 (get_ptyps ());
neuper@55356
   469
nodes [] guh21 (get_ptyps ());
neuper@38036
   470
*)
neuper@42390
   471
wneuper@59269
   472
"----------- fun mark --------------------------------------------";
wneuper@59269
   473
"----------- fun mark --------------------------------------------";
wneuper@59269
   474
"----------- fun mark --------------------------------------------";
wneuper@59269
   475
(*
wneuper@59269
   476
> val xs = [1,1,1,2,4,4,5];
wneuper@59269
   477
> mark (op=) xs;
wneuper@59269
   478
val it = [(1,1),(2,1),(3,1),(0,2),(1,4),(2,4),(0,5)]
wneuper@59269
   479
*)
wneuper@59269
   480
wneuper@59269
   481
"----------- fun coll --------------------------------------------";
wneuper@59269
   482
"----------- fun coll --------------------------------------------";
wneuper@59269
   483
"----------- fun coll --------------------------------------------";
wneuper@59269
   484
(* 
wneuper@59269
   485
> val xs = [1,1,1,2,4,4,4];
wneuper@59269
   486
> coll (op=) xs;
wneuper@59269
   487
val it = [1,2,4] : int list
wneuper@59269
   488
*)
wneuper@59269
   489
"----------- fun coll_variants -----------------------------------";
wneuper@59269
   490
"----------- fun coll_variants -----------------------------------";
wneuper@59269
   491
"----------- fun coll_variants -----------------------------------";
wneuper@59269
   492
(* val xs = [(1,1),(2,1),(3,1),(0,2),(1,4),(2,4),(0,5)];
wneuper@59269
   493
> col [] ([(fst o hd) xs],(snd o hd) xs) (tl xs);
wneuper@59269
   494
val it = [([1,2,3],1),([0],2),([1,2],4),([0],5)]  *)
wneuper@59269
   495
"----------- fun add_id ------------------------------------------";
wneuper@59269
   496
"----------- fun add_id ------------------------------------------";
wneuper@59269
   497
"----------- fun add_id ------------------------------------------";
wneuper@59269
   498
(*
wneuper@59269
   499
> val xs = [([1,2,3],1),([0],2),([1,2],4),([0],5)];
wneuper@59269
   500
> add_id xs;
wneuper@59269
   501
val it = [(1,([#,#,#],1)),(2,([#],2)),(3,([#,#],4)),(4,([#],5))]
wneuper@59269
   502
 *)
wneuper@59269
   503
"----------- fun filter_vat --------------------------------------";
wneuper@59269
   504
"----------- fun filter_vat --------------------------------------";
wneuper@59269
   505
"----------- fun filter_vat --------------------------------------";
wneuper@59269
   506
(*> map (filter_vat oris) [1,2,3];
wneuper@59269
   507
val it =
wneuper@59269
   508
  [[(1,[1,2,3],"#Given",Const (#,#),[# $ #]),
wneuper@59269
   509
    (2,[1,2,3],"#Find",Const (#,#),[Free #]),
wneuper@59269
   510
    (3,[1,2,3],"#Find",Const (#,#),[# $ #,# $ #]),
wneuper@59269
   511
    (4,[1,2],"#Relate",Const (#,#),[# $ #,# $ #]),
wneuper@59269
   512
    (6,[1],"#undef",Const (#,#),[Free #]),
wneuper@59269
   513
    (9,[1,2],"#undef",Const (#,#),[# $ #]),
wneuper@59269
   514
    (11,[1,2,3],"#undef",Const (#,#),[# $ #])],
wneuper@59269
   515
   [(1,[1,2,3],"#Given",Const (#,#),[# $ #]),
wneuper@59269
   516
    (2,[1,2,3],"#Find",Const (#,#),[Free #]),
wneuper@59269
   517
    (3,[1,2,3],"#Find",Const (#,#),[# $ #,# $ #]),
wneuper@59269
   518
    (4,[1,2],"#Relate",Const (#,#),[# $ #,# $ #]),
wneuper@59269
   519
    (7,[2],"#undef",Const (#,#),[Free #]),
wneuper@59269
   520
    (9,[1,2],"#undef",Const (#,#),[# $ #]),
wneuper@59269
   521
    (11,[1,2,3],"#undef",Const (#,#),[# $ #])],
wneuper@59269
   522
   [(1,[1,2,3],"#Given",Const (#,#),[# $ #]),
wneuper@59269
   523
    (2,[1,2,3],"#Find",Const (#,#),[Free #]),
wneuper@59269
   524
    (3,[1,2,3],"#Find",Const (#,#),[# $ #,# $ #]),
wneuper@59269
   525
    (5,[3],"#Relate",Const (#,#),[# $ #,# $ #,# $ #]),
wneuper@59269
   526
    (8,[3],"#undef",Const (#,#),[Free #]),
wneuper@59269
   527
    (10,[3],"#undef",Const (#,#),[# $ #]),
wneuper@59269
   528
    (11,[1,2,3],"#undef",Const (#,#),[# $ #])]] : ori list list*)
wneuper@59269
   529
"----------- fun match_pbl ---------------------------------------";
wneuper@59269
   530
"----------- fun match_pbl ---------------------------------------";
wneuper@59269
   531
"----------- fun match_pbl ---------------------------------------";
wneuper@59269
   532
(* 
wneuper@59269
   533
val fmz = ["equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))",
wneuper@59269
   534
	      "solveFor x","errorBound (eps=0)","solutions L"];
wneuper@59269
   535
val pbt as {thy = thy, where_ = pre, ppc = ppc,...} =
wneuper@59269
   536
    get_pbt ["univariate","equation"];
wneuper@59269
   537
match_pbl fmz pbt;
wneuper@59269
   538
*)
wneuper@59269
   539
"----------- fun match_oris --------------------------------------";
wneuper@59269
   540
"----------- fun match_oris --------------------------------------";
wneuper@59269
   541
"----------- fun match_oris --------------------------------------";
wneuper@59269
   542
(* val (pblRD,ori)=("xxx",oris);
wneuper@59269
   543
 val py = get_pbt ["equation"];
wneuper@59269
   544
 val py = get_pbt ["univariate","equation"];
wneuper@59269
   545
 val py = get_pbt ["linear","univariate","equation"];
wneuper@59269
   546
 val py = get_pbt ["root\"","univariate","equation"];
wneuper@59269
   547
 match_oris (#prls py) ori (#ppc py, #where_ py);
wneuper@59269
   548
  *)