walther@59633
|
1 |
(* Title: ProgLang/auto_prog.sml
|
walther@59633
|
2 |
Author: Walther Neuper 190922
|
walther@59633
|
3 |
(c) due to copyright terms
|
walther@59633
|
4 |
*)
|
walther@59633
|
5 |
|
walther@59633
|
6 |
"-----------------------------------------------------------------------------------------------";
|
walther@59633
|
7 |
"-----------------------------------------------------------------------------------------------";
|
walther@59633
|
8 |
"table of contents -----------------------------------------------------------------------------";
|
walther@59633
|
9 |
"-----------------------------------------------------------------------------------------------";
|
walther@59633
|
10 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------------------------------------";
|
walther@59633
|
11 |
"-------- test the same called by interSteps norm_Poly -----------------------------------------";
|
walther@59633
|
12 |
"-------- test the same called by interSteps norm_Rational -------------------------------------";
|
walther@59637
|
13 |
"-------- fun op #> ----------------------------------------------------------------------------";
|
walther@59633
|
14 |
"-------- fun rules2scr_Rls --------------------------------------------------------------------";
|
walther@59633
|
15 |
"-------- fun rule2stac, fun rule2stac_inst ----------------------------------------------------";
|
walther@59633
|
16 |
"-------- fun stacpbls -------------------------------------------------------------------------";
|
walther@59633
|
17 |
"-------- fun is_calc, fun op_of_calc ----------------------------------------------------------";
|
walther@59636
|
18 |
"-------- fun subst_typ ------------------------------------------------------------------------";
|
walther@59636
|
19 |
"-------- fun subst_typs -----------------------------------------------------------------------";
|
walther@59633
|
20 |
"-----------------------------------------------------------------------------------------------";
|
walther@59633
|
21 |
"-----------------------------------------------------------------------------------------------";
|
walther@59633
|
22 |
"-----------------------------------------------------------------------------------------------";
|
walther@59633
|
23 |
|
walther@59633
|
24 |
|
walther@59633
|
25 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------------------------------------";
|
walther@59633
|
26 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------------------------------------";
|
walther@59633
|
27 |
"-------- check auto-gen.script for Rewrite_Set_Inst -------------------------------------------";
|
walther@59633
|
28 |
val rls = assoc_rls "integration";
|
walther@59633
|
29 |
val Seq {scr = Prog auto_script,...} = rls;
|
walther@59633
|
30 |
writeln(term2str auto_script);
|
walther@59633
|
31 |
|
walther@59633
|
32 |
if contain_bdv (get_rules rls) then ()
|
walther@59633
|
33 |
else error "scrtools.sml: contain_bdv doesnt work for 'integration'";
|
walther@59633
|
34 |
|
walther@59633
|
35 |
if terms2str (formal_args auto_script) = "[\"t_t\",\"v\"]"
|
walther@59633
|
36 |
then () else error "formal_args of auto-gen.script changed";
|
walther@59633
|
37 |
init_istate (Rewrite_Set_Inst (["(''bdv'', x)"], "integration_rules"))
|
walther@59633
|
38 |
(str2term "someTermWithBdv");
|
walther@59633
|
39 |
|
walther@59633
|
40 |
"-------- test the same called by interSteps norm_Poly -----------------------------------------";
|
walther@59633
|
41 |
"-------- test the same called by interSteps norm_Poly -----------------------------------------";
|
walther@59633
|
42 |
"-------- test the same called by interSteps norm_Poly -----------------------------------------";
|
walther@59633
|
43 |
val Seq {scr = Prog auto_script,...} = assoc_rls "norm_Poly";
|
walther@59633
|
44 |
writeln(term2str auto_script);
|
walther@59633
|
45 |
(*Program Stepwise t_t =
|
walther@59637
|
46 |
(Try (Rewrite_Set discard_minus) #>
|
walther@59637
|
47 |
Try (Rewrite_Set expand_poly_) #>
|
walther@59637
|
48 |
Try (Repeat (Calculate TIMES)) #>
|
walther@59637
|
49 |
Try (Rewrite_Set order_mult_rls_) #>
|
walther@59637
|
50 |
Try (Rewrite_Set simplify_power_) #>
|
walther@59637
|
51 |
Try (Rewrite_Set calc_add_mult_pow_) #>
|
walther@59637
|
52 |
Try (Rewrite_Set reduce_012_mult_) #>
|
walther@59637
|
53 |
Try (Rewrite_Set order_add_rls_) #>
|
walther@59637
|
54 |
Try (Rewrite_Set collect_numerals_) #>
|
walther@59637
|
55 |
Try (Rewrite_Set reduce_012_) #>
|
walther@59635
|
56 |
Try (Rewrite_Set discard_parentheses1))
|
walther@59633
|
57 |
??.empty ..WORKS, NEVERTHELESS *)
|
walther@59633
|
58 |
atomty auto_script;
|
walther@59633
|
59 |
|
walther@59633
|
60 |
reset_states (); (*<-- evaluate, if ML-blocks are edited below*)
|
walther@59633
|
61 |
CalcTree
|
walther@59633
|
62 |
[(["Term (b + a - b)", "normalform N"],
|
walther@59633
|
63 |
("Poly",["polynomial","simplification"],
|
walther@59633
|
64 |
["simplification","for_polynomials"]))];
|
walther@59633
|
65 |
Iterator 1;
|
walther@59633
|
66 |
moveActiveRoot 1;
|
walther@59633
|
67 |
|
walther@59633
|
68 |
autoCalculate 1 CompleteCalc;
|
walther@59633
|
69 |
val ((pt,p),_) = get_calc 1;
|
walther@59633
|
70 |
show_pt pt;
|
walther@59633
|
71 |
(* isabisac17 = 15 [
|
walther@59633
|
72 |
(([], Frm), Simplify (b + a - b)),
|
walther@59633
|
73 |
(([1], Frm), b + a - b),
|
walther@59633
|
74 |
(([1], Res), a),
|
walther@59633
|
75 |
(([], Res), a)] *)
|
walther@59633
|
76 |
|
walther@59633
|
77 |
interSteps 1 ([], Res);
|
walther@59633
|
78 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
walther@59633
|
79 |
show_pt pt;
|
walther@59633
|
80 |
(* isabisac17 = 15 [
|
walther@59633
|
81 |
(([], Frm), Simplify (b + a - b)),
|
walther@59633
|
82 |
(([1], Frm), b + a - b),
|
walther@59633
|
83 |
(([1], Res), a),
|
walther@59633
|
84 |
(([], Res), a)] *)
|
walther@59633
|
85 |
|
walther@59633
|
86 |
interSteps 1 ([1], Res);(*<SYSERROR><CALCID>1</CALCID><ERROR>error in kernel 8</ERROR></SYSERROR>*)
|
walther@59633
|
87 |
"~~~~~ fun interSteps, args:"; val (cI, ip) = (1, ([1], Res));
|
walther@59633
|
88 |
val ((pt, p), tacis) = get_calc cI;
|
walther@59633
|
89 |
(*if*) (not o is_interpos) ip = false;
|
walther@59633
|
90 |
val ip' = lev_pred' pt ip;
|
walther@59633
|
91 |
|
walther@59633
|
92 |
(*Math_Engine.detailstep pt ip ..ERROR interSteps>..>init_istate: "norm_Poly" has EmptyScr*)
|
walther@59633
|
93 |
val ("donesteps", ctree_BEFORE_step_into, pos'_BEFORE_step_into) = Math_Engine.detailstep pt ip;
|
walther@59633
|
94 |
"~~~~~ fun detailstep, args:"; val (pt, (pos as (p, _))) = (pt, ip);
|
walther@59633
|
95 |
val nd = Ctree.get_nd pt p
|
walther@59633
|
96 |
val cn = Ctree.children nd;
|
walther@59633
|
97 |
(*if*) null cn = false;
|
walther@59633
|
98 |
|
walther@59633
|
99 |
"~~~~~ to detailrls return val:";
|
walther@59633
|
100 |
(*else*)
|
walther@59694
|
101 |
val return_val = ("donesteps", pt, (p @ [length (Ctree.children (Ctree.get_nd pt p))], Pos.Res));
|
walther@59633
|
102 |
if p @ [length (Ctree.children (Ctree.get_nd pt p))] = [1, 4]
|
walther@59633
|
103 |
then () else error "detailrls: auto-generated norm_Poly doesnt work";
|
walther@59633
|
104 |
|
walther@59633
|
105 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
walther@59633
|
106 |
show_pt pt; (*[
|
walther@59633
|
107 |
(([], Frm), Simplify (b + a - b)),
|
walther@59633
|
108 |
(([1], Frm), b + a - b),
|
walther@59633
|
109 |
(([1,1], Frm), b + a - b),
|
walther@59633
|
110 |
(([1,1], Res), b + a + -1 * b),
|
walther@59633
|
111 |
(([1,2], Res), a + b + -1 * b),
|
walther@59633
|
112 |
(([1,3], Res), a + 0 * b),
|
walther@59633
|
113 |
(([1,4], Res), a),
|
walther@59633
|
114 |
(([1], Res), a),
|
walther@59633
|
115 |
(([], Res), a)] *)
|
walther@59633
|
116 |
if existpt' ([1,4], Res) pt then ()
|
walther@59633
|
117 |
else error "auto-generated norm_Poly doesnt work";
|
walther@59633
|
118 |
|
walther@59633
|
119 |
"-------- test the same called by interSteps norm_Rational -------------------------------------";
|
walther@59633
|
120 |
"-------- test the same called by interSteps norm_Rational -------------------------------------";
|
walther@59633
|
121 |
"-------- test the same called by interSteps norm_Rational -------------------------------------";
|
walther@59633
|
122 |
val Seq {scr = Prog auto_script,...} = assoc_rls "norm_Rational";
|
walther@59633
|
123 |
writeln(term2str auto_script);
|
walther@59633
|
124 |
atomty auto_script;
|
walther@59633
|
125 |
(***
|
walther@59633
|
126 |
*** Const (Program.Stepwise, 'z => 'z => 'z)
|
walther@59633
|
127 |
*** . Free (t_t, 'z)
|
walther@59633
|
128 |
*** . Const (Program.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
walther@59633
|
129 |
*** . . Const (Program.Try, ('a => 'a) => 'a => 'a)
|
walther@59635
|
130 |
*** . . . Const (Program.Rewrite'_Set, ID => 'a => 'a)
|
walther@59633
|
131 |
*** . . . . Free (discard_minus, ID)
|
walther@59633
|
132 |
*** . . Const (Program.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
walther@59633
|
133 |
*** . . . Const (Program.Try, ('a => 'a) => 'a => 'a)
|
walther@59635
|
134 |
*** . . . . Const (Program.Rewrite'_Set, ID => 'a => 'a)
|
walther@59633
|
135 |
*** . . . . . Free (rat_mult_poly, ID)
|
walther@59633
|
136 |
*** . . . Const (Program.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
walther@59633
|
137 |
*** . . . . Const (Program.Try, ('a => 'a) => 'a => 'a)
|
walther@59635
|
138 |
*** . . . . . Const (Program.Rewrite'_Set, ID => 'a => 'a)
|
walther@59633
|
139 |
*** . . . . . . Free (make_rat_poly_with_parentheses, ID)
|
walther@59633
|
140 |
*** . . . . Const (Program.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
walther@59633
|
141 |
*** . . . . . Const (Program.Try, ('a => 'a) => 'a => 'a)
|
walther@59635
|
142 |
*** . . . . . . Const (Program.Rewrite'_Set, ID => 'a => 'a)
|
walther@59633
|
143 |
*** . . . . . . . Free (cancel_p_rls, ID)
|
walther@59633
|
144 |
*** . . . . . Const (Program.Seq, ('a => 'a) => ('a => 'a) => 'a => 'a)
|
walther@59633
|
145 |
*** . . . . . . Const (Program.Try, ('a => 'a) => 'a => 'a)
|
walther@59635
|
146 |
*** . . . . . . . Const (Program.Rewrite'_Set, ID => 'a => 'a)
|
walther@59633
|
147 |
*** . . . . . . . . Free (norm_Rational_rls, ID)
|
walther@59633
|
148 |
*** . . . . . . Const (Program.Try, ('a => 'a) => 'a => 'a)
|
walther@59635
|
149 |
*** . . . . . . . Const (Program.Rewrite'_Set, ID => 'a => 'a)
|
walther@59633
|
150 |
*** . . . . . . . . Free (discard_parentheses1, ID)
|
walther@59633
|
151 |
*** . . Const (empty, 'a)
|
walther@59633
|
152 |
***)
|
walther@59633
|
153 |
reset_states ();
|
walther@59633
|
154 |
CalcTree
|
walther@59633
|
155 |
[(["Term (b + a - b)", "normalform N"],
|
walther@59633
|
156 |
("Poly",["polynomial","simplification"],
|
walther@59633
|
157 |
["simplification","of_rationals"]))];
|
walther@59633
|
158 |
Iterator 1;
|
walther@59633
|
159 |
moveActiveRoot 1;
|
walther@59633
|
160 |
autoCalculate 1 CompleteCalc;
|
walther@59633
|
161 |
|
walther@59633
|
162 |
interSteps 1 ([], Res);
|
walther@59633
|
163 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
walther@59633
|
164 |
|
walther@59633
|
165 |
interSteps 1 ([1], Res);
|
walther@59633
|
166 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
walther@59633
|
167 |
|
walther@59633
|
168 |
(*with "Program SimplifyScript (t_::real) = \
|
walther@59635
|
169 |
\ ((Rewrite_Set norm_Rational) t_)"
|
walther@59633
|
170 |
val (Form form, SOME tac, asm) = pt_extract (pt, ([1], Res));
|
walther@59633
|
171 |
*)
|
walther@59633
|
172 |
val (Form form, SOME tac, asm) = pt_extract (pt, ([2], Res));
|
walther@59633
|
173 |
case (term2str form, tac, terms2strs asm) of
|
walther@59633
|
174 |
("a", Check_Postcond ["polynomial", "simplification"], []) => ()
|
walther@59633
|
175 |
| _ => error "scrtools.sml: auto-generated norm_Rational doesnt work";
|
walther@59633
|
176 |
|
walther@59637
|
177 |
"-------- fun op #> ----------------------------------------------------------------------------";
|
walther@59637
|
178 |
"-------- fun op #> ----------------------------------------------------------------------------";
|
walther@59637
|
179 |
"-------- fun op #> ----------------------------------------------------------------------------";
|
walther@59633
|
180 |
val rules = (#rules o rep_rls) isolate_root;
|
walther@59633
|
181 |
val rs = map (rule2stac @{theory}) rules;
|
walther@59637
|
182 |
val t = #> rs;
|
walther@59637
|
183 |
if term2str t = "Try (Repeat (Rewrite ''rroot_to_lhs'')) #>\n" ^
|
walther@59637
|
184 |
"Try (Repeat (Rewrite ''rroot_to_lhs_mult'')) #>\n" ^
|
walther@59637
|
185 |
"Try (Repeat (Rewrite ''rroot_to_lhs_add_mult'')) #>\n" ^
|
walther@59637
|
186 |
"Try (Repeat (Rewrite ''risolate_root_add'')) #>\n" ^
|
walther@59637
|
187 |
"Try (Repeat (Rewrite ''risolate_root_mult'')) #>\n" ^
|
walther@59635
|
188 |
"Try (Repeat (Rewrite ''risolate_root_div''))"
|
walther@59637
|
189 |
then () else error "fun #> changed"
|
walther@59633
|
190 |
|
walther@59633
|
191 |
"-------- fun rules2scr_Rls --------------------------------------------------------------------";
|
walther@59633
|
192 |
"-------- fun rules2scr_Rls --------------------------------------------------------------------";
|
walther@59633
|
193 |
"-------- fun rules2scr_Rls --------------------------------------------------------------------";
|
walther@59633
|
194 |
(*compare Prog_Expr.*)
|
walther@59633
|
195 |
val prog = Auto_Prog.rules2scr_Rls @{theory} [Rule.Thm ("thm111", @{thm thm111}), Rule.Thm ("refl", @{thm refl})]
|
walther@59633
|
196 |
;
|
walther@59633
|
197 |
writeln (t2str @{theory} prog);
|
walther@59633
|
198 |
(*auto_generated t_t =
|
walther@59633
|
199 |
Repeat
|
walther@59637
|
200 |
((Try (Repeat (Rewrite ''thm111'')) #>
|
walther@59635
|
201 |
Try (Repeat (Rewrite ''refl'')))
|
walther@59633
|
202 |
??.empty)*)
|
walther@59633
|
203 |
;
|
walther@59633
|
204 |
if t2str @{theory} prog =
|
walther@59635
|
205 |
"auto_generated t_t =\n" ^
|
walther@59635
|
206 |
"Repeat\n" ^
|
walther@59637
|
207 |
" ((Try (Repeat (Rewrite ''thm111'')) #> Try (Repeat (Rewrite ''refl'')))\n" ^
|
walther@59635
|
208 |
" ??.empty)"
|
walther@59635
|
209 |
then () else error "rules2scr_Rls auto_generated changed";
|
walther@59633
|
210 |
|
walther@59633
|
211 |
"-------- fun rule2stac, fun rule2stac_inst ----------------------------------------------------";
|
walther@59633
|
212 |
"-------- fun rule2stac, fun rule2stac_inst ----------------------------------------------------";
|
walther@59633
|
213 |
"-------- fun rule2stac, fun rule2stac_inst ----------------------------------------------------";
|
walther@59633
|
214 |
val t = rule2stac @{theory} (Thm ("real_diff_minus", num_str @{thm real_diff_minus}));
|
walther@59635
|
215 |
if term2str t = "Try (Repeat (Rewrite ''real_diff_minus''))" then ()
|
walther@59633
|
216 |
else error "rule2stac Thm.. changed";
|
walther@59633
|
217 |
|
walther@59633
|
218 |
val t = rule2stac @{theory} (Calc ("Groups.plus_class.plus", eval_binop "#add_"));
|
walther@59633
|
219 |
if term2str t = "Try (Repeat (Calculate ''PLUS''))" then ()
|
walther@59633
|
220 |
else error "rule2stac Calc.. changed";
|
walther@59633
|
221 |
|
walther@59633
|
222 |
val t = rule2stac @{theory} (Rls_ rearrange_assoc);
|
walther@59635
|
223 |
if term2str t = "Try (Rewrite_Set ''rearrange_assoc'')" then ()
|
walther@59633
|
224 |
else error "rule2stac Rls_.. changed";
|
walther@59633
|
225 |
|
walther@59633
|
226 |
val t = rule2stac_inst @{theory} (Thm ("risolate_bdv_add", num_str @{thm risolate_bdv_add}));
|
walther@59635
|
227 |
if term2str t = "Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''risolate_bdv_add''))" then ()
|
walther@59633
|
228 |
else error "rule2stac_inst Thm.. changed";
|
walther@59633
|
229 |
case t of
|
walther@59633
|
230 |
(Const ("Tactical.Try", _) $
|
walther@59633
|
231 |
(Const ("Tactical.Repeat", _) $
|
walther@59633
|
232 |
(Const ("Prog_Tac.Rewrite'_Inst", _) $
|
walther@59633
|
233 |
(Const ("List.list.Cons", _) $
|
walther@59633
|
234 |
(Const ("Product_Type.Pair", _) $
|
walther@59633
|
235 |
bdv $
|
walther@59633
|
236 |
Free ("v", _)) $
|
walther@59633
|
237 |
Const ("List.list.Nil", _)) $
|
walther@59635
|
238 |
risolate_bdv_add))) =>
|
walther@59633
|
239 |
(if HOLogic.dest_string bdv = "bdv" andalso
|
walther@59633
|
240 |
HOLogic.dest_string risolate_bdv_add = "risolate_bdv_add" then ()
|
walther@59633
|
241 |
else error "rule2stac_inst changed 1")
|
walther@59633
|
242 |
| _ => error "rule2stac_inst changed 2";
|
walther@59633
|
243 |
|
walther@59633
|
244 |
"-------- fun stacpbls -------------------------------------------------------------------------";
|
walther@59633
|
245 |
"-------- fun stacpbls -------------------------------------------------------------------------";
|
walther@59633
|
246 |
"-------- fun stacpbls -------------------------------------------------------------------------";
|
walther@59633
|
247 |
val {scr, ...} = get_met ["Test","sqrt-equ-test"]; val Prog sc = scr; val ts = stacpbls sc;
|
walther@59633
|
248 |
case stacpbls sc of
|
walther@59635
|
249 |
[Const ("Prog_Tac.Rewrite", _) $ square_equation_left,
|
walther@59635
|
250 |
Const ("Prog_Tac.Rewrite'_Set", _) $ Test_simplify,
|
walther@59635
|
251 |
Const ("Prog_Tac.Rewrite'_Set", _) $ rearrange_assoc,
|
walther@59635
|
252 |
Const ("Prog_Tac.Rewrite'_Set", _) $ isolate_root,
|
walther@59635
|
253 |
Const ("Prog_Tac.Rewrite'_Set", _) $ norm_equation,
|
walther@59633
|
254 |
Const ("Prog_Tac.Rewrite'_Set'_Inst", _) $
|
walther@59633
|
255 |
(Const ("List.list.Cons", _) $ (Const ("Product_Type.Pair", _) $ bdv $ Free ("v_v", _)) $
|
walther@59635
|
256 |
Const ("List.list.Nil", _)) $ isolate_bdv] =>
|
walther@59633
|
257 |
if HOLogic.dest_string square_equation_left = "square_equation_left" andalso
|
walther@59633
|
258 |
HOLogic.dest_string Test_simplify = "Test_simplify" andalso
|
walther@59633
|
259 |
HOLogic.dest_string rearrange_assoc = "rearrange_assoc" andalso
|
walther@59633
|
260 |
HOLogic.dest_string isolate_root = "isolate_root" andalso
|
walther@59633
|
261 |
HOLogic.dest_string norm_equation = "norm_equation" andalso
|
walther@59633
|
262 |
HOLogic.dest_string bdv = "bdv" andalso
|
walther@59633
|
263 |
HOLogic.dest_string isolate_bdv = "isolate_bdv"
|
walther@59633
|
264 |
then () else error "stacpbls (Test.Solve_root_equation) changed 2"
|
walther@59633
|
265 |
| _ => error "stacpbls (Test.Solve_root_equation) changed 1";
|
walther@59633
|
266 |
|
walther@59633
|
267 |
(* inappropriate input is skipped *)
|
walther@59633
|
268 |
val t = @{term "(a::real) = (rhs (NTH 1 sol_a))"};
|
walther@59633
|
269 |
case stacpbls t of [] => () | _ => error "stacpbls rhs (NTH 1 sol_a) changed";
|
walther@59633
|
270 |
|
walther@59633
|
271 |
@{term "(SubProblem (BiegelinieX,[vonBelastungZu,Biegelinien], [Biegelinien,ausBelastung]) [REAL q__q, REAL v_v])"};
|
walther@59633
|
272 |
case stacpbls t of [] => () | _ => error "stacpbls (SubProblem ...) changed";
|
walther@59633
|
273 |
|
walther@59633
|
274 |
"-------- fun is_calc, fun op_of_calc ----------------------------------------------------------";
|
walther@59633
|
275 |
"-------- fun is_calc, fun op_of_calc ----------------------------------------------------------";
|
walther@59633
|
276 |
"-------- fun is_calc, fun op_of_calc ----------------------------------------------------------";
|
walther@59633
|
277 |
val rls = prep_rls @{theory} Test_simplify; (* adds the Program *)
|
walther@59633
|
278 |
val Prog sc = (#scr o rep_rls) rls;
|
walther@59633
|
279 |
val stacs = stacpbls sc;
|
walther@59633
|
280 |
|
walther@59633
|
281 |
val calcs = filter is_calc stacs;
|
walther@59633
|
282 |
val ids = map op_of_calc calcs;
|
walther@59633
|
283 |
case ids of
|
walther@59633
|
284 |
["PLUS", "TIMES", "DIVIDE", "POWER"] => ()
|
walther@59633
|
285 |
| _ => error "op_of_calc";
|
walther@59633
|
286 |
|
walther@59633
|
287 |
val calcs = ((assoc_calc' @{theory} |> map) o (map Auto_Prog.op_of_calc) o
|
walther@59633
|
288 |
(filter Auto_Prog.is_calc) o Auto_Prog.stacpbls) sc;
|
walther@59633
|
289 |
case calcs of
|
walther@59633
|
290 |
[("PLUS", ("Groups.plus_class.plus", _)), ("TIMES", ("Groups.times_class.times", _)),
|
walther@59633
|
291 |
("DIVIDE", ("Rings.divide_class.divide", _)), ("POWER", ("Prog_Expr.pow", _))] => ()
|
walther@59633
|
292 |
| _ => error "get_calcs changed"
|
walther@59636
|
293 |
|
walther@59636
|
294 |
"-------- fun subst_typ ------------------------------------------------------------------------";
|
walther@59636
|
295 |
"-------- fun subst_typ ------------------------------------------------------------------------";
|
walther@59636
|
296 |
"-------- fun subst_typ ------------------------------------------------------------------------";
|
walther@59636
|
297 |
val Rule.Rls {scr = Prog prog, ...} = assoc_rls "isolate_bdv";
|
walther@59636
|
298 |
(* term2str prog |> writeln
|
walther@59636
|
299 |
auto_generated_inst t_t v =
|
walther@59636
|
300 |
Repeat
|
walther@59637
|
301 |
((Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''risolate_bdv_add'')) #>
|
walther@59637
|
302 |
Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''risolate_bdv_mult_add'')) #>
|
walther@59637
|
303 |
Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''risolate_bdv_mult'')) #>
|
walther@59637
|
304 |
Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''mult_square'')) #>
|
walther@59637
|
305 |
Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''constant_square'')) #>
|
walther@59636
|
306 |
Try (Repeat (Rewrite_Inst [(''bdv'', v)] ''constant_mult_square'')))
|
walther@59636
|
307 |
??.empty)
|
walther@59636
|
308 |
*)
|
walther@59636
|
309 |
|
walther@59636
|
310 |
val frees = vars prog; (* = [Free ("t_t", "'z"), Free ("v", "real"), Free ("v", "'a")]*)
|
walther@59636
|
311 |
if length frees = 3 then () else error "test setup Auto_Prog.subst_typ changed 1";
|
walther@59636
|
312 |
val args = formal_args prog; (* = [Free ("t_t", "'z"), Free ("v", "real")]*)
|
walther@59636
|
313 |
if length args = 2 then () else error "test setup Auto_Prog.subst_typ changed 2";
|
walther@59636
|
314 |
|
walther@59636
|
315 |
val typ_t = HOLogic.realT
|
walther@59636
|
316 |
val typ_bdv = HOLogic.realT
|
walther@59636
|
317 |
|
walther@59636
|
318 |
val vars_v = (* = [Free ("v", "real"), Free ("v", "'a")]*)
|
walther@59636
|
319 |
filter (fn t => curry op = (t |> dest_Free |> fst) "v") frees
|
walther@59636
|
320 |
val typs_v = (* = ["real", "'a"]*)
|
walther@59636
|
321 |
map (fn t => (t |> dest_Free |> snd)) vars_v;
|
walther@59636
|
322 |
|
walther@59636
|
323 |
val subst_ty = subst_typ "v" HOLogic.realT frees; (* = [("real", "real"), ("'a", "real")*)
|
walther@59636
|
324 |
if length subst_ty = 2 then () else error "Auto_Prog.subst_typ changed";
|
walther@59636
|
325 |
|
walther@59636
|
326 |
"-------- fun subst_typs -----------------------------------------------------------------------";
|
walther@59636
|
327 |
"-------- fun subst_typs -----------------------------------------------------------------------";
|
walther@59636
|
328 |
"-------- fun subst_typs -----------------------------------------------------------------------";
|
walther@59636
|
329 |
val Rule.Rls {scr = Prog prog, ...} = assoc_rls "isolate_bdv";
|
walther@59636
|
330 |
val frees = vars prog; (* = [Free ("t_t", "'z"), Free ("v", "real"), Free ("v", "'a")]*)
|
walther@59636
|
331 |
if length frees = 3 then () else error "test setup Auto_Prog.subst_typs changed 1";
|
walther@59636
|
332 |
val args = formal_args prog; (* = [Free ("t_t", "'z"), Free ("v", "real")]*)
|
walther@59636
|
333 |
if length args = 2 then () else error "test setup Auto_Prog.subst_typs changed 2";
|
walther@59636
|
334 |
|
walther@59636
|
335 |
val prog' = subst_typs prog HOLogic.realT HOLogic.realT
|
walther@59636
|
336 |
val frees' = vars prog'; (* = [Free ("t_t", "'z"), Free ("v", "real")]*);
|
walther@59636
|
337 |
if length frees' = 2 then () else error "Auto_Prog.subst_typs changed 2"
|