test/Tools/isac/Interpret/rewtools.sml
author Walther Neuper <walther.neuper@jku.at>
Wed, 01 Apr 2020 18:54:03 +0200
changeset 59848 06a5cfe04223
parent 59801 17d807bf28fb
child 59849 d82a32869f27
permissions -rw-r--r--
renaming, cleanup
akargl@42181
     1
(* Title: test for rewtools.sml
neuper@37906
     2
   authors: Walther Neuper 2000, 2006
neuper@55397
     3
wneuper@59465
     4
theory Test_Some imports Isac.Build_Thydata begin 
neuper@55397
     5
ML_file "~~/test/Tools/isac/ADDTESTS/accumulate-val/lucas_interpreter.sml"
neuper@55458
     6
ML {* KEStore_Elems.set_ref_thy @{theory};
neuper@55458
     7
  fun autoCalculate' cI auto = autoCalculate cI auto |> Future.join *}
neuper@55397
     8
ML_file "Interpret/rewtools.sml"
neuper@37906
     9
*)
neuper@37906
    10
neuper@38061
    11
"--------------------------------------------------------";
neuper@38061
    12
"--------------------------------------------------------";
neuper@38061
    13
"table of contents --------------------------------------";
neuper@38061
    14
"--------------------------------------------------------";
neuper@38061
    15
"----------- fun thy_containing_rls ---------------------";
wneuper@59366
    16
"----------- apply thy_containing_rls -------------------";
neuper@38061
    17
"----------- fun thy_containing_cal ---------------------";
neuper@38061
    18
"----------- initContext Thy_ Integration-demo ----------";
neuper@38061
    19
"----------- initContext..Thy_, fun context_thm ---------";
neuper@38061
    20
"----------- initContext..Thy_, fun context_rls ---------";
neuper@38061
    21
"----------- checkContext..Thy_, fun context_thy --------";
neuper@38061
    22
"----------- checkContext..Thy_, fun context_rls --------";
neuper@38061
    23
"----------- checkContext..Thy_ on last formula ---------"; 
neuper@38061
    24
"----------- fun guh2theID ------------------------------";
neuper@38061
    25
"----------- debugging on Tests/solve_linear_as_rootpbl -";
neuper@38061
    26
"--------------------------------------------------------";
wneuper@55498
    27
(*============ inhibit exn WN120321 ==============================================
neuper@38061
    28
"--------------------------------------------------------";
neuper@38061
    29
"----------- fun filter_appl_rews -----------------------";
wneuper@55498
    30
============ inhibit exn WN120321 ==============================================*)
neuper@38061
    31
"----------- fun is_contained_in ------------------------";
wneuper@55498
    32
"----------- build fun get_bdv_subst --------------------------------";
neuper@38061
    33
"--------------------------------------------------------";
neuper@38061
    34
"--------------------------------------------------------";
neuper@37906
    35
neuper@38061
    36
"----------- fun thy_containing_rls ---------------------";
neuper@38061
    37
"----------- fun thy_containing_rls ---------------------";
neuper@38061
    38
"----------- fun thy_containing_rls ---------------------";
wneuper@59366
    39
(*ERROR WAS: Theory loader: undefined entry for theory "Isac.Complex_Main"*)
wneuper@59366
    40
if thy_containing_rls "Biegelinie" "norm_Poly" = ("IsacKnowledge", "Poly") then ()
wneuper@59366
    41
else error ("thy_containing_rls changed for 'Biegelinie', 'norm_Poly'")  
wneuper@59366
    42
;
wneuper@59366
    43
"~~~~~ fun thy_containing_rls, args:"; val (thy', rls') = ("Biegelinie", "norm_Poly");
wneuper@59366
    44
    val thy = Thy_Info_get_theory thy'; (*.., EqSystem, Isac.Biegelinie}*)
wneuper@59366
    45
val xxx = AList.lookup op= (KEStore_Elems.get_rlss thy) rls';
wneuper@59366
    46
val SOME (thy'', _) = xxx;
wneuper@59366
    47
val SOME ("Poly", _) = xxx;
wneuper@59366
    48
if thy'' = "Poly" then () else error "--- fun thy_containing_rls: changed";
wneuper@59366
    49
(*ERROR WAS: Theory loader: undefined entry for theory "Isac.Complex_Main" *)
wneuper@59366
    50
if partID' thy'' = "IsacKnowledge" then () else error "fun partID': changed"
wneuper@59366
    51
;
wneuper@59366
    52
"~~~~~ fun partID', args:"; val (thy') = (thy');
wneuper@59366
    53
Thy_Info_get_theory thy' (*.., EqSystem, Isac.Biegelinie}*)
wneuper@59366
    54
;
wneuper@59366
    55
"~~~~~ fun partID, args:"; val (thy) = (Thy_Info_get_theory thy');
wneuper@59366
    56
(*ERROR WAS: Theory loader: undefined entry for theory "Isac.Complex_Main"*)
wneuper@59366
    57
knowthys () 
wneuper@59366
    58
;
wneuper@59600
    59
"~~~~~ fun knowthys , args:"; val () = ();
wneuper@59366
    60
        val allthys = filter_out (member Context.eq_thy
wneuper@59366
    61
          [(*Thy_Info_get_theory "ProgLang",*) Thy_Info_get_theory "Interpret", 
wneuper@59600
    62
            Thy_Info_get_theory "MathEngine", Thy_Info_get_theory "BridgeLibisabelle"]) 
wneuper@59366
    63
          (Theory.ancestors_of (Thy_Info_get_theory "Build_Thydata"));
wneuper@59366
    64
length allthys = 152; (*in Isabelle2015/Isac*)
wneuper@59366
    65
(*ERROR WAS: Theory loader: undefined entry for theory "Isac.Complex_Main"
wneuper@59366
    66
Thy_Info_get_theory "Complex_Main";*)
wneuper@59366
    67
Thy_Info.get_theory "Complex_Main";;
wneuper@59366
    68
wneuper@59366
    69
"----------- apply thy_containing_rls -------------------";
wneuper@59366
    70
"----------- apply thy_containing_rls -------------------";
wneuper@59366
    71
"----------- apply thy_containing_rls -------------------";
neuper@55458
    72
if thy_containing_rls "Biegelinie" "norm_Poly" = ("IsacKnowledge", "Poly") then ()
neuper@55458
    73
else error ("thy_containing_rls changed for 'Biegelinie', 'norm_Poly'")
neuper@55458
    74
;
neuper@55458
    75
if thy_containing_rls "Biegelinie" "e_rls" = ("IsacScripts", "KEStore") then ()
neuper@55458
    76
else error ("thy_containing_rls changed for 'Biegelinie', 'e_rls'")
neuper@55458
    77
;
walther@59801
    78
if thy_containing_rls "Build_Thydata" "prog_expr" = (*FIXME: handle redifinition in several thys*)
wneuper@59602
    79
  ("IsacKnowledge", "Base_Tools") then ()
walther@59801
    80
else error ("thy_containing_rls changed for 'Biegelinie', 'prog_expr'")
neuper@37906
    81
neuper@38061
    82
"----------- fun thy_containing_cal ---------------------";
neuper@38061
    83
"----------- fun thy_containing_cal ---------------------";
neuper@38061
    84
"----------- fun thy_containing_cal ---------------------";
walther@59603
    85
(* ATTENTION: both, "IsacKnowledge" and "Prog_Expr" are fixed as results for any input*)
walther@59603
    86
if thy_containing_cal "Biegelinie" "PLUS" = ("IsacKnowledge", "Base_Tools")
neuper@55458
    87
then () else error "(wrong) thy_containing_cal 'Biegelinie' 'PLUS' changed"
neuper@42407
    88
neuper@38061
    89
"----------- initContext Thy_ Integration-demo ----------";
neuper@38061
    90
"----------- initContext Thy_ Integration-demo ----------";
neuper@38061
    91
"----------- initContext Thy_ Integration-demo ----------";
s1210629013@55445
    92
reset_states ();
neuper@37906
    93
CalcTree
neuper@37906
    94
[(["functionTerm (2 * x)","integrateBy x","antiDerivative FF"], 
neuper@38058
    95
  ("Integrate",["integrate","function"],
neuper@37906
    96
  ["diff","integration"]))];
neuper@37906
    97
Iterator 1;
neuper@37906
    98
moveActiveRoot 1;
wneuper@59248
    99
autoCalculate 1 CompleteCalc;
neuper@37906
   100
interSteps 1 ([1],Res);
neuper@37906
   101
interSteps 1 ([1,1],Res);
neuper@37906
   102
val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@37906
   103
if existpt' ([1,1,1], Frm) pt then ()
neuper@38031
   104
else error "integrate.sml: interSteps on Rewrite_Set_Inst 1";
neuper@37906
   105
initContext  1 Thy_ ([1,1,1], Frm);
neuper@37906
   106
neuper@38061
   107
"----------- initContext..Thy_, fun context_thm ---------";
neuper@38061
   108
"----------- initContext..Thy_, fun context_thm ---------";
neuper@38061
   109
"----------- initContext..Thy_, fun context_thm ---------";
s1210629013@55445
   110
reset_states (); (*start of calculation, return No.1*)
neuper@41970
   111
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@41970
   112
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@37906
   113
   ["Test","squ-equ-test-subpbl1"]))];
