test/Tools/isac/Knowledge/diff.sml
author wneuper <walther.neuper@jku.at>
Tue, 27 Jul 2021 12:32:43 +0200
changeset 60341 59106f9e08cc
parent 60340 0ee698b0a703
child 60350 3e9b709fc755
permissions -rw-r--r--
//test/../diff.sml works again
walther@60330
     1
(* Title: test/Tools/isac/Knowledge/diff.sml
walther@60330
     2
   Author: Walther Neuper
walther@60330
     3
   Use is subject to license terms.
neuper@37906
     4
*)
walther@60330
     5
"-----------------------------------------------------------------------------------------------";
walther@60330
     6
"-----------------------------------------------------------------------------------------------";
walther@60330
     7
"table of contents -----------------------------------------------------------------------------";
walther@60330
     8
"-----------------------------------------------------------------------------------------------";
neuper@38081
     9
"----------- problemtype --------------------------------";
neuper@38081
    10
"----------- for correction of diff_const ---------------";
neuper@38081
    11
"----------- for correction of diff_quot ----------------";
neuper@38081
    12
"----------- differentiate by rewrite -------------------";
neuper@38081
    13
"----------- differentiate: me (*+ tacs input*) ---------";
neuper@38081
    14
"----------- 1.5.02 me from script ----------------------";
neuper@38081
    15
"----------- primed id ----------------------------------";
neuper@38081
    16
"----------- diff_conv, sym_diff_conv -------------------";
walther@60242
    17
"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
wneuper@59248
    18
"----------- autoCalculate diff after_simplification ----";
wneuper@59248
    19
"----------- autoCalculate differentiate_equality -------";
neuper@38081
    20
"----------- tests for examples -------------------------";
walther@60242
    21
"------------inform for x \<up> 2+x+1 -------------------------";
neuper@38081
    22
"--------------------------------------------------------";
neuper@38081
    23
"--------------------------------------------------------";
neuper@38081
    24
"--------------------------------------------------------";
neuper@37906
    25
neuper@37906
    26
neuper@41929
    27
val thy = @{theory "Diff"};
neuper@37906
    28
neuper@38081
    29
"----------- problemtype --------------------------------";
neuper@38081
    30
"----------- problemtype --------------------------------";
neuper@38081
    31
"----------- problemtype --------------------------------";
neuper@37994
    32
val pbt = {Given =["functionTerm f_f", "differentiateFor v_v"],
neuper@37906
    33
	   Where =[],
neuper@37994
    34
	   Find  =["derivative f_f'"],
neuper@37906
    35
	   With  =[],
neuper@37906
    36
	   Relate=[]}:string ppc;
walther@60230
    37
val chkpbt = ((map (the o (TermC.parse thy))) o P_Model.to_list) pbt;
neuper@37906
    38
walther@60242
    39
val org = ["functionTerm (d_d x (x \<up> 2 + 3 * x + 4))", 
walther@59997
    40
	   "differentiateFor x", "derivative f_f'"];
walther@60230
    41
val chkorg = map (the o (TermC.parse thy)) org;
neuper@37906
    42
walther@59997
    43
Problem.from_store ["derivative_of", "function"];
walther@60154
    44
MethodC.from_store ["diff", "differentiate_on_R"];
neuper@37906
    45
neuper@38081
    46
"----------- for correction of diff_const ---------------";
neuper@38081
    47
"----------- for correction of diff_const ---------------";
neuper@38081
    48
"----------- for correction of diff_const ---------------";
neuper@37906
    49
(*re-evaluate this file, otherwise > *** ME_Isa: 'erls' not known*)
walther@60340
    50
val t = (Thm.term_of o the o (TermC.parse thy)) "Not (x =!= a)";
wneuper@59384
    51
case rewrite_set_ thy false erls_diff t of
wenzelm@60309
    52
  SOME (Const (\<^const_name>\<open>True\<close>, _), []) => ()
wneuper@59384
    53
| _ => error "rewrite_set_  Not (x =!= a)  changed";
neuper@37906
    54
walther@60230
    55
val t =(Thm.term_of o the o (TermC.parse thy)) "2 is_const";
wneuper@59384
    56
case rewrite_set_ thy false erls_diff t of
wenzelm@60309
    57
  SOME (Const (\<^const_name>\<open>True\<close>, _), []) => ()
wneuper@59384
    58
| _ => error "rewrite_set_   2 is_const   changed";
neuper@37906
    59
