test/Tools/isac/Knowledge/polyminus.sml
author wneuper <walther.neuper@jku.at>
Thu, 15 Jul 2021 14:10:18 +0200
changeset 60324 5c7128feb370
parent 60278 343efa173023
child 60325 a7c0e6ab4883
permissions -rw-r--r--
ewrite.sml + poly.sml + rational.sml: ok, repair rewrite-orders
wneuper@59582
     1
(* title:  Knowledge/polyminus.sml
neuper@37906
     2
   author: Walther Neuper
neuper@37906
     3
   WN071207,
neuper@37906
     4
   (c) due to copyright terms
neuper@37906
     5
*)
neuper@38037
     6
"--------------------------------------------------------";
neuper@38037
     7
"--------------------------------------------------------";
neuper@38037
     8
"table of contents --------------------------------------";
neuper@38037
     9
"--------------------------------------------------------";
walther@60324
    10
"----------- fun contains_mult_pot_only --------------------------------------------------------";
walther@60324
    11
"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
walther@60324
    12
"----------- fun ist_monom ---------------------------------------------------------------------";
neuper@38037
    13
"----------- fun eval_ist_monom -------------------------";
neuper@38037
    14
"----------- watch order_add_mult  ----------------------";
neuper@38037
    15
"----------- build predicate for +- ordering ------------";
neuper@38037
    16
"----------- build fasse_zusammen -----------------------";
neuper@38037
    17
"----------- build verschoenere -------------------------";
neuper@38037
    18
"----------- met simplification for_polynomials with_minu";
neuper@38080
    19
"----------- me simplification.for_polynomials.with_minus";
neuper@38037
    20
"----------- pbl polynom vereinfachen p.33 --------------";
neuper@38037
    21
"----------- met probe fuer_polynom ---------------------";
neuper@38037
    22
"----------- pbl polynom probe --------------------------";
neuper@38037
    23
"----------- pbl klammer polynom vereinfachen p.34 ------";
neuper@38037
    24
"----------- try fun applyTactics -----------------------";
neuper@38037
    25
"----------- pbl binom polynom vereinfachen p.39 --------";
neuper@38037
    26
"----------- pbl binom polynom vereinfachen: cube -------";
walther@59968
    27
"----------- Refine.refine Vereinfache -------------------------";
walther@59973
    28
"----------- *** Problem.prep_input: syntax error in '#Where' of [v";
neuper@38037
    29
"--------------------------------------------------------";
neuper@38037
    30
"--------------------------------------------------------";
neuper@38037
    31
"--------------------------------------------------------";
neuper@38037
    32
neuper@41929
    33
val thy = @{theory "PolyMinus"};
neuper@37906
    34
walther@60324
    35
"----------- fun contains_mult_pot_only --------------------------------------------------------";
walther@60324
    36
"----------- fun contains_mult_pot_only --------------------------------------------------------";
walther@60324
    37
"----------- fun contains_mult_pot_only --------------------------------------------------------";
walther@60324
    38
val t = @{term 0};
walther@60324
    39
 if contains_mult_pot_only t then () else error "contains_mult_pot_only 1";
walther@60324
    40
walther@60324
    41
val t = @{term "a"};
walther@60324
    42
if contains_mult_pot_only t then () else error "contains_mult_pot_only 2";
walther@60324
    43
walther@60324
    44
val t = @{term "2 * a"};
walther@60324
    45
if contains_mult_pot_only t then () else error "contains_mult_pot_only 3";
walther@60324
    46
walther@60324
    47
val t = @{term "2 * a * b"};
walther@60324
    48
if contains_mult_pot_only t then () else error "contains_mult_pot_only 4";
walther@60324
    49
walther@60324
    50
val t = @{term "a * b"};
walther@60324
    51
if contains_mult_pot_only t then () else error "contains_mult_pot_only 5";
walther@60324
    52
walther@60324
    53
val t = @{term "2 * a \<up> 2 * b"};
walther@60324
    54
if contains_mult_pot_only t then () else error "contains_mult_pot_only 6";
walther@60324
    55
walther@60324
    56
val t = @{term "a \<up> 2 * b \<up> 3"};
walther@60324
    57
if contains_mult_pot_only t then () else error "contains_mult_pot_only 7";
walther@60324
    58
walther@60324
    59
(* but also ..*)
walther@60324
    60
val t = @{term "a \<up> 2 * 4 * b \<up> 3 * 5"};
walther@60324
    61
if contains_mult_pot_only t then () else error "contains_mult_pot_only 8";
walther@60324
    62
walther@60324
    63
walther@60324
    64
"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
walther@60324
    65
"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
walther@60324
    66
"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
walther@60324
    67
val t = TermC.str2term "12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * (g::real)";
walther@60324
    68
walther@60324
    69
val SOME ("12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g = True", _) =
walther@60324
    70
           eval_kleiner "aaa" "bbb" t "ccc";
walther@60324
    71
"~~~~~ fun eval_kleiner , args:"; val (_, _, (p as (Const ("PolyMinus.kleiner",_) $ a $ b)), _) =
walther@60324
    72
  ("aaa", "bbb", t, "ccc");
walther@60324
    73
    (*if*) TermC.is_num b (*else*);
walther@60324
    74
walther@60324
    75
   	(*if*) identifier a < identifier b  (*else*);
walther@60324
    76
"~~~~~ fun identifier , args:"; val (t) = (a);
walther@60324
    77
walther@60324
    78
(*+*)case a of
walther@60324
    79
  Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $
walther@60324
    80
    (Const ("Num.num.Bit0", _) $ (Const ("Num.num.Bit1", _) $ Const ("Num.num.One", _)))) => ()
walther@60324
    81
| _ => error "eval_kleiner CHANGED";
walther@60324
    82
