test/Tools/isac/Interpret/script.sml
author Walther Neuper <neuper@ist.tugraz.at>
Fri, 23 Sep 2011 13:58:27 +0200
branchdecompose-isar
changeset 42283 b95f0dde56c1
parent 42281 19d9ab32a0ce
child 42387 767debe8a50c
permissions -rw-r--r--
tuned
neuper@41999
     1
(* Title:  test/../script.sml
neuper@41999
     2
   Author: Walther Neuper 050908
neuper@37906
     3
   (c) copyright due to lincense terms.
neuper@37906
     4
*)
neuper@37906
     5
"-----------------------------------------------------------------";
neuper@37906
     6
"table of contents -----------------------------------------------";
neuper@37906
     7
"-----------------------------------------------------------------";
neuper@37906
     8
"----------- WN0509 why does next_tac doesnt find Substitute -----";
neuper@37906
     9
"----------- WN0509 Substitute 2nd part --------------------------";
neuper@37906
    10
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@41969
    11
"----------- fun init_form, fun get_stac -------------------------";
neuper@41972
    12
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
neuper@42283
    13
"----------- Take as 1st stac in script --------------------------";
neuper@37906
    14
"-----------------------------------------------------------------";
neuper@37906
    15
"-----------------------------------------------------------------";
neuper@37906
    16
"-----------------------------------------------------------------";
neuper@37906
    17
t@42214
    18
val thy= @{theory Isac};
neuper@42281
    19
neuper@37906
    20
"----------- WN0509 why does next_tac doesnt find Substitute -----";
neuper@37906
    21
"----------- WN0509 why does next_tac doesnt find Substitute -----";
neuper@37906
    22
"----------- WN0509 why does next_tac doesnt find Substitute -----";
neuper@37906
    23
neuper@37906
    24
(*replace met 'IntegrierenUndKonstanteBestimmen' with this script...*)
neuper@37906
    25
