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