neuper@41999
|
1 |
(* Title: test/../script.sml
|
neuper@41999
|
2 |
Author: Walther Neuper 050908
|
neuper@37906
|
3 |
(c) copyright due to lincense terms.
|
neuper@37906
|
4 |
*)
|
neuper@37906
|
5 |
"-----------------------------------------------------------------";
|
neuper@37906
|
6 |
"table of contents -----------------------------------------------";
|
neuper@37906
|
7 |
"-----------------------------------------------------------------";
|
neuper@37906
|
8 |
"----------- WN0509 why does next_tac doesnt find Substitute -----";
|
neuper@37906
|
9 |
"----------- WN0509 Substitute 2nd part --------------------------";
|
neuper@37906
|
10 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
neuper@41969
|
11 |
"----------- fun init_form, fun get_stac -------------------------";
|
neuper@41972
|
12 |
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
|
neuper@42283
|
13 |
"----------- Take as 1st stac in script --------------------------";
|
neuper@42394
|
14 |
"----------- 'trace_script' from outside 'fun me '----------------";
|
neuper@42438
|
15 |
"----------- fun sel_rules ---------------------------------------";
|
neuper@42438
|
16 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
wneuper@59257
|
17 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
18 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
19 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
20 |
"----------- fun dsc_valT ----------------------------------------";
|
wneuper@59257
|
21 |
"----------- fun itms2args ---------------------------------------";
|
wneuper@59257
|
22 |
"----------- fun rep_tac_ ----------------------------------------";
|
neuper@37906
|
23 |
"-----------------------------------------------------------------";
|
neuper@37906
|
24 |
"-----------------------------------------------------------------";
|
neuper@37906
|
25 |
"-----------------------------------------------------------------";
|
neuper@37906
|
26 |
|
neuper@42438
|
27 |
val thy = @{theory Isac};
|
neuper@42281
|
28 |
|
neuper@37906
|
29 |
"----------- WN0509 why does next_tac doesnt find Substitute -----";
|
neuper@37906
|
30 |
"----------- WN0509 why does next_tac doesnt find Substitute -----";
|
neuper@37906
|
31 |
"----------- WN0509 why does next_tac doesnt find Substitute -----";
|
neuper@37906
|
32 |
|
neuper@37906
|
33 |
(*replace met 'IntegrierenUndKonstanteBestimmen' with this script...*)
|
neuper@37906
|
34 |
val str = (*#1#*)
|
akargl@42169
|
35 |
"Script BiegelinieScript " ^
|
akargl@42169
|
36 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
37 |
"(rb_rb::bool list) (rm_rm::bool list) = " ^
|
akargl@42169
|
38 |
" (let q___q = Take (M_b v_v = q__q); " ^
|
akargl@42169
|
39 |
" (M1__M1::bool) = ((Substitute [v_v = 0])) q___q " ^
|
akargl@42169
|
40 |
" in True)";
|
akargl@42169
|
41 |
|
wneuper@59188
|
42 |
val sc' = ((inst_abs thy) o Thm.term_of o the o (parse thy)) str;
|
neuper@37906
|
43 |
|
neuper@37906
|
44 |
val str = (*#2#*)
|
akargl@42169
|
45 |
"Script BiegelinieScript " ^
|
akargl@42169
|
46 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
47 |
"(rb_rb::bool list) (rm_rm::bool list) = " ^
|
akargl@42169
|
48 |
" (M1__M1::bool) = ((Substitute [v_v = 0]) @@ " ^
|
akargl@42169
|
49 |
" in True)";(*..doesnt find Substitute with ..@@ !!!!!!!!!!!!!!!!!!!!!*)
|
neuper@37906
|
50 |
|
neuper@37906
|
51 |
val str = (*#3#*)
|
akargl@42169
|
52 |
"Script BiegelinieScript " ^
|
akargl@42169
|
53 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
54 |
"(rb_rb::bool list) (rm_rm::bool list) = " ^
|
akargl@42169
|
55 |
" (let q___q = Take (q_q v_v = q__q); " ^
|
akargl@42169
|
56 |
" (M1__M1::bool) = Substitute [v_v = 0] q___q ; " ^
|
akargl@42169
|
57 |
" M1__m1 = Substitute [M_b 0 = 0] M1__M1 " ^
|
akargl@42169
|
58 |
" in True)"
|
neuper@37906
|
59 |
;
|
neuper@37906
|
60 |
val str = (*#4#*)
|
akargl@42169
|
61 |
"Script BiegelinieScript " ^
|
akargl@42169
|
62 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
63 |
"(rb_rb::bool list) (rm_rm::bool list) = " ^
|
akargl@42169
|
64 |
" (let q___q = Take (q_q v_v = q__q); " ^
|
akargl@42169
|
65 |
" (M1__M1::bool) = Substitute [v_v = 0] q___q ; " ^
|
akargl@42169
|
66 |
" M1__M1 = Substitute [v_v = 1] q___q ; " ^
|
akargl@42169
|
67 |
" M1__M1 = Substitute [v_v = 2] q___q ; " ^
|
akargl@42169
|
68 |
" M1__M1 = Substitute [v_v = 3] q___q ; " ^
|
akargl@42169
|
69 |
" M1__M1 = Substitute [M_b 0 = 0] M1__M1 " ^
|
akargl@42169
|
70 |
" in True)"
|
neuper@37906
|
71 |
;
|
neuper@37906
|
72 |
val str = (*#5#*)
|
akargl@42169
|
73 |
"Script BiegelinieScript " ^
|
akargl@42169
|
74 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
75 |
"(rb_rb::bool list) (rm_rm::bool list) = " ^
|
akargl@42169
|
76 |
" (let q___q = Take (M_b v_v = q__q); " ^
|
akargl@42169
|
77 |
" (M1__M1::bool) = Substitute [v_v = 0] q___q ; " ^
|
akargl@42169
|
78 |
" M2__M2 = Take q___q ; " ^
|
akargl@42169
|
79 |
" M2__M2 = Substitute [v_v = 2] q___q " ^
|
akargl@42169
|
80 |
" in True)"
|
neuper@37906
|
81 |
;
|
akargl@42145
|
82 |
|
wneuper@59188
|
83 |
val sc' = ((inst_abs thy) o Thm.term_of o the o (parse thy)) str;
|
neuper@37906
|
84 |
atomty sc';
|
akargl@42145
|
85 |
|
neuper@48790
|
86 |
val {scr = Prog sc,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
|
neuper@37906
|
87 |
(*---------------------------------------------------------------------
|
neuper@38031
|
88 |
if sc = sc' then () else error"script.sml, doesnt find Substitute #1";
|
neuper@37906
|
89 |
---------------------------------------------------------------------*)
|
neuper@37906
|
90 |
|
neuper@37906
|
91 |
"----------- WN0509 Substitute 2nd part --------------------------";
|
neuper@37906
|
92 |
"----------- WN0509 Substitute 2nd part --------------------------";
|
neuper@37906
|
93 |
"----------- WN0509 Substitute 2nd part --------------------------";
|
neuper@37906
|
94 |
(*replace met 'IntegrierenUndKonstanteBestimmen' with this script...*)
|
neuper@37906
|
95 |
val str = (*Substitute ; Substitute works*)
|
akargl@42169
|
96 |
"Script BiegelinieScript " ^
|
akargl@42169
|
97 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
98 |
"(rb_rb::bool list) (rm_rm::bool list) = "^
|
neuper@37906
|
99 |
(*begin after the 2nd integrate*)
|
akargl@42169
|
100 |
" (let M__M = Take (M_b v_v = q__q); " ^
|
akargl@42169
|
101 |
" e1__e1 = nth_nth 1 rm_rm ; " ^
|
akargl@42169
|
102 |
" (x1__x1::real) = argument_in (lhs e1__e1); " ^
|
akargl@42169
|
103 |
" (M1__M1::bool) = Substitute [v_v = x1__x1] M__M; " ^
|
akargl@42169
|
104 |
" M1__M1 = Substitute [e1__e1] M1__M1 " ^
|
akargl@42169
|
105 |
" in True)"
|
neuper@37906
|
106 |
;
|
wneuper@59188
|
107 |
val sc' = ((inst_abs thy) o Thm.term_of o the o (parse thy)) str;
|
neuper@37906
|
108 |
atomty sc';
|
akargl@42145
|
109 |
|
neuper@37906
|
110 |
val str = (*Substitute @@ Substitute does NOT work???*)
|
akargl@42169
|
111 |
"Script BiegelinieScript " ^
|
akargl@42169
|
112 |
"(l_l::real) (q__q::real) (v_v::real) (b_b::real=>real) " ^
|
akargl@42169
|
113 |
"(rb_rb::bool list) (rm_rm::bool list) = "^
|
neuper@37906
|
114 |
(*begin after the 2nd integrate*)
|
akargl@42169
|
115 |
" (let M__M = Take (M_b v_v = q__q); " ^
|
akargl@42169
|
116 |
" e1__e1 = nth_nth 1 rm_rm ; " ^
|
akargl@42169
|
117 |
" (x1__x1::real) = argument_in (lhs e1__e1); " ^
|
akargl@42169
|
118 |
" (M1__M1::bool) = ((Substitute [v_v = x1__x1]) @@ " ^
|
akargl@42169
|
119 |
" (Substitute [e1__e1])) M__M " ^
|
akargl@42169
|
120 |
" in True)"
|
neuper@37906
|
121 |
;
|
neuper@37906
|
122 |
|
neuper@48790
|
123 |
val {scr = Prog sc,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
|
neuper@37906
|
124 |
(*---------------------------------------------------------------------
|
akargl@42169
|
125 |
if sc = sc' then () else error "script.sml, doesnt find Substitute #1";
|
neuper@37906
|
126 |
---------------------------------------------------------------------*)
|
neuper@37906
|
127 |
val fmz = ["Traegerlaenge L",
|
neuper@37906
|
128 |
"Streckenlast (- q_0 * x^^^2 / 2 + x * c + c_2)",
|
neuper@37906
|
129 |
"Biegelinie y",
|
neuper@37906
|
130 |
"RandbedingungenBiegung [y 0 = 0, y L = 0]",
|
neuper@37906
|
131 |
"RandbedingungenMoment [M_b 0 = 0, M_b L = 0]",
|
neuper@37906
|
132 |
"FunktionsVariable x"];
|
neuper@37906
|
133 |
val (dI',pI',mI') =
|
neuper@38058
|
134 |
("Biegelinie",["MomentBestimmte","Biegelinien"],
|
neuper@37906
|
135 |
["IntegrierenUndKonstanteBestimmen"]);
|
neuper@37906
|
136 |
val p = e_pos'; val c = [];
|
neuper@37906
|
137 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
akargl@42169
|
138 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
akargl@42169
|
139 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
akargl@42169
|
140 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
akargl@42169
|
141 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
akargl@42169
|
142 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
143 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
144 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
145 |
case nxt of (_, Apply_Method ["IntegrierenUndKonstanteBestimmen"]) => ()
|
neuper@38031
|
146 |
| _ => error "script.sml, doesnt find Substitute #2";
|
akargl@42169
|
147 |
(* ERROR: caused by f2str f *)
|
neuper@52101
|
148 |
trace_rewrite := false;
|
neuper@42387
|
149 |
|
neuper@37906
|
150 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f(*------------------------*);
|
neuper@37906
|
151 |
trace_rewrite:=false;
|
akargl@42169
|
152 |
(*Exception TYPE raised:
|
akargl@42169
|
153 |
Illegal type for constant "HOL.eq" :: "[real, bool] => bool"
|
akargl@42169
|
154 |
Atools.argument'_in (Tools.lhs (ListG.nth_ (1 + -1 + -1) [])) =
|
akargl@42169
|
155 |
ListG.nth_ (1 + -1 + -1) []
|
akargl@42169
|
156 |
Exception-
|
akargl@42169
|
157 |
TYPE
|
akargl@42169
|
158 |
("Illegal type for constant \"op =\" :: \"[real, bool] => bool\"",
|
akargl@42169
|
159 |
[],
|
akargl@42169
|
160 |
[Const ("HOL.Trueprop", "bool => prop") $
|
neuper@55279
|
161 |
(Const ("HOL.eq", "["Real.real, bool] => bool") $ ... $ ...)])
|
akargl@42169
|
162 |
raised
|
akargl@42169
|
163 |
... this was because eval_argument_in took "argument_in (lhs (M_b 0 = 0))"
|
akargl@42169
|
164 |
ie. the argument had not been simplified before ^^^^^^^^^^^^^^^
|
akargl@42169
|
165 |
thus corrected eval_argument_in OK*)
|
neuper@37906
|
166 |
val {srls,...} = get_met ["IntegrierenUndKonstanteBestimmen"];
|
neuper@42387
|
167 |
val e1__e1 = str2term "NTH 1 [M_b 0 = 0, M_b L = 0]";
|
akargl@42169
|
168 |
val e1__e1 = eval_listexpr_ @{theory Biegelinie} srls e1__e1; term2str e1__e1;
|
akargl@42169
|
169 |
if term2str e1__e1 = "M_b 0 = 0"
|
akargl@42169
|
170 |
then ()
|
akargl@42169
|
171 |
else error"script.sml diff.beh. eval_listexpr_ nth_nth 1 [...";
|
neuper@37906
|
172 |
|
neuper@37906
|
173 |
(*TODO.WN050913 ??? doesnt eval_listexpr_ go into subterms ???...
|
akargl@42169
|
174 |
val x1__ = str2term"argument_in (lhs (M_b 0 = 0))";
|
akargl@42169
|
175 |
val x1__ = eval_listexpr_ Biegelinie.thy srls x1__; term2str x1__;
|
akargl@42169
|
176 |
(*no rewrite*)
|
akargl@42169
|
177 |
calculate_ Biegelinie.thy ("Tools.lhs", eval_rhs"eval_lhs_") x1__;
|
akargl@42169
|
178 |
val SOME (str, t) = eval_lhs 0 "Tools.lhs" (str2term"lhs (M_b 0 = 0)") 0;*)
|
neuper@37906
|
179 |
|
akargl@42169
|
180 |
val l__l = str2term "lhs (M_b 0 = 0)";
|
akargl@42169
|
181 |
val l__l = eval_listexpr_ @{theory Biegelinie} srls l__l; term2str l__l;
|
akargl@42169
|
182 |
val SOME (str, t) = eval_lhs 0 "Tools.lhs" (str2term "lhs (M_b 0 = 0)") 0;
|
neuper@42387
|
183 |
|
akargl@42169
|
184 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f (*------------------------*);
|
wneuper@59253
|
185 |
val thm = case nxt of ("Rewrite", Rewrite ("Belastung_Querkraft", thm)) => thm
|
wneuper@59253
|
186 |
| _ => error "--- WN0509 Substitute 2nd part --- changed 1";
|
wneuper@59253
|
187 |
if (term2str o Thm.prop_of) thm = "- qq ?x = Q' ?x" then ()
|
wneuper@59253
|
188 |
else error "--- WN0509 Substitute 2nd part --- changed 2";
|
neuper@37906
|
189 |
|
neuper@37906
|
190 |
|
neuper@37906
|
191 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
neuper@37906
|
192 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
neuper@37906
|
193 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
akargl@42145
|
194 |
|
s1210629013@55445
|
195 |
reset_states ();
|
neuper@41970
|
196 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@41970
|
197 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@37906
|
198 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@37906
|
199 |
Iterator 1;
|
neuper@37906
|
200 |
moveActiveRoot 1;
|
wneuper@59248
|
201 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@59248
|
202 |
autoCalculate 1 (Step 1);
|
wneuper@59248
|
203 |
autoCalculate 1 (Step 1);
|
neuper@37906
|
204 |
val ((pt, p), _) = get_calc 1; show_pt pt;
|
neuper@37906
|
205 |
val appltacs = sel_appl_atomic_tacs pt p;
|
wneuper@59252
|
206 |
case appltacs of
|
wneuper@59252
|
207 |
[Rewrite ("radd_commute", radd_commute),
|
wneuper@59252
|
208 |
Rewrite ("add_assoc", add_assoc), Calculate "TIMES"]
|
wneuper@59253
|
209 |
=> if (term2str o Thm.prop_of) radd_commute = "?m + ?n = ?n + ?m" andalso
|
wneuper@59253
|
210 |
(term2str o Thm.prop_of) add_assoc = "?a + ?b + ?c = ?a + (?b + ?c)" then ()
|
wneuper@59252
|
211 |
else error "script.sml fun sel_appl_atomic_tacs diff.behav. 2"
|
wneuper@59252
|
212 |
| _ => error "script.sml fun sel_appl_atomic_tacs diff.behav. 1";
|
neuper@37906
|
213 |
|
neuper@37906
|
214 |
trace_script := true;
|
neuper@37906
|
215 |
trace_script := false;
|
neuper@37906
|
216 |
applyTactic 1 p (hd appltacs);
|
neuper@37906
|
217 |
val ((pt, p), _) = get_calc 1; show_pt pt;
|
neuper@37906
|
218 |
val appltacs = sel_appl_atomic_tacs pt p;
|
neuper@48895
|
219 |
(*applyTactic 1 p (hd appltacs); WAS assy: call by ([3], Pbl)*)
|
neuper@37906
|
220 |
|
akargl@42169
|
221 |
"~~~~~ fun applyTactic, args:"; val ((cI:calcID), ip, tac) = (1, p, (hd appltacs));
|
akargl@42169
|
222 |
val ((pt, _), _) = get_calc cI;
|
akargl@42169
|
223 |
val p = get_pos cI 1;
|
akargl@42169
|
224 |
locatetac;
|
akargl@42169
|
225 |
locatetac tac;
|
akargl@42169
|
226 |
|
akargl@42169
|
227 |
(*locatetac tac (pt, ip); (*WAS assy: call by ([3], Pbl)*)*)
|
akargl@42169
|
228 |
"~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, ip));
|
akargl@42169
|
229 |
val (mI,m) = mk_tac'_ tac;
|
akargl@42169
|
230 |
applicable_in p pt m ; (*Appl*)
|
akargl@42169
|
231 |
member op = specsteps mI; (*false*)
|
akargl@42169
|
232 |
(*loc_solve_ (mI,m) ptp; (*Argument: (mI, m) : string * tac Reason: Can't unify tac_ with tac*)*)
|
akargl@42169
|
233 |
loc_solve_; (*without _ ??? result is -> lOc writing error ???*)
|
akargl@42169
|
234 |
(*val it = fn: string * tac_ -> ptree * (pos * pos_) -> lOc_*)
|
akargl@42169
|
235 |
(mI,m); (*string * tac*)
|
akargl@42169
|
236 |
ptp (*ptree * pos'*);
|
akargl@42169
|
237 |
"~~~~~ fun loc_solve_, args:"; val (m ,(pt,pos)) = ((mI,m), ptp);
|
akargl@42169
|
238 |
(*val (msg, cs') = solve m (pt, pos);
|
akargl@42169
|
239 |
(*Argument: m : string * tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
|
akargl@42169
|
240 |
m;
|
akargl@42169
|
241 |
(pt, pos);
|
akargl@42169
|
242 |
"~~~~~ fun solve, args:"; val ((mI,m), (pt, po as (p,p_))) = (m, (pt, pos));
|
akargl@42169
|
243 |
(*solve has still p_!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
akargl@42169
|
244 |
|
akargl@42169
|
245 |
e_metID = get_obj g_metID pt (par_pblobj pt p); (*false*)
|
akargl@42169
|
246 |
val ctxt = get_ctxt pt po;
|
akargl@42169
|
247 |
|
akargl@42169
|
248 |
(*generate1 (assoc_thy (get_obj g_domID pt (par_pblobj pt p))) m (e_istate, ctxt) (p,p_) pt;
|
akargl@42169
|
249 |
(*Argument: m : tac Reason: Can't unify tac_ with tac (Different type constructors)*)*)
|
akargl@42169
|
250 |
(assoc_thy (get_obj g_domID pt (par_pblobj pt p)));
|
akargl@42169
|
251 |
assoc_thy;
|
akargl@42169
|
252 |
|
wneuper@59248
|
253 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
254 |
|
neuper@41969
|
255 |
"----------- fun init_form, fun get_stac -------------------------";
|
neuper@41969
|
256 |
"----------- fun init_form, fun get_stac -------------------------";
|
neuper@41969
|
257 |
"----------- fun init_form, fun get_stac -------------------------";
|
neuper@41969
|
258 |
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
|
neuper@41969
|
259 |
val (dI',pI',mI') = ("Test",["sqroot-test","univariate","equation","test"],
|
neuper@41969
|
260 |
["Test","squ-equ-test-subpbl1"]);
|
neuper@41969
|
261 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@41969
|
262 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
263 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
264 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
265 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
266 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
267 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
268 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
269 |
"~~~~~ fun me, args:"; val (_,tac) = nxt;
|
neuper@41969
|
270 |
"~~~~~ fun locatetac, args:"; val ptp as (pt, p) = (pt, p);
|
neuper@41969
|
271 |
val (mI,m) = mk_tac'_ tac;
|
neuper@41969
|
272 |
val Appl m = applicable_in p pt m;
|
neuper@41969
|
273 |
member op = specsteps mI; (*false*)
|
neuper@41969
|
274 |
"~~~~~ fun loc_solve_, args:"; val (m, (pt, pos) ) = ((mI, m), ptp);
|
neuper@41969
|
275 |
"~~~~~ fun solve, args:"; val (("Apply_Method", Apply_Method' (mI,_,_,_)), pos as (p,_)) = (m, pos);
|
neuper@41969
|
276 |
val {srls, ...} = get_met mI;
|
neuper@41969
|
277 |
val PblObj {meth=itms, ...} = get_obj I pt p;
|
neuper@41969
|
278 |
val thy' = get_obj g_domID pt p;
|
neuper@41969
|
279 |
val thy = assoc_thy thy';
|
neuper@41969
|
280 |
val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
|
neuper@41969
|
281 |
val ini = init_form thy sc env;
|
neuper@48790
|
282 |
"----- fun init_form, args:"; val (Prog sc) = sc;
|
neuper@41969
|
283 |
"----- fun get_stac, args:"; val (y, h $ body) = (thy, sc);
|
neuper@41969
|
284 |
case get_stac thy sc of SOME (Free ("e_e", _)) => ()
|
neuper@41969
|
285 |
| _ => error "script: Const (?, ?) in script (as term) changed";;
|
neuper@41969
|
286 |
|
neuper@41972
|
287 |
|
neuper@41972
|
288 |
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
|
neuper@41972
|
289 |
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
|
neuper@41972
|
290 |
"----------- x+1=2 start SubProblem 'stac2tac_ TODO: no match for ";
|
neuper@41972
|
291 |
val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
|
neuper@41972
|
292 |
val (dI',pI',mI') =
|
neuper@41972
|
293 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@41972
|
294 |
["Test","squ-equ-test-subpbl1"]);
|
neuper@41972
|
295 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@41972
|
296 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
297 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
298 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
299 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
300 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
301 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
302 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
303 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
304 |
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
|
neuper@41972
|
305 |
(*val (p,_,f,nxt,_,pt) = me nxt p [1] pt; WAS: Empty_Tac, helpless*)
|
neuper@41972
|
306 |
show_pt pt;
|
neuper@41972
|
307 |
"~~~~~ fun me, args:"; val (_,tac) = nxt;
|
neuper@41973
|
308 |
val (pt, p) = case locatetac tac (pt,p) of
|
neuper@41973
|
309 |
("ok", (_, _, ptp)) => ptp | _ => error "script.sml locatetac";
|
neuper@41972
|
310 |
"~~~~~ fun step, args:"; val (ip as (_,p_), (ptp as (pt,p), tacis)) = (p, ((pt, e_pos'), []))
|
neuper@55279
|
311 |
val pIopt = get_pblID (pt,ip); (*SOME ["LINEAR", "univariate", "equation", "test"]*)
|
neuper@41972
|
312 |
tacis; (*= []*)
|
neuper@41972
|
313 |
member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); (*= false*)
|
neuper@41972
|
314 |
"~~~~~ fun nxt_solve_, args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
|
neuper@41972
|
315 |
(*WAS stac2tac_ TODO: no match for SubProblem*)
|
neuper@41972
|
316 |
val thy' = get_obj g_domID pt (par_pblobj pt p);
|
neuper@41972
|
317 |
val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
|
neuper@48790
|
318 |
"~~~~~ fun next_tac, args:"; val (thy, (ptp as (pt,(p,_)):ptree * pos'), (sc as Prog (h $ body)),
|
neuper@41972
|
319 |
(ScrState (E,l,a,v,s,b), ctxt)) = ((thy',srls), (pt,pos), sc, is);
|
neuper@41972
|
320 |
l; (*= [R, L, R, L, R, R]*)
|
neuper@41972
|
321 |
val Appy (m', scrst as (_,_,_,v,_,_)) = nstep_up thy ptp sc E l Skip_ a v;
|
neuper@41972
|
322 |
"~~~~~ dont like to go into nstep_up...";
|
neuper@41972
|
323 |
val t = str2term ("SubProblem" ^
|
neuper@55279
|
324 |
"(Test', [LINEAR, univariate, equation, test], [Test, solve_linear])" ^
|
neuper@41972
|
325 |
"[BOOL (-1 + x = 0), REAL x]");
|
neuper@41972
|
326 |
val (tac, tac_) = stac2tac_ pt @{theory "Isac"} t; (*WAS stac2tac_ TODO: no match for SubProblem*)
|
neuper@41972
|
327 |
case tac_ of
|
neuper@41972
|
328 |
Subproblem' _ => ()
|
neuper@41972
|
329 |
| _ => error "script.sml x+1=2 start SubProblem from script";
|
neuper@41972
|
330 |
|
neuper@41972
|
331 |
|
neuper@42283
|
332 |
"----------- Take as 1st stac in script --------------------------";
|
neuper@42283
|
333 |
"----------- Take as 1st stac in script --------------------------";
|
neuper@42283
|
334 |
"----------- Take as 1st stac in script --------------------------";
|
neuper@42283
|
335 |
val p = e_pos'; val c = [];
|
neuper@42283
|
336 |
val (p,_,f,nxt,_,pt) =
|
neuper@42283
|
337 |
CalcTreeTEST
|
neuper@42283
|
338 |
[(["functionTerm (x^^^2 + 1)", "integrateBy x", "antiDerivative FF"],
|
neuper@42283
|
339 |
("Integrate", ["integrate","function"], ["diff","integration"]))];
|
neuper@42283
|
340 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*)
|
neuper@42283
|
341 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@42283
|
342 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@42283
|
343 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@42283
|
344 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@42283
|
345 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@42283
|
346 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@42283
|
347 |
case nxt of (_, Apply_Method ["diff", "integration"]) => ()
|
neuper@42283
|
348 |
| _ => error "integrate.sml -- me method [diff,integration] -- spec";
|
neuper@42283
|
349 |
"----- step 8: returns nxt = Rewrite_Set_Inst ([\"(bdv, x)\"],\"integration\")";
|
neuper@42283
|
350 |
|
neuper@42283
|
351 |
"~~~~~ fun me, args:"; val (((_,tac):tac'_), (p:pos'), _, (pt:ptree)) = (nxt, p, c, pt);
|
neuper@42283
|
352 |
"~~~~~ fun locatetac, args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
|
neuper@42283
|
353 |
val (mI,m) = mk_tac'_ tac;
|
neuper@42283
|
354 |
val Appl m = applicable_in p pt m;
|
neuper@42283
|
355 |
member op = specsteps mI (*false*);
|
neuper@42283
|
356 |
"~~~~~ fun loc_solve_, args:"; val (m, (pt,pos)) = ((mI,m), ptp);
|
neuper@42283
|
357 |
"~~~~~ fun solve, args:"; val ((_, m as Apply_Method' (mI, _, _, _)), (pt, (pos as (p,_)))) =
|
neuper@42283
|
358 |
(m, (pt, pos));
|
neuper@42283
|
359 |
val {srls, ...} = get_met mI;
|
neuper@42283
|
360 |
val PblObj {meth=itms, ...} = get_obj I pt p;
|
neuper@42283
|
361 |
val thy' = get_obj g_domID pt p;
|
neuper@42283
|
362 |
val thy = assoc_thy thy';
|
neuper@42283
|
363 |
val (is as ScrState (env,_,_,_,_,_), ctxt, sc) = init_scrstate thy itms mI;
|
neuper@42283
|
364 |
val ini = init_form thy sc env;
|
neuper@42283
|
365 |
val p = lev_dn p;
|
neuper@42283
|
366 |
ini = NONE; (*true*)
|
neuper@42283
|
367 |
val (m', (is', ctxt'), _) = next_tac (thy', srls) (pt, (p, Res)) sc (is, ctxt);
|
neuper@42283
|
368 |
val d = e_rls (*FIXME: get simplifier from domID*);
|
neuper@42283
|
369 |
"~~~~~ fun locate_gen, args:"; val ((ts as (thy',srls)), (m:tac_), ((pt,p):ptree * pos'),
|
neuper@48790
|
370 |
(scr as Prog (h $ body),d), (ScrState (E,l,a,v,S,b), ctxt)) =
|
neuper@42283
|
371 |
((thy',srls), m', (pt,(p, Res)), (sc,d), (is', ctxt'));
|
neuper@42283
|
372 |
val thy = assoc_thy thy';
|
neuper@42283
|
373 |
l = [] orelse ((*init.in solve..Apply_Method...*)
|
neuper@42283
|
374 |
(last_elem o fst) p = 0 andalso snd p = Res); (*true*)
|
neuper@42283
|
375 |
"~~~~~ fun assy, args:"; val (ya, (is as (E,l,a,v,S,b),ss),
|
neuper@42283
|
376 |
(Const ("HOL.Let",_) $ e $ (Abs (id,T,body)))) =
|
neuper@42283
|
377 |
((thy',ctxt,srls,d,Aundef), ((E,[R],a,v,S,b), [(m,EmptyMout,pt,p,[])]), body);
|
neuper@42283
|
378 |
(*check: true*) term2str e = "Take (Integral f_f D v_v)";
|
neuper@42283
|
379 |
"~~~~~ fun assy, args:"; val ((thy',ctxt,sr,d,ap), (is as (E,l,a,v,S,b), (m,_,pt,(p,p_),c)::ss), t) =
|
neuper@42283
|
380 |
(ya, ((E , l@[L,R], a,v,S,b),ss), e);
|
neuper@42283
|
381 |
val (a', STac stac) = handle_leaf "locate" thy' sr E a v t;
|
neuper@42283
|
382 |
(* val ctxt = get_ctxt pt (p,p_)
|
neuper@42283
|
383 |
exception PTREE "get_obj: pos = [0] does not exist" raised
|
neuper@42283
|
384 |
(line 908 of "/usr/local/isabisac/src/Tools/isac/Interpret/ctree.sml")*)
|
neuper@42283
|
385 |
|
neuper@42283
|
386 |
|
neuper@42394
|
387 |
"----------- 'trace_script' from outside 'fun me '----------------";
|
neuper@42394
|
388 |
"----------- 'trace_script' from outside 'fun me '----------------";
|
neuper@42394
|
389 |
"----------- 'trace_script' from outside 'fun me '----------------";
|
neuper@42394
|
390 |
val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
|
neuper@42394
|
391 |
val (dI',pI',mI') =
|
neuper@42394
|
392 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@42394
|
393 |
["Test","squ-equ-test-subpbl1"]);
|
neuper@42394
|
394 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@42394
|
395 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
396 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
397 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
398 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
399 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
400 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@42394
|
401 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
|
neuper@42394
|
402 |
(*from_pblobj_or_detail': no istate = from_pblobj_or_detail' "Isac" p pt;*)
|
neuper@42394
|
403 |
|
neuper@42394
|
404 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*---------------------------------------------------*)
|
neuper@42394
|
405 |
val (p'''', pt'''') = (p, pt);
|
wneuper@59253
|
406 |
f2str f = "x + 1 = 2"; case snd nxt of Rewrite_Set "norm_equation" => () | _ => error "CHANGED";
|
neuper@42394
|
407 |
val (p, p_) = p(* = ([1], Frm)*);
|
neuper@48790
|
408 |
val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
|
neuper@42394
|
409 |
val (env, loc_, curry_arg, res, Safe, true) = scrstate;
|
neuper@42394
|
410 |
env2str env = "[\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"]";
|
neuper@42394
|
411 |
loc_ = [];
|
neuper@42394
|
412 |
curry_arg = NONE;
|
neuper@42394
|
413 |
term2str res = "??.empty"; (* scrstate before starting interpretation *)
|
neuper@48790
|
414 |
(*term2str (go loc_ sc) = "Prog Solve_root_equation e_e v_v = ...*)
|
neuper@42394
|
415 |
|
neuper@42394
|
416 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
417 |
val (p'''', pt'''') = (p, pt);
|
wneuper@59253
|
418 |
f2str f = "x + 1 + -1 * 2 = 0";
|
wneuper@59253
|
419 |
case snd nxt of Rewrite_Set "Test_simplify" => () | _ => error "CHANGED";
|
neuper@42394
|
420 |
val (p, p_) = p(* = ([1], Res)*);
|
neuper@48790
|
421 |
val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
|
neuper@42394
|
422 |
val (env, loc_, curry_arg, res, Safe, true) = scrstate;
|
neuper@42394
|
423 |
env2str env = "[\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"]";
|
neuper@42394
|
424 |
loc_ = [R, L, R, L, L, R, R];
|
neuper@42394
|
425 |
curry_arg = SOME (str2term "e_e::bool");
|
neuper@42394
|
426 |
term2str res = "x + 1 + -1 * 2 = 0";(* scrstate after norm_equation, before Test_simplify *)
|
neuper@42394
|
427 |
term2str (go loc_ sc) = "Rewrite_Set norm_equation False";
|
neuper@42394
|
428 |
|
neuper@42394
|
429 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
430 |
val (p'''', pt'''') = (p, pt);
|
wneuper@59253
|
431 |
f2str f = "-1 + x = 0";
|
wneuper@59253
|
432 |
case snd nxt of Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]) => ()
|
wneuper@59253
|
433 |
| _ => error "CHANGED";
|
neuper@42394
|
434 |
val (p, p_) = p(* = ([2], Res)*);
|
neuper@48790
|
435 |
val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
|
neuper@42394
|
436 |
val (env, loc_, curry_arg, res, Safe, false) = scrstate;
|
neuper@42394
|
437 |
env2str env = "[\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"]";
|
neuper@42394
|
438 |
loc_ = [R, L, R, L, R, R];
|
neuper@42394
|
439 |
curry_arg = SOME (str2term "e_e::bool");
|
neuper@42394
|
440 |
term2str res = "-1 + x = 0"; (* scrstate after Test_simplify, before Subproblem *)
|
neuper@42394
|
441 |
term2str (go loc_ sc) = "Rewrite_Set Test_simplify False";
|
neuper@42394
|
442 |
|
neuper@42394
|
443 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
444 |
val (p'''', pt'''') = (p, pt); (*f2str f = exception Match; ...is a model, not a formula*)
|
neuper@42394
|
445 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
446 |
val (p'''', pt'''') = (p, pt);
|
neuper@42394
|
447 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
448 |
val (p'''', pt'''') = (p, pt);
|
neuper@42394
|
449 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
450 |
val (p'''', pt'''') = (p, pt);
|
neuper@42394
|
451 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
452 |
val (p'''', pt'''') = (p, pt);
|
neuper@42394
|
453 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
454 |
val (p'''', pt'''') = (p, pt);
|
neuper@42394
|
455 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
456 |
val (p'''', pt'''') = (p, pt);
|
neuper@42394
|
457 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*nxt = Apply_Method ["Test", "solve_linear"]*)
|
neuper@42394
|
458 |
(*from_pblobj_or_detail': no istate = from_pblobj_or_detail' "Isac" p pt;*)
|
neuper@42394
|
459 |
|
neuper@42394
|
460 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*---------------------------------------------------*)
|
neuper@42394
|
461 |
val (p'''', pt'''') = (p, pt);
|
wneuper@59253
|
462 |
f2str f = "-1 + x = 0";
|
wneuper@59253
|
463 |
case snd nxt of Rewrite_Set_Inst (["(bdv, x)"], "isolate_bdv") => () | _ => error "CHANGED";
|
neuper@42394
|
464 |
val (p, p_) = p(* = ([3, 1], Frm)*);
|
neuper@48790
|
465 |
val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
|
neuper@42394
|
466 |
val (env, loc_, curry_arg, res, Safe, true) = scrstate;
|
neuper@42394
|
467 |
env2str env = "[\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"]";
|
neuper@42394
|
468 |
loc_ = [];
|
neuper@42394
|
469 |
curry_arg = NONE;
|
neuper@42394
|
470 |
term2str res = "??.empty"; (* scrstate before starting interpretation *)
|
neuper@48790
|
471 |
(*term2str (go loc_ sc) = "Prog Solve_linear e_e v_v = ...*)
|
neuper@42394
|
472 |
|
neuper@42394
|
473 |
val (p,_,f,nxt,_,pt) = me nxt p'''' [] pt''''; (*-------------------------------------------*)
|
neuper@42394
|
474 |
val (p'''', pt'''') = (p, pt);
|
wneuper@59253
|
475 |
f2str f = "x = 0 + -1 * -1";
|
wneuper@59253
|
476 |
case snd nxt of Rewrite_Set "Test_simplify" => () | _ => error "CHANGED";
|
neuper@42394
|
477 |
val (p, p_) = p(* = ([3, 1], Res)*);
|
neuper@48790
|
478 |
val (srls, (ScrState scrstate, ctxt), Prog sc) = from_pblobj_or_detail' "Isac" (p, p_) pt;
|
neuper@42394
|
479 |
val (env, loc_, curry_arg, res, Safe, true) = scrstate;
|
neuper@42394
|
480 |
env2str env = "[\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"]";
|
neuper@42394
|
481 |
loc_ = [R, L, R, L, R, L, R];
|
neuper@42394
|
482 |
curry_arg = SOME (str2term "e_e::bool");
|
neuper@42394
|
483 |
term2str res = "x = 0 + -1 * -1";(* scrstate after isolate_bdv, before Test_simplify *)
|
neuper@42394
|
484 |
term2str (go loc_ sc) = "Rewrite_Set_Inst [(bdv, v_v)] isolate_bdv False";
|
neuper@42394
|
485 |
|
neuper@42438
|
486 |
"----------- fun sel_rules ---------------------------------------";
|
neuper@42438
|
487 |
"----------- fun sel_rules ---------------------------------------";
|
neuper@42438
|
488 |
"----------- fun sel_rules ---------------------------------------";
|
neuper@42438
|
489 |
(* compare test/../interface.sml
|
neuper@42438
|
490 |
"--------- getTactic, fetchApplicableTactics ------------";
|
neuper@42438
|
491 |
*)
|
s1210629013@55445
|
492 |
reset_states ();
|
neuper@42438
|
493 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@42438
|
494 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@42438
|
495 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@42438
|
496 |
Iterator 1;
|
neuper@42438
|
497 |
moveActiveRoot 1;
|
wneuper@59248
|
498 |
autoCalculate 1 CompleteCalc;
|
neuper@42438
|
499 |
val ((pt,_),_) = get_calc 1;
|
neuper@42438
|
500 |
show_pt pt;
|
neuper@42394
|
501 |
|
neuper@42438
|
502 |
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
|
neuper@42438
|
503 |
val tacs = sel_rules pt ([],Pbl);
|
wneuper@59253
|
504 |
case tacs of [Apply_Method ["Test", "squ-equ-test-subpbl1"]] => ()
|
wneuper@59253
|
505 |
| _ => error "script.sml: diff.behav. in sel_rules ([],Pbl)";
|
neuper@42438
|
506 |
|
neuper@42438
|
507 |
val tacs = sel_rules pt ([1],Res);
|
wneuper@59253
|
508 |
case tacs of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
|
neuper@55279
|
509 |
Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
|
wneuper@59253
|
510 |
Check_elementwise "Assumptions"] => ()
|
wneuper@59253
|
511 |
| _ => error "script.sml: diff.behav. in sel_rules ([1],Res)";
|
neuper@42438
|
512 |
|
neuper@42438
|
513 |
val tacs = sel_rules pt ([3],Pbl);
|
wneuper@59253
|
514 |
case tacs of [Apply_Method ["Test", "solve_linear"]] => ()
|
wneuper@59253
|
515 |
| _ => error "script.sml: diff.behav. in sel_rules ([3],Pbl)";
|
neuper@42438
|
516 |
|
neuper@42438
|
517 |
val tacs = sel_rules pt ([3,1],Res);
|
wneuper@59253
|
518 |
case tacs of [Rewrite_Set_Inst (["(bdv, x)"], "isolate_bdv"), Rewrite_Set "Test_simplify"] => ()
|
wneuper@59253
|
519 |
| _ => error "script.sml: diff.behav. in sel_rules ([3,1],Res)";
|
neuper@42438
|
520 |
|
neuper@42438
|
521 |
val tacs = sel_rules pt ([3],Res);
|
wneuper@59253
|
522 |
case tacs of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
|
neuper@55279
|
523 |
Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
|
wneuper@59253
|
524 |
Check_elementwise "Assumptions"] => ()
|
wneuper@59253
|
525 |
| _ => error "script.sml: diff.behav. in sel_rules ([3],Res)";
|
neuper@42438
|
526 |
|
neuper@42438
|
527 |
val tacs = (sel_rules pt ([],Res)) handle PTREE str => [Tac str];
|
wneuper@59253
|
528 |
case tacs of [Tac "no tactics applicable at the end of a calculation"] => ()
|
wneuper@59253
|
529 |
| _ => error "script.sml: diff.behav. in sel_rules ([],Res)";
|
neuper@42438
|
530 |
|
neuper@42438
|
531 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
neuper@42438
|
532 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
neuper@42438
|
533 |
"----------- fun sel_appl_atomic_tacs ----------------------------";
|
s1210629013@55445
|
534 |
reset_states ();
|
neuper@42438
|
535 |
CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"],
|
neuper@42438
|
536 |
("Test", ["sqroot-test","univariate","equation","test"],
|
neuper@42438
|
537 |
["Test","squ-equ-test-subpbl1"]))];
|
neuper@42438
|
538 |
Iterator 1;
|
neuper@42438
|
539 |
moveActiveRoot 1;
|
wneuper@59248
|
540 |
autoCalculate 1 CompleteCalc;
|
neuper@42438
|
541 |
|
neuper@42438
|
542 |
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
|
neuper@42438
|
543 |
fetchApplicableTactics 1 99999 ([],Pbl);
|
neuper@42438
|
544 |
|
neuper@42438
|
545 |
fetchApplicableTactics 1 99999 ([1],Res);
|
neuper@42438
|
546 |
"~~~~~ fun fetchApplicableTactics, args:"; val (cI, (scope:int), (p:pos')) = (1, 99999, ([1],Res));
|
neuper@42438
|
547 |
val ((pt, _), _) = get_calc cI;
|
neuper@42438
|
548 |
(*version 1:*)
|
wneuper@59253
|
549 |
case sel_rules pt p of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
|
neuper@55279
|
550 |
Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
|
wneuper@59253
|
551 |
Check_elementwise "Assumptions"] => ()
|
wneuper@59253
|
552 |
| _ => error "fetchApplicableTactics ([1],Res) changed";
|
neuper@42438
|
553 |
(*version 2:*)
|
neuper@42438
|
554 |
(*WAS:
|
neuper@42438
|
555 |
sel_appl_atomic_tacs pt p;
|
neuper@42438
|
556 |
...
|
neuper@55279
|
557 |
### atomic_appl_tacs: not impl. for tac='Subproblem(Test,["LINEAR","univariate","equation","test"])'
|
neuper@42438
|
558 |
### atomic_appl_tacs: not impl. for tac = 'Check_elementwise "Assumptions"'
|
neuper@42438
|
559 |
*)
|
neuper@42438
|
560 |
|
neuper@42438
|
561 |
"~~~~~ fun sel_appl_atomic_tacs, args:"; val (pt, (p,p_)) = (pt, p);
|
neuper@42438
|
562 |
is_spec_pos p_ = false;
|
neuper@42438
|
563 |
val pp = par_pblobj pt p
|
neuper@42438
|
564 |
val thy' = (get_obj g_domID pt pp):theory'
|
neuper@42438
|
565 |
val thy = assoc_thy thy'
|
neuper@42438
|
566 |
val metID = get_obj g_metID pt pp
|
neuper@42438
|
567 |
val metID' =
|
neuper@42438
|
568 |
if metID = e_metID
|
neuper@42438
|
569 |
then (thd3 o snd3) (get_obj g_origin pt pp)
|
neuper@42438
|
570 |
else metID
|
neuper@48790
|
571 |
val {scr=Prog sc,srls,erls,rew_ord'=ro,...} = get_met metID'
|
neuper@42438
|
572 |
val ScrState (env,_,a,v,_,_) = get_istate pt (p,p_)
|
neuper@42438
|
573 |
val alltacs = (*we expect at least 1 stac in a script*)
|
neuper@42438
|
574 |
map ((stac2tac pt thy) o rep_stacexpr o #2 o
|
neuper@42438
|
575 |
(handle_leaf "selrul" thy' srls env a v)) (stacpbls sc)
|
neuper@42438
|
576 |
val f =
|
neuper@42438
|
577 |
case p_ of
|
neuper@42438
|
578 |
Frm => get_obj g_form pt p
|
wneuper@59257
|
579 |
| Res => (fst o (get_obj g_result pt)) p;
|
neuper@42438
|
580 |
(*WN120611 stopped and took version 1 again for fetchApplicableTactics !
|
neuper@42438
|
581 |
(distinct o flat o (map (atomic_appl_tacs thy ro erls f))) alltacs
|
neuper@42438
|
582 |
...
|
neuper@55279
|
583 |
### atomic_appl_tacs: not impl. for tac='Subproblem(Test,["LINEAR","univariate","equation","test"])'
|
neuper@42438
|
584 |
### atomic_appl_tacs: not impl. for tac = 'Check_elementwise "Assumptions"'
|
neuper@42438
|
585 |
*)
|
neuper@42438
|
586 |
|
wneuper@59257
|
587 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
588 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
589 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
590 |
(*
|
wneuper@59257
|
591 |
> val str = "Rewrite_Set_Inst";
|
wneuper@59257
|
592 |
> val esc = esc_underscore str;
|
wneuper@59257
|
593 |
val it = "Rewrite'_Set'_Inst" : string
|
wneuper@59257
|
594 |
> val des = de_esc_underscore esc;
|
wneuper@59257
|
595 |
val des = de_esc_underscore esc;*)
|
wneuper@59257
|
596 |
|
wneuper@59257
|
597 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
598 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
599 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
600 |
(*
|
wneuper@59257
|
601 |
> val t = (Thm.term_of o the o (parse thy)) "a+b";
|
wneuper@59257
|
602 |
val it = Const (#,#) $ Free (#,#) $ Free ("b","RealDef.real") : term
|
wneuper@59257
|
603 |
> val plus_a = go [L] t;
|
wneuper@59257
|
604 |
> val b = go [R] t;
|
wneuper@59257
|
605 |
> val plus = go [L,L] t;
|
wneuper@59257
|
606 |
> val a = go [L,R] t;
|
wneuper@59257
|
607 |
|
wneuper@59257
|
608 |
> val t = (Thm.term_of o the o (parse thy)) "a+b+c";
|
wneuper@59257
|
609 |
val t = Const (#,#) $ (# $ # $ Free #) $ Free ("c","RealDef.real") : term
|
wneuper@59257
|
610 |
> val pl_pl_a_b = go [L] t;
|
wneuper@59257
|
611 |
> val c = go [R] t;
|
wneuper@59257
|
612 |
> val a = go [L,R,L,R] t;
|
wneuper@59257
|
613 |
> val b = go [L,R,R] t;
|
wneuper@59257
|
614 |
*)
|
wneuper@59257
|
615 |
|
wneuper@59257
|
616 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
617 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
618 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
619 |
(*
|
wneuper@59257
|
620 |
> formal_args scr;
|
wneuper@59257
|
621 |
[Free ("f_","RealDef.real"),Free ("v_","RealDef.real"),
|
wneuper@59257
|
622 |
Free ("eqs_","bool List.list")] : term list
|
wneuper@59257
|
623 |
*)
|
wneuper@59257
|
624 |
"----------- fun dsc_valT ----------------------------------------";
|
wneuper@59257
|
625 |
"----------- fun dsc_valT ----------------------------------------";
|
wneuper@59257
|
626 |
"----------- fun dsc_valT ----------------------------------------";
|
wneuper@59257
|
627 |
(*> val t = (Thm.term_of o the o (parse thy)) "equality";
|
wneuper@59257
|
628 |
> val T = type_of t;
|
wneuper@59257
|
629 |
val T = "bool => Tools.una" : typ
|
wneuper@59257
|
630 |
> val dsc = dsc_valT t;
|
wneuper@59257
|
631 |
val dsc = "una" : string
|
wneuper@59257
|
632 |
|
wneuper@59257
|
633 |
> val t = (Thm.term_of o the o (parse thy)) "fixedValues";
|
wneuper@59257
|
634 |
> val T = type_of t;
|
wneuper@59257
|
635 |
val T = "bool List.list => Tools.nam" : typ
|
wneuper@59257
|
636 |
> val dsc = dsc_valT t;
|
wneuper@59257
|
637 |
val dsc = "nam" : string*)
|
wneuper@59257
|
638 |
"----------- fun itms2args ---------------------------------------";
|
wneuper@59257
|
639 |
"----------- fun itms2args ---------------------------------------";
|
wneuper@59257
|
640 |
"----------- fun itms2args ---------------------------------------";
|
wneuper@59257
|
641 |
(*
|
wneuper@59257
|
642 |
> val sc = ... Solve_root_equation ...
|
wneuper@59257
|
643 |
> val mI = ("Script","sqrt-equ-test");
|
wneuper@59257
|
644 |
> val PblObj{meth={ppc=itms,...},...} = get_obj I pt [];
|
wneuper@59257
|
645 |
> val ts = itms2args thy mI itms;
|
wneuper@59257
|
646 |
> map (term_to_string''' thy) ts;
|
wneuper@59257
|
647 |
["sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x)","x","#0"] : string list
|
wneuper@59257
|
648 |
*)
|
wneuper@59257
|
649 |
"----------- fun rep_tac_ ----------------------------------------";
|
wneuper@59257
|
650 |
"----------- fun rep_tac_ ----------------------------------------";
|
wneuper@59257
|
651 |
"----------- fun rep_tac_ ----------------------------------------";
|
wneuper@59257
|
652 |
(***************fun rep_tac_ (Rewrite_Inst' (thy', rod, rls, put, subs, (thmID, _), f, (f', _))) =
|
wneuper@59257
|
653 |
Fehlersuche 25.4.01
|
wneuper@59257
|
654 |
(a)----- als String zusammensetzen:
|
wneuper@59257
|
655 |
ML> term2str f;
|
wneuper@59257
|
656 |
val it = "d_d x #4 + d_d x (x ^^^ #2 + #3 * x)" : string
|
wneuper@59257
|
657 |
ML> term2str f';
|
wneuper@59257
|
658 |
val it = "#0 + d_d x (x ^^^ #2 + #3 * x)" : string
|
wneuper@59257
|
659 |
ML> subs;
|
wneuper@59257
|
660 |
val it = [(Free ("bdv","RealDef.real"),Free ("x","RealDef.real"))] : subst
|
wneuper@59257
|
661 |
> val tt = (Thm.term_of o the o (parse thy))
|
wneuper@59257
|
662 |
"(Rewrite_Inst[(bdv,x)]diff_const False(d_d x #4 + d_d x (x ^^^ #2 + #3 * x)))=(#0 + d_d x (x ^^^ #2 + #3 * x))";
|
wneuper@59257
|
663 |
> atomty tt;
|
wneuper@59257
|
664 |
ML> tracing (term2str tt);
|
wneuper@59257
|
665 |
(Rewrite_Inst [(bdv,x)] diff_const False d_d x #4 + d_d x (x ^^^ #2 + #3 * x)) =
|
wneuper@59257
|
666 |
#0 + d_d x (x ^^^ #2 + #3 * x)
|
wneuper@59257
|
667 |
|
wneuper@59257
|
668 |
(b)----- laut rep_tac_:
|
wneuper@59257
|
669 |
> val ttt=HOLogic.mk_eq (lhs,f');
|
wneuper@59257
|
670 |
> atomty ttt;
|
wneuper@59257
|
671 |
|
wneuper@59257
|
672 |
|
wneuper@59257
|
673 |
(*Fehlersuche 1-2Monate vor 4.01:*)
|
wneuper@59257
|
674 |
> val tt = (Thm.term_of o the o (parse thy))
|
wneuper@59257
|
675 |
"Rewrite_Inst[(bdv,x)]square_equation_left True(x=#1+#2)";
|
wneuper@59257
|
676 |
> atomty tt;
|
wneuper@59257
|
677 |
|
wneuper@59257
|
678 |
> val f = (Thm.term_of o the o (parse thy)) "x=#1+#2";
|
wneuper@59257
|
679 |
> val f' = (Thm.term_of o the o (parse thy)) "x=#3";
|
wneuper@59257
|
680 |
> val subs = [((Thm.term_of o the o (parse thy)) "bdv",
|
wneuper@59257
|
681 |
(Thm.term_of o the o (parse thy)) "x")];
|
wneuper@59257
|
682 |
> val sT = (type_of o fst o hd) subs;
|
wneuper@59257
|
683 |
> val subs' = list2isalist (HOLogic.mk_prodT (sT, sT))
|
wneuper@59257
|
684 |
(map HOLogic.mk_prod subs);
|
wneuper@59257
|
685 |
> val sT' = type_of subs';
|
wneuper@59257
|
686 |
> val lhs = Const ("Script.Rewrite'_Inst",[sT',idT,fT,fT] ---> fT)
|
wneuper@59257
|
687 |
$ subs' $ Free (thmID,idT) $ @{term True} $ f;
|
wneuper@59257
|
688 |
> lhs = tt;
|
wneuper@59257
|
689 |
val it = true : bool
|
wneuper@59257
|
690 |
> rep_tac_ (Rewrite_Inst'
|
wneuper@59257
|
691 |
("Script","tless_true","eval_rls",false,subs,
|
wneuper@59257
|
692 |
("square_equation_left",""),f,(f',[])));
|
wneuper@59257
|
693 |
*)
|
wneuper@59257
|
694 |
(****************************| rep_tac_ (Rewrite' (thy', _, _, put, (thmID, _), f, (f', _)))=
|
wneuper@59257
|
695 |
> val tt = (Thm.term_of o the o (parse thy)) (*____ ____..test*)
|
wneuper@59257
|
696 |
"Rewrite square_equation_left True (x=#1+#2) = (x=#3)";
|
wneuper@59257
|
697 |
|
wneuper@59257
|
698 |
> val f = (Thm.term_of o the o (parse thy)) "x=#1+#2";
|
wneuper@59257
|
699 |
> val f' = (Thm.term_of o the o (parse thy)) "x=#3";
|
wneuper@59257
|
700 |
> val Thm (id,thm) =
|
wneuper@59257
|
701 |
rep_tac_ (Rewrite'
|
wneuper@59257
|
702 |
("Script","tless_true","eval_rls",false,
|
wneuper@59257
|
703 |
("square_equation_left",""),f,(f',[])));
|
wneuper@59257
|
704 |
> val SOME ct = parse thy
|
wneuper@59257
|
705 |
"Rewrite square_equation_left True (x=#1+#2)";
|
wneuper@59257
|
706 |
> rewrite_ Script.thy tless_true eval_rls true thm ct;
|
wneuper@59257
|
707 |
val it = SOME ("x = #3",[]) : (cterm * cterm list) option
|
wneuper@59257
|
708 |
*)
|
wneuper@59257
|
709 |
(**************************************** | rep_tac_ (Rewrite_Set_Inst'
|
wneuper@59257
|
710 |
WN050824: type error ...
|
wneuper@59257
|
711 |
let val fT = type_of f;
|
wneuper@59257
|
712 |
val sT = (type_of o fst o hd) subs;
|
wneuper@59257
|
713 |
val subs' = list2isalist (HOLogic.mk_prodT (sT, sT))
|
wneuper@59257
|
714 |
(map HOLogic.mk_prod subs);
|
wneuper@59257
|
715 |
val sT' = type_of subs';
|
wneuper@59257
|
716 |
val b = if put then @{term True} else @{term False}
|
wneuper@59257
|
717 |
val lhs = Const ("Script.Rewrite'_Set'_Inst",
|
wneuper@59257
|
718 |
[sT',idT,fT,fT] ---> fT)
|
wneuper@59257
|
719 |
$ subs' $ Free (id_rls rls,idT) $ b $ f;
|
wneuper@59257
|
720 |
in (((make_rule (assoc_thy thy')) o HOLogic.mk_eq) (lhs,f'),(lhs,f')) end*)
|
wneuper@59257
|
721 |
(* ... vals from Rewrite_Inst' ...
|
wneuper@59257
|
722 |
> rep_tac_ (Rewrite_Set_Inst'
|
wneuper@59257
|
723 |
("Script",false,subs,
|
wneuper@59257
|
724 |
"isolate_bdv",f,(f',[])));
|
wneuper@59257
|
725 |
*)
|
wneuper@59257
|
726 |
(* val (Rewrite_Set' (thy',put,rls,f,(f',asm)))=m;
|
wneuper@59257
|
727 |
*)
|
wneuper@59257
|
728 |
(************************************** | rep_tac_ (Rewrite_Set' (thy',put,rls,f,(f',asm)))=
|
wneuper@59257
|
729 |
13.3.01:
|
wneuper@59257
|
730 |
val thy = assoc_thy thy';
|
wneuper@59257
|
731 |
val t = HOLogic.mk_eq (lhs,f');
|
wneuper@59257
|
732 |
make_rule thy t;
|
wneuper@59257
|
733 |
--------------------------------------------------
|
wneuper@59257
|
734 |
val lll = (Thm.term_of o the o (parse thy))
|
wneuper@59257
|
735 |
"Rewrite_Set SqRoot_simplify False (d_d x (x ^^^ #2 + #3 * x) + d_d x #4)";
|
wneuper@59257
|
736 |
|
wneuper@59257
|
737 |
--------------------------------------------------
|
wneuper@59257
|
738 |
> val f = (Thm.term_of o the o (parse thy)) "x=#1+#2";
|
wneuper@59257
|
739 |
> val f' = (Thm.term_of o the o (parse thy)) "x=#3";
|
wneuper@59257
|
740 |
> val Thm (id,thm) =
|
wneuper@59257
|
741 |
rep_tac_ (Rewrite_Set'
|
wneuper@59257
|
742 |
("Script",false,"SqRoot_simplify",f,(f',[])));
|
wneuper@59257
|
743 |
val id = "(Rewrite_Set SqRoot_simplify True x = #1 + #2) = (x = #3)" : string
|
wneuper@59257
|
744 |
val thm = "(Rewrite_Set SqRoot_simplify True x = #1 + #2) = (x = #3)" : thm
|
wneuper@59257
|
745 |
*)
|
wneuper@59257
|
746 |
(***************************************** | rep_tac_ (Calculate' (thy',op_,f,(f',thm')))=
|
wneuper@59257
|
747 |
> val lhs'=(Thm.term_of o the o (parse thy))"Calculate plus (#1+#2)";
|
wneuper@59257
|
748 |
... test-root-equ.sml: calculate ...
|
wneuper@59257
|
749 |
> val Appl m'=applicable_in p pt (Calculate "PLUS");
|
wneuper@59257
|
750 |
> val (lhs,_)=tac_2etac m';
|
wneuper@59257
|
751 |
> lhs'=lhs;
|
wneuper@59257
|
752 |
val it = true : bool*)
|