val str = (*#1#*)
akargl@42169
    26
"Script BiegelinieScript                                             " ^ 
akargl@42169
    27
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^ 
akargl@42169
    28
"(rb_rb::bool list) (rm_rm::bool list) =                             " ^
akargl@42169
    29
"  (let q___q = Take (M_b v_v = q__q);                               " ^
akargl@42169
    30
"       (M1__M1::bool) = ((Substitute [v_v = 0])) q___q              " ^
akargl@42169
    31
" in True)";
akargl@42169
    32
neuper@37906
    33
val sc' = ((inst_abs thy) o term_of o the o (parse thy)) str;
neuper@37906
    34
neuper@37906
    35
val str = (*#2#*)
akargl@42169
    36
"Script BiegelinieScript                                             " ^ 
akargl@42169
    37
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^ 
akargl@42169
    38
"(rb_rb::bool list) (rm_rm::bool list) =                             " ^ 
akargl@42169
    39
"       (M1__M1::bool) = ((Substitute [v_v = 0]) @@                  " ^
akargl@42169
    40
" in True)";(*..doesnt find Substitute with ..@@ !!!!!!!!!!!!!!!!!!!!!*)
neuper@37906
    41
neuper@37906
    42
val str = (*#3#*)
akargl@42169
    43
"Script BiegelinieScript                                             " ^
akargl@42169
    44
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^
akargl@42169
    45
"(rb_rb::bool list) (rm_rm::bool list) =                             " ^
akargl@42169
    46
"  (let q___q = Take (q_q v_v = q__q);                               " ^
akargl@42169
    47
"      (M1__M1::bool) = Substitute [v_v = 0]      q___q ;            " ^
akargl@42169
    48
"       M1__m1 =        Substitute [M_b 0 = 0]  M1__M1               " ^
akargl@42169
    49
" in True)"
neuper@37906
    50
;
neuper@37906
    51
val str = (*#4#*)
akargl@42169
    52
"Script BiegelinieScript                                             " ^
akargl@42169
    53
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^
akargl@42169
    54
"(rb_rb::bool list) (rm_rm::bool list) =                             " ^
akargl@42169
    55
"  (let q___q = Take (q_q v_v = q__q);                               " ^
akargl@42169
    56
"      (M1__M1::bool) = Substitute [v_v = 0]      q___q ;            " ^
akargl@42169
    57
"       M1__M1 =        Substitute [v_v = 1]      q___q ;            " ^
akargl@42169
    58
"       M1__M1 =        Substitute [v_v = 2]      q___q ;            " ^
akargl@42169
    59
"       M1__M1 =        Substitute [v_v = 3]      q___q ;            " ^
akargl@42169
    60
"       M1__M1 =        Substitute [M_b 0 = 0]  M1__M1               " ^
akargl@42169
    61
" in True)"
neuper@37906
    62
;
neuper@37906
    63
val str = (*#5#*)
akargl@42169
    64
"Script BiegelinieScript                                             " ^
akargl@42169
    65
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^
akargl@42169
    66
"(rb_rb::bool list) (rm_rm::bool list) =                             " ^
akargl@42169
    67
"  (let q___q = Take (M_b v_v = q__q);                               " ^
akargl@42169
    68
"      (M1__M1::bool) = Substitute [v_v = 0]      q___q ;            " ^
akargl@42169
    69
"       M2__M2 = Take q___q ;                                        " ^
akargl@42169
    70
"       M2__M2 =        Substitute [v_v = 2]      q___q              " ^
akargl@42169
    71
" in True)"
neuper@37906
    72
;
akargl@42145
    73
neuper@37906
    74
val sc' = ((inst_abs thy) o term_of o the o (parse thy)) str;
neuper@37906
    75
atomty sc';
akargl@42145
    76
akargl@42169
    77
val {scr = Script sc,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
neuper@37906
    78
(*---------------------------------------------------------------------
neuper@38031
    79
if sc = sc' then () else error"script.sml, doesnt find Substitute #1";
neuper@37906
    80
---------------------------------------------------------------------*)
neuper@37906
    81
neuper@37906
    82
"----------- WN0509 Substitute 2nd part --------------------------";
neuper@37906
    83
"----------- WN0509 Substitute 2nd part --------------------------";
neuper@37906
    84
"----------- WN0509 Substitute 2nd part --------------------------";
neuper@37906
    85
(*replace met 'IntegrierenUndKonstanteBestimmen' with this script...*)
neuper@37906
    86
val str = (*Substitute ; Substitute works*)
akargl@42169
    87
"Script BiegelinieScript                                             " ^
akargl@42169
    88
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^
akargl@42169
    89
"(rb_rb::bool list) (rm_rm::bool list) =                             "^
neuper@37906
    90
(*begin after the 2nd integrate*)
akargl@42169
    91
"  (let M__M = Take (M_b v_v = q__q);                                " ^
akargl@42169
    92
"       e1__e1 = nth_nth 1 rm_rm ;                                   " ^
akargl@42169
    93
"       (x1__x1::real) = argument_in (lhs e1__e1);                   " ^
akargl@42169
    94
"       (M1__M1::bool) = Substitute [v_v = x1__x1] M__M;             " ^
akargl@42169
    95
"        M1__M1        = Substitute [e1__e1] M1__M1                  " ^
akargl@42169
    96
" in True)"
neuper@37906
    97
;
neuper@37906
    98
val sc' = ((inst_abs thy) o term_of o the o (parse thy)) str;
neuper@37906
    99
atomty sc';
akargl@42145
   100
neuper@37906
   101
val str = (*Substitute @@ Substitute does NOT work???*)
akargl@42169
   102
"Script BiegelinieScript                                             " ^
akargl@42169
   103
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real)              " ^
akargl@42169
   104
"(rb_rb::bool list) (rm_rm::bool list) =                             "^
neuper@37906
   105
(*begin after the 2nd integrate*)
akargl@42169
   106
"  (let M__M = Take (M_b v_v = q__q);                                " ^
akargl@42169
   107
"       e1__e1 = nth_nth 1 rm_rm ;                                   " ^
akargl@42169
   108
"       (x1__x1::real) = argument_in (lhs e1__e1);                   " ^
akargl@42169
   109
"       (M1__M1::bool) = ((Substitute [v_v = x1__x1]) @@             " ^
akargl@42169
   110
"                       (Substitute [e1__e1]))        M__M           " ^
akargl@42169
   111
" in True)"
neuper@37906
   112
;
neuper@37906
   113
akargl@42169
   114
val {scr = Script sc,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
neuper@37906
   115
(*---------------------------------------------------------------------
akargl@42169
   116
if sc = sc' then () else error "script.sml, doesnt find Substitute #1";
neuper@37906
   117
---------------------------------------------------------------------*)
neuper@37906
   118
val fmz = ["Traegerlaenge L",
neuper@37906
   119
	   "Streckenlast (- q_0 * x^^^2 / 2 + x * c + c_2)",
neuper@37906
   120
	   "Biegelinie y",
neuper@37906
   121
	   "RandbedingungenBiegung [y 0 = 0, y L = 0]",
neuper@37906
   122
	   "RandbedingungenMoment [M_b 0 = 0, M_b L = 0]",
neuper@37906
   123
	   "FunktionsVariable x"];
neuper@37906
   124
val (dI',pI',mI') =
neuper@38058
   125
  ("Biegelinie",["MomentBestimmte","Biegelinien"],
neuper@37906
   126
   ["IntegrierenUndKonstanteBestimmen"]);
neuper@37906
   127
val p = e_pos'; val c = [];
neuper@37906
   128
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
akargl@42169
   129
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
akargl@42169
   130
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
akargl@42169
   131
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
akargl@42169
   132
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
akargl@42169
   133
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   134
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   135
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   136
case nxt of (_, Apply_Method ["IntegrierenUndKonstanteBestimmen"]) => ()
neuper@38031
   137
	  | _ => error "script.sml, doesnt find Substitute #2";
akargl@42145
   138
akargl@42169
   139
(*========== inhibit exn AK110721 ================================================
akargl@42169
   140
(* ERROR: caused by f2str f *)
neuper@37906
   141
trace_rewrite:=true;
neuper@37906
   142
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f(*------------------------*);
neuper@37906
   143
trace_rewrite:=false;
akargl@42169
   144
  (*Exception TYPE raised:
akargl@42169
   145
    Illegal type for constant "HOL.eq" :: "[real, bool] => bool"
akargl@42169
   146
    Atools.argument'_in (Tools.lhs (ListG.nth_ (1 + -1 + -1) [])) =
akargl@42169
   147
    ListG.nth_ (1 + -1 + -1) []
akargl@42169
   148
    Exception-
akargl@42169
   149
       TYPE
akargl@42169
   150
          ("Illegal type for constant \"op =\" :: \"[real, bool] => bool\"",
akargl@42169
   151
             [],
akargl@42169
   152
             [Const ("HOL.Trueprop", "bool => prop") $
akargl@42169
   153
                   (Const ("HOL.eq", "[RealDef.real, bool] => bool") $ ... $ ...)])
akargl@42169
   154
       raised
akargl@42169
   155
    ... this was because eval_argument_in took "argument_in (lhs (M_b 0 = 0))"
akargl@42169
   156
    ie. the argument had not been simplified before          ^^^^^^^^^^^^^^^
akargl@42169
   157
    thus corrected eval_argument_in OK*)
akargl@42169
   158
========== inhibit exn AK110721 ================================================*)
neuper@37906
   159
neuper@37906
   160
val {srls,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
akargl@42169
   161
val e1__e1 = str2term "nth_nth 1 [M_b 0 = 0, M_b L = 0]";
akargl@42169
   162
val e1__e1 = eval_listexpr_ @{theory Biegelinie} srls e1__e1; term2str e1__e1;
akargl@42169
   163
akargl@42145
   164
(*========== inhibit exn 110721 ================================================
akargl@42169
   165
(*AK110722
akargl@42169
   166
 TRIAL: Should be the same
akargl@42169
   167
 term2str e1__e1 = "M_b 0 = 0";
akargl@42169
   168
 term2str e1__e1;*)
akargl@42145
   169
akargl@42169
   170
if term2str e1__e1 = "M_b 0 = 0"
akargl@42169
   171
  then ()
akargl@42169
   172
  else error"script.sml diff.beh. eval_listexpr_ nth_nth 1 [...";
akargl@42145
   173
========== inhibit exn 110721 ================================================*)
neuper@37906
   174
neuper@37906
   175
(*TODO.WN050913 ??? doesnt eval_listexpr_ go into subterms ???...
akargl@42169
   176
 val x1__ = str2term"argument_in (lhs (M_b 0 = 0))";
akargl@42169
   177
 val x1__ = eval_listexpr_ Biegelinie.thy srls x1__; term2str x1__;
akargl@42169
   178
 (*no rewrite*)
akargl@42169
   179
 calculate_ Biegelinie.thy ("Tools.lhs", eval_rhs"eval_lhs_") x1__;
akargl@42169
   180
 val SOME (str, t) = eval_lhs 0 "Tools.lhs" (str2term"lhs (M_b 0 = 0)") 0;*)
neuper@37906
   181
akargl@42169
   182
val l__l = str2term "lhs (M_b 0 = 0)";
akargl@42169
   183
(*AK110722 eval_listexpr_ is prob. without _ ????*)
akargl@42169
   184
val l__l = eval_listexpr_ @{theory Biegelinie} srls l__l; term2str l__l;
akargl@42169
   185
val SOME (str, t) = eval_lhs 0 "Tools.lhs" (str2term "lhs (M_b 0 = 0)") 0;
akargl@42145
   186
(*========== inhibit exn 110721 ================================================
neuper@37906
   187
trace_rewrite:=true;
akargl@42169
   188
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f (*------------------------*);
neuper@37906
   189
trace_rewrite:=false;
akargl@42145
   190
========== inhibit exn 110721 ================================================*)
neuper@37906
   191
neuper@37906
   192
show_mets();
neuper@37906
   193
neuper@37906
   194
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@37906
   195
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@37906
   196
"----------- fun sel_appl_atomic_tacs ----------------------------";
akargl@42145
   197
neuper@37906
   198
states:=[];
neuper@41970
   199
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@41970
   200
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@37906
   201
   ["Test","squ-equ-test-subpbl1"]))];
neuper@37906
   202
Iterator 1;
neuper@37906
   203
moveActiveRoot 1;
neuper@37906
   204
autoCalculate 1 CompleteCalcHead;
neuper@37906
   205
autoCalculate 1 (Step 1);
neuper@37906
   206
autoCalculate 1 (Step 1);
neuper@37906
   207
val ((pt, p), _) = get_calc 1; show_pt pt;
neuper@37906
   208
val appltacs = sel_appl_atomic_tacs pt p;
akargl@42145
   209
akargl@42169
   210
(*========== inhibit exn AK110721 ================================================
akargl@42169
   211
(*(*These SHOULD be the same*)
akargl@42145
   212
 print_depth(999);
akargl@42145
   213
 appltacs;
akargl@42145
   214
 [Rewrite ("radd_commute", "?m + ?n = ?n + ?m"),
akargl@42145
   215
    Rewrite ("radd_assoc", "?m + ?n + ?k = ?m + (?n + ?k)"),
akargl@42169
   216
    Calculate "TIMES"];*)
akargl@42145
   217
neuper@37906
   218
if appltacs = 
neuper@37906
   219
   [Rewrite ("radd_commute", "?m + ?n = ?n + ?m"),
neuper@37906
   220
    Rewrite ("radd_assoc", "?m + ?n + ?k = ?m + (?n + ?k)"),
akargl@42169
   221
    Calculate "TIMES"] then ()
neuper@38031
   222
else error "script.sml fun sel_appl_atomic_tacs diff.behav.";
akargl@42169
   223
========== inhibit exn AK110721 ================================================*)
neuper@37906
   224
neuper@37906
   225
trace_script := true;
neuper@37906
   226
trace_script := false;
neuper@37906
   227
applyTactic 1 p (hd appltacs);
neuper@37906
   228
val ((pt, p), _) = get_calc 1; show_pt pt;
neuper@37906
   229
val appltacs = sel_appl_atomic_tacs pt p;
neuper@37906
   230
akargl@42169
   231
(*(* AK110722 Debugging start*)
akargl@42169
   232
(*applyTactic 1 p (hd appltacs); WAS assy: call by ([3], Pbl)*)
akargl@42169
   233
"~~~~~ fun applyTactic, args:"; val ((cI:calcID), ip, tac) = (1, p, (hd appltacs));
akargl@42169
   234
val ((pt, _), _) = get_calc cI;
akargl@42169
   235
val p = get_pos cI 1;
akargl@42169
   236
akargl@42169
   237
locatetac;
akargl@42169
   238
locatetac tac;
akargl@42169
   239
locatetac tac;
akargl@42169
   240
akargl@42169
   241
(*locatetac tac (pt, ip); (*WAS assy: call by ([3], Pbl)*)*)
akargl@42169
   242
"~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, ip));
akargl@42169
   243
val (mI,m) = mk_tac'_ tac;
akargl@42169
   244
akargl@42169
   245
applicable_in p pt m ; (*Appl*)
akargl@42169
   246
akargl@42169
   247
member op = specsteps mI; (*false*)
akargl@42169
   248
akargl@42169
   249
(*loc_solve_ (mI,m) ptp; (*Argument: (mI, m) : string * tac Reason: Can't unify tac_ with tac*)*)
akargl@42169
   250
loc_solve_; (*without _ ??? result is -> lOc writing error ???*)
akargl@42169
   251
(*val it = fn: string * tac_ -> ptree * (pos * pos_) -> lOc_*)
akargl@42169
   252
(mI,m); (*string * tac*)
akargl@42169
   253
ptp (*ptree * pos'*);
akargl@42169
   254
akargl@42169
   255
"~~~~~ fun loc_solve_, args:"; val (m ,(pt,pos)) = ((mI,m), ptp);
akargl@42169
   256
(*val (msg, cs') = solve m (pt, pos);
akargl@42169
   257
(*Argument: m : string * tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
akargl@42169
   258
akargl@42169
   259
m;
akargl@42169
   260
(pt, pos);
akargl@42169
   261
akargl@42169
   262
"~~~~~ fun solve, args:"; val ((mI,m), (pt, po as (p,p_))) = (m, (pt, pos));
akargl@42169
   263
(*solve has still p_!!!!!!!!!!!!!!!!!!!!!!!!!*)
akargl@42169
   264
akargl@42169
   265
e_metID = get_obj g_metID pt (par_pblobj pt p); (*false*)
akargl@42169
   266
val ctxt = get_ctxt pt po;
akargl@42169
   267
akargl@42169
   268
(*generate1 (assoc_thy (get_obj g_domID pt (par_pblobj pt p))) m (e_istate, ctxt) (p,p_) pt;
akargl@42169
   269
(*Argument: m : tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
akargl@42169
   270
(assoc_thy (get_obj g_domID pt (par_pblobj pt p)));
akargl@42169
   271
assoc_thy;
akargl@42169
   272
akargl@42169
   273
(*not finished - error continues in fun generate1*)
akargl@42169
   274
(* AK110722 Debugging end*)*)
akargl@42169
   275
(*========== inhibit exn AK110721 ================================================
akargl@42169
   276
"----- WN080102 these vvv do not work, because locatetac starts the search" ^
akargl@42169
   277
 "1 stac too low";
akargl@42169
   278
(* AK110722 ERROR: assy: call by ([3], Pbl) *)
neuper@37906
   279
applyTactic 1 p (hd appltacs);
akargl@42169
   280
============ inhibit exn AK110721 ==============================================*)
akargl@42169
   281
neuper@37906
   282
autoCalculate 1 CompleteCalc;
neuper@37906
   283
neuper@41969
   284
"----------- fun init_form, fun get_stac -------------------------";
neuper@41969
   285
"----------- fun init_form, fun get_stac -------------------------";
neuper@41969
   286
"----------- fun init_form, fun get_stac -------------------------";
neuper@41969
   287
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
neuper@41969
   288
val (dI',pI',mI') = ("Test",["sqroot-test","univariate","equation","test"],
neuper@41969
   289
  ["Test","squ-equ-test-subpbl1"]);
neuper@41969
   290
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@41969
   291
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   292
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   293
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   294
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   295
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   296
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   297
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   298
"~~~~~ fun me, args:"; val (_,tac) = nxt;
neuper@41969
   299
"~~~~~ fun locatetac, args:"; val ptp as (pt, p) = (pt, p);
neuper@41969
   300
val (mI,m) = mk_tac'_ tac;
neuper@41969
   301
val Appl m = applicable_in p pt m;
neuper@41969
   302
member op = specsteps mI; (*false*)
neuper@41969
   303
"~~~~~ fun loc_solve_, args:"; val (m, (pt, pos) ) = ((mI, m), ptp);
neuper@41969
   304
"~~~~~ fun solve, args:"; val (("Apply_Method", Apply_Method' (mI,_,_,_)), pos as (p,_)) = (m, pos);
neuper@41969
   305
val {srls, ...} = get_met mI;
neuper@41969
   306
val PblObj {meth=itms, ...} = get_obj I pt p;
neuper@41969
   307
val thy' = get_obj g_domID pt p;
neuper@41969
   308
val thy = assoc_thy thy';
neuper@41969
   309
val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
neuper@41969
   310
val ini = init_form thy sc env;
neuper@41969
   311
"----- fun init_form, args:"; val (Script sc) = sc;
neuper@41969
   312
"----- fun get_stac, args:"; val (y, h $ body) = (thy, sc);
neuper@41969
   313
case get_stac thy sc of SOME (Free ("e_e", _)) => ()
neuper@41969
   314
| _ => error "script: Const (?, ?) in script (as term) changed";;
neuper@41969
   315
neuper@41972
   316
neuper@41972
   317
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
neuper@41972
   318
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
neuper@41972
   319
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
neuper@41972
   320
val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
neuper@41972
   321
val (dI',pI',mI') =
neuper@41972
   322
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@41972
   323
   ["Test","squ-equ-test-subpbl1"]);
neuper@41972
   324
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@41972
   325
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   326
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   327
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   328
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   329
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   330
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   331
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   332
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   333
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
neuper@41972
   334
(*val (p,_,f,nxt,_,pt) = me nxt p [1] pt; WAS: Empty_Tac, helpless*)
neuper@41972
   335
show_pt pt;
neuper@41972
   336
"~~~~~ fun me, args:"; val (_,tac) = nxt;
neuper@41973
   337
val (pt, p) = case locatetac tac (pt,p) of
neuper@41973
   338
	("ok", (_, _, ptp))  => ptp | _ => error "script.sml locatetac";
neuper@41972
   339
"~~~~~ fun step, args:"; val (ip as (_,p_), (ptp as (pt,p), tacis)) = (p, ((pt, e_pos'), []))
neuper@41999
   340
val pIopt = get_pblID (pt,ip); (*SOME ["linear", "univariate", "equation", "test"]*)
neuper@41972
   341
tacis; (*= []*)
neuper@41972
   342
member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); (*= false*)
neuper@41972
   343
"~~~~~ fun nxt_solve_, args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
neuper@41972
   344
                                 (*WAS stac2tac_ TODO: no match for SubProblem*)
neuper@41972
   345
val thy' = get_obj g_domID pt (par_pblobj pt p);
neuper@41972
   346
val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
neuper@41972
   347
"~~~~~ fun next_tac, args:"; val (thy, (ptp as (pt,(p,_)):ptree * pos'), (sc as Script (h $ body)), 
neuper@41972
   348
	                               (ScrState (E,l,a,v,s,b), ctxt)) = ((thy',srls), (pt,pos), sc, is);
neuper@41972
   349
l; (*= [R, L, R, L, R, R]*)
neuper@41972
   350
val Appy (m', scrst as (_,_,_,v,_,_)) = nstep_up thy ptp sc E l Skip_ a v;
neuper@41972
   351
"~~~~~ dont like to go into nstep_up...";
neuper@41972
   352
val t = str2term ("SubProblem" ^ 
neuper@41972
   353
  "(Test', [linear, univariate, equation, test], [Test, solve_linear])" ^
neuper@41972
   354
  "[BOOL (-1 + x = 0), REAL x]");
neuper@41972
   355
val (tac, tac_) = stac2tac_ pt @{theory "Isac"} t; (*WAS stac2tac_ TODO: no match for SubProblem*)
neuper@41972
   356
case tac_ of 
neuper@41972
   357
  Subproblem' _ => ()
neuper@41972
   358
| _ => error "script.sml x+1=2 start SubProblem from script";
neuper@41972
   359
neuper@41972
   360
neuper@42283
   361
"----------- Take as 1st stac in script --------------------------";
neuper@42283
   362
"----------- Take as 1st stac in script --------------------------";
neuper@42283
   363
"----------- Take as 1st stac in script --------------------------";
neuper@42283
   364
val p = e_pos'; val c = []; 
neuper@42283
   365
val (p,_,f,nxt,_,pt) = 
neuper@42283
   366
    CalcTreeTEST 
neuper@42283
   367
        [(["functionTerm (x^^^2 + 1)", "integrateBy x", "antiDerivative FF"],
neuper@42283
   368
          ("Integrate", ["integrate","function"], ["diff","integration"]))];
neuper@42283
   369
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*)
neuper@42283
   370
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42283
   371
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42283
   372
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42283
   373
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42283
   374
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42283
   375
val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@42283
   376
case nxt of (_, Apply_Method ["diff", "integration"]) => ()
neuper@42283
   377
          | _ => error "integrate.sml -- me method [diff,integration] -- spec";
neuper@42283
   378
"----- step 8: returns nxt = Rewrite_Set_Inst ([\"(bdv, x)\"],\"integration\")";
neuper@42283
   379
neuper@42283
   380
"~~~~~ fun me, args:"; val (((_,tac):tac'_), (p:pos'), _, (pt:ptree)) = (nxt, p, c, pt);
neuper@42283
   381
"~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
neuper@42283
   382
val (mI,m) = mk_tac'_ tac;
neuper@42283
   383
val Appl m = applicable_in p pt m;
neuper@42283
   384
member op = specsteps mI (*false*);
neuper@42283
   385
"~~~~~ fun loc_solve_, args:"; val (m, (pt,pos)) = ((mI,m), ptp);
neuper@42283
   386
"~~~~~ fun solve, args:"; val ((_, m as Apply_Method' (mI, _, _, _)), (pt, (pos as (p,_)))) = 
neuper@42283
   387
                            (m, (pt, pos));
neuper@42283
   388
val {srls, ...} = get_met mI;
neuper@42283
   389
        val PblObj {meth=itms, ...} = get_obj I pt p;
neuper@42283
   390
        val thy' = get_obj g_domID pt p;
neuper@42283
   391
        val thy = assoc_thy thy';
neuper@42283
   392
        val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
neuper@42283
   393
        val ini = init_form thy sc env;
neuper@42283
   394
        val p = lev_dn p;
neuper@42283
   395
ini = NONE; (*true*)
neuper@42283
   396
            val (m', (is', ctxt'), _) = next_tac (thy', srls) (pt, (p, Res)) sc (is, ctxt);
neuper@42283
   397
	            val d = e_rls (*FIXME: get simplifier from domID*);
neuper@42283
   398
"~~~~~ fun locate_gen, args:"; val ((ts as (thy',srls)), (m:tac_), ((pt,p):ptree * pos'), 
neuper@42283
   399
	                     (scr as Script (h $ body),d), (ScrState (E,l,a,v,S,b), ctxt)) = 
neuper@42283
   400
                   ((thy',srls), m', (pt,(p, Res)), (sc,d), (is', ctxt'));
neuper@42283
   401
val thy = assoc_thy thy';
neuper@42283
   402
l = [] orelse ((*init.in solve..Apply_Method...*)
neuper@42283
   403
			         (last_elem o fst) p = 0 andalso snd p = Res); (*true*)
neuper@42283
   404
"~~~~~ fun assy, args:"; val (ya, (is as (E,l,a,v,S,b),ss), 
neuper@42283
   405
                   (Const ("HOL.Let",_) $ e $ (Abs (id,T,body)))) = 
neuper@42283
   406
                 ((thy',ctxt,srls,d,Aundef), ((E,[R],a,v,S,b), [(m,EmptyMout,pt,p,[])]), body);
neuper@42283
   407
 (*check: true*) term2str e = "Take (Integral f_f D v_v)";
neuper@42283
   408
"~~~~~ fun assy, args:"; val ((thy',ctxt,sr,d,ap), (is as (E,l,a,v,S,b), (m,_,pt,(p,p_),c)::ss), t) = 
neuper@42283
   409
                           (ya, ((E , l@[L,R], a,v,S,b),ss), e);
neuper@42283
   410
val (a', STac stac) = handle_leaf "locate" thy' sr E a v t;
neuper@42283
   411
(*             val ctxt = get_ctxt pt (p,p_)
neuper@42283
   412
exception PTREE "get_obj: pos = [0] does not exist" raised 
neuper@42283
   413
(line 908 of "/usr/local/isabisac/src/Tools/isac/Interpret/ctree.sml")*)
neuper@42283
   414
neuper@42283
   415