walther@59965
    60
val thm = @{thm diff_const};
walther@60340
    61
val ct = (Thm.term_of o the o (TermC.parse thy)) "d_d x x";
walther@59656
    62
val subst = [(@{term "bdv::real"}, @{term "x::real"})];
wneuper@59384
    63
val NONE = (rewrite_inst_ thy tless_true erls_diff false subst thm ct);
neuper@37906
    64
neuper@38081
    65
"----------- for correction of diff_quot ----------------";
neuper@38081
    66
"----------- for correction of diff_quot ----------------";
neuper@38081
    67
"----------- for correction of diff_quot ----------------";
wneuper@59384
    68
val thy = @{theory "Diff"};
walther@60340
    69
val ct = (Thm.term_of o the o (TermC.parse thy)) "Not (x = 0)";
wneuper@59384
    70
rewrite_set_ thy false erls_diff ct;
neuper@37906
    71
walther@60340
    72
val ct = (Thm.term_of o the o (TermC.parse thy)) "d_d x ((x+1) / (x - 1))";
wneuper@59384
    73
val thm = @{thm diff_quot};
neuper@37926
    74
val SOME (ctt,_) =
wneuper@59384
    75
    (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
neuper@37906
    76
neuper@38081
    77
"----------- differentiate by rewrite -------------------";
neuper@38081
    78
"----------- differentiate by rewrite -------------------";
neuper@38081
    79
"----------- differentiate by rewrite -------------------";
wneuper@59384
    80
val thy = @{theory "Diff"};
walther@60340
    81
val ct = (Thm.term_of o the o (TermC.parse thy)) "d_d x (x \<up> 2 + 3 * x + 4)";
neuper@37906
    82
"--- 1 ---";
wneuper@59384
    83
val thm = @{thm "diff_sum"};
wneuper@59384
    84
val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
neuper@37906
    85
"--- 2 ---";
wneuper@59384
    86
val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
neuper@37906
    87
"--- 3 ---";
wneuper@59384
    88
val thm = @{thm "diff_prod_const"};
wneuper@59384
    89
val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
neuper@37906
    90
"--- 4 ---";
wneuper@59384
    91
val thm = @{thm "diff_pow"};
wneuper@59384
    92
val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
neuper@37906
    93
"--- 5 ---";
wneuper@59384
    94
val thm = @{thm "diff_const"};
wneuper@59384
    95
val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
neuper@37906
    96
"--- 6 ---";
wneuper@59384
    97
val thm = @{thm "diff_var"};
wneuper@59384
    98
val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
walther@60242
    99
if UnparseC.term ct = "2 * x \<up> (2 - 1) + 3 * 1 + 0" then ()
neuper@38031
   100
else error "diff.sml diff.behav. in rewrite 1";
neuper@37906
   101
"--- 7 ---";
wneuper@59384
   102
"--- 7 ---";
wneuper@59384
   103
val rls = Test_simplify;
walther@60340
   104
val ct = (Thm.term_of o the o (TermC.parse thy)) "2 * x \<up> (2 - 1) + 3 * 1 + 0";
wneuper@59384
   105
val (ct, _) = the (rewrite_set_ thy true rls ct);
walther@59868
   106
if UnparseC.term ct = "3 + 2 * x" then () else error "rewrite_set_ Test_simplify 2 changed";
neuper@37906
   107
neuper@38081
   108
"----------- differentiate: me (*+ tacs input*) ---------";
neuper@38081
   109
"----------- differentiate: me (*+ tacs input*) ---------";
neuper@38081
   110
"----------- differentiate: me (*+ tacs input*) ---------";
walther@60242
   111
val fmz = ["functionTerm (x \<up> 2 + 3 * x + 4)", 
walther@59997
   112
	   "differentiateFor x", "derivative f_f'"];
neuper@37906
   113
val (dI',pI',mI') =
walther@59997
   114
  ("Diff",["derivative_of", "function"],
walther@59997
   115
   ["diff", "diff_simpl"]);
neuper@37906
   116
val p = e_pos'; val c = []; 
neuper@37906
   117
"--- s1 ---";
neuper@37906
   118
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@37906
   119
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   120
"--- s2 ---";
neuper@37906
   121
(*val nxt = ("Add_Given",
walther@60242
   122
Add_Given "functionTerm (d_d x (x \<up> #2 + #3 * x + #4))");*)
neuper@37906
   123
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   124
"--- s3 ---";
neuper@37906
   125
(*val nxt = ("Add_Given",Add_Given "differentiateFor x");*)
neuper@37906
   126
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   127
"--- s4 ---";
neuper@37994
   128
(*val nxt = ("Add_Find",Add_Find "derivative f_f'");*)
neuper@37906
   129
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   130
"--- s5 ---";
neuper@37906
   131
(*val nxt = ("Specify_Theory",Specify_Theory dI');*)
neuper@37906
   132
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   133
"--- s6 ---";
neuper@37906
   134
(*val nxt = ("Specify_Problem",Specify_Problem pI');*)
neuper@37906
   135
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   136
"--- s7 ---";
neuper@37906
   137
(*val nxt = ("Specify_Method",Specify_Method mI');*)
neuper@37906
   138
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   139
"--- s8 ---";
neuper@37906
   140
(*val nxt = ("Apply_Method",Apply_Method mI');*)
neuper@37906
   141
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   142
"--- 1 ---";
walther@59997
   143
(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_sum", "")));*)
neuper@37906
   144
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   145
"--- 2 ---";
walther@59997
   146
(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_sum", "")));*)
neuper@37906
   147
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   148
(*val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   149
val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
neuper@37906
   150
"--- 3 ---";
wneuper@59497
   151
(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_prod_const",...;*)
neuper@37906
   152
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   153
(*val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
neuper@37906
   154
"--- 4 ---";
walther@59997
   155
(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_pow", "")));*)
neuper@37906
   156
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   157
(*val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
neuper@37906
   158
"--- 5 ---";
wneuper@59497
   159
(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_prod_const",...;*)
neuper@37906
   160
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   161
(*val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
neuper@37906
   162
"--- 6 ---";
walther@59997
   163
(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_var", "")));*)
neuper@37906
   164
val (p,_,f,nxt,_,pt) = me nxt p c pt; 
walther@60242
   165
if f2str f =  "2 * x \<up> (2 - 1) + 3 * 1 + 0" then () 
walther@60242
   166
else error "diff.sml: diff.behav. in d_d x \<up> 2 + 3 * x + 4";
neuper@37906
   167
"--- 7 ---";
neuper@37906
   168
(*val nxt = ("Rewrite_Set",Rewrite_Set "make_polynomial");*)
neuper@37906
   169
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   170
"--- 8 ---";
walther@59997
   171
(*val nxt = ("Check_Postcond",Check_Postcond ("Diff", "differentiate_on_R"));*)
neuper@37906
   172
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   173
"--- 9 ---";
neuper@37906
   174
(*val nxt = ("End_Proof'",End_Proof');*)
neuper@37906
   175
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
wneuper@59253
   176
if f2str f = "3 + 2 * x"
walther@59749
   177
  then case nxt of End_Proof' => ()
wneuper@59253
   178
  | _ => error "diff.sml: new.behav. in me (*+ tacs input*) 1"
wneuper@59253
   179
else error "diff.sml: new.behav. in me (*+ tacs input*) 2";
walther@59814
   180
(*if f = EmptyMout then () else error "new behaviour in + tacs input"*)
neuper@37906
   181
neuper@38081
   182
"----------- 1.5.02 me from script ----------------------";
neuper@38081
   183
"----------- 1.5.02 me from script ----------------------";
neuper@38081
   184
"----------- 1.5.02 me from script ----------------------";
walther@60329
   185
(*exp_Diff_No- 1.xml*)
walther@60242
   186
val fmz = ["functionTerm (x \<up> 2 + 3 * x + 4)", 
walther@59997
   187
	   "differentiateFor x", "derivative f_f'"];
neuper@37906
   188
val (dI',pI',mI') =
walther@59997
   189
  ("Diff",["derivative_of", "function"],
walther@59997
   190
   ["diff", "diff_simpl"]);
neuper@37906
   191
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@37906
   192
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   193
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   194
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   195
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   196
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   197
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   198
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59997
   199
(*nxt = ("Apply_Method",Apply_Method ("Diff", "differentiate_on_R*)
neuper@37906
   200
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   201
neuper@37906
   202
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   203
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   204
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   205
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   206
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   207
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   208
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   209
val (p,_,f,nxt,_,pt) = me nxt p c pt;
walther@59749
   210
case nxt of End_Proof' => ()
wneuper@59253
   211
| _ => error "new behaviour in tests/differentiate, 1.5.02 me from script";
neuper@37906
   212
neuper@38081
   213
"----------- primed id ----------------------------------";
neuper@38081
   214
"----------- primed id ----------------------------------";
neuper@38081
   215
"----------- primed id ----------------------------------";
walther@60230
   216
val f_ = TermC.str2term "f_f::bool";
walther@60230
   217
val f  = TermC.str2term "A = s * (a - s)";
walther@60230
   218
val v_ = TermC.str2term "v_v";
walther@60230
   219
val v  = TermC.str2term "s";
walther@60230
   220
val screxp0 = TermC.str2term "Take ((primed (lhs f_f)) = d_d v_v (rhs f_f))";
walther@60230
   221
TermC.atomty screxp0;
neuper@37906
   222
neuper@38081
   223
val screxp1 = subst_atomic [(f_, f), (v_, v)] screxp0;
walther@59868
   224
UnparseC.term screxp1;
walther@60230
   225
TermC.atomty screxp1;
neuper@37906
   226
wneuper@59592
   227
val SOME (f'_,_) = rewrite_set_ (@{theory "Isac_Knowledge"}) false srls_diff screxp1; 
walther@59868
   228
if UnparseC.term f'_= "Take (A' = d_d s (s * (a - s)))" then ()
neuper@38031
   229
else error "diff.sml: diff.behav. in 'primed'";
walther@60230
   230
TermC.atomty f'_;
neuper@37906
   231
wneuper@59585
   232
val str = "Program DiffEqScr (f_f::bool) (v_v::real) =                         \
neuper@38081
   233
\ (let f_f' = Take ((primed (lhs f_f)) = d_d v_v (rhs f_f))           \
walther@59637
   234
\ in (((Try (Repeat (Rewrite frac_conv))) #>              \
walther@59637
   235
 \ (Try (Repeat (Rewrite root_conv))) #>                  \
walther@59637
   236
 \ (Try (Repeat (Rewrite realpow_pow))) #>                  \
neuper@37906
   237
 \ (Repeat                                                        \
walther@59635
   238
 \   ((Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sum        )) Or \
walther@59635
   239
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_prod_const )) Or \
walther@59635
   240
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_prod       )) Or \
walther@59635
   241
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_quot       )) Or \
walther@59635
   242
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sin        )) Or \
walther@59635
   243
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sin_chain  )) Or \
walther@59635
   244
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_cos        )) Or \
walther@59635
   245
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_cos_chain  )) Or \
walther@59635
   246
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_pow        )) Or \
walther@59635
   247
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_pow_chain  )) Or \
walther@59635
   248
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_ln         )) Or \
walther@59635
   249
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_ln_chain   )) Or \
walther@59635
   250
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_exp        )) Or \
walther@59635
   251
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_exp_chain  )) Or \
walther@59635
   252
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sqrt       )) Or \
walther@59635
   253
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sqrt_chain )) Or \
walther@59635
   254
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_const      )) Or \
walther@59635
   255
 \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_var        )) Or \
