test/Tools/isac/Knowledge/poly.sml
author Walther Neuper <walther.neuper@jku.at>
Tue, 04 Feb 2020 16:27:54 +0100
changeset 59787 bc053953d442
parent 59592 99c8d2ff63eb
child 59790 a1944acd8dcf
permissions -rw-r--r--
lucin: set_found ONCE in locate_input_tactic makes "fun me" work
neuper@37906
     1
(* testexamples for Poly, polynomials
neuper@37906
     2
   author: Matthias Goldgruber 2003
neuper@37906
     3
   (c) due to copyright terms
neuper@37906
     4
neuper@38022
     5
12345678901234567890123456789012345678901234567890123456789012345678901234567890
neuper@38022
     6
        10        20        30        40        50        60        70        80
neuper@42395
     7
LEGEND:
neuper@42395
     8
WN060104: examples marked with 'SPB' came into 'exp_IsacCore_Simp_Poly_Book.xml'
neuper@42395
     9
          examples marked with 'SPO' came into 'exp_IsacCore_Simp_Poly_Other.xml'
neuper@38022
    10
*)
neuper@42395
    11
neuper@38022
    12
"--------------------------------------------------------";
neuper@38022
    13
"--------------------------------------------------------";
neuper@38022
    14
"table of contents --------------------------------------";
neuper@38022
    15
"--------------------------------------------------------";
wneuper@59529
    16
"----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59522
    17
"----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522
    18
"----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522
    19
"----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522
    20
"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
neuper@42395
    21
"-------- investigate (new 2002) uniary minus -----------";
neuper@38036
    22
"-------- check make_polynomial with simple terms -------";
neuper@38036
    23
"-------- fun is_multUnordered --------------------------";
neuper@38036
    24
"-------- examples from textbook Schalk I ---------------";
neuper@38022
    25
"-------- check pbl  'polynomial simplification' --------";
neuper@38022
    26
"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@38036
    27
"-------- interSteps for Schalk 299a --------------------";
neuper@38022
    28
"-------- norm_Poly NOT COMPLETE ------------------------";
neuper@38022
    29
"-------- ord_make_polynomial ---------------------------";
neuper@38022
    30
"--------------------------------------------------------";
neuper@38022
    31
"--------------------------------------------------------";
neuper@38022
    32
"--------------------------------------------------------";
neuper@37906
    33
neuper@37906
    34
wneuper@59529
    35
"----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59529
    36
"----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59529
    37
"----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59529
    38
val thy = @{theory Partial_Fractions};
wneuper@59529
    39
val ctxt = Proof_Context.init_global thy;
wneuper@59529
    40
wneuper@59529
    41
val t = (the o (parseNEW  ctxt)) "x / x";
wneuper@59529
    42
if is_polyexp t then error "NOT is_polyexp (x / x)" else ();
wneuper@59529
    43
wneuper@59529
    44
val t = (the o (parseNEW  ctxt)) "-1 * A * 3";
wneuper@59529
    45
if is_polyexp t then () else error "is_polyexp (-1 * A * 3)";
wneuper@59529
    46
wneuper@59529
    47
val t = (the o (parseNEW  ctxt)) "-1 * AA * 3";
wneuper@59529
    48
if is_polyexp t then () else error "is_polyexp (-1 * AA * 3)";
neuper@38022
    49
wneuper@59522
    50
"----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522
    51
"----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522
    52
"----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522
    53
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
    54
val t = (Thm.term_of o the o (parse thy)) "1";
wneuper@59522
    55
if has_degree_in t v = 0 then () else error "has_degree_in (1) x";
wneuper@59522
    56
wneuper@59522
    57
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
    58
val t = (Thm.term_of o the o (parse thy)) "1";
wneuper@59522
    59
if has_degree_in t v = 0 then () else error "has_degree_in (1) AA";
wneuper@59522
    60
wneuper@59522
    61
(*----------*)
wneuper@59522
    62
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
    63
val t = (Thm.term_of o the o (parse thy)) "a*b+c";
wneuper@59522
    64
if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) x";
wneuper@59522
    65
wneuper@59522
    66
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
    67
val t = (Thm.term_of o the o (parse thy)) "a*b+c";
wneuper@59522
    68
if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) AA";
wneuper@59522
    69
wneuper@59522
    70
(*----------*)
wneuper@59522
    71
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
    72
val t = (Thm.term_of o the o (parse thy)) "a*x+c";
wneuper@59522
    73
if has_degree_in t v = ~1 then () else error "has_degree_in (a*x+c) x";
wneuper@59522
    74
wneuper@59522
    75
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
    76
val t = (Thm.term_of o the o (parse thy)) "a*AA+c";
wneuper@59522
    77
if has_degree_in t v = ~1 then () else error "has_degree_in (a*AA+c) AA";
wneuper@59522
    78
wneuper@59522
    79
(*----------*)
wneuper@59522
    80
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
    81
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x^^^7";
wneuper@59522
    82
if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*x^^^7) x";
wneuper@59522
    83
wneuper@59522
    84
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
    85
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA^^^7";
wneuper@59522
    86
if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*AA^^^7) AA";
wneuper@59522
    87
wneuper@59522
    88
(*----------*)
wneuper@59522
    89
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
    90
val t = (Thm.term_of o the o (parse thy)) "x^^^7";
wneuper@59522
    91
if has_degree_in t v = 7 then () else error "has_degree_in (x^^^7) x";
wneuper@59522
    92
wneuper@59522
    93
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
    94
val t = (Thm.term_of o the o (parse thy)) "AA^^^7";
wneuper@59522
    95
if has_degree_in t v = 7 then () else error "has_degree_in (AA^^^7) AA";
wneuper@59522
    96
wneuper@59522
    97
(*----------*)
wneuper@59522
    98
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
    99
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x";
wneuper@59522
   100