walther@60324
    83
neuper@37906
    84
"----------- fun eval_ist_monom ----------------------------------";
neuper@37906
    85
"----------- fun eval_ist_monom ----------------------------------";
neuper@37906
    86
"----------- fun eval_ist_monom ----------------------------------";
walther@60230
    87
ist_monom (TermC.str2term "12");
walther@60230
    88
case eval_ist_monom 0 0 (TermC.str2term "12 ist_monom") 0 of
neuper@37926
    89
    SOME ("12 ist_monom = True", _) => ()
neuper@38031
    90
  | _ => error "polyminus.sml: 12 ist_monom = True";
neuper@37906
    91
walther@60230
    92
case eval_ist_monom 0 0 (TermC.str2term "a ist_monom") 0 of
neuper@37926
    93
    SOME ("a ist_monom = True", _) => ()
neuper@38031
    94
  | _ => error "polyminus.sml: a ist_monom = True";
neuper@37906
    95
walther@60230
    96
case eval_ist_monom 0 0 (TermC.str2term "(3*a) ist_monom") 0 of
neuper@37926
    97
    SOME ("3 * a ist_monom = True", _) => ()
neuper@38031
    98
  | _ => error "polyminus.sml: 3 * a ist_monom = True";
neuper@37906
    99
walther@60242
   100
case eval_ist_monom 0 0 (TermC.str2term "(a \<up> 2) ist_monom") 0 of 
walther@60242
   101
   SOME ("a \<up> 2 ist_monom = True", _) => ()
walther@60242
   102
  | _ => error "polyminus.sml: a \<up> 2 ist_monom = True";
neuper@37906
   103
walther@60242
   104
case eval_ist_monom 0 0 (TermC.str2term "(3*a \<up> 2) ist_monom") 0 of
walther@60242
   105
    SOME ("3 * a \<up> 2 ist_monom = True", _) => ()
walther@60242
   106
  | _ => error "polyminus.sml: 3*a \<up> 2 ist_monom = True";
neuper@37906
   107
walther@60230
   108
case eval_ist_monom 0 0 (TermC.str2term "(a*b) ist_monom") 0 of
neuper@37926
   109
    SOME ("a * b ist_monom = True", _) => ()
neuper@38031
   110
  | _ => error "polyminus.sml: a*b ist_monom = True";
neuper@37906
   111
walther@60230
   112
case eval_ist_monom 0 0 (TermC.str2term "(3*a*b) ist_monom") 0 of
neuper@37926
   113
    SOME ("3 * a * b ist_monom = True", _) => ()
neuper@38031
   114
  | _ => error "polyminus.sml: 3*a*b ist_monom = True";
neuper@37906
   115
neuper@37906
   116
neuper@37906
   117
"----------- watch order_add_mult  -------------------------------";
neuper@37906
   118
"----------- watch order_add_mult  -------------------------------";
neuper@37906
   119
"----------- watch order_add_mult  -------------------------------";
neuper@37906
   120
"----- with these simple variables it works...";
walther@59901
   121
(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
walther@59901
   122
Rewrite.trace_on:=false;
walther@60230
   123
val t = TermC.str2term "((a + d) + c) + b";
walther@59868
   124
val SOME (t,_) = rewrite_set_ thy false order_add_mult t; UnparseC.term t;
walther@59868
   125
if UnparseC.term t = "a + (b + (c + d))" then ()
neuper@38031
   126
else error "polyminus.sml 1 watch order_add_mult";
walther@59901
   127
Rewrite.trace_on:=false;
neuper@37906
   128
neuper@37906
   129
"----- the same stepwise...";
neuper@41929
   130
val od = ord_make_polynomial true (@{theory "Poly"});
walther@60230
   131
val t = TermC.str2term "((a + d) + c) + b";
neuper@37906
   132
"((a + d) + c) + b"; 
walther@59868
   133
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.commute} t; UnparseC.term t;
neuper@37906
   134
"b + ((a + d) + c)";
walther@59868
   135
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.commute} t; UnparseC.term t;
neuper@37906
   136
"b + (c + (a + d))";
walther@59868
   137
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.left_commute} t;UnparseC.term t;
neuper@37906
   138
"b + (a + (c + d))";
walther@59868
   139
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.left_commute} t;UnparseC.term t;
neuper@37906
   140
"a + (b + (c + d))";
walther@59868
   141
if UnparseC.term t = "a + (b + (c + d))" then ()
neuper@38031
   142
else error "polyminus.sml 2 watch order_add_mult";
neuper@37906
   143
neuper@37906
   144
"----- if parentheses are right, left_commute is (almost) sufficient...";
walther@60230
   145
val t = TermC.str2term "a + (d + (c + b))";
neuper@37906
   146
"a + (d + (c + b))";
walther@59868
   147
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.left_commute} t;UnparseC.term t;
neuper@37906
   148
"a + (c + (d + b))";
walther@59868
   149
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.commute} t;UnparseC.term t;
neuper@37906
   150
"a + (c + (b + d))";
walther@59868
   151
val SOME (t,_) = rewrite_ thy od Rule_Set.empty true @{thm add.left_commute} t;UnparseC.term t;
neuper@37906
   152
"a + (b + (c + d))";
neuper@37906
   153
neuper@37906
   154
"----- but we do not want the parentheses at right; thus: cond.rew.";
neuper@37906
   155
"WN0712707 complicated monomials do not yet work ...";
walther@60230
   156
val t = TermC.str2term "((5*a + 4*d) + 3*c) + 2*b";
walther@59868
   157
val SOME (t,_) = rewrite_set_ thy false order_add_mult t; UnparseC.term t;
walther@59868
   158
if UnparseC.term t = "2 * b + (3 * c + (4 * d + 5 * a))" then ()
neuper@38031
   159