walther@59637
   256
 \    (Repeat (Rewrite_Set             make_polynomial)))) #> \
walther@59637
   257
 \ (Try (Repeat (Rewrite sym_frac_conv))) #>              \
walther@59635
   258
 \ (Try (Repeat (Rewrite sym_root_conv))))) f_f')"
neuper@37906
   259
;
walther@60340
   260
val sc = (inst_abs o Thm.term_of o the o (TermC.parse thy)) str;
neuper@37906
   261
neuper@37906
   262
neuper@38081
   263
"----------- diff_conv, sym_diff_conv -------------------";
neuper@38081
   264
"----------- diff_conv, sym_diff_conv -------------------";
neuper@38081
   265
"----------- diff_conv, sym_diff_conv -------------------";
walther@60230
   266
val subs = [(TermC.str2term "bdv", TermC.str2term "x")];
neuper@37906
   267
val rls = diff_conv;
neuper@37906
   268
walther@60242
   269
val t = TermC.str2term "2/x \<up> 2"; 
walther@59868
   270
val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
walther@60329
   271
if UnparseC.term t = "2 * x \<up> - 2" then () else error "diff.sml 1/x";
neuper@37906
   272
walther@60242
   273
val t = TermC.str2term "sqrt (x \<up> 3)";
walther@59868
   274