if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*x) x";
wneuper@59522
   101
wneuper@59522
   102
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   103
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA";
wneuper@59522
   104
if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*AA) AA";
wneuper@59522
   105
wneuper@59522
   106
(*----------*)
wneuper@59522
   107
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
   108
val t = (Thm.term_of o the o (parse thy)) "(a*b+x)*x";
wneuper@59522
   109
if has_degree_in t v = ~1 then () else error "has_degree_in (a*b+x)*x() x";
wneuper@59522
   110
wneuper@59522
   111
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   112
val t = (Thm.term_of o the o (parse thy)) "(a*b+AA)*AA";
wneuper@59522
   113
if has_degree_in t v = ~1 then () else error "has_degree_in ((a*b+AA)*AA) AA";
wneuper@59522
   114
wneuper@59522
   115
(*----------*)
wneuper@59522
   116
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
   117
val t = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
   118
if has_degree_in t v = 1 then () else error "has_degree_in (x) x";
wneuper@59522
   119
wneuper@59522
   120
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   121
val t = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   122
if has_degree_in t v = 1 then () else error "has_degree_in (AA) AA";
wneuper@59522
   123
wneuper@59522
   124
(*----------*)
wneuper@59522
   125
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
   126
val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*x";
wneuper@59522
   127
if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*x) x";
wneuper@59522
   128
wneuper@59522
   129
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   130
val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*AA";
wneuper@59522
   131
if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*AA) AA";
wneuper@59522
   132
wneuper@59522
   133
"----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522
   134
"----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522
   135
"----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522
   136
val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
   137
wneuper@59522
   138
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x^^^7";
wneuper@59522
   139
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*x^^^7) x changed";
wneuper@59522
   140
wneuper@59522
   141
val t = (Thm.term_of o the o (parse thy)) "x^^^7";
wneuper@59522
   142
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (x^^^7) x changed";
wneuper@59522
   143
wneuper@59522
   144
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x";
wneuper@59522
   145
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*x) x changed";
wneuper@59522
   146
wneuper@59522
   147
val t = (Thm.term_of o the o (parse thy)) "(a*b+x)*x";
wneuper@59522
   148
if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+x)*x) x changed";
wneuper@59522
   149
wneuper@59522
   150
val t = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522
   151
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (x) x changed";
wneuper@59522
   152
wneuper@59522
   153
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)";
wneuper@59522
   154
if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) x changed";
wneuper@59522
   155
wneuper@59522
   156
val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*x";
wneuper@59522
   157
if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*x) x changed";
wneuper@59522
   158
wneuper@59522
   159
(*. . . . . . . . . . . . the same with Const ("Partial_Functions.AA", _) . . . . . . . . . . . *)
wneuper@59522
   160
val thy = @{theory Partial_Fractions}
wneuper@59522
   161
val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   162
wneuper@59522
   163
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA^^^7";
wneuper@59522
   164
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*AA^^^7) AA changed";
wneuper@59522
   165
wneuper@59522
   166
val t = (Thm.term_of o the o (parse thy)) "AA^^^7";
wneuper@59522
   167
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (AA^^^7) AA changed";
wneuper@59522
   168
wneuper@59522
   169
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA";
wneuper@59522
   170
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*AA) AA changed";
wneuper@59522
   171
wneuper@59522
   172
val t = (Thm.term_of o the o (parse thy)) "(a*b+AA)*AA";
wneuper@59522
   173
if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+AA)*AA) AA changed";
wneuper@59522
   174
wneuper@59522
   175
val t = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522
   176
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (AA) AA changed";
wneuper@59522
   177
wneuper@59522
   178
val t = (Thm.term_of o the o (parse thy)) "(a*b+c)";
wneuper@59522
   179
if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) AA changed";
wneuper@59522
   180
wneuper@59522
   181
val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*AA";
wneuper@59522
   182
if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*AA) AA changed";
wneuper@59522
   183
wneuper@59522
   184
"----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
wneuper@59522
   185
"----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
wneuper@59522
   186
"----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
wneuper@59522
   187
val thy = @{theory Partial_Fractions}
wneuper@59522
   188
val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*x + x^^^2) has_degree_in x) = 2";
wneuper@59522
   189
val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522
   190
wneuper@59522
   191
val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*AA + AA^^^2) has_degree_in AA) = 2";
wneuper@59522
   192
val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522
   193
wneuper@59522
   194
"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
wneuper@59522
   195
"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
wneuper@59522
   196
"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
wneuper@59522
   197
val t = (Thm.term_of o the o (parse thy)) "(-8 - 2*x + x^^^2) is_expanded_in x";
wneuper@59522
   198
val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
wneuper@59522
   199
if Rule.term2str t' = "-8 - 2 * x + x ^^^ 2 is_expanded_in x = True"
wneuper@59522
   200
         andalso id = "-8 - 2 * x + x ^^^ 2 is_expanded_in x = True"
wneuper@59522
   201
then () else error "eval_is_expanded_in x ..changed";
wneuper@59522
   202
wneuper@59522
   203
val thy = @{theory Partial_Fractions}
wneuper@59522
   204
val t = (Thm.term_of o the o (parse thy)) "(-8 - 2*AA + AA^^^2) is_expanded_in AA";
wneuper@59522
   205
val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
wneuper@59522
   206
if  Rule.term2str t' = "-8 - 2 * AA + AA ^^^ 2 is_expanded_in AA = True"
wneuper@59522
   207
          andalso id = "-8 - 2 * AA + AA ^^^ 2 is_expanded_in AA = True"
wneuper@59522
   208
then () else error "eval_is_expanded_in AA ..changed";
wneuper@59522
   209
wneuper@59522
   210
wneuper@59522
   211
val t = (Thm.term_of o the o (parse thy)) "(8 + 2*x + x^^^2) is_poly_in x";
wneuper@59522
   212
