test/Tools/isac/OLDTESTS/script.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Thu, 22 Dec 2016 11:36:20 +0100
changeset 59279 255c853ea2f0
parent 59188 c477d0f79ab9
child 59476 863c3629ad24
permissions -rw-r--r--
renamed Ctree.ptree --> Ctree.ctree
     1 (* tests for ME/script.sml
     2    WN.13.3.00
     3 
     4    WN050908 OLD FILE, MERGE WITH smltest/ME/script.sml
     5 
     6 use"systest/script.sml";
     7 use"script.sml";
     8 *)
     9 
    10 
    11 "         scripts: Variante 'funktional'               ";
    12 "############## Make_fun_by_new_variable ##############";
    13 "############## Make_fun_by_explicit ##############";
    14 "################ Solve_root_equation #################";
    15 "------- Notlocatable: Free_Solve -------";
    16 
    17 "  --- test100:  nxt_tac order------------------------------------ ";
    18 "  --- test100:  order 1 3 1 2 ----------------------------------- ";
    19 " --- test200: nxt_tac order ------------------------------------- ";
    20 " --- test200: order 3 1 1 2 --------------------------------- ";
    21 
    22 "  --- root-equation:  nxt_tac order------------------------------ ";
    23 "  --- root-equation:  1.norm_equation ------------------------------ ";
    24 (* --- test200: calculate -----------------------------------------*)
    25 "  --- check_elementwise ------------------------------ ";
    26 
    27 "  --- test 30.4.02 Testterm:  Repeat Repeat Or ------------------ ";
    28 "  --- test 9.5.02 Testeq: While Try Repeat @@ ------------------ ";
    29 
    30 "--------- sel_rules ---------------------------------------------";
    31 "-----------------------------------------------------------------";
    32 
    33 
    34 
    35 
    36 
    37 " ################################################# 6.5.03";
    38 "         scripts: Variante 'funktional'            6.5.03";
    39 " ################################################# 6.5.03 ";
    40 
    41 val c = (the o (parse DiffApp.thy)) 
    42   "Script Maximum_value(fix_::bool list)(m_::real) (rs_::bool list)\
    43    \      (v_::real) (itv_::real set) (err_::bool) =          \ 
    44    \ (let e_e = (hd o (filterVar m_)) rs_;              \
    45    \      t_ = (if 1 < length_ rs_                            \
    46    \           then (SubProblem (Reals_,[make,function],[no_met])\
    47    \                     [REAL m_, REAL v_v, BOOL_LIST rs_])\
    48    \           else (hd rs_));                                \
    49    \      (mx_::real) = SubProblem (Reals_,[on_interval,max_of,function], \
    50    \                                [Isac,maximum_on_interval])\
    51    \                               [BOOL t_, REAL v_v, REAL_SET itv_]\
    52    \ in ((SubProblem (Reals_,[find_values,tool],[Isac,find_values])   \
    53    \      [REAL mx_, REAL (Rhs t_), REAL v_v, REAL m_,     \
    54    \       BOOL_LIST (dropWhile (ident e_e) rs_)])::bool list))";
    55 
    56 
    57 "################################################### 6.5.03";
    58 "############## Make_fun_by_new_variable ########### 6.5.03";
    59 "################################################### 6.5.03";
    60 
    61 val sc = (the o (parse DiffApp.thy)) (*start interpretieren*)
    62   "Script Make_fun_by_new_variable (f_::real) (v_::real)     \
    63    \      (eqs_::bool list) =                                 \
    64    \(let h_ = (hd o (filterVar f_)) eqs_;             \
    65    \     es_ = dropWhile (ident h_) eqs_;                    \
    66    \     vs_ = dropWhile (ident f_) (Vars h_);                \
    67    \     v_1 = nth_ 1 vs_;                                   \
    68    \     v_2 = nth_ 2 vs_;                                   \
    69    \     e_1 = (hd o (filterVar v_1)) es_;            \
    70    \     e_2 = (hd o (filterVar v_2)) es_;            \
    71    \  (s_1::bool list) = (SubProblem (Reals_,[univar,equation],[no_met])\
    72    \                    [BOOL e_1, REAL v_1]);\
    73    \  (s_2::bool list) = (SubProblem (Reals_,[univar,equation],[no_met])\
    74    \                    [BOOL e_2, REAL v_2])\
    75    \in Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] h_)";
    76 
    77 val ags = map (Thm.term_of o the o (parse DiffApp.thy)) 
    78   ["A::real", "alpha::real", 
    79    "[A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]"];
    80 val ll = [](*:loc_*);
    81 (* problem with exn PTREE + eval_to -------------------------
    82 "-------------- subproblem with empty formalizaton -------";
    83 val (mI1,m1) = 
    84   ("Subproblem", tac2tac_ pt p
    85    (Subproblem (("Reals",["univar","equation","test"],
    86 		(""(*"ANDERN !!!!!!!*),"no_met")),[])));
    87 val (mI2,m2) = (mI1,m1);
    88 val (mI3,m3) = 
    89   ("Substitute", tac2tac_ pt p
    90    (Substitute [("a","#2*r*sin alpha"),("b","#2*r*cos alpha")]));
    91 "------- same_tacpbl + eval_to -------";
    92 val SOME(l1,t1) = same_tacpbl sc ll (mI1,m1);
    93 loc_2str l1;
    94 (*"[R, R, D, R, D, R, D, R, D, R, D, R, D, R, D, L, R]"*)
    95 Syntax.string_of_term (thy2ctxt' "DiffApp") t1;
    96 (*"solve_univar (Reals, [univar, equation], no_met) B.1 B.3 "?6 ?4 *)
    97 
    98 val SOME(l2,t2) = same_tacpbl sc l1 (mI2,m2);
    99 loc_2str l2;
   100 (*"[R, R, D, R, D, R, D, R, D, R, D, R, D, R, D, R, D, L, R]"*)
   101 Syntax.string_of_term (thy2ctxt' "DiffApp") t2;
   102 (*"solve_univar (Reals, [univar, equation], no_met) B.1 B.3 "?7 ?3 *)
   103 
   104 val SOME(l3,t3) = same_tacpbl sc l2 (mI3,m3);
   105 loc_2str l3;
   106 (*"[R, R, D, R, D, R, D, R, D, R, D, R, D, R, D, R, D, R, D]"*)
   107 Syntax.string_of_term (thy2ctxt' "DiffApp") t3;
   108 (*"Substitute [(v_1, (Rhs o hd) B.1), (v_2, (Rhs o hd) B.0)] B.8"*)
   109 
   110 
   111 "------- eq_tacIDs + eq_consts + eval_args -------";
   112 val eq_ids = eq_tacIDs (*start-loc_*)[] sc (mI,m) [];
   113 val eq_cons = filter (eq_consts m) eq_ids;
   114 val Ready (l,(_,m)::_,_) = eval_args sc (mI,m) [(1,ags)] eq_cons;
   115 "------- locate -------";
   116 
   117 
   118 "-------------- subproblem with formalizaton -------";
   119 val (mI,m) = 
   120   ("Subproblem", tac2tac_ pt []
   121    (Subproblem (("Reals",["univar","equation","test"],
   122 		(""(*"ANDERN !!!!!!!*),"no_met")),
   123 	       ["a//#2=r*sin alpha","a"])));
   124 "------- same_tacpbl + eval_to -------";
   125 
   126 
   127 "------- eq_tacIDs + eq_consts + eval_args -------";
   128 val eq_ids = eq_tacIDs [] sc (mI,m) [];
   129 val eq_cons = filter (eq_consts m) eq_ids;
   130 val Ready (l,(_,m)::_,_) = eval_args sc (mI,m) [(1,ags)] eq_cons;
   131 
   132 
   133 "------- locate -------";
   134 -------------------------------------------------------*)
   135 (* use"ME/script.sml";
   136    use"test-script.sml";
   137    *)
   138 
   139 
   140 
   141 "############## Make_fun_by_explicit ############## 6.5.03";
   142 "############## Make_fun_by_explicit ############## 6.5.03";
   143 "############## Make_fun_by_explicit ############## 6.5.03";
   144 val c = (the o (parse DiffApp.thy)) 
   145    "Script Make_fun_by_explicit (f_::real) (v_::real)         \
   146    \      (eqs_::bool list) =                                 \
   147    \ (let h_  = (hd o (filterVar f_)) eqs_;                   \
   148    \      e_1 = hd (dropWhile (ident h_) eqs_);               \
   149    \      vs_ = dropWhile (ident f_) (Vars h_);                \
   150    \      v_1 = hd (dropWhile (ident v_v) vs_);                \
   151    \      (s_1::bool list)=(SubProblem(Reals_,[univar,equation],[no_met])\
   152    \                          [BOOL e_1, REAL v_1])\
   153    \ in Substitute [(v_1 = (rhs o hd) s_1)] h_)";
   154 
   155 
   156 (*#####################################################--------11.5.02
   157 "################ Solve_root_equation #################";
   158 (*#####################################################*)
   159 val sc = (Thm.term_of o the o (parse Test.thy))
   160   "Script Solve_root_equation (eq_::bool) (v_::real) (err_::bool) =\
   161    \ (let e_e = Rewrite square_equation_left True eq_;     \
   162    \      e_e = Rewrite_Set Test_simplify False e_;          \
   163    \      e_e = Rewrite_Set rearrange_assoc False e_;          \
   164    \      e_e = Rewrite_Set isolate_root False e_;             \
   165    \      e_e = Rewrite_Set Test_simplify False e_;          \
   166 
   167    \      e_e = Rewrite square_equation_left True e_;        \
   168    \      e_e = Rewrite_Set Test_simplify False e_;          \
   169 
   170    \      e_e = Rewrite_Set norm_equation False e_;        \
   171    \      e_e = Rewrite_Set Test_simplify False e_;      \
   172    \      e_e = Rewrite_Set_Inst [(bdv,v_)] isolate_bdv False e_;\
   173    \      e_e = Rewrite_Set Test_simplify False e_e       \
   174    \ in [e_::bool])";
   175 val ags = map (Thm.term_of o the o (parse Test.thy)) 
   176   ["sqrt(#9+#4*x)=sqrt x + sqrt(#5+x)", "x::real","#0"];
   177 val fmz = 
   178   ["equality (sqrt(#9+#4*x)=sqrt x + sqrt(#5+x))",
   179    "solveFor x","errorBound (eps = #0)","solutions v_i_"];
   180 ----------------------------------------------------------------11.5.02...*)
   181 
   182 
   183 (*################################# meNEW raises exception with not-locatable
   184 "--------------------- Notlocatable: Free_Solve ---------------------";
   185 "--------------------- Notlocatable: Free_Solve ---------------------";
   186 "--------------------- Notlocatable: Free_Solve ---------------------";
   187 val fmz = []; 
   188 val (dI',pI',mI') =
   189   ("Test",["sqroot-test","univariate","equation","test"],
   190    ["Test","sqrt-equ-test"]);
   191 (*val (mI,m) = ("Init_Proof",Init_Proof (fmz, (dI',pI',mI')));
   192 val (p,_,f,nxt,_,pt) = me (mI,m) e_pos'[1] EmptyPtree;*)
   193 
   194 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   195 val nxt = ("Model_Problem",
   196 	   Model_Problem ["sqroot-test","univariate","equation","test"]);
   197 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   198 val nxt =
   199   ("Add_Given",
   200    Add_Given "equality (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))");
   201 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   202 val nxt = ("Add_Given",Add_Given "solveFor x");
   203 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   204 val nxt = ("Add_Given",Add_Given "errorBound (eps = 0)");
   205 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   206 val nxt = ("Add_Find",Add_Find "solutions v_i_");
   207 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   208 val nxt = ("Specify_Theory",Specify_Theory "Test");
   209 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   210 val nxt =
   211   ("Specify_Problem",Specify_Problem ["sqroot-test","univariate","equation","test"]);
   212 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   213 val nxt = ("Specify_Method",Specify_Method ["Test","sqrt-equ-test"]);
   214 val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   215 
   216 "--- -1 ---";
   217 val nxt = ("Free_Solve",Free_Solve);  
   218 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   219 
   220 "--- 0 ---";
   221 val nxt = ("Take",Take "sqrt(9+4*x)=sqrt x + sqrt(5+x)");
   222 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   223 (*me ("Begin_Trans" ////*)
   224 
   225 "--- 1 ---";
   226 val nxt = ("Rewrite_Asm",Rewrite_Asm ("square_equation_left",""));
   227 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   228 
   229 "--- 2 ---";
   230 val nxt = ("Rewrite_Set",Rewrite_Set "Test_simplify");
   231 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   232 
   233 "--- 3 ---";
   234 val nxt = ("Rewrite_Set",Rewrite_Set "rearrange_assoc");
   235 val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   236 if f = Form'
   237     (FormKF
   238        (~1,EdUndef,1,Nundef,
   239         "9 + 4 * x = 5 + 2 * x + 2 * sqrt (x ^^^ 2 + 5 * x)"))
   240 then () else error "behaviour in root-expl. Free_Solve changed";
   241 writeln (pr_ctree pr_short pt);
   242 ---------------------------------meNEW raises exception with not-locatable*)
   243 
   244 
   245 val d = e_rls;
   246 
   247 "  --- test100:  nxt_tac order------------------------------------ ";
   248 "  --- test100:  nxt_tac order------------------------------------ ";
   249 
   250 val scr as (Prog sc) = Prog (((inst_abs Test.thy) 
   251 				  o Thm.term_of o the o (parse thy))
   252  "Script Testeq (e_e::bool) =                                        \
   253    \(While (contains_root e_e) Do                                     \
   254    \((Try (Repeat (Rewrite rroot_square_inv False))) @@    \
   255    \  (Try (Repeat (Rewrite square_equation_left True))) @@ \
   256    \  (Try (Repeat (Rewrite radd_0 False)))))\
   257    \ e_e            ");
   258 atomty sc;
   259 val (dI',pI',mI') = ("Test",["sqroot-test","univariate","equation","test"],
   260 		     ["Test","sqrt-equ-test"]);
   261 val p = e_pos'; val c = []; 
   262 val (mI,m) = ("Init_Proof",Init_Proof ([], (dI',pI',mI')));
   263 val (p,_,_,_,_,pt) = me (mI,m) p c  EmptyPtree;
   264 val nxt = ("Specify_Theory",Specify_Theory "Test");
   265 val (p,_,_,_,_,pt) = me nxt p c pt;
   266 val nxt = ("Specify_Method",Specify_Method ["Test","sqrt-equ-test"]); (*for asm in square_equation_left*)
   267 val (p,_,_,_,_,pt) = me nxt p c pt;
   268 val p = ([1],Res):pos';
   269 val eq_ = (Thm.term_of o the o (parse thy))"e_::bool";
   270 
   271 val ct =   "0+(sqrt(sqrt(sqrt a))^^^2)^^^2=0";
   272 val ve0_= (Thm.term_of o the o (parse thy)) ct;
   273 val ets0=[([],(Tac_(Script.thy,"BS","",""),[(eq_,ve0_)],[(eq_,ve0_)],
   274 	       e_term,e_term,Safe)),
   275 	  ([],(User', [],                [],        e_term, e_term,Sundef))]:ets;
   276 val l0 = [];
   277 " --------------- 1. ---------------------------------------------";
   278 val (pt,_) = cappend_atomic pt[1]e_istate e_term(Rewrite("test",""))(str2term ct,[])Complete;
   279 (*12.10.03:*** Unknown theorem(s) "rroot_square_inv"
   280 val Appl m'=applicable_in p pt (Rewrite("rroot_square_inv",""));
   281 *)
   282 
   283 
   284 val scr as (Prog sc) = 
   285     Prog (((inst_abs Test.thy)  o Thm.term_of o the o (parse thy)) 
   286  "Script Testterm (g_::real) = (Calculate cancel g_)");
   287 (*
   288 val scr as (Prog sc) = 
   289     Prog (((inst_abs Test.thy)  o Thm.term_of o the o (parse thy)) 
   290  "Script Testterm (g_::real) = (Calculate power g_)");
   291 val scr as (Prog sc) = 
   292     Prog (((inst_abs Test.thy)  o Thm.term_of o the o (parse thy)) 
   293  "Script Testterm (g_::real) = (Calculate pow g_)");
   294 ..............................................................*)
   295 writeln
   296 "%%%%%%%%%%TODO 7.9.00---vvvvvv--- conflicts with Isa-types \n\
   297 \     (Repeat (Calculate cancel g_)) Or                     \n\
   298 \     (Repeat (Calculate power g_)) Or                        \n\
   299 \%%%%%%%%%%%%%%%%%%%%%---^^^^^^--- conflicts with Isa-types \n\
   300 \%%%%%%%%%%%%%%%%%%%%%TODO before Detail Rewrite_Set";
   301 
   302 
   303 "--------- sel_rules ---------------------------------------------";
   304 "--------- sel_rules ---------------------------------------------";
   305 "--------- sel_rules ---------------------------------------------";
   306 (* mv test/../script.sml: -----> *)
   307 "----------- fun sel_rules ---------------------------------------"
   308