val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
walther@60242
   275
if UnparseC.term t = "x \<up> (3 / 2)" then () else error "diff.sml x \<up> 1/2";
neuper@37906
   276
walther@60242
   277
val t = TermC.str2term "2 / sqrt x \<up> 3";
walther@59868
   278
val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
walther@60341
   279
if UnparseC.term t = "2 * x \<up> (- 3 / 2)" then () else error "diff.sml x \<up> - 1/2";
walther@60341
   280
walther@60341
   281
val rls = diff_sym_conv;
neuper@37906
   282
walther@60329
   283
val t = TermC.str2term "2 * x \<up> - 2";
walther@60341
   284
val SOME (t, _) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
walther@60242
   285
if UnparseC.term t = "2 / x \<up> 2" then () else error "diff.sml sym 1/x";
neuper@37906
   286
neuper@37906
   287
walther@60242
   288
val t = TermC.str2term "x \<up> (3 / 2)";
walther@59868
   289
val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
walther@60341
   290
if UnparseC.term t = "sqrt (x \<up> 3)" then ((*..wrong rewrite*)) else error"diff.sml sym x \<up> 1/x";
neuper@37906
   291
walther@60242
   292
val t = TermC.str2term "2 * x \<up> (-3 / 2)";
walther@59868
   293
