test/Tools/isac/Interpret/script.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Tue, 25 Jun 2019 16:21:18 +0200
changeset 59561 a95feb17054f
parent 59559 f25ce1922b60
child 59582 23984b62804f
permissions -rw-r--r--
lucin: adapt tests to new file src/../lucas-interpreter.sml
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
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@41969
     9
"----------- fun init_form, fun get_stac -------------------------";
neuper@42438
    10
"----------- fun sel_rules ---------------------------------------";
neuper@42438
    11
"----------- fun sel_appl_atomic_tacs ----------------------------";
wneuper@59257
    12
"----------- fun de_esc_underscore -------------------------------";
wneuper@59257
    13
"----------- fun go ----------------------------------------------";
wneuper@59257
    14
"----------- fun formal_args -------------------------------------";
wneuper@59257
    15
"----------- fun dsc_valT ----------------------------------------";
wneuper@59257
    16
"----------- fun itms2args ---------------------------------------";
wneuper@59257
    17
"----------- fun rep_tac_ ----------------------------------------";
wneuper@59539
    18
"----------- fun init_scrstate -----------------------------------------------------------------";
neuper@37906
    19
"-----------------------------------------------------------------";
neuper@37906
    20
"-----------------------------------------------------------------";
neuper@37906
    21
"-----------------------------------------------------------------";
neuper@37906
    22
neuper@42438
    23
val thy =  @{theory Isac};
neuper@42281
    24
neuper@37906
    25
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@37906
    26
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@37906
    27
"----------- fun sel_appl_atomic_tacs ----------------------------";
akargl@42145
    28
s1210629013@55445
    29
reset_states ();
neuper@41970
    30
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@41970
    31
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@37906
    32
   ["Test","squ-equ-test-subpbl1"]))];
neuper@37906
    33
Iterator 1;
neuper@37906
    34
moveActiveRoot 1;
wneuper@59248
    35
autoCalculate 1 CompleteCalcHead;
wneuper@59248
    36
autoCalculate 1 (Step 1);
wneuper@59248
    37
autoCalculate 1 (Step 1);
neuper@37906
    38
val ((pt, p), _) = get_calc 1; show_pt pt;
neuper@37906
    39
val appltacs = sel_appl_atomic_tacs pt p;
wneuper@59252
    40
case appltacs of 
wneuper@59252
    41
  [Rewrite ("radd_commute", radd_commute), 
wneuper@59252
    42
  Rewrite ("add_assoc", add_assoc), Calculate "TIMES"]
wneuper@59253
    43
  => if (term2str o Thm.prop_of) radd_commute = "?m + ?n = ?n + ?m" andalso 
wneuper@59253
    44
        (term2str o Thm.prop_of) add_assoc = "?a + ?b + ?c = ?a + (?b + ?c)" then ()
wneuper@59252
    45
        else error "script.sml fun sel_appl_atomic_tacs diff.behav. 2"
wneuper@59252
    46
| _ => error "script.sml fun sel_appl_atomic_tacs diff.behav. 1";
neuper@37906
    47
neuper@37906
    48
trace_script := true;
neuper@37906
    49
trace_script := false;
neuper@37906
    50
applyTactic 1 p (hd appltacs);
neuper@37906
    51
val ((pt, p), _) = get_calc 1; show_pt pt;
neuper@37906
    52
val appltacs = sel_appl_atomic_tacs pt p;
neuper@48895
    53
(*applyTactic 1 p (hd appltacs); WAS assy: call by ([3], Pbl)*)
neuper@37906
    54
akargl@42169
    55
"~~~~~ fun applyTactic, args:"; val ((cI:calcID), ip, tac) = (1, p, (hd appltacs));
akargl@42169
    56
val ((pt, _), _) = get_calc cI;
akargl@42169
    57
val p = get_pos cI 1;
akargl@42169
    58
locatetac;
akargl@42169
    59
locatetac tac;
akargl@42169
    60
akargl@42169
    61
