1 (* tests on tools for scripts
4 (c) due to copyright terms
6 use"../smltest/Scripts/scrtools.sml";
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 "-----------------------------------------------------------------";
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);
29 (prep_met Test.thy "met_testinter" [] e_metID
30 (["Test","test_interSteps_1"]:metID,
31 [("#Given" ,["term t_"]),
32 ("#Find" ,["normalform n_"])
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))\
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*)
54 val {scr = Script parsed_script,...} = get_met ["Test","test_interSteps_1"];
55 writeln(term2str parsed_script);
58 (*the structure of the auto-gen. script is interpreted correctly*)
61 [(["term (b + a - b)",(*this is Schalk 299b*)
63 ("Poly.thy",["polynomial","simplification"],
64 ["Test","test_interSteps_1"]))];
67 autoCalculate 1 CompleteCalcHead;
69 fetchProposedTactic 1 (*..Apply_Method*);
70 autoCalculate 1 (Step 1);
71 getTactic 1 ([1], Frm) (*still empty*);
73 fetchProposedTactic 1 (*discard_minus_*);
74 autoCalculate 1 (Step 1);
76 fetchProposedTactic 1 (*order_add_rls_*);
77 autoCalculate 1 (Step 1);
79 fetchProposedTactic 1 (*collect_numerals_*);
80 autoCalculate 1 (Step 1);
82 autoCalculate 1 CompleteCalc;
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";
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);
98 [(["term (b + a - b)", "normalform N"],
99 ("Poly.thy",["polynomial","simplification"],
100 ["simplification","for_polynomials"]))];
103 autoCalculate 1 CompleteCalc;
105 interSteps 1 ([], Res);
106 val ((pt,p),_) = get_calc 1; show_pt pt;
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";
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);
122 *** Const (Script.Stepwise, ['z, 'z] => '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)
157 [(["term (b + a - b)", "normalform N"],
158 ("Poly.thy",["polynomial","simplification"],
159 ["simplification","of_rationals"]))];
162 autoCalculate 1 CompleteCalc;
164 interSteps 1 ([], Res);
165 val ((pt,p),_) = get_calc 1; show_pt pt;
167 interSteps 1 ([1], Res);
168 val ((pt,p),_) = get_calc 1; show_pt pt;
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));
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";
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);
188 if contain_bdv (get_rules rls) then ()
189 else raise error "scrtools.sml: contain_bdv doesnt work for 'integration'";
191 two_scr_arg auto_script;
192 init_istate (Rewrite_Set_Inst (["(bdv, x)"], "integration_rules"))
193 (str2term "someTermWithBdv");