val SOME (id, t') = eval_is_poly_in 0 0 t 0;
wneuper@59522
   213
if  Rule.term2str t' = "8 + 2 * x + x ^^^ 2 is_poly_in x = True"
wneuper@59522
   214
          andalso id = "8 + 2 * x + x ^^^ 2 is_poly_in x = True"
wneuper@59522
   215
then () else error "is_poly_in x ..changed";
wneuper@59522
   216
wneuper@59522
   217
val t = (Thm.term_of o the o (parse thy)) "(8 + 2*AA + AA^^^2) is_poly_in AA";
wneuper@59522
   218
val SOME (id, t') = eval_is_poly_in 0 0 t 0;
wneuper@59522
   219
if  Rule.term2str t' = "8 + 2 * AA + AA ^^^ 2 is_poly_in AA = True"
wneuper@59522
   220
          andalso id = "8 + 2 * AA + AA ^^^ 2 is_poly_in AA = True"
wneuper@59522
   221
then () else error "is_poly_in AA ..changed";
wneuper@59522
   222
wneuper@59522
   223
wneuper@59522
   224
val thy = @{theory Partial_Fractions}
wneuper@59522
   225
val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*x + x^^^2) has_degree_in x) = 2";
wneuper@59522
   226
val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522
   227
wneuper@59522
   228
val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*AA + AA^^^2) has_degree_in AA) = 2";
wneuper@59522
   229
val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522
   230
neuper@42395
   231
"-------- investigate (new 2002) uniary minus -----------";
neuper@42395
   232
"-------- investigate (new 2002) uniary minus -----------";
neuper@42395
   233
"-------- investigate (new 2002) uniary minus -----------";
neuper@42395
   234
(*---------------------------------------------- vvvvvvvvvvvvvv -----------------------*)
wneuper@59188
   235