val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
walther@60329
   294
if UnparseC.term t ="2 / sqrt (x \<up> 3)"then()else error"diff.sml sym x \<up> - 1/x";
neuper@37906
   295
neuper@37906
   296
walther@60242
   297
"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
walther@60242
   298
"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
walther@60242
   299
"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
s1210629013@55445
   300
reset_states ();
neuper@37906
   301
CalcTree
walther@60242
   302
[(["functionTerm (x \<up> 2 + x+ 1/x + 2/x \<up> 2)",
walther@60242
   303
   (*"functionTerm ((x \<up> 3) \<up> 5)",*)
neuper@37994
   304
   "differentiateFor x", "derivative f_f'"], 
walther@59997
   305
  ("Isac_Knowledge", ["derivative_of", "function"],
walther@59997
   306
  ["diff", "differentiate_on_R"]))];
neuper@37906
   307
Iterator 1;
neuper@37906
   308
moveActiveRoot 1;
wneuper@59248
   309
autoCalculate 1 CompleteCalc;
walther@59983
   310
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@59868
   311
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = 
walther@60341
   312
			  "1 + 2 * x + - 1 / x \<up> 2 + - 4 / x \<up> 3" then ()
walther@60242
   313
else error "diff.sml: differentiate_on_R 2/x \<up> 2 changed";
neuper@37906
   314
neuper@38081
   315
"---------------------------------------------------------";
s1210629013@55445
   316
reset_states ();
neuper@37906
   317
CalcTree
walther@60242
   318
[(["functionTerm (x \<up> 3 * x  \<up>  5)",
neuper@37994
   319
   "differentiateFor x", "derivative f_f'"], 
walther@59997
   320
  ("Isac_Knowledge", ["derivative_of", "function"],
walther@59997
   321
  ["diff", "differentiate_on_R"]))];
neuper@37906
   322
Iterator 1;
neuper@37906
   323
moveActiveRoot 1;
walther@59627
   324
autoCalculate 1 CompleteCalc;
walther@60330
   325
(* Rewrite.trace_on := false; (*true false*)
walther@59901
   326
   LItool.trace_on := false;
neuper@37906
   327
   *)
walther@59983
   328
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   329
walther@59868
   330
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = 
walther@60242
   331
			 "8 * x \<up> 7" then () 
walther@60242
   332
else error "diff.sml: differentiate_on_R (x \<up> 3 * x \<up> 5) changed";
neuper@37906
   333
wneuper@59248
   334
"----------- autoCalculate diff after_simplification ----";
wneuper@59248
   335
"----------- autoCalculate diff after_simplification ----";
wneuper@59248
   336
"----------- autoCalculate diff after_simplification ----";
s1210629013@55445
   337
reset_states ();
neuper@37906
   338
CalcTree
walther@60242
   339
[(["functionTerm (x \<up> 3 * x \<up> 5)",
neuper@37994
   340
   "differentiateFor x", "derivative f_f'"], 
walther@59997
   341
  ("Isac_Knowledge", ["derivative_of", "function"],
walther@59997
   342
  ["diff", "after_simplification"]))];
neuper@37906
   343
Iterator 1;
neuper@37906
   344
moveActiveRoot 1;
walther@60330
   345
(* Rewrite.trace_on := false; (*true false*)
walther@59901
   346
   LItool.trace_on := true;
neuper@37906
   347
   *)
wneuper@59248
   348