neuper@37906
   114
Iterator 1; moveActiveRoot 1;
wneuper@59248
   115
autoCalculate 1 CompleteCalc;
neuper@37906
   116
neuper@37906
   117
"----- no thy-context at result -----";
neuper@37906
   118
val p = ([], Res);
neuper@37906
   119
initContext 1 Thy_ p;
wneuper@55498
   120
val ((pt,_),_) = get_calc 1; show_pt pt; (* 11 lines with subpbl *)
neuper@37906
   121
neuper@37906
   122
interSteps 1 ([2], Res);
wneuper@55498
   123
val ((pt,_),_) = get_calc 1; show_pt pt; (* added [2,1]..[2,6] *)
neuper@37906
   124
interSteps 1 ([3,1], Res);
wneuper@55498
   125
val ((pt,_),_) = get_calc 1; show_pt pt; (* added [3,1,1] Frm + Res *)
neuper@37906
   126
neuper@37906
   127
val p = ([2,4], Res);
wneuper@55498
   128
"~~~~~ fun initContext, args:"; val ((cI:calcID), Thy_, (pos as (p,p_):pos')) = (1, Thy_, p);
wneuper@55498
   129
  member op = [Pbl,Met] p_ = false;
wneuper@55498
   130
  pos = ([],Res) = false;
wneuper@55498
   131
  val cs as (ptp as (pt,_),_) = get_calc cI;
wneuper@55498
   132
  exist_lev_on' pt pos = true;
wneuper@55498
   133
              val pos' = lev_on' pt pos
wneuper@55498
   134
              val tac = get_tac_checked pt pos';
wneuper@55498
   135
  is_rewtac tac = true;
wneuper@55498
   136
"~~~~~ fun context_thy, args:"; val ((pt, pos as (p,p_)), (tac as Rewrite (thmID,_))) =
wneuper@55498
   137
  ((pt, pos), tac);
wneuper@55498
   138
    val Appl (Rewrite' (thy', ord', erls, _, (thmID,thm), f, (res,asm))) = applicable_in pos pt tac
wneuper@55498
   139
            val thm = Global_Theory.get_thm (Isac ()(*WN141021 assoc_thy thy' ERROR*)) thmID
wneuper@55498
   140
            val thm_deriv = Thm.get_name_hint thm;
wneuper@55498
   141
wneuper@55498
   142
if thm2guh (thy_containing_thm thm_deriv) (thmID_of_derivation_name thm_deriv)
wneuper@55498
   143
   = "thy_isac_Test-thm-radd_left_commute" then ()
wneuper@55498
   144
else error "context_thy mini-subpbl ([2,4], Res) changed";
wneuper@55498
   145
(*~/proto3/kbase/thy$ ls -l thy_isac_Test-thm-radd_left_commute*
wneuper@55498
   146
-rw-rw-r-- 1 wneuper wneuper 638 Aug  8 16:04 thy_isac_Test-thm-radd_left_commute.html*)
neuper@37906
   147
akargl@42108
   148
neuper@37906
   149
val p = ([3,1,1], Frm);
wneuper@55498
   150
"~~~~~ fun initContext, args:"; val ((cI:calcID), Thy_, (pos as (p,p_):pos')) = (1, Thy_, p);
wneuper@55498
   151
  member op = [Pbl,Met] p_ = false;
wneuper@55498
   152
  pos = ([],Res) = false;
wneuper@55498
   153
  val cs as (ptp as (pt,_),_) = get_calc cI;
wneuper@55498
   154
  exist_lev_on' pt pos = true;
wneuper@55498
   155
              val pos' = lev_on' pt pos
wneuper@55498
   156
              val tac = get_tac_checked pt pos';
wneuper@55498
   157
  is_rewtac tac = true;
wneuper@55498
   158
"~~~~~ fun context_thy, args:"; val ((pt, pos as (p,p_)), (tac as Rewrite_Inst (subs, (thmID,_))))=
wneuper@55498
   159
  ((pt, pos), tac);
wneuper@55498
   160
val Appl (Rewrite_Inst' (thy', ord', erls, _, subst, (thmID,_), f, (res, asm))) = 
wneuper@55498
   161
  applicable_in pos pt tac
wneuper@55498
   162
             val thm = Global_Theory.get_thm (Isac ()(*WN141021 assoc_thy thy' ERROR*)) thmID
wneuper@55498
   163
             val thm_deriv = Thm.get_name_hint thm;
wneuper@55498
   164
if thm2guh (thy_containing_thm thm_deriv) (thmID_of_derivation_name thm_deriv) =
wneuper@55498
   165
  "thy_isac_Test-thm-risolate_bdv_add" then ()
wneuper@55498
   166
else error "context_thy mini-subpbl ([3,1,1], Frm) changed";
wneuper@55498
   167
(*~/proto3/kbase/thy$ ls -l thy_isac_Test-thm-risolate_bdv_add*
wneuper@55498
   168
-rw-rw-r-- 1 wneuper wneuper 646 Aug  8 16:04 thy_isac_Test-thm-risolate_bdv_add.html*)
neuper@37906
   169
neuper@37906
   170
wneuper@55498
   171
val p = ([2,5], Res);
wneuper@55498
   172
"~~~~~ fun initContext, args:"; val ((cI:calcID), Thy_, (pos as (p,p_):pos')) = (1, Thy_, p);
wneuper@55498
   173
  member op = [Pbl,Met] p_ = false;
wneuper@55498
   174
  pos = ([],Res) = false;
wneuper@55498
   175
  val cs as (ptp as (pt,_),_) = get_calc cI;
wneuper@55498
   176
 exist_lev_on' pt pos = true;
wneuper@55498
   177
              val pos' = lev_on' pt pos
wneuper@55498
   178
              val tac = get_tac_checked pt pos';
wneuper@55498
   179
if is_rewtac tac = false then () 
wneuper@55498
   180
else error "initContext: context_thy .. Calculate PLUS .. TO BE IMPLEMENTED"
neuper@37906
   181
neuper@38061
   182
"----------- initContext..Thy_, fun context_rls ---------";
neuper@38061
   183
"----------- initContext..Thy_, fun context_rls ---------";
neuper@38061
   184
"----------- initContext..Thy_, fun context_rls ---------";
neuper@37906
   185
(*using pt from above*)
neuper@37906
   186
val p = ([1], Res);
neuper@37906
   187
val tac = Rewrite_Set "Test_simplify";
neuper@37906
   188
initContext 1 Thy_ p;
neuper@37906
   189
(*Res->Res, Rewrite_Set "Test_simplify" x + 1 + -1 * 2 = 0 -> -1 + x = 0
neuper@37906
   190
  --- in initContext..Thy_ ---*)
neuper@37906
   191
val ContRls {rls,result,...} = context_thy (pt,p) tac;
neuper@37906
   192
if rls = "thy_isac_Test-rls-Test_simplify" 
neuper@37906
   193
   andalso term2str result = "-1 + x = 0" then ()
wneuper@55498
   194
else error "rewtools.sml initContext..Th_ thy_isac_Test-rls-Test_simplify";
neuper@37906
   195
neuper@37906
   196
val p = ([3,1], Frm);
wneuper@59494
   197
val tac = Rewrite_Set_Inst (["(''bdv'', x)"],"isolate_bdv");
neuper@37906
   198
initContext 1 Thy_ p;
neuper@37906
   199
(*Frm->Res, Rewrite_Set_Inst "isolate_bdv" -1 + x = 0 ->  x = 0 + -1 * -1
neuper@37906
   200
  --- in initContext..Thy_ ---*)
neuper@37906
   201
val ContRlsInst {rls,result,...} = context_thy (pt,p) tac;
neuper@37906
   202
if rls =  "thy_isac_Test-rls-isolate_bdv"
neuper@37906
   203
   andalso term2str result = "x = 0 + -1 * -1" then ()
neuper@38031
   204
else error "rewtools.sml initContext..Th_ thy_Test-thm-risolate_bdv_add";
neuper@37906
   205
neuper@38061
   206
"----------- checkContext..Thy_, fun context_thy --------";
neuper@38061
   207
"----------- checkContext..Thy_, fun context_thy --------";
neuper@38061
   208
"----------- checkContext..Thy_, fun context_thy --------";
neuper@37906
   209
(*using pt from above*)
neuper@37906
   210
val p = ([2,4], Res);
wneuper@59253
   211
val tac = Rewrite ("radd_left_commute", @{thm radd_left_commute});
neuper@37906
   212
checkContext 1 p "thy_Test-thm-radd_left_commute";
neuper@37906
   213
(* radd_left_commute: 1 + (-2 + x) = 0 -> -2 + (1 + x) = 0
neuper@37906
   214
  --- in checkContext..Thy_ ---*)
neuper@37906
   215
val ContThm {thm,result,...} = context_thy (pt,p) tac;
neuper@37906
   216
if thm =  "thy_isac_Test-thm-radd_left_commute"
neuper@37906
   217
   andalso term2str result = "-2 + (1 + x) = 0" then ()
neuper@38031
   218
else error "rewtools.sml checkContext.._ thy_Test-thm-radd_left_commute";
neuper@37906
   219
neuper@37906
   220
val p = ([3,1,1], Frm);
wneuper@59494
   221
val tac = Rewrite_Inst (["(''bdv'',x)"],("risolate_bdv_add", @{thm "risolate_bdv_add"}));
neuper@37906
   222
checkContext 1 p "thy_Test-thm-risolate_bdv_add";
neuper@37906
   223
(* risolate_bdv_add:  -1 + x = 0 -> x = 0 + -1 * -1
neuper@37906
   224
  --- in checkContext..Thy_ ---*)
neuper@37906
   225
val ContThmInst {thm,result,...} = context_thy (pt,p) tac;
neuper@37906
   226
if thm =  "thy_isac_Test-thm-risolate_bdv_add"
wneuper@59253
   227
   andalso term2str result = "x = 0 + - 1 * -1" then ()
neuper@38031
   228
else error "rewtools.sml checkContext..T_ thy_Test-thm-risolate_bdv_add";
neuper@37906
   229
neuper@37906
   230
val p = ([2,5], Res);
neuper@37906
   231
val tac = Calculate "plus";
neuper@37906
   232
(*checkContext..Thy_ 1 ([2,5], Res);*)
neuper@37906
   233
(*FIXXXME #######################vvvvv kestoreID !!!!!!!!!!!!!!!!*)
neuper@37906
   234
checkContext 1 p ;
neuper@37906
   235
(* Calculate "plus"  -2 + (1 + x) = 0 -> -1 + x = 0
neuper@37906
   236
  --- in checkContext..Thy_ ---*)
neuper@37906
   237
neuper@38061
   238
"----------- checkContext..Thy_, fun context_rls --------";
neuper@38061
   239
"----------- checkContext..Thy_, fun context_rls --------";
neuper@38061
   240
"----------- checkContext..Thy_, fun context_rls --------";
neuper@37906
   241
(*using pt from above*)
neuper@37906
   242
val p = ([1], Res);
neuper@37906
   243
val tac = Rewrite_Set "Test_simplify";
neuper@37906
   244
checkContext 1 p "thy_isac_Test-rls-Test_simplify";
neuper@37906
   245
(*Res->Res, Rewrite_Set "Test_simplify" x + 1 + -1 * 2 = 0 -> -1 + x = 0
neuper@37906
   246
  --- in checkContext..Thy_ ---*)
neuper@37906
   247
val ContRls {rls,result,...} = context_thy (pt,p) tac;
neuper@37906
   248
if rls = "thy_isac_Test-rls-Test_simplify" 
neuper@37906
   249
   andalso term2str result = "-1 + x = 0" then ()
neuper@38031
   250
else error "rewtools.sml checkContext..Thy_ thy_Test-rls-Test_simplify";
neuper@37906
   251
neuper@37906
   252
val p = ([3,1], Frm);
wneuper@59494
   253
val tac = Rewrite_Set_Inst (["(''bdv'', x)"],"isolate_bdv");
neuper@37906
   254
checkContext 1 p "thy_Test-rls-isolate_bdv";
neuper@37906
   255
val ContRlsInst {rls,result,...} = context_thy (pt,p) tac;
neuper@37906
   256
if rls = "thy_isac_Test-rls-isolate_bdv" 
neuper@37906
   257
   andalso term2str result = "x = 0 + -1 * -1" then ()
neuper@38031
   258
else error "rewtools.sml checkContext..Thy_ thy_Test-thm-isolate_bdv";
neuper@37906
   259
neuper@38061
   260
"----------- checkContext..Thy_ on last formula ---------"; 
neuper@38061
   261
"----------- checkContext..Thy_ on last formula ---------"; 
neuper@38061
   262
"----------- checkContext..Thy_ on last formula ---------"; 
s1210629013@55445
   263
reset_states (); (*start of calculation, return No.1*)
neuper@41970
   264
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@41970
   265
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@37906
   266
   ["Test","squ-equ-test-subpbl1"]))];
neuper@37906
   267
Iterator 1; moveActiveRoot 1;
neuper@37906
   268
wneuper@59248
   269
autoCalculate 1 CompleteCalcHead;
walther@59747
   270
autoCalculate 1 (Steps 1);
neuper@37906
   271
val (ptp as (pt,p), tacis) = get_calc 1; show_pt pt;
neuper@37906
   272
initContext 1 Thy_ ([1], Frm);
neuper@37906
   273
checkContext 1 ([1], Frm) "thy_isac_Test-thm-radd_left_commute";
neuper@37906
   274
walther@59747
   275
autoCalculate 1 (Steps 1);
neuper@37906
   276
val (ptp as (pt,p), tacis) = get_calc 1; show_pt pt;
neuper@37906
   277
initContext 1 Thy_ ([1], Res);
neuper@37906
   278
checkContext 1 ([1], Res) "thy_isac_Test-rls-Test_simplify";
neuper@37906
   279
neuper@38061
   280
"----------- fun guh2theID ------------------------------";
neuper@38061
   281
"----------- fun guh2theID ------------------------------";
neuper@38061
   282
"----------- fun guh2theID ------------------------------";
neuper@37906
   283
val guh = "thy_scri_ListG-thm-zip_Nil";
wneuper@59348
   284
(*default_print_depth 3; 999*)
akargl@42181
   285
take_fromto 1 4 (Symbol.explode guh);
akargl@42181
   286
take_fromto 5 9 (Symbol.explode guh);
akargl@42181
   287
val rest = takerest (9,(Symbol.explode guh)); 
neuper@37906
   288
neuper@37906
   289
separate "-" rest;
neuper@37906
   290
space_implode "-" rest;
neuper@37906
   291
commas rest;
neuper@37906
   292
neuper@37906
   293
val delim = "-";
neuper@37906
   294
val thyID = takewhile [] (not o (curry op= delim)) rest;
neuper@37906
   295
val rest' = dropuntil (curry op= delim) rest;
neuper@37906
   296
val setc = take_fromto 1 5 rest';
neuper@37906
   297
val xstr = takerest (5, rest');
neuper@37906
   298
neuper@37906
   299
if guh2theID guh = ["IsacScripts", "ListG", "Theorems", "zip_Nil"] then ()
neuper@38031
   300
else error "rewtools.sml: guh2theID thy_scri_ListG-thm-zip_Nil changed";
neuper@37906
   301
neuper@37906
   302
neuper@38061
   303
"----------- debugging on Tests/solve_linear_as_rootpbl -";
neuper@38061
   304
"----------- debugging on Tests/solve_linear_as_rootpbl -";
neuper@38061
   305
"----------- debugging on Tests/solve_linear_as_rootpbl -";
akargl@42108
   306
"----- initContext -----";
s1210629013@55445
   307
reset_states ();
neuper@37906
   308
CalcTree 
neuper@42124
   309
    [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
neuper@38058
   310
      ("Test",
neuper@55279
   311
       ["LINEAR","univariate","equation","test"],
neuper@37906
   312
       ["Test","solve_linear"]))];
neuper@37906
   313
Iterator 1; moveActiveRoot 1;
wneuper@59248
   314
autoCalculate 1 CompleteCalcHead;
neuper@37906
   315
walther@59747
   316
autoCalculate 1 (Steps 1); val (ptp as (pt,p), tacis) = get_calc 1; show_pt pt;
neuper@37906
   317
if is_curr_endof_calc pt ([1],Frm) then ()
neuper@38031
   318
else error "rewtools.sml is_curr_endof_calc ([1],Frm)";
neuper@37906
   319
walther@59747
   320
autoCalculate 1 (Steps 1); val (ptp as (pt,p), tacis) = get_calc 1; show_pt pt;
akargl@42125
   321
neuper@37906
   322
if not (is_curr_endof_calc pt ([1],Frm)) then ()
neuper@38031
   323
else error "rewtools.sml is_curr_endof_calc ([1],Frm) not";
neuper@37906
   324
if is_curr_endof_calc pt ([1],Res) then ()
neuper@38031
   325
else error "rewtools.sml is_curr_endof_calc ([1],Res)";
neuper@37906
   326
neuper@37906
   327
initContext 1 Thy_ ([1],Res);
neuper@37906
   328
neuper@37906
   329
"----- checkContext -----";
s1210629013@55445
   330
reset_states ();
neuper@37906
   331
CalcTree 
neuper@42124
   332
    [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
neuper@38058
   333
      ("Test",
neuper@55279
   334
       ["LINEAR","univariate","equation","test"],
neuper@37906
   335
       ["Test","solve_linear"]))];
neuper@37906
   336
Iterator 1; moveActiveRoot 1;
wneuper@59248
   337
autoCalculate 1 CompleteCalc;
neuper@37906
   338
interSteps 1 ([1],Res);
akargl@42108
   339
neuper@37906
   340
val (ptp as (pt,p), tacis) = get_calc 1; show_pt pt;
neuper@37906
   341
checkContext 1 ([1],Res) "thy_isac_Test-rls-Test_simplify";
neuper@37906
   342
neuper@37906
   343
interSteps 1 ([2],Res);
neuper@37906
   344
val (ptp as (pt,p), tacis) = get_calc 1; show_pt pt;
neuper@37906
   345
neuper@37906
   346
checkContext 1 ([2,1],Res) "thy_isac_Test-rls-Test_simplify";
neuper@37906
   347
checkContext 1 ([2,2],Res) "thy_isac_Test-rls-Test_simplify";
neuper@37906
   348
neuper@38061
   349
"----------- fun is_contained_in ------------------------";
neuper@38061
   350
"----------- fun is_contained_in ------------------------";
neuper@38061
   351
"----------- fun is_contained_in ------------------------";
neuper@37969
   352
val r1 = Thm ("real_diff_minus",num_str @{thm real_diff_minus});
walther@59848
   353
if Rule.contains_rule r1 Test_simplify then ()
walther@59848
   354
else error "rewtools.sml Rule.contains_rule Thm";
neuper@37906
   355
walther@59773
   356
val r1 = Num_Calc ("Groups.plus_class.plus", eval_binop "#add_");
walther@59848
   357
if Rule.contains_rule r1 Test_simplify then ()
walther@59848
   358
else error "rewtools.sml Rule.contains_rule Num_Calc";
neuper@37906
   359
walther@59773
   360
val r1 = Num_Calc ("Groups.minus_class.minus", eval_binop "#add_");
walther@59848
   361
if not (Rule.contains_rule r1 Test_simplify) then ()
walther@59848
   362
else error "rewtools.sml Rule.contains_rule Num_Calc";
neuper@42400
   363
wneuper@55498
   364
"----------- build fun get_bdv_subst --------------------------------";
wneuper@55498
   365
"----------- build fun get_bdv_subst --------------------------------";
wneuper@55498
   366
"----------- build fun get_bdv_subst --------------------------------";
neuper@48790
   367
val {scr = Prog prog, ...} = get_met ["diff", "differentiate_on_R"];
neuper@42433
   368
val env = [(str2term "v_v", str2term "x")];
neuper@42433
   369
subst2str env = "[\"\n(v_v, x)\"]";
neuper@42433
   370
neuper@42433
   371
"~~~~~ fun get_bdv_subst, args:"; val (prog, env) = (prog, env);
neuper@42433
   372
    fun scan (Const _) = NONE
neuper@42433
   373
      | scan (Free _) = NONE
neuper@42433
   374
      | scan (Var _) = NONE
neuper@42433
   375
      | scan (Bound _) = NONE
wneuper@59494
   376
      | scan (t as Const ("List.list.Cons", _) $ (Const ("Product_Type.Pair", _) $ _ $ _) $ _) =
wneuper@59494
   377
        if TermC.is_bdv_subst t then SOME t else NONE
neuper@42433
   378
      | scan (Abs (_, _, body)) = scan body
wneuper@59494
   379
      | scan (t1 $ t2) = case scan t1 of NONE => scan t2 | SOME subst => SOME subst
neuper@42433
   380
neuper@42433
   381
val SOME tm = scan prog;
wneuper@59494
   382
val subst = tm |> subst_atomic env;
wneuper@59494
   383
if term2str tm = "[(''bdv'', v_v)]" then () else error "get_bdv_subst changed 1";
neuper@42433
   384
wneuper@59494
   385
if subst'_to_sube subst = ["(''bdv'', x)"] then () else error "get_bdv_subst changed 2";
neuper@42433
   386
neuper@42433
   387
case get_bdv_subst prog env of
wneuper@59494
   388
  (SOME ["(''bdv'', x)"], [(Free ("bdv", _), Free ("x", _))]: subst) => ()
neuper@42433
   389
| _ => error "get_bdv_subst changed 3";
neuper@42433
   390
neuper@42433
   391
val (SOME subs, _) = get_bdv_subst prog env;