val t = (#prop o Thm.rep_thm) @{thm real_diff_0}; (*"0 - ?x = - ?x"*)
neuper@37906
   236
atomty t;
wneuper@59117
   237
(*
wneuper@59117
   238
*** Const (HOL.Trueprop, bool => prop)
wneuper@59117
   239
*** . Const (HOL.eq, real => real => bool)
wneuper@59117
   240
*** . . Const (Groups.minus_class.minus, real => real => real)
wneuper@59117
   241
*** . . . Const (Groups.zero_class.zero, real)
neuper@37906
   242
*** . . . Var ((x, 0), real)
wneuper@59117
   243
*** . . Const (Groups.uminus_class.uminus, real => real)
wneuper@59117
   244
*** . . . Var ((x, 0), real)
wneuper@59117
   245
*)
neuper@42395
   246
case t of
neuper@42395
   247
  Const ("HOL.Trueprop", _) $
wneuper@59117
   248
    (Const ("HOL.eq", _) $ 
wneuper@59117
   249
      (Const ("Groups.minus_class.minus", _) $ Const ("Groups.zero_class.zero", _) $ 
wneuper@59117
   250
        Var (("x", 0), _)) $
wneuper@59117
   251
             (Const ("Groups.uminus_class.uminus", _) $ Var (("x", 0), _))) => ()
neuper@42395
   252
| _ => error "internal representation of \"0 - ?x = - ?x\" changed";
neuper@37906
   253
neuper@42395
   254
(*----------------------------------- vvvv --------------------------------------------*)
wneuper@59188
   255
val t = (Thm.term_of o the o (parse thy)) "-1";
neuper@37906
   256
atomty t;
neuper@37906
   257
(*** -------------
neuper@37906
   258
*** Free ( -1, real)                      *)
neuper@42395
   259
case t of
neuper@42395
   260
  Free ("-1", _) => ()
neuper@42395
   261
| _ => error "internal representation of \"-1\" changed";
neuper@42395
   262
(*----------------------------------- vvvvv -------------------------------------------*)
wneuper@59188
   263
val t = (Thm.term_of o the o (parse thy)) "- 1";
neuper@37906
   264
atomty t;
wneuper@59117
   265
(*
wneuper@59117
   266
*** 
wneuper@59117
   267
*** Free (-1, real)
wneuper@59117
   268
*** 
wneuper@59117
   269
*)
neuper@42395
   270
case t of
wneuper@59117
   271
 Free ("-1", _) => ()
neuper@42395
   272
| _ => error "internal representation of \"- 1\" changed";
neuper@37906
   273
neuper@42395
   274
"======= these external values all have the same internal representation";
neuper@42395
   275
(* "1-x" causes syntyx error --- binary minus detected by blank inbetween !!!*)
neuper@42395
   276
(*----------------------------------- vvvvv -------------------------------------------*)
wneuper@59188
   277
val t = (Thm.term_of o the o (parse thy)) "-x";
neuper@37906
   278
atomty t;
neuper@37906
   279
(**** -------------
neuper@37906
   280
*** Free ( -x, real)*)
neuper@42395
   281
case t of
neuper@42395
   282
  Const ("Groups.uminus_class.uminus", _) $ Free ("x", _) => ()
neuper@42395
   283
| _ => error "internal representation of \"-x\" changed";
neuper@42395
   284
(*----------------------------------- vvvvv -------------------------------------------*)
wneuper@59188
   285
val t = (Thm.term_of o the o (parse thy)) "- x";
neuper@37906
   286
atomty t;
neuper@37906
   287
(**** -------------
neuper@37906
   288
*** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*)
neuper@42395
   289
case t of
neuper@42395
   290
  Const ("Groups.uminus_class.uminus", _) $ Free ("x", _) => ()
neuper@42395
   291
| _ => error "internal representation of \"- x\" changed";
neuper@42395
   292
(*----------------------------------- vvvvvv ------------------------------------------*)
wneuper@59188
   293
val t = (Thm.term_of o the o (parse thy)) "-(x)";
neuper@37906
   294
atomty t;
neuper@37906
   295
(**** -------------
neuper@37906
   296
*** Free ( -x, real)*)
neuper@42395
   297
case t of
neuper@42395
   298
  Const ("Groups.uminus_class.uminus", _) $ Free ("x", _) => ()
neuper@42395
   299
| _ => error "internal representation of \"-(x)\" changed";
neuper@37906
   300
neuper@38036
   301
"-------- check make_polynomial with simple terms -------";
neuper@38036
   302
"-------- check make_polynomial with simple terms -------";
neuper@38036
   303
"-------- check make_polynomial with simple terms -------";
neuper@38036
   304
"----- check 1 ---";
neuper@38036
   305
val t = str2term "2*3*a";
neuper@38036
   306
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
neuper@38036
   307
if term2str t = "6 * a" then () else error "check make_polynomial 1";
neuper@38036
   308
neuper@38036
   309
"----- check 2 ---";
neuper@38036
   310
val t = str2term "2*a + 3*a";
neuper@38036
   311
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
neuper@38036
   312
if term2str t = "5 * a" then () else error "check make_polynomial 2";
neuper@38036
   313
neuper@38036
   314
"----- check 3 ---";
neuper@38036
   315
val t = str2term "2*a + 3*a + 3*a";
neuper@38036
   316
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
neuper@38036
   317
if term2str t = "8 * a" then () else error "check make_polynomial 3";
neuper@38036
   318
neuper@38036
   319
"----- check 4 ---";
neuper@38036
   320
val t = str2term "3*a - 2*a";
neuper@38036
   321
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
neuper@38036
   322
if term2str t = "a" then () else error "check make_polynomial 4";
neuper@38036
   323
neuper@38036
   324
"----- check 5 ---";
neuper@38036
   325
val t = str2term "4*(3*a - 2*a)";
neuper@38036
   326
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
neuper@38036
   327
if term2str t = "4 * a" then () else error "check make_polynomial 5";
neuper@38036
   328
neuper@38036
   329
"----- check 6 ---";
neuper@38036
   330
val t = str2term "4*(3*a^^^2 - 2*a^^^2)";
neuper@38036
   331
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
neuper@38036
   332
if term2str t = "4 * a ^^^ 2" then () else error "check make_polynomial 6";
neuper@38036
   333
neuper@38036
   334
"-------- fun is_multUnordered --------------------------";
neuper@38036
   335
"-------- fun is_multUnordered --------------------------";
neuper@38036
   336
"-------- fun is_multUnordered --------------------------";
wneuper@59592
   337
val thy = @{theory "Isac_Knowledge"};
neuper@38040
   338
"===== works for a simple example, see rewrite.sml -- fun app_rev ===";
neuper@38040
   339
val t = str2term "x^^^2 * x";
neuper@38040
   340
val SOME (t', _) = rewrite_set_ thy true order_mult_ t;
neuper@38040
   341
if term2str t' = "x * x ^^^ 2" then ()
neuper@38040
   342
else error "poly.sml Poly.is'_multUnordered doesn't work";
neuper@38040
   343
neuper@38040
   344
(* 100928 trace_rewrite shows the first occurring difference in 267b:
neuper@38036
   345
###  rls: order_mult_ on: 5 * x ^^^ 2 * (2 * x ^^^ 7) + 5 * x ^^^ 2 * 3 + (6 * x ^^^ 7 + 9) + (-1 * (3 * x ^^^ 5 * (6 * x ^^^ 4)) + -1 * (3 * x ^^^ 5 * -1) +
neuper@38036
   346
 (-48 * x ^^^ 4 + 8))
neuper@38036
   347
######  rls: e_rls-is_multUnordered on: p is_multUnordered
neuper@38036
   348
#######  try calc: Poly.is'_multUnordered'
neuper@38036
   349
=======  calc. to: False  !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!!
neuper@38036
   350
*)
neuper@38036
   351
val t = str2term "5 * x ^^^ 2 * (2 * x ^^^ 7) + 5 * x ^^^ 2 * 3 + (6 * x ^^^ 7 + 9) + (-1 * (3 * x ^^^ 5 * (6 * x ^^^ 4)) + -1 * (3 * x ^^^ 5 * -1) +  (-48 * x ^^^ 4 + 8))";
neuper@38036
   352
neuper@38036
   353
"----- is_multUnordered ---";
neuper@38036
   354
val tsort = sort_variables t;
neuper@38036
   355
term2str tsort = "2 * (5 * (x ^^^ 2 * x ^^^ 7)) + 3 * (5 * x ^^^ 2) + 6 * x ^^^ 7 + 9 +\n-1 * (3 * (6 * (x ^^^ 4 * x ^^^ 5))) +\n-1 * (-1 * (3 * x ^^^ 5)) +\n-48 * x ^^^ 4 +\n8";
neuper@38036
   356
is_polyexp t;
neuper@38036
   357
tsort = t;
neuper@38036
   358
is_polyexp t andalso not (t = sort_variables t);
neuper@38036
   359
if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1";
neuper@38036
   360
neuper@38036
   361
"----- eval_is_multUnordered ---";
neuper@38036
   362
val tm = str2term "(5 * x ^^^ 2 * (2 * x ^^^ 7) + 5 * x ^^^ 2 * 3 + (6 * x ^^^ 7 + 9) + (-1 * (3 * x ^^^ 5 * (6 * x ^^^ 4)) + -1 * (3 * x ^^^ 5 * -1) +  (-48 * x ^^^ 4 + 8))) is_multUnordered";
neuper@38036
   363
case eval_is_multUnordered "testid" "" tm thy of
neuper@41924
   364
    SOME (_, Const ("HOL.Trueprop", _) $ 
neuper@41922
   365
                   (Const ("HOL.eq", _) $
neuper@38036
   366
                          (Const ("Poly.is'_multUnordered", _) $ _) $ 
neuper@41928
   367
                          Const ("HOL.True", _))) => ()
neuper@38036
   368
  | _ => error "poly.sml diff. eval_is_multUnordered";
neuper@38036
   369
neuper@38040
   370
"----- rewrite_set_ STILL DIDN'T WORK";
neuper@38040
   371
val SOME (t, _) = rewrite_set_ thy true order_mult_ t;
neuper@38040
   372
term2str t;
neuper@38036
   373
neuper@38036
   374
"-------- examples from textbook Schalk I ---------------";
neuper@38036
   375
"-------- examples from textbook Schalk I ---------------";
neuper@38036
   376
"-------- examples from textbook Schalk I ---------------";
neuper@38036
   377
"-----SPB Schalk I p.63 No.267b ---";
neuper@42395
   378
val t = str2term "(5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1)";
neuper@37926
   379
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   380
if (term2str t) = "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
neuper@42395
   381
then () else error "poly.sml: diff.behav. in make_polynomial 1";
neuper@37906
   382
neuper@38036
   383
"-----SPB Schalk I p.63 No.275b ---";
neuper@42395
   384
val t = str2term "(3*x^^^2 - 2*x*y + y^^^2) * (x^^^2 - 2*y^^^2)";
neuper@42395
   385
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@42395
   386
if (term2str t) = ("3 * x ^^^ 4 + -2 * x ^^^ 3 * y + -5 * x ^^^ 2 * y ^^^ 2 + " ^
neuper@42395
   387
  "4 * x * y ^^^ 3 +\n-2 * y ^^^ 4")
neuper@42395
   388
then () else error "poly.sml: diff.behav. in make_polynomial 2";
neuper@37906
   389
neuper@38036
   390
"-----SPB Schalk I p.63 No.279b ---";
neuper@42395
   391
val t = str2term "(x-a)*(x-b)*(x-c)*(x-d)";
neuper@42395
   392
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906
   393
if (term2str t) = 
neuper@42395
   394
  ("a * b * c * d + -1 * a * b * c * x + -1 * a * b * d * x + a * b * x ^^^ 2 +\n" ^
neuper@42395
   395
  "-1 * a * c * d * x +\na * c * x ^^^ 2 +\na * d * x ^^^ 2 +\n-1 * a * x ^^^ 3 +\n" ^
neuper@42395
   396
  "-1 * b * c * d * x +\nb * c * x ^^^ 2 +\nb * d * x ^^^ 2 +\n-1 * b * x ^^^ 3 +\n" ^
neuper@42395
   397
  "c * d * x ^^^ 2 +\n-1 * c * x ^^^ 3 +\n-1 * d * x ^^^ 3 +\nx ^^^ 4")
neuper@42395
   398
then () else error "poly.sml: diff.behav. in make_polynomial 3";
neuper@37906
   399
neuper@38036
   400
"-----SPB Schalk I p.63 No.291 ---";
neuper@42395
   401
val t = str2term "(5+96*x^^^3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (-15*x*(-8*x- 5)))";
neuper@42395
   402
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@42395
   403
if (term2str t) = "50 + -770 * x + 4520 * x ^^^ 2 + -16320 * x ^^^ 3 + -26880 * x ^^^ 4"
neuper@42395
   404
then () else error "poly.sml: diff.behav. in make_polynomial 4";
neuper@37906
   405
neuper@38036
   406
"-----SPB Schalk I p.64 No.295c ---";
neuper@42395
   407
val t = str2term "(13*a^^^4*b^^^9*c - 12*a^^^3*b^^^6*c^^^9)^^^2";
neuper@42395
   408
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@42395
   409
if (term2str t) = ("169 * a ^^^ 8 * b ^^^ 18 * c ^^^ 2 + -312 * a ^^^ 7 * b ^^^ 15 * c ^^^ 10" ^
neuper@42395
   410
  " +\n144 * a ^^^ 6 * b ^^^ 12 * c ^^^ 18")
neuper@42395
   411
then ()else error "poly.sml: diff.behav. in make_polynomial 5";
neuper@37906
   412
neuper@38036
   413
"-----SPB Schalk I p.64 No.299a ---";
neuper@42395
   414
val t = str2term "(x - y)*(x + y)";
neuper@42395
   415
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@42395
   416
if (term2str t) = "x ^^^ 2 + -1 * y ^^^ 2"
neuper@42395
   417
then () else error "poly.sml: diff.behav. in make_polynomial 6";
neuper@37906
   418
neuper@38036
   419
"-----SPB Schalk I p.64 No.300c ---";
neuper@42395
   420
val t = str2term "(3*x^^^2*y - 1)*(3*x^^^2*y + 1)";
neuper@42395
   421
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@42395
   422
if (term2str t) = "-1 + 9 * x ^^^ 4 * y ^^^ 2"
neuper@42395
   423
then () else error "poly.sml: diff.behav. in make_polynomial 7";
neuper@37906
   424
neuper@38036
   425
"-----SPB Schalk I p.64 No.302 ---";
neuper@37906
   426
val t = str2term
neuper@42395
   427
  "(13*x^^^2 + 5)*(13*x^^^2 - 5) - (5*x^^^2 + 3)*(5*x^^^2 - 3) - (12*x^^^2 + 4)*(12*x^^^2 - 4)";
neuper@42395
   428
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@42395
   429
if term2str t = "0"
neuper@42395
   430
then () else error "poly.sml: diff.behav. in make_polynomial 8";
neuper@42395
   431
(* RL?MG?: Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *)
neuper@37906
   432
neuper@38036
   433
"-----SPB Schalk I p.64 No.306a ---";
neuper@37906
   434
val t = str2term "((x^^^2 + 1)*(x^^^2 - 1))^^^2";
neuper@37926
   435
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   436
if (term2str t) = "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8" then ()
neuper@42395
   437
else error "poly.sml: diff.behav. in 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 = -2 * x ^^^ 4";
neuper@37906
   438
neuper@37906
   439
(*WN071729 when reducing "rls reduce_012_" for Schaerding,
neuper@37906
   440
the above resulted in the term below ... but reduces from then correctly*)
neuper@37906
   441
val t = str2term "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8";
neuper@37926
   442
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   443
if (term2str t) = "1 + -2 * x ^^^ 4 + x ^^^ 8"
neuper@42395
   444
then () else error "poly.sml: diff.behav. in make_polynomial 9b";
neuper@37906
   445
neuper@38036
   446
"-----SPB Schalk I p.64 No.296a ---";
neuper@37906
   447
val t = str2term "(x - a)^^^3";
neuper@37926
   448
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   449
if (term2str t) = "-1 * a ^^^ 3 + 3 * a ^^^ 2 * x + -3 * a * x ^^^ 2 + x ^^^ 3"
neuper@38031
   450
then () else error "poly.sml: diff.behav. in make_polynomial 10";
neuper@37906
   451
neuper@38036
   452
"-----SPB Schalk I p.64 No.296c ---";
neuper@37906
   453
val t = str2term "(-3*x - 4*y)^^^3";
neuper@37926
   454
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   455
if (term2str t) = "-27 * x ^^^ 3 + -108 * x ^^^ 2 * y + -144 * x * y ^^^ 2 + -64 * y ^^^ 3"
neuper@38031
   456
then () else error "poly.sml: diff.behav. in make_polynomial 11";
neuper@37906
   457
neuper@38036
   458
"-----SPB Schalk I p.62 No.242c ---";
neuper@37906
   459
val t = str2term "x^^^(-4)*(x^^^(-4)*y^^^(-2))^^^(-1)*y^^^(-2)";
neuper@37926
   460
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   461
if (term2str t) = "1"
neuper@42395
   462
then () else error "poly.sml: diff.behav. in make_polynomial 12";
neuper@37906
   463
neuper@38036
   464
"-----SPB Schalk I p.60 No.209a ---";
neuper@37906
   465
val t = str2term "a^^^(7-x) * a^^^x";
neuper@37926
   466
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   467
if term2str t = "a ^^^ 7"
neuper@42395
   468
then () else error "poly.sml: diff.behav. in make_polynomial 13";
neuper@37906
   469
neuper@38036
   470
"-----SPB Schalk I p.60 No.209d ---";
neuper@37906
   471
val t = str2term "d^^^x * d^^^(x+1) * d^^^(2 - 2*x)";
neuper@37926
   472
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   473
if term2str t = "d ^^^ 3"
neuper@42395
   474
then () else error "poly.sml: diff.behav. in make_polynomial 14";
neuper@37906
   475
neuper@37906
   476
(*---------------------------------------------------------------------*)
neuper@42395
   477
(*---------------- ?RL?Bsple bei denen es Probleme gibt----------------*)
neuper@37906
   478
(*---------------------------------------------------------------------*)
neuper@38036
   479
"-----Schalk I p.64 No.303 ---";
neuper@37906
   480
val t = str2term "(a + 2*b)*(a^^^2 + 4*b^^^2)*(a - 2*b) - (a - 6*b)*(a^^^2 + 36*b^^^2)*(a + 6*b)";
neuper@37926
   481
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@42395
   482
if term2str t = "1280 * b ^^^ 4"
neuper@42395
   483
then () else error "poly.sml: diff.behav. in make_polynomial 14b";
neuper@37906
   484
(* Richtig - aber Binomische Formel wurde nicht verwendet! *)
neuper@37906
   485
neuper@37906
   486
(*--------------------------------------------------------------------*)
neuper@37906
   487
(*----------------------- Eigene Beispiele ---------------------------*)
neuper@37906
   488
(*--------------------------------------------------------------------*)
neuper@38036
   489
"-----SPO ---";
neuper@37906
   490
val t = str2term "a^^^2*a^^^(-2)";
neuper@37926
   491
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   492
if term2str t = "1" then ()
neuper@38031
   493
else error "poly.sml: diff.behav. in make_polynomial 15";
neuper@38036
   494
"-----SPO ---";
neuper@37906
   495
val t = str2term "a + a + a";
neuper@37926
   496
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   497
if term2str t = "3 * a" then ()
neuper@38031
   498
else error "poly.sml: diff.behav. in make_polynomial 16";
neuper@38036
   499
"-----SPO ---";
neuper@37906
   500
val t = str2term "a + b + b + b";
neuper@37926
   501
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   502
if term2str t = "a + 3 * b" then ()
neuper@38031
   503
else error "poly.sml: diff.behav. in make_polynomial 17";
neuper@38036
   504
"-----SPO ---";
neuper@37906
   505
val t = str2term "a^^^2*b*b^^^(-1)";
neuper@37926
   506
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   507
if term2str t = "a ^^^ 2" then ()
neuper@38031
   508
else error "poly.sml: diff.behav. in make_polynomial 18";
neuper@38036
   509
"-----SPO ---";
neuper@37906
   510
val t = str2term "a^^^2*a^^^(-2)";
neuper@37926
   511
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   512
if (term2str t) = "1" then ()
neuper@38031
   513
else error "poly.sml: diff.behav. in make_polynomial 19";
neuper@38036
   514
"-----SPO ---";
neuper@37906
   515
val t = str2term "b + a - b";
neuper@37926
   516
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   517
if (term2str t) = "a" then ()
neuper@38031
   518
else error "poly.sml: diff.behav. in make_polynomial 20";
neuper@38036
   519
"-----SPO ---";
neuper@37906
   520
val t = str2term "b * a * a";
neuper@37926
   521
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   522
if term2str t = "a ^^^ 2 * b" then ()
neuper@38031
   523
else error "poly.sml: diff.behav. in make_polynomial 21";
neuper@38036
   524
"-----SPO ---";
neuper@37906
   525
val t = str2term "(a^^^2)^^^3";
neuper@37926
   526
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   527
if term2str t = "a ^^^ 6" then ()
neuper@38031
   528
else error "poly.sml: diff.behav. in make_polynomial 22";
neuper@38036
   529
"-----SPO ---";
neuper@37906
   530
val t = str2term "x^^^2 * y^^^2 + x * x^^^2 * y";
neuper@37926
   531
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   532
if term2str t = "x ^^^ 3 * y + x ^^^ 2 * y ^^^ 2" then ()
neuper@38031
   533
else error "poly.sml: diff.behav. in make_polynomial 23";
neuper@38036
   534
"-----SPO ---";
wneuper@59188
   535
val t = (Thm.term_of o the o (parse thy)) "a^^^2 * (-a)^^^2";
neuper@37926
   536
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   537
if (term2str t) = "a ^^^ 4" then ()
neuper@38031
   538
else error "poly.sml: diff.behav. in make_polynomial 24";
neuper@38036
   539
"-----SPO ---";
neuper@37906
   540
val t = str2term "a * b * b^^^(-1) + a";
neuper@37926
   541
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   542
if (term2str t) = "2 * a" then ()
neuper@38031
   543
else error "poly.sml: diff.behav. in make_polynomial 25";
neuper@38036
   544
"-----SPO ---";
neuper@37906
   545
val t = str2term "a*c*b^^^(2*n) + 3*a + 5*b^^^(2*n)*c*b";
neuper@37926
   546
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906
   547
if (term2str t) = "3 * a + 5 * b ^^^ (1 + 2 * n) * c + a * b ^^^ (2 * n) * c"
neuper@38031
   548
then () else error "poly.sml: diff.behav. in make_polynomial 26";
neuper@37906
   549
neuper@42395
   550
(*MG030627 -------------vvv-: Verschachtelte Terme -----------*)
neuper@38036
   551
"-----SPO ---";
neuper@37906
   552
val t = str2term "(1 + (x*y*a) + x)^^^(1 + (x*y*a) + x)";
neuper@42395
   553
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906
   554
if term2str t = "(1 + x + a * x * y) ^^^ (1 + x + a * x * y)"
neuper@42395
   555
then () else error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*)
neuper@42395
   556
