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