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