neuper@37906
   557
val t = str2term "(1 + x*(y*z)*zz)^^^(1 + x*(y*z)*zz)";
neuper@42395
   558
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906
   559
if term2str t = "(1 + x * y * z * zz) ^^^ (1 + x * y * z * zz)"
neuper@42395
   560
then () else error "poly.sml: diff.behav. in make_polynomial 28";
neuper@37906
   561
neuper@38036
   562
"-------- check pbl  'polynomial simplification' --------";
neuper@38036
   563
"-------- check pbl  'polynomial simplification' --------";
neuper@38036
   564
"-------- check pbl  'polynomial simplification' --------";
neuper@42395
   565
val fmz = ["Term ((5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1))", "normalform N"];
neuper@38036
   566
"-----0 ---";
neuper@37906
   567
case refine fmz ["polynomial","simplification"]of
neuper@37906
   568
    [Matches (["polynomial", "simplification"], _)] => ()
neuper@38031
   569
  | _ => error "poly.sml diff.behav. in check pbl, refine";
neuper@37906
   570
(*...if there is an error, then ...*)
neuper@37906
   571
neuper@38036
   572
"-----1 ---";
wneuper@59348
   573
(*default_print_depth 7;*)
neuper@37906
   574
val pbt = get_pbt ["polynomial","simplification"];
wneuper@59348
   575
