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