else error "polyminus.sml: order_add_mult changed";
neuper@37906
   160
neuper@37906
   161
"----- here we see rew_sub going into subterm with ord.rew....";
neuper@41929
   162
val od = ord_make_polynomial false (@{theory "Poly"});
walther@60230
   163
val t = TermC.str2term "b + a + c + d";
walther@59868
   164
val SOME (t,_) = rewrite_ thy od Rule_Set.empty false @{thm add.commute} t; UnparseC.term t;
walther@59868
   165
val SOME (t,_) = rewrite_ thy od Rule_Set.empty false @{thm add.commute} t; UnparseC.term t;
neuper@37906
   166
(*@@@ rew_sub gosub: t = d + (b + a + c)
neuper@37906
   167
  @@@ rew_sub begin: t = b + a + c*)
neuper@37906
   168
neuper@37906
   169
neuper@37906
   170
"----------- build predicate for +- ordering ---------------------";
neuper@37906
   171
"----------- build predicate for +- ordering ---------------------";
neuper@37906
   172
"----------- build predicate for +- ordering ---------------------";
neuper@37906
   173
"a" < "b";
neuper@37906
   174
"ba" < "ab";
neuper@37906
   175
"123" < "a"; (*unused due to ---vvv*)
neuper@37906
   176
"12" < "3"; (*true !!!*)
neuper@37906
   177
neuper@37906
   178
" a kleiner b ==> (b + a) = (a + b)";
walther@60230
   179
TermC.str2term "aaa";
walther@60230
   180
TermC.str2term "222 * aaa";
neuper@42390
   181
walther@60230
   182
case eval_kleiner 0 0 (TermC.str2term "123 kleiner 32") 0 of
neuper@42390
   183
    SOME ("123 kleiner 32 = False", _) => ()
neuper@38031
   184
  | _ => error "polyminus.sml: 12 kleiner 9 = False";
neuper@42390
   185
walther@60230
   186
case eval_kleiner 0 0 (TermC.str2term "a kleiner b") 0 of
neuper@37926
   187
    SOME ("a kleiner b = True", _) => ()
neuper@38031
   188
  | _ => error "polyminus.sml: a kleiner b = True";
neuper@37906
   189
walther@60230
   190
case eval_kleiner 0 0 (TermC.str2term "(10*g) kleiner f") 0 of
neuper@37926
   191
    SOME ("10 * g kleiner f = False", _) => ()
neuper@38031
   192
  | _ => error "polyminus.sml: 10 * g kleiner f = False";
neuper@37906
   193
walther@60242
   194
case eval_kleiner 0 0 (TermC.str2term "(a \<up> 2) kleiner b") 0 of
walther@60242
   195
    SOME ("a \<up> 2 kleiner b = True", _) => ()
walther@60242
   196
  | _ => error "polyminus.sml: a \<up> 2 kleiner b = True";
neuper@37906
   197
walther@60242
   198
case eval_kleiner 0 0 (TermC.str2term "(3*a \<up> 2) kleiner b") 0 of
walther@60242
   199
    SOME ("3 * a \<up> 2 kleiner b = True", _) => ()
walther@60242
   200
  | _ => error "polyminus.sml: 3 * a \<up> 2 kleiner b = True";
neuper@37906
   201
walther@60230
   202
case eval_kleiner 0 0 (TermC.str2term "(a*b) kleiner c") 0 of
neuper@37926
   203
    SOME ("a * b kleiner c = True", _) => ()
neuper@38031
   204
  | _ => error "polyminus.sml: a * b kleiner b = True";
neuper@37906
   205
walther@60230
   206
case eval_kleiner 0 0 (TermC.str2term "(3*a*b) kleiner c") 0 of
neuper@37926
   207
    SOME ("3 * a * b kleiner c = True", _) => ()
neuper@38031
   208
  | _ => error "polyminus.sml: 3 * a * b kleiner b = True";
neuper@37906
   209
neuper@42390
   210
"======= compare tausche_plus with real_num_collect";
neuper@37906
   211
val od = dummy_ord;
neuper@37906
   212
neuper@37906
   213
val erls = erls_ordne_alphabetisch;
walther@60230
   214
val t = TermC.str2term "b + a";
walther@59868
   215
val SOME (t,_) = rewrite_ thy od erls false @{thm tausche_plus} t; UnparseC.term t;
walther@59868
   216
if UnparseC.term t = "a + b" then ()
neuper@38031
   217
else error "polyminus.sml: ordne_alphabetisch1 b + a";
neuper@37906
   218
neuper@37906
   219
val erls = Atools_erls;
walther@60230
   220
val t = TermC.str2term "2*a + 3*a";
walther@59868
   221
val SOME (t,_) = rewrite_ thy od erls false @{thm real_num_collect} t; UnparseC.term t;
neuper@37906
   222
neuper@42390
   223
"======= test rewrite_, rewrite_set_";
walther@59901
   224