(*default_print_depth 3;*)
neuper@37906
   576
(*if there is ...
neuper@37906
   577
> val NoMatch' {Given=gi, Where=wh, Find=fi,...} = match_pbl fmz pbt;
neuper@37906
   578
... then trace_rewrite:*)
neuper@37906
   579
neuper@38036
   580
"-----2 ---";
neuper@52101
   581
trace_rewrite := false;
neuper@37906
   582
match_pbl fmz pbt;
neuper@42395
   583
trace_rewrite := false;
neuper@37906
   584
(*... if there is no rewrite, then there is something wrong with prls*)
neuper@52101
   585
                              
neuper@38036
   586
"-----3 ---";
wneuper@59348
   587
(*default_print_depth 7;*)
neuper@37906
   588
val prls = (#prls o get_pbt) ["polynomial","simplification"];
wneuper@59348
   589
(*default_print_depth 3;*)
neuper@42395
   590
val t = str2term "((5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1)) is_polyexp";
neuper@37926
   591
val SOME (t',_) = rewrite_set_ thy false prls t;
neuper@48760
   592
if t' = @{term True} then () 
neuper@38031
   593
else error "poly.sml: diff.behav. in check pbl 'polynomial..";
neuper@42395
   594
(*... if this works, but --1-- does still NOT work, check types:*)
neuper@37906
   595
neuper@38036
   596
"-----4 ---";
neuper@42395
   597
(*show_types:=true;*)
neuper@37906
   598
(*
neuper@37906
   599
> val NoMatch' {Given=gi, Where=wh, Find=fi,...} = match_pbl fmz pbt;
neuper@37906
   600
val wh = [False "(t_::real => real) (is_polyexp::real)"]
neuper@37906
   601
......................^^^^^^^^^^^^...............^^^^*)
neuper@37906
   602
val Matches' _ = match_pbl fmz pbt;
neuper@42395
   603
(*show_types:=false;*)
neuper@37906
   604
walther@59787
   605
neuper@38036
   606
"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@38036
   607
"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@38036
   608
"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@42395
   609
val fmz = ["Term ((5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1))", "normalform N"];
neuper@37906
   610
val (dI',pI',mI') =
neuper@37991
   611
  ("Poly",["polynomial","simplification"],
neuper@37906
   612
   ["simplification","for_polynomials"]);
neuper@37906
   613
val p = e_pos'; val c = []; 
neuper@37906
   614
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59787
   615
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Given "Term\n ((5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n  (3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1))"*)
walther@59787
   616
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Find "normalform N"*)
walther@59787
   617
walther@59787
   618
(*+*)if itms2str_ ctxt (get_obj g_pbl pt (fst p)) =
walther@59787
   619
(*+*)  "[\n(0 ,[] ,false ,#Find ,Inc normalform ,(??.empty, [])),\n(1 ,[1] ,true ,#Given ,Cor Term\n ((5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n  (3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1)) ,(t_t, [(5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n(3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1)]))]"
walther@59787
   620
(*+*)then () else error "No.267b: itm list CHANGED";
walther@59787
   621
walther@59787
   622
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*nxt = Specify_Theory "Poly"*)
walther@59787
   623
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Problem ["polynomial", "simplification"]*)
walther@59787
   624
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Method ["simplification", "for_polynomials"]*)
walther@59787
   625
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Apply_Method ["simplification", "for_polynomials"]*)
walther@59787
   626
