src/smltest/Scripts/scrtools.sml
author wneuper
Sat, 30 Sep 2006 11:39:40 +0200
branchstart_Take
changeset 669 aaa641d8546d
parent 598 5e49c921df27
permissions -rw-r--r--
began with inform for Simplify
     1 (* tests on tools for scripts
     2    author: Walther Neuper
     3    060605,
     4    (c) due to copyright terms
     5 
     6 use"../smltest/Scripts/scrtools.sml";
     7 use"scrtools.sml";
     8 *)
     9 "-----------------------------------------------------------------";
    10 "table of contents -----------------------------------------------";
    11 "-----------------------------------------------------------------";
    12 "-------- test auto-generated script '(Repeat (Calculate times))'-";
    13 "-------- test the same called by interSteps norm_Poly -----------";
    14 "-------- test the same called by interSteps norm_Rational -------";
    15 "-------- check auto-gen.script for Rewrite_Set_Inst -------------";
    16 "-----------------------------------------------------------------";
    17 "-----------------------------------------------------------------";
    18 "-----------------------------------------------------------------";
    19 
    20 
    21 "-------- test auto-generated script '(Repeat (Calculate times))'-";
    22 "-------- test auto-generated script '(Repeat (Calculate times))'-";
    23 "-------- test auto-generated script '(Repeat (Calculate times))'-";
    24 val Seq {scr = Script auto_script,...} = assoc_rls "norm_Poly";
    25 writeln(term2str auto_script);
    26 atomty auto_script;
    27 
    28 store_met
    29  (prep_met Test.thy "met_testinter" [] e_metID
    30  (["Test","test_interSteps_1"]:metID,
    31   [("#Given" ,["term t_"]),
    32    ("#Find"  ,["normalform n_"])
    33    ],
    34   {rew_ord'="dummy_ord",rls'=tval_rls,calc=[],srls=e_rls,prls=e_rls,
    35    crls=tval_rls, nrls=e_rls},
    36 "Script Stepwise t_   =                         \
    37  \(Try (Rewrite_Set discard_minus_ False) @@    \
    38  \ Try (Rewrite_Set expand_poly_ False) @@      \
    39  \ Try (Repeat (Calculate times)) @@            \
    40  \ Try (Rewrite_Set order_mult_rls_ False) @@   \
    41  \ Try (Rewrite_Set simplify_power_ False) @@   \
    42  \ Try (Rewrite_Set calc_add_mult_pow_ False) @@\
    43  \ Try (Rewrite_Set reduce_012_mult_ False) @@  \
    44  \ Try (Rewrite_Set order_add_rls_ False) @@    \
    45  \ Try (Rewrite_Set collect_numerals_ False) @@ \
    46  \ Try (Rewrite_Set reduce_012_ False) @@       \
    47  \ Try (Rewrite_Set discard_parentheses_ False))\
    48  \ t_"
    49 (*presently this script cannot become equal in types to auto_script, because:
    50   this t_ must be either 'real' or 'bool'  #1#, 
    51   while the auto_script must be 'z and type-instantiated before usage*)
    52  ));
    53 show_mets(); 
    54 val {scr = Script parsed_script,...} = get_met ["Test","test_interSteps_1"];
    55 writeln(term2str parsed_script);
    56 atomty parsed_script;
    57 
    58 (*the structure of the auto-gen. script is interpreted correctly*)
    59 states:=[];
    60 CalcTree
    61 [(["term (b + a - b)",(*this is Schalk 299b*)
    62 	   "normalform N"], 
    63   ("Poly.thy",["polynomial","simplification"],
    64   ["Test","test_interSteps_1"]))];
    65 Iterator 1;
    66 moveActiveRoot 1;
    67 autoCalculate 1 CompleteCalcHead;
    68 
    69 fetchProposedTactic 1  (*..Apply_Method*);
    70 autoCalculate 1 (Step 1);
    71 getTactic 1 ([1], Frm)  (*still empty*);
    72 
    73 fetchProposedTactic 1  (*discard_minus_*);
    74 autoCalculate 1 (Step 1);
    75 
    76 fetchProposedTactic 1  (*order_add_rls_*);
    77 autoCalculate 1 (Step 1);
    78 
    79 fetchProposedTactic 1  (*collect_numerals_*);
    80 autoCalculate 1 (Step 1);
    81 
    82 autoCalculate 1 CompleteCalc;
    83 
    84 val ((pt,p),_) = get_calc 1; show_pt pt;
    85 if existpt' ([1], Frm) pt then ()
    86 else raise error "scrtools.sml: test-script test_interSteps_1 doesnt work";
    87 
    88 
    89 "-------- test the same called by interSteps norm_Poly -----------";
    90 "-------- test the same called by interSteps norm_Poly -----------";
    91 "-------- test the same called by interSteps norm_Poly -----------";
    92 val Seq {scr = Script auto_script,...} = assoc_rls "norm_Poly";
    93 writeln(term2str auto_script);
    94 atomty auto_script;
    95 
    96 states:=[];
    97 CalcTree
    98 [(["term (b + a - b)", "normalform N"], 
    99   ("Poly.thy",["polynomial","simplification"],
   100   ["simplification","for_polynomials"]))];
   101 Iterator 1;
   102 moveActiveRoot 1;
   103 autoCalculate 1 CompleteCalc;
   104 
   105 interSteps 1 ([], Res);
   106 val ((pt,p),_) = get_calc 1; show_pt pt;
   107 
   108 interSteps 1 ([1], Res);
   109 val ((pt,p),_) = get_calc 1; show_pt pt;
   110 if existpt' ([1,4], Res) pt then ()
   111 else raise error  "scrtools.sml: auto-generated norm_Poly doesnt work";
   112 
   113 
   114 
   115 "-------- test the same called by interSteps norm_Rational -------";
   116 "-------- test the same called by interSteps norm_Rational -------";
   117 "-------- test the same called by interSteps norm_Rational -------";
   118 val Seq {scr = Script auto_script,...} = assoc_rls "norm_Rational";
   119 writeln(term2str auto_script);
   120 atomty auto_script;
   121 (***
   122 *** Const (Script.Stepwise, ['z, 'z] => 'z)
   123 *** . Free (t_, 'z)
   124 *** . Const (Script.Seq, ['a => 'a, 'a => 'a, 'a] => 'a)
   125 *** . . Const (Script.Try, ['a => 'a, 'a] => 'a)
   126 *** . . . Const (Script.Rewrite'_Set, [Script.ID, bool, 'a] => 'a)
   127 *** . . . . Free (discard_minus_, Script.ID)
   128 *** . . . . Const (False, bool)
   129 *** . . Const (Script.Seq, ['a => 'a, 'a => 'a, 'a] => 'a)
   130 *** . . . Const (Script.Try, ['a => 'a, 'a] => 'a)
   131 *** . . . . Const (Script.Rewrite'_Set, [Script.ID, bool, 'a] => 'a)
   132 *** . . . . . Free (rat_mult_poly, Script.ID)
   133 *** . . . . . Const (False, bool)
   134 *** . . . Const (Script.Seq, ['a => 'a, 'a => 'a, 'a] => 'a)
   135 *** . . . . Const (Script.Try, ['a => 'a, 'a] => 'a)
   136 *** . . . . . Const (Script.Rewrite'_Set, [Script.ID, bool, 'a] => 'a)
   137 *** . . . . . . Free (make_rat_poly_with_parentheses, Script.ID)
   138 *** . . . . . . Const (False, bool)
   139 *** . . . . Const (Script.Seq, ['a => 'a, 'a => 'a, 'a] => 'a)
   140 *** . . . . . Const (Script.Try, ['a => 'a, 'a] => 'a)
   141 *** . . . . . . Const (Script.Rewrite'_Set, [Script.ID, bool, 'a] => 'a)
   142 *** . . . . . . . Free (cancel_p_rls, Script.ID)
   143 *** . . . . . . . Const (False, bool)
   144 *** . . . . . Const (Script.Seq, ['a => 'a, 'a => 'a, 'a] => 'a)
   145 *** . . . . . . Const (Script.Try, ['a => 'a, 'a] => 'a)
   146 *** . . . . . . . Const (Script.Rewrite'_Set, [Script.ID, bool, 'a] => 'a)
   147 *** . . . . . . . . Free (norm_Rational_rls, Script.ID)
   148 *** . . . . . . . . Const (False, bool)
   149 *** . . . . . . Const (Script.Try, ['a => 'a, 'a] => 'a)
   150 *** . . . . . . . Const (Script.Rewrite'_Set, [Script.ID, bool, 'a] => 'a)
   151 *** . . . . . . . . Free (discard_parentheses_, Script.ID)
   152 *** . . . . . . . . Const (False, bool)
   153 *** . . Free (t_, 'a)
   154 ***)
   155 states:=[];
   156 CalcTree
   157 [(["term (b + a - b)", "normalform N"], 
   158   ("Poly.thy",["polynomial","simplification"],
   159   ["simplification","of_rationals"]))];
   160 Iterator 1;
   161 moveActiveRoot 1;
   162 autoCalculate 1 CompleteCalc;
   163 
   164 interSteps 1 ([], Res);
   165 val ((pt,p),_) = get_calc 1; show_pt pt;
   166 
   167 interSteps 1 ([1], Res);
   168 val ((pt,p),_) = get_calc 1; show_pt pt;
   169 
   170 (*with "Script SimplifyScript (t_::real) =                \
   171        \  ((Rewrite_Set norm_Rational False) t_)"
   172 val (Form form, Some tac, asm) = pt_extract (pt, ([1], Res));
   173 *)
   174 val (Form form, Some tac, asm) = pt_extract (pt, ([2], Res));
   175 case (term2str form, tac, terms2strs asm) of
   176     ("a", Check_Postcond ["polynomial", "simplification"], []) => ()
   177   | _ => raise error "scrtools.sml: auto-generated norm_Rational doesnt work";
   178 
   179 
   180 
   181 "-------- check auto-gen.script for Rewrite_Set_Inst -------------";
   182 "-------- check auto-gen.script for Rewrite_Set_Inst -------------";
   183 "-------- check auto-gen.script for Rewrite_Set_Inst -------------";
   184 val rls = assoc_rls "integration";
   185 val Seq {scr = Script auto_script,...} = rls;
   186 writeln(term2str auto_script);
   187 
   188 if contain_bdv (get_rules rls) then ()
   189 else raise error "scrtools.sml: contain_bdv doesnt work for 'integration'";
   190 
   191 two_scr_arg auto_script;
   192 init_istate (Rewrite_Set_Inst (["(bdv, x)"], "integration_rules")) 
   193 			      (str2term "someTermWithBdv");