(*locatetac tac (pt, ip); (*WAS assy: call by ([3], Pbl)*)*)
akargl@42169
    62
"~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, ip));
akargl@42169
    63
val (mI,m) = mk_tac'_ tac;
akargl@42169
    64
applicable_in p pt m ; (*Appl*)
akargl@42169
    65
member op = specsteps mI; (*false*)
akargl@42169
    66
(*loc_solve_ (mI,m) ptp; (*Argument: (mI, m) : string * tac Reason: Can't unify tac_ with tac*)*)
akargl@42169
    67
loc_solve_; (*without _ ??? result is -> lOc writing error ???*)
wneuper@59279
    68
(*val it = fn: string * tac_ -> ctree * (pos * pos_) -> lOc_*)
akargl@42169
    69
(mI,m); (*string * tac*)
wneuper@59279
    70
ptp (*ctree * pos'*);
akargl@42169
    71
"~~~~~ fun loc_solve_, args:"; val (m ,(pt,pos)) = ((mI,m), ptp);
akargl@42169
    72
(*val (msg, cs') = solve m (pt, pos);
akargl@42169
    73
(*Argument: m : string * tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
akargl@42169
    74
m;
akargl@42169
    75
(pt, pos);
akargl@42169
    76
"~~~~~ fun solve, args:"; val ((mI,m), (pt, po as (p,p_))) = (m, (pt, pos));
akargl@42169
    77
(*solve has still p_!!!!!!!!!!!!!!!!!!!!!!!!!*)
akargl@42169
    78
akargl@42169
    79
e_metID = get_obj g_metID pt (par_pblobj pt p); (*false*)
akargl@42169
    80
val ctxt = get_ctxt pt po;
akargl@42169
    81
akargl@42169
    82
(*generate1 (assoc_thy (get_obj g_domID pt (par_pblobj pt p))) m (e_istate, ctxt) (p,p_) pt;
akargl@42169
    83
(*Argument: m : tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
akargl@42169
    84
(assoc_thy (get_obj g_domID pt (par_pblobj pt p)));
akargl@42169
    85
assoc_thy;
akargl@42169
    86
wneuper@59248
    87
autoCalculate 1 CompleteCalc;
neuper@37906
    88
neuper@41969
    89
"----------- fun init_form, fun get_stac -------------------------";
neuper@41969
    90
"----------- fun init_form, fun get_stac -------------------------";
neuper@41969
    91
"----------- fun init_form, fun get_stac -------------------------";
neuper@41969
    92
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
neuper@41969
    93
val (dI',pI',mI') = ("Test",["sqroot-test","univariate","equation","test"],
neuper@41969
    94
  ["Test","squ-equ-test-subpbl1"]);
neuper@41969
    95
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@41969
    96
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
    97
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
    98
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
    99
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   100
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   101
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   102
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41969
   103
"~~~~~ fun me, args:"; val (_,tac) = nxt;
neuper@41969
   104
"~~~~~ fun locatetac, args:"; val ptp as (pt, p) = (pt, p);
neuper@41969
   105
val (mI,m) = mk_tac'_ tac;
neuper@41969
   106
val Appl m = applicable_in p pt m;
neuper@41969
   107
member op = specsteps mI; (*false*)
neuper@41969
   108
"~~~~~ fun loc_solve_, args:"; val (m, (pt, pos) ) = ((mI, m), ptp);
neuper@41969
   109
"~~~~~ fun solve, args:"; val (("Apply_Method", Apply_Method' (mI,_,_,_)), pos as (p,_)) = (m, pos);
neuper@41969
   110
val {srls, ...} = get_met mI;
neuper@41969
   111
val PblObj {meth=itms, ...} = get_obj I pt p;
neuper@41969
   112
val thy' = get_obj g_domID pt p;
neuper@41969
   113
val thy = assoc_thy thy';
neuper@41969
   114
val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
neuper@41969
   115
val ini = init_form thy sc env;
neuper@48790
   116
"----- fun init_form, args:"; val (Prog sc) = sc;
neuper@41969
   117
"----- fun get_stac, args:"; val (y, h $ body) = (thy, sc);
neuper@41969
   118
case get_stac thy sc of SOME (Free ("e_e", _)) => ()
neuper@41969
   119
| _ => error "script: Const (?, ?) in script (as term) changed";;
neuper@41969
   120
neuper@42438
   121
"----------- fun sel_rules ---------------------------------------";
neuper@42438
   122
"----------- fun sel_rules ---------------------------------------";
neuper@42438
   123
"----------- fun sel_rules ---------------------------------------";
neuper@42438
   124
(* compare test/../interface.sml
neuper@42438
   125
"--------- getTactic, fetchApplicableTactics ------------";
neuper@42438
   126
*)
s1210629013@55445
   127
 reset_states ();
neuper@42438
   128
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@42438
   129
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@42438
   130
    ["Test","squ-equ-test-subpbl1"]))];
neuper@42438
   131
 Iterator 1;
neuper@42438
   132
 moveActiveRoot 1;
wneuper@59248
   133
 autoCalculate 1 CompleteCalc;
neuper@42438
   134
 val ((pt,_),_) = get_calc 1;
neuper@42438
   135
 show_pt pt;
neuper@42394
   136
neuper@42438
   137
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
neuper@42438
   138
 val tacs = sel_rules pt ([],Pbl);
wneuper@59253
   139
 case tacs of [Apply_Method ["Test", "squ-equ-test-subpbl1"]] => ()
wneuper@59253
   140
 | _ => error "script.sml: diff.behav. in sel_rules ([],Pbl)";
neuper@42438
   141
neuper@42438
   142
 val tacs = sel_rules pt ([1],Res);
wneuper@59253
   143
 case tacs of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
neuper@55279
   144
      Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
wneuper@59253
   145
      Check_elementwise "Assumptions"] => ()
wneuper@59253
   146
 | _ => error "script.sml: diff.behav. in sel_rules ([1],Res)";
neuper@42438
   147
neuper@42438
   148
 val tacs = sel_rules pt ([3],Pbl);
wneuper@59253
   149
 case tacs of [Apply_Method ["Test", "solve_linear"]] => ()
wneuper@59253
   150
 | _ => error "script.sml: diff.behav. in sel_rules ([3],Pbl)";
neuper@42438
   151
neuper@42438
   152
 val tacs = sel_rules pt ([3,1],Res);
wneuper@59497
   153
 case tacs of [Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"), Rewrite_Set "Test_simplify"] => ()
wneuper@59253
   154
 | _ => error "script.sml: diff.behav. in sel_rules ([3,1],Res)";
neuper@42438
   155
neuper@42438
   156
 val tacs = sel_rules pt ([3],Res);
wneuper@59253
   157
 case tacs of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
neuper@55279
   158
      Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
wneuper@59253
   159
      Check_elementwise "Assumptions"] => ()
wneuper@59253
   160
 | _ => error "script.sml: diff.behav. in sel_rules ([3],Res)";
neuper@42438
   161
neuper@42438
   162
 val tacs = (sel_rules pt ([],Res)) handle PTREE str => [Tac str];
wneuper@59253
   163
 case tacs of [Tac "no tactics applicable at the end of a calculation"] => ()
wneuper@59253
   164
 | _ => error "script.sml: diff.behav. in sel_rules ([],Res)";
neuper@42438
   165
neuper@42438
   166
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@42438
   167
"----------- fun sel_appl_atomic_tacs ----------------------------";
neuper@42438
   168
"----------- fun sel_appl_atomic_tacs ----------------------------";
s1210629013@55445
   169
 reset_states ();
neuper@42438
   170
 CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], 
neuper@42438
   171
   ("Test", ["sqroot-test","univariate","equation","test"],
neuper@42438
   172
    ["Test","squ-equ-test-subpbl1"]))];
neuper@42438
   173
 Iterator 1;
neuper@42438
   174
 moveActiveRoot 1;
wneuper@59248
   175
 autoCalculate 1 CompleteCalc;
neuper@42438
   176
neuper@42438
   177
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
neuper@42438
   178
 fetchApplicableTactics 1 99999 ([],Pbl);
neuper@42438
   179
neuper@42438
   180
 fetchApplicableTactics 1 99999 ([1],Res);
neuper@42438
   181
"~~~~~ fun fetchApplicableTactics, args:"; val (cI, (scope:int), (p:pos')) = (1, 99999, ([1],Res));
neuper@42438
   182
val ((pt, _), _) = get_calc cI;
neuper@42438
   183
(*version 1:*)
wneuper@59253
   184
case sel_rules pt p of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
neuper@55279
   185
  Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
wneuper@59253
   186
  Check_elementwise "Assumptions"] => ()
wneuper@59253
   187
| _ => error "fetchApplicableTactics ([1],Res) changed";
neuper@42438
   188
(*version 2:*)
neuper@42438
   189
(*WAS:
neuper@42438
   190
sel_appl_atomic_tacs pt p;
neuper@42438
   191
...
neuper@55279
   192
### atomic_appl_tacs: not impl. for tac='Subproblem(Test,["LINEAR","univariate","equation","test"])' 
neuper@42438
   193
### atomic_appl_tacs: not impl. for tac = 'Check_elementwise "Assumptions"' 
neuper@42438
   194
*)
neuper@42438
   195
neuper@42438
   196
"~~~~~ fun sel_appl_atomic_tacs, args:"; val (pt, (p,p_)) = (pt, p);
neuper@42438
   197
is_spec_pos p_ = false;
neuper@42438
   198
        val pp = par_pblobj pt p
neuper@42438
   199
        val thy' = (get_obj g_domID pt pp):theory'
neuper@42438
   200
        val thy = assoc_thy thy'
neuper@42438
   201
        val metID = get_obj g_metID pt pp
neuper@42438
   202
        val metID' =
neuper@42438
   203
          if metID = e_metID 
neuper@42438
   204
          then (thd3 o snd3) (get_obj g_origin pt pp)
neuper@42438
   205
          else metID
neuper@48790
   206
        val {scr=Prog sc,srls,erls,rew_ord'=ro,...} = get_met metID'
neuper@42438
   207
        val ScrState (env,_,a,v,_,_) = get_istate pt (p,p_)
neuper@42438
   208
        val alltacs = (*we expect at least 1 stac in a script*)
neuper@42438
   209
          map ((stac2tac pt thy) o rep_stacexpr o #2 o
neuper@42438
   210
           (handle_leaf "selrul" thy' srls env a v)) (stacpbls sc)
neuper@42438
   211
        val f =
neuper@42438
   212
          case p_ of
neuper@42438
   213
              Frm => get_obj g_form pt p
wneuper@59257
   214
            | Res => (fst o (get_obj g_result pt)) p;
neuper@42438
   215
(*WN120611 stopped and took version 1 again for fetchApplicableTactics !
neuper@42438
   216
(distinct o flat o (map (atomic_appl_tacs thy ro erls f))) alltacs
neuper@42438
   217
...
neuper@55279
   218
### atomic_appl_tacs: not impl. for tac='Subproblem(Test,["LINEAR","univariate","equation","test"])' 
neuper@42438
   219
### atomic_appl_tacs: not impl. for tac = 'Check_elementwise "Assumptions"' 
neuper@42438
   220
*)
neuper@42438
   221
wneuper@59257
   222
"----------- fun de_esc_underscore -------------------------------";
wneuper@59257
   223
"----------- fun de_esc_underscore -------------------------------";
wneuper@59257
   224
"----------- fun de_esc_underscore -------------------------------";
wneuper@59257
   225
(*
wneuper@59257
   226
> val str = "Rewrite_Set_Inst";
wneuper@59257
   227
> val esc = esc_underscore str;
wneuper@59257
   228
val it = "Rewrite'_Set'_Inst" : string
wneuper@59257
   229
> val des = de_esc_underscore esc;
wneuper@59257
   230
 val des = de_esc_underscore esc;*)
wneuper@59257
   231
wneuper@59257
   232
"----------- fun go ----------------------------------------------";
wneuper@59257
   233
"----------- fun go ----------------------------------------------";
wneuper@59257
   234
"----------- fun go ----------------------------------------------";
wneuper@59257
   235
(*
wneuper@59257
   236
> val t = (Thm.term_of o the o (parse thy)) "a+b";
wneuper@59257
   237
val it = Const (#,#) $ Free (#,#) $ Free ("b","RealDef.real") : term
wneuper@59257
   238
> val plus_a = go [L] t; 
wneuper@59257
   239
> val b = go [R] t; 
wneuper@59257
   240
> val plus = go [L,L] t; 
wneuper@59257
   241
> val a = go [L,R] t;
wneuper@59257
   242
wneuper@59257
   243
> val t = (Thm.term_of o the o (parse thy)) "a+b+c";
wneuper@59257
   244
val t = Const (#,#) $ (# $ # $ Free #) $ Free ("c","RealDef.real") : term
wneuper@59257
   245
> val pl_pl_a_b = go [L] t; 
wneuper@59257
   246
> val c = go [R] t; 
wneuper@59257
   247
> val a = go [L,R,L,R] t; 
wneuper@59257
   248
> val b = go [L,R,R] t; 
wneuper@59257
   249
*)
wneuper@59257
   250
wneuper@59257
   251
"----------- fun formal_args -------------------------------------";
wneuper@59257
   252
"----------- fun formal_args -------------------------------------";
wneuper@59257
   253
"----------- fun formal_args -------------------------------------";
wneuper@59257
   254
(*
wneuper@59257
   255
> formal_args scr;
wneuper@59257
   256
  [Free ("f_","RealDef.real"),Free ("v_","RealDef.real"),
wneuper@59257
   257
   Free ("eqs_","bool List.list")] : term list
wneuper@59257
   258
*)
wneuper@59257
   259
"----------- fun dsc_valT ----------------------------------------";
wneuper@59257
   260
"----------- fun dsc_valT ----------------------------------------";
wneuper@59257
   261
"----------- fun dsc_valT ----------------------------------------";
wneuper@59257
   262
(*> val t = (Thm.term_of o the o (parse thy)) "equality";
wneuper@59257
   263
> val T = type_of t;
wneuper@59257
   264
val T = "bool => Tools.una" : typ
wneuper@59257
   265
> val dsc = dsc_valT t;
wneuper@59257
   266
val dsc = "una" : string
wneuper@59257
   267
wneuper@59257
   268
> val t = (Thm.term_of o the o (parse thy)) "fixedValues";
wneuper@59257
   269
> val T = type_of t;
wneuper@59257
   270
val T = "bool List.list => Tools.nam" : typ
wneuper@59257
   271
> val dsc = dsc_valT t;
wneuper@59257
   272
val dsc = "nam" : string*)
wneuper@59257
   273
"----------- fun itms2args ---------------------------------------";
wneuper@59257
   274
"----------- fun itms2args ---------------------------------------";
wneuper@59257
   275
"----------- fun itms2args ---------------------------------------";
wneuper@59257
   276
(*
wneuper@59257
   277
> val sc = ... Solve_root_equation ...
wneuper@59257
   278
> val mI = ("Script","sqrt-equ-test");
wneuper@59257
   279
> val PblObj{meth={ppc=itms,...},...} = get_obj I pt [];
wneuper@59257
   280
> val ts = itms2args thy mI itms;
wneuper@59257
   281
> map (term_to_string''' thy) ts;
wneuper@59257
   282
["sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x)","x","#0"] : string list
wneuper@59257
   283
*)
wneuper@59257
   284
"----------- fun rep_tac_ ----------------------------------------";
wneuper@59257
   285
"----------- fun rep_tac_ ----------------------------------------";
wneuper@59257
   286
"----------- fun rep_tac_ ----------------------------------------";
wneuper@59257
   287
(***************fun rep_tac_ (Rewrite_Inst' (thy', rod, rls, put, subs, (thmID, _), f, (f', _))) = 
wneuper@59257
   288
Fehlersuche 25.4.01
wneuper@59257
   289
(a)----- als String zusammensetzen:
wneuper@59257
   290
ML> term2str f; 
wneuper@59257
   291
val it = "d_d x #4 + d_d x (x ^^^ #2 + #3 * x)" : string
wneuper@59257
   292
ML> term2str f'; 
wneuper@59257
   293
val it = "#0 + d_d x (x ^^^ #2 + #3 * x)" : string
wneuper@59257
   294
ML> subs;
wneuper@59257
   295
val it = [(Free ("bdv","RealDef.real"),Free ("x","RealDef.real"))] : subst
wneuper@59257
   296
> val tt = (Thm.term_of o the o (parse thy))
wneuper@59497
   297
  "(Rewrite_Inst[(''bdv'',x)]diff_const False(d_d x #4 + d_d x (x ^^^ #2 + #3 * x)))=(#0 + d_d x (x ^^^ #2 + #3 * x))";
wneuper@59257
   298
> atomty tt;
wneuper@59257
   299
ML> tracing (term2str tt); 
wneuper@59497
   300
(Rewrite_Inst [(''bdv'',x)] diff_const False d_d x #4 + d_d x (x ^^^ #2 + #3 * x)) =
wneuper@59257
   301
 #0 + d_d x (x ^^^ #2 + #3 * x)
wneuper@59257
   302
wneuper@59257
   303
(b)----- laut rep_tac_:
wneuper@59257
   304
> val ttt=HOLogic.mk_eq (lhs,f');
wneuper@59257
   305
> atomty ttt;
wneuper@59257
   306
wneuper@59257
   307
wneuper@59257
   308
(*Fehlersuche 1-2Monate vor 4.01:*)
wneuper@59257
   309
> val tt = (Thm.term_of o the o (parse thy))
wneuper@59497
   310
  "Rewrite_Inst[(''bdv'',x)]square_equation_left True(x=#1+#2)";
wneuper@59257
   311
> atomty tt;
wneuper@59257
   312
wneuper@59257
   313
> val f = (Thm.term_of o the o (parse thy)) "x=#1+#2";
wneuper@59257
   314
> val f' = (Thm.term_of o the o (parse thy)) "x=#3";
wneuper@59257
   315
> val subs = [((Thm.term_of o the o (parse thy)) "bdv",
wneuper@59257
   316
	       (Thm.term_of o the o (parse thy)) "x")];
wneuper@59257
   317
> val sT = (type_of o fst o hd) subs;
wneuper@59257
   318
> val subs' = list2isalist (HOLogic.mk_prodT (sT, sT))
wneuper@59257
   319
			      (map HOLogic.mk_prod subs);
wneuper@59257
   320
> val sT' = type_of subs';
wneuper@59257
   321
> val lhs = Const ("Script.Rewrite'_Inst",[sT',idT,fT,fT] ---> fT) 
wneuper@59257
   322
  $ subs' $ Free (thmID,idT) $ @{term True} $ f;
wneuper@59257
   323
> lhs = tt;
wneuper@59257
   324
val it = true : bool
wneuper@59257
   325
> rep_tac_ (Rewrite_Inst' 
wneuper@59257
   326
	       ("Script","tless_true","eval_rls",false,subs,
wneuper@59257
   327
		("square_equation_left",""),f,(f',[])));
wneuper@59257
   328
*)
wneuper@59257
   329
(****************************| rep_tac_ (Rewrite' (thy', _, _, put, (thmID, _), f, (f', _)))=
wneuper@59257
   330
> val tt = (Thm.term_of o the o (parse thy)) (*____   ____..test*)
wneuper@59257
   331
  "Rewrite square_equation_left True (x=#1+#2) = (x=#3)";
wneuper@59257
   332
wneuper@59257
   333
> val f = (Thm.term_of o the o (parse thy)) "x=#1+#2";
wneuper@59257
   334
> val f' = (Thm.term_of o the o (parse thy)) "x=#3";
wneuper@59257
   335
> val Thm (id,thm) = 
wneuper@59257
   336
  rep_tac_ (Rewrite' 
wneuper@59257
   337
   ("Script","tless_true","eval_rls",false,
wneuper@59257
   338
    ("square_equation_left",""),f,(f',[])));
wneuper@59257
   339
> val SOME ct = parse thy   
wneuper@59257
   340
  "Rewrite square_equation_left True (x=#1+#2)"; 
wneuper@59257
   341
> rewrite_ Script.thy tless_true eval_rls true thm ct;
wneuper@59257
   342
val it = SOME ("x = #3",[]) : (cterm * cterm list) option
wneuper@59257
   343
*)
wneuper@59257
   344
(****************************************  | rep_tac_ (Rewrite_Set_Inst' 
wneuper@59257
   345
WN050824: type error ...
wneuper@59257
   346
  let val fT = type_of f;
wneuper@59257
   347
    val sT = (type_of o fst o hd) subs;
wneuper@59257
   348
    val subs' = list2isalist (HOLogic.mk_prodT (sT, sT))
wneuper@59257
   349
      (map HOLogic.mk_prod subs);
wneuper@59257
   350
    val sT' = type_of subs';
wneuper@59257
   351
    val b = if put then @{term True} else @{term False}
wneuper@59257
   352
    val lhs = Const ("Script.Rewrite'_Set'_Inst",
wneuper@59257
   353
		     [sT',idT,fT,fT] ---> fT) 
wneuper@59257
   354
      $ subs' $ Free (id_rls rls,idT) $ b $ f;
wneuper@59257
   355
  in (((make_rule (assoc_thy thy')) o HOLogic.mk_eq) (lhs,f'),(lhs,f')) end*)
wneuper@59257
   356
(* ... vals from Rewrite_Inst' ...
wneuper@59257
   357
> rep_tac_ (Rewrite_Set_Inst' 
wneuper@59257
   358
	       ("Script",false,subs,
wneuper@59257
   359
		"isolate_bdv",f,(f',[])));
wneuper@59257
   360
*)
wneuper@59257
   361
(* val (Rewrite_Set' (thy',put,rls,f,(f',asm)))=m;
wneuper@59257
   362
*)
wneuper@59257
   363
(**************************************   | rep_tac_ (Rewrite_Set' (thy',put,rls,f,(f',asm)))=
wneuper@59257
   364
13.3.01:
wneuper@59257
   365
val thy = assoc_thy thy';
wneuper@59257
   366
val t = HOLogic.mk_eq (lhs,f');
wneuper@59257
   367
make_rule thy t;
wneuper@59257
   368
--------------------------------------------------
wneuper@59257
   369
val lll = (Thm.term_of o the o (parse thy)) 
wneuper@59257
   370
  "Rewrite_Set SqRoot_simplify False (d_d x (x ^^^ #2 + #3 * x) + d_d x #4)";
wneuper@59257
   371
wneuper@59257
   372
--------------------------------------------------
wneuper@59257
   373
> val f = (Thm.term_of o the o (parse thy)) "x=#1+#2";
wneuper@59257
   374
> val f' = (Thm.term_of o the o (parse thy)) "x=#3";
wneuper@59257
   375
> val Thm (id,thm) = 
wneuper@59257
   376
  rep_tac_ (Rewrite_Set' 
wneuper@59257
   377
   ("Script",false,"SqRoot_simplify",f,(f',[])));
wneuper@59257
   378
val id = "(Rewrite_Set SqRoot_simplify True x = #1 + #2) = (x = #3)" : string
wneuper@59257
   379
val thm = "(Rewrite_Set SqRoot_simplify True x = #1 + #2) = (x = #3)" : thm
wneuper@59257
   380
*)
wneuper@59257
   381
(*****************************************   | rep_tac_ (Calculate' (thy',op_,f,(f',thm')))=
wneuper@59257
   382
> val lhs'=(Thm.term_of o the o (parse thy))"Calculate plus (#1+#2)";
wneuper@59257
   383
  ... test-root-equ.sml: calculate ...
wneuper@59257
   384
> val Appl m'=applicable_in p pt (Calculate "PLUS");
wneuper@59257
   385
> val (lhs,_)=tac_2etac m';
wneuper@59257
   386
> lhs'=lhs;
wneuper@59257
   387
val it = true : bool*)
wneuper@59539
   388
wneuper@59539
   389
"----------- fun init_scrstate -----------------------------------------------------------------";
wneuper@59539
   390
"----------- fun init_scrstate -----------------------------------------------------------------";
wneuper@59539
   391
"----------- fun init_scrstate -----------------------------------------------------------------";
wneuper@59539
   392
val fmz = ["Traegerlaenge L","Streckenlast q_0","Biegelinie y",
wneuper@59539
   393
	     "Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0]",
wneuper@59540
   394
	     "FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
wneuper@59540
   395
	     "AbleitungBiegelinie dy"];
wneuper@59539
   396
val (dI',pI',mI') = ("Biegelinie", ["Biegelinien"],
wneuper@59539
   397
		     ["IntegrierenUndKonstanteBestimmen2"]);
wneuper@59539
   398
val p = e_pos'; val c = [];
wneuper@59539
   399
(*[], Pbl*)val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))]; (*nxt = Model_Problem*)
wneuper@59539
   400
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Given "Traegerlaenge L"*)
wneuper@59539
   401
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Given "Streckenlast q_0"*)
wneuper@59539
   402
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Find "Biegelinie y"*)
wneuper@59539
   403
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Relation "Randbedingungen [y 0 = 0]", ERROR MISSING step: M_b 0 = 0*)
wneuper@59539
   404
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Relation "Randbedingungen [y L = 0, M_b 0 = 0, M_b L = 0]"*)
wneuper@59539
   405
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Specify_Theory "Biegelinie"*)
wneuper@59539
   406
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Specify_Problem ["Biegelinien"]*)
wneuper@59539
   407
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Specify_Method ["IntegrierenUndKonstanteBestimmen2"]*)
wneuper@59539
   408
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Given "FunktionsVariable x"*)
wneuper@59539
   409
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Given "GleichungsVariablen [c, c_2, c_3, c_4]"*)
wneuper@59540
   410
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Add_Given "AbleitungBiegelinie dy"*)
wneuper@59539
   411
(*[], Met*)val (p''''',_,f,nxt''''',_,pt''''') = me nxt p c pt; (*nxt''''' = Apply_Method ["IntegrierenUndKonstanteBestimmen2"*)
wneuper@59539
   412
wneuper@59539
   413
val PblObj {meth, spec = (thy, _ , metID), ...} = get_obj I pt''''' (fst p''''');
wneuper@59539
   414
"~~~~~ fun init_scrstate , args:"; val (thy, itms, metID) = (assoc_thy thy, meth, metID);
wneuper@59539
   415
val (ScrState st, ctxt, Prog _) = init_scrstate thy itms metID;
wneuper@59539
   416
if scrstate2str st =
wneuper@59549
   417
"([\"\n(l, L)\",\"\n(q, q_0)\",\"\n(v, x)\",\"\n(b, dy)\",\"\n(s, [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0])\",\"\n(vs, [c, c_2, c_3, c_4])\",\"\n(id_abl, y)\"], [], NONE, \n??.empty, Safe, true)"
wneuper@59539
   418
then () else error "init_scrstate changed for Biegelinie";
wneuper@59539
   419
wneuper@59539
   420
(*[1], Pbl*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' c pt'''''; (*nxt = Model_Problem*)
wneuper@59539
   421
if p = ([1], Pbl) andalso (fst nxt) = "Model_Problem" then ()
wneuper@59539
   422
else error "modeling root-problem of Biegelinie 7.70 changed";