(*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Rewrite_Set "norm_Poly"*)
walther@59787
   627
walther@59787
   628
(*+*)if f2str f = "(5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n(3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1)"
walther@59787
   629
(*+*)then () else error "";
walther@59787
   630
walther@59787
   631
(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Empty_Tac: ERROR DETECTED Feb.2020*)
walther@59787
   632
walther@59787
   633
(*+*)if f2str f = "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
walther@59787
   634
(*+*)then () else error "";
walther@59787
   635
walther@59787
   636
(*[1], Res* )val (p,_,f,nxt,_,pt) = me nxt p c pt;( *SINCE Feb.2020 Lucin.find_next_step without result*)
walther@59787
   637
walther@59787
   638
(*+*)if f2str f = "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
walther@59787
   639
(*+*)then () else error "poly.sml diff.behav. in me Schalk I p.63 No.267b";
walther@59787
   640
neuper@37906
   641
neuper@38036
   642
"-------- interSteps for Schalk 299a --------------------";
neuper@38036
   643
"-------- interSteps for Schalk 299a --------------------";
neuper@38036
   644
"-------- interSteps for Schalk 299a --------------------";
s1210629013@55445
   645
reset_states ();
neuper@37906
   646
CalcTree
neuper@42395
   647
[(["Term ((x - y)*(x + (y::real)))", "normalform N"], 
neuper@37991
   648
  ("Poly",["polynomial","simplification"],
neuper@37906
   649
  ["simplification","for_polynomials"]))];