(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
neuper@37906
   225
val erls = erls_ordne_alphabetisch;
walther@60230
   226
val t = TermC.str2term "b + a";
walther@59868
   227
val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; UnparseC.term t;
walther@59868
   228
if UnparseC.term t = "a + b" then ()
neuper@38031
   229
else error "polyminus.sml: ordne_alphabetisch a + b";
neuper@37906
   230
walther@60230
   231
val t = TermC.str2term "2*b + a";
walther@59868
   232
val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; UnparseC.term t;
walther@59868
   233
if UnparseC.term t = "a + 2 * b" then ()
neuper@38031
   234
else error "polyminus.sml: ordne_alphabetisch a + 2 * b";
neuper@37906
   235
walther@60230
   236
val t = TermC.str2term "a + c + b";
walther@59868
   237
val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; UnparseC.term t;
walther@59868
   238
if UnparseC.term t = "a + b + c" then ()
neuper@38031
   239
else error "polyminus.sml: ordne_alphabetisch a + b + c";
neuper@37906
   240
neuper@42390
   241
"======= rewrite goes into subterms";
walther@60230
   242
val t = TermC.str2term "a + c + b + d";
walther@59868
   243
val SOME (t,_) = rewrite_ thy od erls false @{thm tausche_plus_plus} t; UnparseC.term t;
walther@59868
   244
if UnparseC.term t = "a + b + c + d" then ()
neuper@38031
   245
else error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
neuper@37906
   246
walther@60230
   247
val t = TermC.str2term "a + c + d + b";
walther@59868
   248
val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; UnparseC.term t;
walther@59868
   249
if UnparseC.term t = "a + b + c + d" then ()
neuper@38031
   250
else error "polyminus.sml: ordne_alphabetisch2 a + b + c + d";
neuper@37906
   251
neuper@42390
   252
"======= here we see rew_sub going into subterm with cond.rew....";
walther@60230
   253
val t = TermC.str2term "b + a + c + d";
walther@59868
   254
val SOME (t,_) = rewrite_ thy od erls false @{thm tausche_plus} t; UnparseC.term t;
walther@59868
   255
if UnparseC.term t = "a + b + c + d" then ()
neuper@38031
   256
else error "polyminus.sml: ordne_alphabetisch3 a + b + c + d";
neuper@37906
   257
neuper@42390
   258
"======= compile rls for the most complicated terms";
walther@60230
   259
val t = TermC.str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12";
neuper@37906
   260
"5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";
neuper@37926
   261
val SOME (t,_) = rewrite_set_ thy false ordne_alphabetisch t; 
walther@59868
   262
if UnparseC.term t = "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g"
neuper@38031
   263
then () else error "polyminus.sml: ordne_alphabetisch finished";
neuper@37906
   264
neuper@37906
   265
neuper@37906
   266
"----------- build fasse_zusammen --------------------------------";
neuper@37906
   267
"----------- build fasse_zusammen --------------------------------";
neuper@37906
   268
"----------- build fasse_zusammen --------------------------------";
walther@60230
   269
val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g";
neuper@37926
   270
val SOME (t,_) = rewrite_set_ thy false fasse_zusammen t;
walther@59868
   271
if UnparseC.term t = "3 + -2 * e + 2 * f + 2 * g" then ()
neuper@38031
   272
else error "polyminus.sml: fasse_zusammen finished";
neuper@37906
   273
neuper@37906
   274
"----------- build verschoenere ----------------------------------";
neuper@37906
   275
"----------- build verschoenere ----------------------------------";
neuper@37906
   276
"----------- build verschoenere ----------------------------------";
walther@60230
   277
val t = TermC.str2term "3 + -2 * e + 2 * f + 2 * g";
neuper@37926
   278
val SOME (t,_) = rewrite_set_ thy false verschoenere t;
walther@59868
   279
if UnparseC.term t = "3 - 2 * e + 2 * f + 2 * g" then ()
neuper@38031
   280
else error "polyminus.sml: verschoenere 3 + -2 * e ...";
neuper@37906
   281
walther@59901
   282
(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
walther@59901
   283
Rewrite.trace_on:=false;
neuper@37906
   284
neuper@37906
   285
"----------- met simplification for_polynomials with_minus -------";
neuper@37906
   286
"----------- met simplification for_polynomials with_minus -------";
neuper@37906
   287
"----------- met simplification for_polynomials with_minus -------";
neuper@37906
   288
val str = 
wneuper@59585
   289
"Program SimplifyScript (t_t::real) =                \
walther@59637
   290
\  (((Try (Rewrite_Set ordne_alphabetisch False)) #>     \
walther@59637
   291
\    (Try (Rewrite_Set fasse_zusammen False)) #>     \
neuper@38080
   292
\    (Try (Rewrite_Set verschoenere False))) t_t)"
walther@60230
   293
val sc = (inst_abs o Thm.term_of o the o (TermC.parse thy)) str;
walther@60230
   294
TermC.atomty sc;
neuper@37906
   295
neuper@38080
   296
"----------- me simplification.for_polynomials.with_minus";
neuper@38080
   297
"----------- me simplification.for_polynomials.with_minus";
neuper@38080
   298
"----------- me simplification.for_polynomials.with_minus";
neuper@38080
   299
val c = [];
neuper@38080
   300
val (p,_,f,nxt,_,pt) = 
neuper@38080
   301
      CalcTreeTEST 
neuper@38083
   302
        [(["Term (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)",
neuper@38080
   303
           "normalform N"],
walther@59997
   304
	          ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   305
	           ["simplification", "for_polynomials", "with_minus"]))];
neuper@38080
   306
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   307
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   308
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   309
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   310
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   311
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   312
neuper@38085
   313
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   314
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   315
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   316
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@38085
   317
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59749
   318
if f2str f = "3 - 2 * e + 2 * f + 2 * g" 
walther@59749
   319
then case nxt of End_Proof' => () | _ =>  error "me simplification.for_polynomials.with_minus 1"
walther@59749
   320
else error "polyminus.sml: me simplification.for_polynomials.with_minus 2";
neuper@38085
   321
neuper@37906
   322
"----------- pbl polynom vereinfachen p.33 -----------------------";
neuper@37906
   323
"----------- pbl polynom vereinfachen p.33 -----------------------";
neuper@37906
   324
"----------- pbl polynom vereinfachen p.33 -----------------------";
neuper@37906
   325
"----------- 140 c ---";
s1210629013@55445
   326
reset_states ();
neuper@38083
   327
CalcTree [(["Term (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)",
neuper@37906
   328
	    "normalform N"],
walther@59997
   329
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   330
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   331
moveActiveRoot 1;
wneuper@59248
   332
autoCalculate 1 CompleteCalc;
walther@59983
   333
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   334
if p = ([], Res) andalso 
walther@59868
   335
   UnparseC.term (get_obj g_res pt (fst p)) = "3 - 2 * e + 2 * f + 2 * g"
neuper@38031
   336
then () else error "polyminus.sml: Vereinfache (3 - 2 * e + 2 * f...";
neuper@37906
   337
neuper@42390
   338
"======= 140 d ---";
s1210629013@55445
   339
reset_states ();
neuper@38083
   340
CalcTree [(["Term (-r - 2*s - 3*t + 5 + 4*r + 8*s - 5*t - 2)",
neuper@37906
   341
	    "normalform N"],
walther@59997
   342
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   343
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   344
moveActiveRoot 1;
wneuper@59248
   345
autoCalculate 1 CompleteCalc;
walther@59983
   346
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   347
if p = ([], Res) andalso 
walther@59868
   348
   UnparseC.term (get_obj g_res pt (fst p)) = "3 + 3 * r + 6 * s - 8 * t"
neuper@38031
   349
then () else error "polyminus.sml: Vereinfache 140 d)";
neuper@37906
   350
neuper@42390
   351
"======= 139 c ---";
s1210629013@55445
   352
reset_states ();
neuper@38083
   353
CalcTree [(["Term (3*e - 6*f - 8*e - 4*f + 5*e + 7*f)",
neuper@37906
   354
	    "normalform N"],
walther@59997
   355
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   356
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   357
moveActiveRoot 1;
wneuper@59248
   358
autoCalculate 1 CompleteCalc;
walther@59983
   359
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   360
if p = ([], Res) andalso 
walther@59868
   361
   UnparseC.term (get_obj g_res pt (fst p)) = "- (3 * f)"
neuper@38031
   362
then () else error "polyminus.sml: Vereinfache 139 c)";
neuper@37906
   363
neuper@42390
   364
"======= 139 b ---";
s1210629013@55445
   365
reset_states ();
neuper@38083
   366
CalcTree [(["Term (8*u - 5*v - 5*u + 7*v - 6*u - 3*v)",
neuper@37906
   367
	    "normalform N"],
walther@59997
   368
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   369
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   370
moveActiveRoot 1;
wneuper@59248
   371
autoCalculate 1 CompleteCalc;
walther@59983
   372
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   373
if p = ([], Res) andalso 
walther@59868
   374
   UnparseC.term (get_obj g_res pt (fst p)) = "-3 * u - v"
neuper@38031
   375
then () else error "polyminus.sml: Vereinfache 139 b)";
neuper@37906
   376
neuper@42390
   377
"======= 138 a ---";
s1210629013@55445
   378
reset_states ();
neuper@38083
   379
CalcTree [(["Term (2*u - 3*v - 6*u + 5*v)",
neuper@37906
   380
	    "normalform N"],
walther@59997
   381
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   382
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   383
moveActiveRoot 1;
wneuper@59248
   384
autoCalculate 1 CompleteCalc;
walther@59983
   385
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   386
if p = ([], Res) andalso 
walther@59868
   387
   UnparseC.term (get_obj g_res pt (fst p)) = "-4 * u + 2 * v"
neuper@38031
   388
then () else error "polyminus.sml: Vereinfache 138 a)";
neuper@37906
   389
neuper@37906
   390
"----------- met probe fuer_polynom ------------------------------";
neuper@37906
   391
"----------- met probe fuer_polynom ------------------------------";
neuper@37906
   392
"----------- met probe fuer_polynom ------------------------------";
neuper@37906
   393
val str = 
wneuper@59585
   394
"Program ProbeScript (e_e::bool) (w_s::bool list) =\
neuper@37991
   395
\ (let e_e = Take e_e;                             \
neuper@38085
   396
\      e_e = Substitute w_s e_e                    \
walther@59637
   397
\ in (Repeat((Try (Repeat (Calculate ''TIMES''))) #>  \
walther@59637
   398
\            (Try (Repeat (Calculate ''PLUS''))) #>  \
wneuper@59488
   399
\            (Try (Repeat (Calculate ''MINUS''))))) e_e)"
walther@60230
   400
val sc = (inst_abs o Thm.term_of o the o (TermC.parse thy)) str;
walther@60230
   401
TermC.atomty sc;
neuper@37906
   402
neuper@37906
   403
"----------- pbl polynom probe -----------------------------------";
neuper@37906
   404
"----------- pbl polynom probe -----------------------------------";
neuper@37906
   405
"----------- pbl polynom probe -----------------------------------";
s1210629013@55445
   406
reset_states ();
bonzai@41949
   407
CalcTree [(["Pruefe ((5::int)*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12 =\
wneuper@59582
   408
	    \3 - 2 * e + 2 * f + 2 * (g::int))",
wneuper@59582
   409
	    "mitWert [e = (1::int), f = (2::int), g = (3::int)]",
neuper@37906
   410
	    "Geprueft b"],
walther@59997
   411
	   ("PolyMinus",["polynom", "probe"],
walther@59997
   412
	    ["probe", "fuer_polynom"]))];
neuper@37906
   413
moveActiveRoot 1;
wneuper@59248
   414
autoCalculate 1 CompleteCalc;
wneuper@59248
   415
(* autoCalculate 1 CompleteCalcHead;
walther@59747
   416
   autoCalculate 1 (Steps 1);
walther@59747
   417
   autoCalculate 1 (Steps 1);
walther@59868
   418
   val ((pt,p),_) = get_calc 1; UnparseC.term (get_obj g_res pt (fst p));
neuper@37906
   419
@@@@@WN081114 gives "??.empty", all "Pruefe" are the same,
neuper@37906
   420
although analogies work in interface.sml: FIXME.WN081114 in "Pruefe"*)
neuper@37906
   421
val ((pt,p),_) = get_calc 1;
walther@59868
   422
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "11 = 11"
neuper@38031
   423
then () else error "polyminus.sml: Probe 11 = 11";
walther@59983
   424
Test_Tool.show_pt pt;
t@42115
   425
neuper@37906
   426
"----------- pbl klammer polynom vereinfachen p.34 ---------------";
neuper@37906
   427
"----------- pbl klammer polynom vereinfachen p.34 ---------------";
neuper@37906
   428
"----------- pbl klammer polynom vereinfachen p.34 ---------------";
s1210629013@55445
   429
reset_states ();
neuper@38083
   430
CalcTree [(["Term (2*u - 5 - (3 - 4*u) + (8*u + 9))",
neuper@37906
   431
	    "normalform N"],
walther@59997
   432
	   ("PolyMinus",["klammer", "polynom", "vereinfachen"],
walther@59997
   433
	    ["simplification", "for_polynomials", "with_parentheses"]))];
neuper@37906
   434
moveActiveRoot 1;
wneuper@59248
   435
autoCalculate 1 CompleteCalc;
neuper@37906
   436
val ((pt,p),_) = get_calc 1;
neuper@37906
   437
if p = ([], Res) andalso 
walther@59868
   438
   UnparseC.term (get_obj g_res pt (fst p)) = "1 + 14 * u"
neuper@38031
   439
then () else error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
walther@59983
   440
Test_Tool.show_pt pt;
neuper@37906
   441
neuper@42390
   442
"======= probe p.34 -----";
s1210629013@55445
   443
reset_states ();
wneuper@59582
   444
CalcTree [(["Pruefe (2*u - 5 - (3 - 4*u) + (8*u + 9) = 1 + 14 * (u::int))",
wneuper@59582
   445
	    "mitWert [u = (2::int)]",
neuper@37906
   446
	    "Geprueft b"],
walther@59997
   447
	   ("PolyMinus",["polynom", "probe"],
walther@59997
   448
	    ["probe", "fuer_polynom"]))];
neuper@37906
   449
moveActiveRoot 1;
wneuper@59248
   450
autoCalculate 1 CompleteCalc;
neuper@37906
   451
val ((pt,p),_) = get_calc 1;
walther@59868
   452
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "29 = 29"
neuper@38031
   453
then () else error "polyminus.sml: Probe 29 = 29";
walther@59983
   454
Test_Tool.show_pt pt;
neuper@37906
   455
neuper@37906
   456
"----------- try fun applyTactics --------------------------------";
neuper@37906
   457
"----------- try fun applyTactics --------------------------------";
neuper@37906
   458
"----------- try fun applyTactics --------------------------------";
s1210629013@55445
   459
reset_states ();
neuper@38083
   460
CalcTree [(["Term (5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12)",
neuper@37906
   461
	    "normalform N"],
walther@59997
   462
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   463
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   464
moveActiveRoot 1;
wneuper@59248
   465
autoCalculate 1 CompleteCalcHead;
walther@59747
   466
autoCalculate 1 (Steps 1);
walther@59747
   467
autoCalculate 1 (Steps 1);
walther@59983
   468
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   469
"----- 1  \<up> ";
neuper@37906
   470
fetchApplicableTactics 1 0 p;
walther@59823
   471
val appltacs = specific_from_prog pt p;
neuper@37906
   472
applyTactic 1 p (hd appltacs) (*addiere_x_plus_minus*);
walther@59983
   473
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   474
"----- 2  \<up> ";
walther@59901
   475
(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
neuper@37906
   476
val erls = erls_ordne_alphabetisch;
walther@60230
   477
val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g";
neuper@37926
   478
val SOME (t',_) = 
wneuper@59592
   479
    rewrite_ (@{theory "Isac_Knowledge"}) e_rew_ord erls false @{thm tausche_minus} t;
walther@59868
   480
UnparseC.term t';     "- 9 + 12 + 5 * e - 7 * e + (- 4 + 6) * f - 8 * g + 10 * g";
neuper@37906
   481
walther@60230
   482
val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g";
neuper@37926
   483
val NONE = 
wneuper@59592
   484
    rewrite_ (@{theory "Isac_Knowledge"}) e_rew_ord erls false @{thm tausche_minus_plus} t;
neuper@37906
   485
walther@60230
   486
val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g";
neuper@37926
   487
val SOME (t',_) = 
wneuper@59592
   488
    rewrite_set_ (@{theory "Isac_Knowledge"}) false ordne_alphabetisch t;
walther@59868
   489
UnparseC.term t';     "- 9 + 12 + 5 * e - 7 * e - 8 * g + 10 * g + (- 4 + 6) * f";
walther@59901
   490
Rewrite.trace_on := false;
neuper@37906
   491
neuper@37906
   492
walther@59823
   493
applyTactic 1 p (hd (specific_from_prog pt p)) (*tausche_minus*);
walther@59983
   494
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   495
"----- 3  \<up> ";
walther@59823
   496
applyTactic 1 p (hd (specific_from_prog pt p)) (**);
walther@59983
   497
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   498
"----- 4  \<up> ";
walther@59823
   499
applyTactic 1 p (hd (specific_from_prog pt p)) (**);
walther@59983
   500
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   501
"----- 5  \<up> ";
walther@59823
   502
applyTactic 1 p (hd (specific_from_prog pt p)) (**);
walther@59983
   503
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   504
"----- 6  \<up> ";
neuper@37906
   505
neuper@37906
   506
(*<CALCMESSAGE> failure </CALCMESSAGE>
walther@59823
   507
applyTactic 1 p (hd (specific_from_prog pt p)) (**);
walther@59983
   508
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   509
"----- 7  \<up> ";
neuper@37906
   510
*)
wneuper@59248
   511
autoCalculate 1 CompleteCalc;
walther@59983
   512
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   513
(*independent from failure above: met_simp_poly_minus not confluent:
neuper@37906
   514
(([9], Res), - (8 * g) + 10 * g + (3 - 2 * e + 2 * f)),
neuper@37906
   515
(([], Res), - (8 * g) + 10 * g + (3 - 2 * e + 2 * f))]
neuper@37906
   516
~~~~~~~~~~~###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
t@42115
   517
neuper@37906
   518
neuper@42107
   519
"#############################################################################";
s1210629013@55445
   520
reset_states ();
neuper@38083
   521
CalcTree [(["Term (- (8 * g) + 10 * g + h)",
neuper@37906
   522
	    "normalform N"],
walther@59997
   523
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   524
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   525
moveActiveRoot 1;
wneuper@59248
   526
autoCalculate 1 CompleteCalc;
walther@59983
   527
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@59868
   528
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "2 * g + h"
neuper@38031
   529
then () else error "polyminus.sml: addiere_vor_minus";
neuper@37906
   530
neuper@37906
   531
neuper@42107
   532
"#############################################################################";
s1210629013@55445
   533
reset_states ();
neuper@38083
   534
CalcTree [(["Term (- (8 * g) + 10 * g + f)",
neuper@37906
   535
	    "normalform N"],
walther@59997
   536
	   ("PolyMinus",["plus_minus", "polynom", "vereinfachen"],
walther@59997
   537
	    ["simplification", "for_polynomials", "with_minus"]))];
neuper@37906
   538
moveActiveRoot 1;
wneuper@59248
   539
autoCalculate 1 CompleteCalc;
walther@59983
   540
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@59868
   541
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "f + 2 * g"
neuper@38031
   542
then () else error "polyminus.sml: tausche_vor_plus";
neuper@37906
   543
neuper@37906
   544
"----------- pbl binom polynom vereinfachen p.39 -----------------";
neuper@37906
   545
"----------- pbl binom polynom vereinfachen p.39 -----------------";
neuper@37906
   546
"----------- pbl binom polynom vereinfachen p.39 -----------------";
neuper@37906
   547
val rls = klammern_ausmultiplizieren;
walther@60230
   548
val t = TermC.str2term "(3 * a + 2) * (4 * a - 1)";
walther@59868
   549
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   550
"3 * a * (4 * a) - 3 * a * 1 + (2 * (4 * a) - 2 * 1)";
neuper@37906
   551
val rls = discard_parentheses;
walther@59868
   552
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   553
"3 * a * 4 * a - 3 * a * 1 + (2 * 4 * a - 2 * 1)";
neuper@37906
   554
val rls = ordne_monome;
walther@59868
   555
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   556
"3 * 4 * a * a - 1 * 3 * a + (2 * 4 * a - 1 * 2)";
neuper@37906
   557
(*
walther@60230
   558
val t = TermC.str2term "3 * a * 4 * a";
neuper@37906
   559
val rls = ordne_monome;
walther@59868
   560
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   561
*)
neuper@37906
   562
val rls = klammern_aufloesen;
walther@59868
   563
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   564
"3 * 4 * a * a - 1 * 3 * a + 2 * 4 * a - 1 * 2";
neuper@37906
   565
val rls = ordne_alphabetisch;
neuper@37906
   566
(*TODO: make is_monom more general, a*a=a^2, ...*)
walther@59868
   567
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   568
"3 * 4 * a * a - 1 * 2 - 1 * 3 * a + 2 * 4 * a";
neuper@41977
   569
(*STOPPED.WN080104
neuper@37906
   570
val rls = fasse_zusammen;
walther@59868
   571
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   572
val rls = verschoenere;
walther@59868
   573
val SOME (t,_) = rewrite_set_ thy false rls t; UnparseC.term t;
neuper@37906
   574
*)
neuper@37906
   575
neuper@37906
   576
(*@@@@@@@*)
s1210629013@55445
   577
reset_states ();
neuper@38083
   578
CalcTree [(["Term ((3*a + 2) * (4*a - 1))",
neuper@37906
   579
	    "normalform N"],
walther@59997
   580
	   ("PolyMinus",["binom_klammer", "polynom", "vereinfachen"],
walther@59997
   581
	    ["simplification", "for_polynomials", "with_parentheses_mult"]))];
neuper@37906
   582
moveActiveRoot 1;
wneuper@59248
   583
autoCalculate 1 CompleteCalc;
walther@59983
   584
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   585
if p = ([], Res) andalso 
walther@60242
   586
   UnparseC.term (get_obj g_res pt (fst p)) = "-2 + 12 * a \<up> 2 + 5 * a"
neuper@38031
   587
then () else error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
t@42111
   588
neuper@37906
   589
"----------- pbl binom polynom vereinfachen: cube ----------------";
neuper@37906
   590
"----------- pbl binom polynom vereinfachen: cube ----------------";
neuper@37906
   591
"----------- pbl binom polynom vereinfachen: cube ----------------";
s1210629013@55445
   592
reset_states ();
neuper@38083
   593
CalcTree [(["Term (8*(a - q) + a - 2*q + 3*(a - 2*q))", "normalform N"],
walther@59997
   594
	   ("PolyMinus",["binom_klammer", "polynom", "vereinfachen"],
walther@59997
   595
	    ["simplification", "for_polynomials", "with_parentheses_mult"]))];
neuper@37906
   596
moveActiveRoot 1;
wneuper@59248
   597
autoCalculate 1 CompleteCalc;
walther@59983
   598
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@59868
   599
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "12 * a - 16 * q" 
neuper@42107
   600
then () else error "pbl binom polynom vereinfachen: cube";
neuper@37906
   601
walther@59968
   602
"----------- Refine.refine Vereinfache ----------------------------------";
walther@59968
   603
"----------- Refine.refine Vereinfache ----------------------------------";
walther@59968
   604
"----------- Refine.refine Vereinfache ----------------------------------";
neuper@42390
   605
val fmz = ["Term (8*(a - q) + a - 2*q + 3*(a - 2*(q::real)))", "normalform (N::real)"];
wneuper@59348
   606
(*default_print_depth 11;*)
wenzelm@60237
   607
val matches = Refine.refine fmz ["vereinfachen"];
wneuper@59348
   608
(*default_print_depth 3;*)
neuper@37906
   609
neuper@37906
   610
"----- go into details, if it seems not to work -----";
neuper@37906
   611
"--- does the predicate evaluate correctly ?";
walther@60230
   612
val t = TermC.str2term 
neuper@42390
   613
	    "matchsub (?a * (?b - ?c)) (8 * (a - q) + a - 2 * q + 3 * (a - 2 * (q::real)))";
walther@59603
   614
val ma = eval_matchsub "" "Prog_Expr.matchsub" t thy;
neuper@37906
   615
case ma of
neuper@37926
   616
    SOME ("matchsub (?a * (?b - ?c)) (8 * (a - q) + \
neuper@37906
   617
	  \a - 2 * q + 3 * (a - 2 * q)) = True", _) => ()
neuper@38031
   618
  | _ => error "polyminus.sml matchsub (?a * (?b - ?c)...A";
neuper@37906
   619
neuper@37906
   620
"--- does the respective prls rewrite ?";
walther@59852
   621
val prls = Rule_Set.append_rules "prls_pbl_vereinf_poly" Rule_Set.empty 
walther@60278
   622
	     [Eval ("Poly.is_polyexp", eval_is_polyexp ""),
walther@59878
   623
	      Eval ("Prog_Expr.matchsub", eval_matchsub ""),
neuper@38085
   624
	      Thm ("or_true",@{thm or_true}),
neuper@37906
   625
	      (*"(?a | True) = True"*)
neuper@38085
   626
	      Thm ("or_false",@{thm or_false}),
neuper@37906
   627
	      (*"(?a | False) = ?a"*)
walther@59871
   628
	      Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
neuper@37906
   629
	      (*"(~ True) = False"*)
walther@59871
   630
	      Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})
neuper@37906
   631
	      (*"(~ False) = True"*)];
walther@59901
   632
(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
neuper@37926
   633
val SOME (t', _) = rewrite_set_ thy false prls t;
walther@59901
   634
Rewrite.trace_on := false;
neuper@37906
   635
neuper@37906
   636
"--- does the respective prls rewrite the whole predicate ?";
walther@60230
   637
val t = TermC.str2term 
neuper@37906
   638
	    "Not (matchsub (?a * (?b + ?c)) (8 * (a - q) + a - 2 * q) | \
neuper@37906
   639
	    \     matchsub (?a * (?b - ?c)) (8 * (a - q) + a - 2 * q) | \
neuper@37906
   640
	    \     matchsub ((?b + ?c) * ?a) (8 * (a - q) + a - 2 * q) | \
neuper@37906
   641
	    \     matchsub ((?b - ?c) * ?a) (8 * (a - q) + a - 2 * q) )";
walther@59901
   642
(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
neuper@37926
   643
val SOME (t', _) = rewrite_set_ thy false prls t;
walther@59901
   644
Rewrite.trace_on := false;
walther@59868
   645
if UnparseC.term t' = "False" then ()
neuper@38031
   646
else error "polyminus.sml Not (matchsub (?a * (?b + ?c)) (8 ...";
neuper@37906
   647
walther@59973
   648
"----------- *** Problem.prep_input: syntax error in '#Where' of [v";
walther@59973
   649
"----------- *** Problem.prep_input: syntax error in '#Where' of [v";
walther@59973
   650
"----------- *** Problem.prep_input: syntax error in '#Where' of [v";
neuper@38037
   651
(*see test/../termC.sml for details*)
walther@60230
   652
val t = TermC.parse_patt thy "t_t is_polyexp";
walther@60230
   653
val t = TermC.parse_patt thy ("Not (matchsub (?a + (?b + ?c)) t_t | " ^
neuper@38037
   654
	                "     matchsub (?a + (?b - ?c)) t_t | " ^
neuper@38037
   655
	                "     matchsub (?a - (?b + ?c)) t_t | " ^
neuper@38037
   656
	                "     matchsub (?a + (?b - ?c)) t_t )");
neuper@42390
   657
(*show_types := true;
walther@59868
   658
if UnparseC.term t = "~ (matchsub ((?a::real) + ((?b::real) + (?c::real))) (t_t::real) |\n   matchsub (?a + (?b - ?c)) t_t |\n   matchsub (?a - (?b + ?c)) t_t | matchsub (?a + (?b - ?c)) t_t)"
neuper@38038
   659
then () else error "polyminus.sml type-structure of \"?a :: real\" changed 1";
neuper@42390
   660
show_types := false;*)
walther@59868
   661
if UnparseC.term t =
wneuper@59371
   662
  "\<not> (matchsub (?a + (?b + ?c)) t_t \<or>\n        " ^
wneuper@59371
   663
  "matchsub (?a + (?b - ?c)) t_t \<or>\n        " ^
wneuper@59371
   664
  "matchsub (?a - (?b + ?c)) t_t \<or> " ^
wneuper@59371
   665
  "matchsub (?a + (?b - ?c)) t_t)"
neuper@42390
   666
then () else error "polyminus.sml type-structure of \"?a :: real\" changed 1";
neuper@37906
   667