akargl@42145
|
1 |
(* Title: tests on tools for scripts
|
akargl@42145
|
2 |
Author: Walther Neuper 060605
|
neuper@37906
|
3 |
(c) due to copyright terms
|
neuper@37906
|
4 |
*)
|
neuper@37906
|
5 |
"-----------------------------------------------------------------";
|
neuper@37906
|
6 |
"table of contents -----------------------------------------------";
|
neuper@37906
|
7 |
"-----------------------------------------------------------------";
|
neuper@37906
|
8 |
"-------- test auto-generated script '(Repeat (Calculate times))'-";
|
neuper@37906
|
9 |
"-------- test the same called by interSteps norm_Poly -----------";
|
neuper@37906
|
10 |
"-------- test the same called by interSteps norm_Rational -------";
|
neuper@37906
|
11 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------";
|
neuper@52105
|
12 |
"-------- how to stepwise construct Scripts ----------------------";
|
neuper@37906
|
13 |
"-----------------------------------------------------------------";
|
neuper@37906
|
14 |
"-----------------------------------------------------------------";
|
neuper@37906
|
15 |
"-----------------------------------------------------------------";
|
neuper@37906
|
16 |
|
neuper@37906
|
17 |
|
neuper@37906
|
18 |
"-------- test auto-generated script '(Repeat (Calculate times))'-";
|
neuper@37906
|
19 |
"-------- test auto-generated script '(Repeat (Calculate times))'-";
|
neuper@37906
|
20 |
"-------- test auto-generated script '(Repeat (Calculate times))'-";
|
neuper@48790
|
21 |
val Seq {scr = Prog auto_script,...} = assoc_rls "norm_Poly";
|
neuper@37906
|
22 |
writeln(term2str auto_script);
|
neuper@37906
|
23 |
atomty auto_script;
|
neuper@37906
|
24 |
|
neuper@37906
|
25 |
store_met
|
akargl@42145
|
26 |
(prep_met @{theory "Test"} "met_testinter" [] e_metID
|
neuper@37906
|
27 |
(["Test","test_interSteps_1"]:metID,
|
akargl@42145
|
28 |
[("#Given" ,["Term t_t"]),
|
neuper@37980
|
29 |
("#Find" ,["normalform n_n"])
|
neuper@37906
|
30 |
],
|
akargl@42145
|
31 |
{rew_ord' = "dummy_ord", rls' = tval_rls, calc = [], srls = e_rls, prls = e_rls,
|
neuper@42425
|
32 |
crls=tval_rls, errpats = [], nrls=e_rls},
|
akargl@42145
|
33 |
"Script Stepwise t_t = \
|
akargl@42145
|
34 |
\(Try (Rewrite_Set discard_minus False) @@ \
|
akargl@42145
|
35 |
\ Try (Rewrite_Set expand_poly False) @@ \
|
akargl@42145
|
36 |
\ Try (Repeat (Calculate TIMES)) @@ \
|
akargl@42145
|
37 |
\ Try (Rewrite_Set order_mult_rls False) @@ \
|
akargl@42145
|
38 |
\ Try (Rewrite_Set simplify_power False) @@ \
|
akargl@42145
|
39 |
\ Try (Rewrite_Set calc_add_mult_pow False) @@ \
|
akargl@42145
|
40 |
\ Try (Rewrite_Set reduce_012_mult False) @@ \
|
akargl@42145
|
41 |
\ Try (Rewrite_Set order_add_rls False) @@ \
|
akargl@42145
|
42 |
\ Try (Rewrite_Set collect_numerals False) @@ \
|
akargl@42145
|
43 |
\ Try (Rewrite_Set reduce_012 False) @@ \
|
akargl@42145
|
44 |
\ Try (Rewrite_Set discard_parentheses False)) \
|
akargl@42145
|
45 |
\ t_t"
|
neuper@37906
|
46 |
(*presently this script cannot become equal in types to auto_script, because:
|
akargl@42145
|
47 |
this t_t must be either 'real' or 'bool' #1#,
|
neuper@37906
|
48 |
while the auto_script must be 'z and type-instantiated before usage*)
|
neuper@37906
|
49 |
));
|
akargl@42145
|
50 |
show_mets();
|
neuper@48790
|
51 |
val {scr = Prog parsed_script,...} = get_met ["Test","test_interSteps_1"];
|
neuper@37906
|
52 |
writeln(term2str parsed_script);
|
neuper@37906
|
53 |
atomty parsed_script;
|
neuper@37906
|
54 |
|
neuper@37906
|
55 |
(*the structure of the auto-gen. script is interpreted correctly*)
|
neuper@37906
|
56 |
states:=[];
|
neuper@37906
|
57 |
CalcTree
|
neuper@38083
|
58 |
[(["Term (b + a - b)",(*this is Schalk 299b*)
|
neuper@37906
|
59 |
"normalform N"],
|
neuper@38058
|
60 |
("Poly",["polynomial","simplification"],
|
neuper@37906
|
61 |
["Test","test_interSteps_1"]))];
|
neuper@37906
|
62 |
Iterator 1;
|
neuper@37906
|
63 |
moveActiveRoot 1;
|
neuper@37906
|
64 |
autoCalculate 1 CompleteCalcHead;
|
neuper@37906
|
65 |
|
neuper@37906
|
66 |
fetchProposedTactic 1 (*..Apply_Method*);
|
neuper@37906
|
67 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
68 |
getTactic 1 ([1], Frm) (*still empty*);
|
neuper@37906
|
69 |
|
neuper@37906
|
70 |
fetchProposedTactic 1 (*discard_minus_*);
|
neuper@37906
|
71 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
72 |
|
neuper@37906
|
73 |
fetchProposedTactic 1 (*order_add_rls_*);
|
neuper@37906
|
74 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
75 |
|
neuper@37906
|
76 |
fetchProposedTactic 1 (*collect_numerals_*);
|
neuper@37906
|
77 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
78 |
|
neuper@37906
|
79 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
80 |
|
neuper@37906
|
81 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
82 |
if existpt' ([1], Frm) pt then ()
|
neuper@38031
|
83 |
else error "scrtools.sml: test-script test_interSteps_1 doesnt work";
|
neuper@37906
|
84 |
|
neuper@37906
|
85 |
|
neuper@37906
|
86 |
"-------- test the same called by interSteps norm_Poly -----------";
|
neuper@37906
|
87 |
"-------- test the same called by interSteps norm_Poly -----------";
|
neuper@37906
|
88 |
"-------- test the same called by interSteps norm_Poly -----------";
|
neuper@48790
|
89 |
val Seq {scr = Prog auto_script,...} = assoc_rls "norm_Poly";
|
neuper@37906
|
90 |
writeln(term2str auto_script);
|
neuper@37906
|
91 |
atomty auto_script;
|
neuper@37906
|
92 |
|
neuper@37906
|
93 |
states:=[];
|
neuper@37906
|
94 |
CalcTree
|
neuper@38083
|
95 |
[(["Term (b + a - b)", "normalform N"],
|
neuper@38058
|
96 |
("Poly",["polynomial","simplification"],
|
neuper@37906
|
97 |
["simplification","for_polynomials"]))];
|
neuper@37906
|
98 |
Iterator 1;
|
neuper@37906
|
99 |
moveActiveRoot 1;
|
neuper@37906
|
100 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
101 |
|
neuper@37906
|
102 |
interSteps 1 ([], Res);
|
neuper@37906
|
103 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
104 |
|
neuper@37906
|
105 |
interSteps 1 ([1], Res);
|
neuper@37906
|
106 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
107 |
if existpt' ([1,4], Res) pt then ()
|
neuper@38031
|
108 |
else error "scrtools.sml: auto-generated norm_Poly doesnt work";
|
neuper@37906
|
109 |
|
neuper@37906
|
110 |
|
neuper@37906
|
111 |
|
neuper@37906
|
112 |
"-------- test the same called by interSteps norm_Rational -------";
|
neuper@37906
|
113 |
"-------- test the same called by interSteps norm_Rational -------";
|
neuper@37906
|
114 |
"-------- test the same called by interSteps norm_Rational -------";
|
akargl@42145
|
115 |
|
neuper@48790
|
116 |
val Seq {scr = Prog auto_script,...} = assoc_rls "norm_Rational";
|
neuper@37906
|
117 |
writeln(term2str auto_script);
|
neuper@37906
|
118 |
atomty auto_script;
|
akargl@42145
|
119 |
(***
|
akargl@42145
|
120 |
*** Const (Script.Stepwise, 'z => 'z => 'z)
|
akargl@42145
|
121 |
*** . Free (t_t, 'z)
|
akargl@42145
|
122 |
*** . Const (Script.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
akargl@42145
|
123 |
*** . . Const (Script.Try, ('a => 'a) => 'a => 'a)
|
akargl@42145
|
124 |
*** . . . Const (Script.Rewrite'_Set, ID => bool => 'a => 'a)
|
akargl@42145
|
125 |
*** . . . . Free (discard_minus, ID)
|
akargl@42145
|
126 |
*** . . . . Const (HOL.False, bool)
|
akargl@42145
|
127 |
*** . . Const (Script.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
akargl@42145
|
128 |
*** . . . Const (Script.Try, ('a => 'a) => 'a => 'a)
|
akargl@42145
|
129 |
*** . . . . Const (Script.Rewrite'_Set, ID => bool => 'a => 'a)
|
akargl@42145
|
130 |
*** . . . . . Free (rat_mult_poly, ID)
|
akargl@42145
|
131 |
*** . . . . . Const (HOL.False, bool)
|
akargl@42145
|
132 |
*** . . . Const (Script.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
akargl@42145
|
133 |
*** . . . . Const (Script.Try, ('a => 'a) => 'a => 'a)
|
akargl@42145
|
134 |
*** . . . . . Const (Script.Rewrite'_Set, ID => bool => 'a => 'a)
|
akargl@42145
|
135 |
*** . . . . . . Free (make_rat_poly_with_parentheses, ID)
|
akargl@42145
|
136 |
*** . . . . . . Const (HOL.False, bool)
|
akargl@42145
|
137 |
*** . . . . Const (Script.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
akargl@42145
|
138 |
*** . . . . . Const (Script.Try, ('a => 'a) => 'a => 'a)
|
akargl@42145
|
139 |
*** . . . . . . Const (Script.Rewrite'_Set, ID => bool => 'a => 'a)
|
akargl@42145
|
140 |
*** . . . . . . . Free (cancel_p_rls, ID)
|
akargl@42145
|
141 |
*** . . . . . . . Const (HOL.False, bool)
|
akargl@42145
|
142 |
*** . . . . . Const (Script.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
akargl@42145
|
143 |
*** . . . . . . Const (Script.Try, ('a => 'a) => 'a => 'a)
|
akargl@42145
|
144 |
*** . . . . . . . Const (Script.Rewrite'_Set, ID => bool => 'a => 'a)
|
akargl@42145
|
145 |
*** . . . . . . . . Free (norm_Rational_rls, ID)
|
akargl@42145
|
146 |
*** . . . . . . . . Const (HOL.False, bool)
|
akargl@42145
|
147 |
*** . . . . . . Const (Script.Try, ('a => 'a) => 'a => 'a)
|
akargl@42145
|
148 |
*** . . . . . . . Const (Script.Rewrite'_Set, ID => bool => 'a => 'a)
|
akargl@42145
|
149 |
*** . . . . . . . . Free (discard_parentheses1, ID)
|
akargl@42145
|
150 |
*** . . . . . . . . Const (HOL.False, bool)
|
akargl@42145
|
151 |
*** . . Const (empty, 'a)
|
neuper@37906
|
152 |
***)
|
neuper@37906
|
153 |
states:=[];
|
neuper@37906
|
154 |
CalcTree
|
neuper@38083
|
155 |
[(["Term (b + a - b)", "normalform N"],
|
neuper@38058
|
156 |
("Poly",["polynomial","simplification"],
|
neuper@37906
|
157 |
["simplification","of_rationals"]))];
|
neuper@37906
|
158 |
Iterator 1;
|
neuper@37906
|
159 |
moveActiveRoot 1;
|
neuper@37906
|
160 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
161 |
|
neuper@37906
|
162 |
interSteps 1 ([], Res);
|
neuper@37906
|
163 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
164 |
|
neuper@37906
|
165 |
interSteps 1 ([1], Res);
|
neuper@37906
|
166 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
167 |
|
neuper@37906
|
168 |
(*with "Script SimplifyScript (t_::real) = \
|
neuper@37906
|
169 |
\ ((Rewrite_Set norm_Rational False) t_)"
|
neuper@37926
|
170 |
val (Form form, SOME tac, asm) = pt_extract (pt, ([1], Res));
|
neuper@37906
|
171 |
*)
|
neuper@37926
|
172 |
val (Form form, SOME tac, asm) = pt_extract (pt, ([2], Res));
|
neuper@37906
|
173 |
case (term2str form, tac, terms2strs asm) of
|
neuper@37906
|
174 |
("a", Check_Postcond ["polynomial", "simplification"], []) => ()
|
neuper@38031
|
175 |
| _ => error "scrtools.sml: auto-generated norm_Rational doesnt work";
|
neuper@37906
|
176 |
|
neuper@37906
|
177 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------";
|
neuper@37906
|
178 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------";
|
neuper@37906
|
179 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------";
|
neuper@37906
|
180 |
val rls = assoc_rls "integration";
|
neuper@48790
|
181 |
val Seq {scr = Prog auto_script,...} = rls;
|
neuper@37906
|
182 |
writeln(term2str auto_script);
|
neuper@37906
|
183 |
|
neuper@37906
|
184 |
if contain_bdv (get_rules rls) then ()
|
neuper@38031
|
185 |
else error "scrtools.sml: contain_bdv doesnt work for 'integration'";
|
neuper@37906
|
186 |
|
neuper@37906
|
187 |
two_scr_arg auto_script;
|
neuper@37906
|
188 |
init_istate (Rewrite_Set_Inst (["(bdv, x)"], "integration_rules"))
|
neuper@37906
|
189 |
(str2term "someTermWithBdv");
|
neuper@42426
|
190 |
|
neuper@52105
|
191 |
"-------- how to stepwise construct Scripts ----------------------";
|
neuper@52105
|
192 |
"-------- how to stepwise construct Scripts ----------------------";
|
neuper@52105
|
193 |
"-------- how to stepwise construct Scripts ----------------------";
|
neuper@52105
|
194 |
val thy = @{theory "Rational"};
|
neuper@52105
|
195 |
(*no trailing _*)
|
neuper@52105
|
196 |
val p1 = parse thy (
|
neuper@52105
|
197 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@52105
|
198 |
" (Rewrite_Set discard_minus False " ^
|
neuper@52105
|
199 |
" t_t)");
|
neuper@42426
|
200 |
|
neuper@52105
|
201 |
(*required (): (Rewrite_Set discard_minus False)*)
|
neuper@52105
|
202 |
val p2 = parse thy (
|
neuper@52105
|
203 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@52105
|
204 |
" (Rewrite_Set discard_minus False " ^
|
neuper@52105
|
205 |
" t_t)");
|
neuper@52105
|
206 |
|
neuper@52105
|
207 |
val p3 = parse thy (
|
neuper@52105
|
208 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@52105
|
209 |
" ((Rewrite_Set discard_minus False) " ^
|
neuper@52105
|
210 |
" t_t)");
|
neuper@52105
|
211 |
|
neuper@52105
|
212 |
val p4 = parse thy (
|
neuper@52105
|
213 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@52105
|
214 |
" ((Rewrite_Set discard_minus False) " ^
|
neuper@52105
|
215 |
" t_t)");
|
neuper@52105
|
216 |
|
neuper@52105
|
217 |
val p5 = parse thy (
|
neuper@52105
|
218 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@52105
|
219 |
" ((Try (Rewrite_Set discard_minus False) " ^
|
neuper@52105
|
220 |
" Try (Rewrite_Set discard_parentheses False)) " ^
|
neuper@52105
|
221 |
" t_t)");
|
neuper@52105
|
222 |
|
neuper@52105
|
223 |
val p6 = parse thy (
|
neuper@52105
|
224 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@52105
|
225 |
" ((Try (Rewrite_Set discard_minus False) @@ " ^
|
neuper@52105
|
226 |
" Try (Rewrite_Set rat_mult_poly False) @@ " ^
|
neuper@52105
|
227 |
" Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
|
neuper@52105
|
228 |
" Try (Rewrite_Set cancel_p_rls False) @@ " ^
|
neuper@52105
|
229 |
" (Repeat " ^
|
neuper@52105
|
230 |
" ((Try (Rewrite_Set add_fractions_p_rls False) @@ " ^
|
neuper@52105
|
231 |
" Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
|
neuper@52105
|
232 |
" Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
|
neuper@52105
|
233 |
" Try (Rewrite_Set cancel_p_rls False) @@ " ^
|
neuper@52105
|
234 |
" Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
|
neuper@52105
|
235 |
" Try (Rewrite_Set discard_parentheses False)) " ^
|
neuper@52105
|
236 |
" t_t)"
|
neuper@52105
|
237 |
);
|