neuper@37906
   650
Iterator 1;
neuper@37906
   651
moveActiveRoot 1;
wneuper@59248
   652
autoCalculate 1 CompleteCalc;
neuper@37906
   653
val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@37906
   654
neuper@37906
   655
interSteps 1 ([1],Res)(*<ERROR> syserror in detailstep </ERROR>*);
neuper@37906
   656
val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@37906
   657
if existpt' ([1,1], Frm) pt then ()
neuper@38031
   658
else error "poly.sml: interSteps doesnt work again 1";
neuper@37906
   659
neuper@37906
   660
interSteps 1 ([1,1],Res)(*<ERROR> syserror in detailstep </ERROR>*);
neuper@37906
   661
val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@42395
   662
(*============ inhibit exn WN120316 ==============================================
neuper@37906
   663
if existpt' ([1,1,1], Frm) pt then ()
neuper@38031
   664
else error "poly.sml: interSteps doesnt work again 2";
neuper@42395
   665
============ inhibit exn WN120316 ==============================================*)
neuper@37906
   666
neuper@38036
   667
"-------- norm_Poly NOT COMPLETE ------------------------";
neuper@38036
   668
"-------- norm_Poly NOT COMPLETE ------------------------";
neuper@38036
   669
"-------- norm_Poly NOT COMPLETE ------------------------";
wneuper@59529
   670
val thy = @{theory Simplify};
wneuper@59529
   671
wneuper@59529
   672
val SOME (f',_) = rewrite_set_ thy false norm_Poly
neuper@42395
   673
(str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben");
wneuper@59529
   674
if term2str f' = "L = 2 * 2 * (k + -2 * q) + senkrecht + oben"
neuper@42395
   675
then ((*norm_Poly NOT COMPLETE -- TODO MG*))
neuper@42395
   676
else error "norm_Poly changed behavior";
neuper@38036
   677
neuper@38036
   678
"-------- ord_make_polynomial ---------------------------";
neuper@38036
   679
"-------- ord_make_polynomial ---------------------------";
neuper@38036
   680
"-------- ord_make_polynomial ---------------------------";
neuper@37906
   681
val t1 = str2term "2 * b + (3 * a + 3 * b)";
neuper@37906
   682
val t2 = str2term "3 * a + 3 * b + 2 * b";
neuper@37906
   683
neuper@42395
   684
if ord_make_polynomial true thy [] (t1, t2) then ()
neuper@38031
   685
else error "poly.sml: diff.behav. in ord_make_polynomial";
neuper@37906
   686
neuper@37906
   687
(*WN071202: ^^^ why then is there no rewriting ...*)
neuper@37906
   688
val term = str2term "2*b + (3*a + 3*b)";
wneuper@59592
   689
val NONE = rewrite_set_ (@{theory "Isac_Knowledge"}) false order_add_mult term;
neuper@37906
   690
neuper@37906
   691
(*or why is there no rewriting this way...*)
neuper@37906
   692
val t1 = str2term "2 * b + (3 * a + 3 * b)";
neuper@37906
   693
val t2 = str2term "3 * a + (2 * b + 3 * b)";
neuper@37906
   694