autoCalculate 1 CompleteCalc;
walther@60341
   349
(* Rewrite.trace_on := false; (*true false*)
walther@59901
   350
   LItool.trace_on := false;
neuper@37906
   351
   *)
walther@59983
   352
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   353
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) =  "8 * x \<up> 7"
neuper@38031
   354
then () else error "biegelinie.sml: 1st biegelin.7.27 changed";
neuper@37906
   355
neuper@38081
   356
"--------------------------------------------------------";
s1210629013@55445
   357
reset_states ();
neuper@37906
   358
CalcTree
walther@60242
   359
[(["functionTerm ((x \<up> 3) \<up> 5)",
neuper@37994
   360
   "differentiateFor x", "derivative f_f'"], 
walther@59997
   361
  ("Isac_Knowledge", ["derivative_of", "function"],
walther@59997
   362
  ["diff", "after_simplification"]))];
neuper@37906
   363
Iterator 1;
neuper@37906
   364
moveActiveRoot 1;
wneuper@59248
   365
autoCalculate 1 CompleteCalc;
walther@59983
   366
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@60242
   367
if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "15 * x \<up> 14"
neuper@38031
   368
then () else error "biegelinie.sml: 1st biegelin.7.27 changed";
neuper@37906
   369
wneuper@59248
   370
"----------- autoCalculate differentiate_equality -------";
wneuper@59248
   371
"----------- autoCalculate differentiate_equality -------";
wneuper@59248
   372
"----------- autoCalculate differentiate_equality -------";
s1210629013@55445
   373
reset_states ();
neuper@37906
   374
CalcTree
neuper@42393
   375
[(["functionEq (A = s * (a - (s::real)))", "differentiateFor s", "derivativeEq f_f'"], 
walther@59997
   376
  ("Isac_Knowledge", ["named", "derivative_of", "function"],
walther@59997
   377
  ["diff", "differentiate_equality"]))];
neuper@37906
   378
Iterator 1;
neuper@37906
   379
moveActiveRoot 1;
wneuper@59248
   380
autoCalculate 1 CompleteCalc;
walther@59983
   381
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   382
neuper@38081
   383
"----------- tests for examples -------------------------";
neuper@38081
   384
"----------- tests for examples -------------------------";
neuper@38081
   385
"----------- tests for examples -------------------------";
walther@60230
   386
"----- TermC.parse errors";
walther@60242
   387
(*TermC.str2term "F  =  sqrt( y \<up> 2 - O) * (z + O \<up> 2)";
walther@60230
   388
TermC.str2term "O";
walther@60230
   389
TermC.str2term "OO"; ---errors*)
walther@60230
   390
TermC.str2term "OOO";
neuper@37906
   391
neuper@37906
   392
"----- thm 'diff_prod_const'";
walther@60230
   393
val subs = [(TermC.str2term "bdv", TermC.str2term "l")];
walther@60242
   394
val f = TermC.str2term "G' = d_d l (l * sqrt (7 * s \<up> 2 - l \<up> 2))";
neuper@37906
   395
walther@60242
   396
"------------inform for x \<up> 2+x+1 -------------------------";
walther@60242
   397
"------------inform for x \<up> 2+x+1 -------------------------";
walther@60242
   398
"------------inform for x \<up> 2+x+1 -------------------------";
s1210629013@55445
   399
reset_states ();
neuper@37906
   400
CalcTree
walther@60242
   401
[(["functionTerm (x \<up> 2 + x + 1)",
neuper@37994
   402
   "differentiateFor x", "derivative f_f'"], 
walther@59997
   403
  ("Isac_Knowledge", ["derivative_of", "function"],
walther@59997
   404
  ["diff", "differentiate_on_R"]))];
neuper@37906
   405
Iterator 1;
neuper@37906
   406
moveActiveRoot 1;
wneuper@59248
   407
autoCalculate 1 CompleteCalcHead;
walther@59747
   408
autoCalculate 1 (Steps 1);
walther@59747
   409
autoCalculate 1 (Steps 1);
walther@59747
   410
autoCalculate 1 (Steps 1);
walther@59983
   411
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
wneuper@59123
   412
appendFormula 1 "2*x + d_d x x + d_d x 1" (*|> Future.join*);
walther@59983
   413
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906
   414
if existpt' ([3], Res) pt then ()
walther@60242
   415
else error  "diff.sml: inform d_d x (x \<up> 2 + x + 1) doesnt work";
neuper@38081
   416