Walther@60729
|
1 |
(* Title: Interpret/li-tool.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 |
"-----------------------------------------------------------------";
|
walther@59848
|
8 |
"----------- fun implicit_take, fun get_first_argument -------------------------";
|
walther@59823
|
9 |
"----------- fun from_prog ---------------------------------------";
|
walther@59823
|
10 |
"----------- fun specific_from_prog ----------------------------";
|
wneuper@59257
|
11 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
12 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
13 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
14 |
"----------- fun dsc_valT ----------------------------------------";
|
walther@59848
|
15 |
"----------- fun arguments_from_model ---------------------------------------";
|
wneuper@59583
|
16 |
"----------- fun init_pstate -----------------------------------------------------------------";
|
neuper@37906
|
17 |
"-----------------------------------------------------------------";
|
neuper@37906
|
18 |
"-----------------------------------------------------------------";
|
neuper@37906
|
19 |
"-----------------------------------------------------------------";
|
Walther@60736
|
20 |
open Ctree;
|
Walther@60736
|
21 |
open Pos;
|
Walther@60736
|
22 |
open TermC;
|
Walther@60736
|
23 |
open Istate;
|
Walther@60736
|
24 |
open Tactic;
|
Walther@60736
|
25 |
open Program;
|
Walther@60736
|
26 |
open Auto_Prog;
|
Walther@60736
|
27 |
open Fetch_Tacs;
|
Walther@60736
|
28 |
open Pre_Conds;
|
Walther@60736
|
29 |
open I_Model;
|
Walther@60736
|
30 |
open P_Model
|
Walther@60736
|
31 |
open Rewrite;
|
Walther@60736
|
32 |
open Step;
|
Walther@60736
|
33 |
open LItool;
|
Walther@60736
|
34 |
open LI;
|
Walther@60736
|
35 |
open Test_Code
|
Walther@60736
|
36 |
open Specify
|
Walther@60736
|
37 |
open Solve
|
Walther@60736
|
38 |
open Prog_Tac
|
Walther@60736
|
39 |
open Kernel
|
Walther@60736
|
40 |
open ME_Misc
|
Walther@60736
|
41 |
|
neuper@37906
|
42 |
|
wneuper@59592
|
43 |
val thy = @{theory Isac_Knowledge};
|
neuper@42281
|
44 |
|
Walther@60736
|
45 |
(** -------- fun implicit_take, fun get_first_argument ----------------------- **)
|
walther@59848
|
46 |
"----------- fun implicit_take, fun get_first_argument -------------------------";
|
walther@59848
|
47 |
"----------- fun implicit_take, fun get_first_argument -------------------------";
|
neuper@41969
|
48 |
val fmz = ["equality (x+1=(2::real))", "solveFor x", "solutions L"];
|
walther@59997
|
49 |
val (dI',pI',mI') = ("Test",["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
50 |
["Test", "squ-equ-test-subpbl1"]);
|
Walther@60571
|
51 |
val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(fmz, (dI',pI',mI'))];
|
neuper@41969
|
52 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
53 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
54 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
55 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
56 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
57 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
neuper@41969
|
58 |
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
|
walther@59749
|
59 |
"~~~~~ fun me, args:"; val tac = nxt;
|
walther@59804
|
60 |
"~~~~~ fun Step.by_tactic, args:"; val ptp as (pt, p) = (pt, p);
|
walther@59922
|
61 |
val Applicable.Yes m = Step.check tac (pt, p);
|
walther@59755
|
62 |
(*if*) Tactic.for_specify' m; (*false*)
|
walther@59749
|
63 |
"~~~~~ fun loc_solve_, args:"; val (m, (pt, pos) ) = (m, ptp);
|
walther@59751
|
64 |
"~~~~~ fun Step_Solve.by_tactic , args:"; val (Apply_Method' (mI,_,_,ctxt), pos as (p,_))
|
walther@59751
|
65 |
= (m, pos);
|
Walther@60586
|
66 |
val {prog_rls, ...} = MethodC.from_store ctxt mI;
|
neuper@41969
|
67 |
val PblObj {meth=itms, ...} = get_obj I pt p;
|
neuper@41969
|
68 |
val thy' = get_obj g_domID pt p;
|
Walther@60676
|
69 |
val thy = ThyC.get_theory @{context} thy';
|
Walther@60586
|
70 |
val prog_rls = LItool.get_simplifier (pt, pos)
|
Walther@60711
|
71 |
val (is as Pstate {env, ...}, ctxt, sc) = init_pstate ctxt (I_Model.OLD_to_TEST itms) mI;
|
Walther@60673
|
72 |
val ini = implicit_take @{context} sc env;
|
walther@59845
|
73 |
"----- fun implicit_take, args:"; val (Prog sc) = sc;
|
walther@59848
|
74 |
"----- fun get_first_argument, args:"; val (y, h $ body) = (thy, sc);
|
walther@59848
|
75 |
case get_first_argument sc of SOME (Free ("e_e", _)) => ()
|
neuper@41969
|
76 |
| _ => error "script: Const (?, ?) in script (as term) changed";;
|
neuper@41969
|
77 |
|
Walther@60736
|
78 |
(** -------- fun from_prog ------------------------------------- **)
|
walther@59823
|
79 |
"----------- fun from_prog ---------------------------------------";
|
walther@59823
|
80 |
"----------- fun from_prog ---------------------------------------";
|
neuper@42438
|
81 |
(* compare test/../interface.sml
|
neuper@42438
|
82 |
"--------- getTactic, fetchApplicableTactics ------------";
|
neuper@42438
|
83 |
*)
|
Walther@60549
|
84 |
States.reset ();
|
Walther@60571
|
85 |
CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
|
walther@59997
|
86 |
("Test", ["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
87 |
["Test", "squ-equ-test-subpbl1"]))];
|
neuper@42438
|
88 |
Iterator 1;
|
neuper@42438
|
89 |
moveActiveRoot 1;
|
wneuper@59248
|
90 |
autoCalculate 1 CompleteCalc;
|
Walther@60549
|
91 |
val ((pt,_),_) = States.get_calc 1;
|
walther@59983
|
92 |
Test_Tool.show_pt pt;
|
neuper@42394
|
93 |
|
neuper@42438
|
94 |
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
|
walther@59823
|
95 |
val tacs = from_prog pt ([],Pbl);
|
wneuper@59253
|
96 |
case tacs of [Apply_Method ["Test", "squ-equ-test-subpbl1"]] => ()
|
walther@59823
|
97 |
| _ => error "script.sml: diff.behav. in from_prog ([],Pbl)";
|
neuper@42438
|
98 |
|
walther@59823
|
99 |
val tacs = from_prog pt ([1],Res);
|
wneuper@59253
|
100 |
case tacs of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
|
neuper@55279
|
101 |
Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
|
wneuper@59253
|
102 |
Check_elementwise "Assumptions"] => ()
|
walther@59823
|
103 |
| _ => error "script.sml: diff.behav. in from_prog ([1],Res)";
|
neuper@42438
|
104 |
|
walther@59823
|
105 |
val tacs = from_prog pt ([3],Pbl);
|
wneuper@59253
|
106 |
case tacs of [Apply_Method ["Test", "solve_linear"]] => ()
|
walther@59823
|
107 |
| _ => error "script.sml: diff.behav. in from_prog ([3],Pbl)";
|
neuper@42438
|
108 |
|
walther@59823
|
109 |
val tacs = from_prog pt ([3,1],Res);
|
wneuper@59497
|
110 |
case tacs of [Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"), Rewrite_Set "Test_simplify"] => ()
|
walther@59823
|
111 |
| _ => error "script.sml: diff.behav. in from_prog ([3,1],Res)";
|
neuper@42438
|
112 |
|
walther@59823
|
113 |
val tacs = from_prog pt ([3],Res);
|
wneuper@59253
|
114 |
case tacs of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
|
neuper@55279
|
115 |
Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
|
wneuper@59253
|
116 |
Check_elementwise "Assumptions"] => ()
|
walther@59823
|
117 |
| _ => error "script.sml: diff.behav. in from_prog ([3],Res)";
|
neuper@42438
|
118 |
|
Walther@60736
|
119 |
val tacs = (from_prog pt ([],Res)) handle PTREE str => [Tactic.Tac str];
|
Walther@60736
|
120 |
case tacs of [Tactic.Tac "no tactics applicable at the end of a calculation"] => ()
|
walther@59823
|
121 |
| _ => error "script.sml: diff.behav. in from_prog ([],Res)";
|
neuper@42438
|
122 |
|
Walther@60736
|
123 |
(** --------- fun specific_from_prog ------------------------- **)
|
walther@59823
|
124 |
"----------- fun specific_from_prog ----------------------------";
|
walther@59823
|
125 |
"----------- fun specific_from_prog ----------------------------";
|
Walther@60549
|
126 |
States.reset ();
|
Walther@60571
|
127 |
CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],
|
walther@59997
|
128 |
("Test", ["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
129 |
["Test", "squ-equ-test-subpbl1"]))];
|
neuper@42438
|
130 |
Iterator 1;
|
neuper@42438
|
131 |
moveActiveRoot 1;
|
wneuper@59248
|
132 |
autoCalculate 1 CompleteCalc;
|
neuper@42438
|
133 |
|
neuper@42438
|
134 |
(*UC\label{SOLVE:MANUAL:TACTIC:listall} UC 30.3.2.2 p.175*)
|
neuper@42438
|
135 |
fetchApplicableTactics 1 99999 ([],Pbl);
|
neuper@42438
|
136 |
|
neuper@42438
|
137 |
fetchApplicableTactics 1 99999 ([1],Res);
|
neuper@42438
|
138 |
"~~~~~ fun fetchApplicableTactics, args:"; val (cI, (scope:int), (p:pos')) = (1, 99999, ([1],Res));
|
Walther@60549
|
139 |
val ((pt, _), _) = States.get_calc cI;
|
neuper@42438
|
140 |
(*version 1:*)
|
walther@59823
|
141 |
case from_prog pt p of [Rewrite_Set "norm_equation", Rewrite_Set "Test_simplify",
|
neuper@55279
|
142 |
Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
|
wneuper@59253
|
143 |
Check_elementwise "Assumptions"] => ()
|
wneuper@59253
|
144 |
| _ => error "fetchApplicableTactics ([1],Res) changed";
|
neuper@42438
|
145 |
(*version 2:*)
|
neuper@42438
|
146 |
(*WAS:
|
walther@59823
|
147 |
specific_from_prog pt p;
|
neuper@42438
|
148 |
...
|
walther@59997
|
149 |
### Tactic.applicable: not impl. for tac='Subproblem(Test,["LINEAR", "univariate", "equation", "test"])'
|
walther@59914
|
150 |
### Tactic.applicable: not impl. for tac = 'Check_elementwise "Assumptions"'
|
neuper@42438
|
151 |
*)
|
neuper@42438
|
152 |
|
Walther@60609
|
153 |
"~~~~~ fun specific_from_prog , args:"; val (pt, pos as (p, p_)) = (pt, p);
|
walther@59932
|
154 |
(*if*) Pos.on_specification (p, p_) (*else*);
|
neuper@42438
|
155 |
val pp = par_pblobj pt p
|
walther@59879
|
156 |
val thy' = (get_obj g_domID pt pp):ThyC.id
|
Walther@60676
|
157 |
val thy = ThyC.get_theory @{context} thy'
|
neuper@42438
|
158 |
val metID = get_obj g_metID pt pp
|
neuper@42438
|
159 |
val metID' =
|
walther@60154
|
160 |
if metID = MethodC.id_empty
|
neuper@42438
|
161 |
then (thd3 o snd3) (get_obj g_origin pt pp)
|
neuper@42438
|
162 |
else metID
|
Walther@60586
|
163 |
val {program=Prog sc,prog_rls,asm_rls,rew_ord=ro,...} = MethodC.from_store ctxt metID'
|
walther@59807
|
164 |
val Pstate ist = get_istate_LI pt (p,p_)
|
walther@59722
|
165 |
val ctxt = get_ctxt pt (p, p_)
|
neuper@42438
|
166 |
val alltacs = (*we expect at least 1 stac in a script*)
|
Walther@60640
|
167 |
map ((LItool.tac_from_prog (pt, pos)) o rep_stacexpr o #1 o
|
Walther@60586
|
168 |
(check_leaf "selrul" ctxt prog_rls (get_subst ist) )) (stacpbls sc)
|
neuper@42438
|
169 |
val f =
|
walther@59722
|
170 |
(case p_ of Frm => get_obj g_form pt p | Res => (fst o (get_obj g_result pt)) p
|
walther@59722
|
171 |
| _ => error "");
|
neuper@42438
|
172 |
(*WN120611 stopped and took version 1 again for fetchApplicableTactics !
|
Walther@60586
|
173 |
(distinct op = o flat o (map (Tactic.applicable thy ro asm_rls f))) alltacs
|
neuper@42438
|
174 |
...
|
walther@59997
|
175 |
### Tactic.applicable: not impl. for tac='Subproblem(Test,["LINEAR", "univariate", "equation", "test"])'
|
walther@59914
|
176 |
### Tactic.applicable: not impl. for tac = 'Check_elementwise "Assumptions"'
|
neuper@42438
|
177 |
*)
|
neuper@42438
|
178 |
|
Walther@60736
|
179 |
(** -------- fun de_esc_underscore ----------------------------- **)
|
wneuper@59257
|
180 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
181 |
"----------- fun de_esc_underscore -------------------------------";
|
wneuper@59257
|
182 |
(*
|
wneuper@59257
|
183 |
> val str = "Rewrite_Set_Inst";
|
wneuper@59257
|
184 |
> val esc = esc_underscore str;
|
walther@60278
|
185 |
val it = "Rewrite_Set_Inst" : string
|
wneuper@59257
|
186 |
> val des = de_esc_underscore esc;
|
wneuper@59257
|
187 |
val des = de_esc_underscore esc;*)
|
wneuper@59257
|
188 |
|
Walther@60736
|
189 |
(** -------- fun go -------------------------------------------- **)
|
wneuper@59257
|
190 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
191 |
"----------- fun go ----------------------------------------------";
|
wneuper@59257
|
192 |
(*
|
walther@60340
|
193 |
> val t = (Thm.term_of o the o (TermC.parse thy)) "a+b";
|
walther@59997
|
194 |
val it = Const (#,#) $ Free (#,#) $ Free ("b", "RealDef.real") : term
|
walther@60023
|
195 |
> val plus_a = TermC.sub_at [L] t;
|
walther@60023
|
196 |
> val b = TermC.sub_at [R] t;
|
walther@60023
|
197 |
> val plus = TermC.sub_at [L,L] t;
|
walther@60023
|
198 |
> val a = TermC.sub_at [L,R] t;
|
wneuper@59257
|
199 |
|
walther@60340
|
200 |
> val t = (Thm.term_of o the o (TermC.parse thy)) "a+b+c";
|
walther@59997
|
201 |
val t = Const (#,#) $ (# $ # $ Free #) $ Free ("c", "RealDef.real") : term
|
walther@60023
|
202 |
> val pl_pl_a_b = TermC.sub_at [L] t;
|
walther@60023
|
203 |
> val c = TermC.sub_at [R] t;
|
walther@60023
|
204 |
> val a = TermC.sub_at [L,R,L,R] t;
|
walther@60023
|
205 |
> val b = TermC.sub_at [L,R,R] t;
|
wneuper@59257
|
206 |
*)
|
wneuper@59257
|
207 |
|
Walther@60736
|
208 |
(** -------- fun formal_args ----------------------------------- **)
|
wneuper@59257
|
209 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
210 |
"----------- fun formal_args -------------------------------------";
|
wneuper@59257
|
211 |
(*
|
Walther@60586
|
212 |
> formal_args program;
|
walther@59997
|
213 |
[Free ("f_", "RealDef.real"),Free ("v_", "RealDef.real"),
|
walther@59997
|
214 |
Free ("eqs_", "bool List.list")] : term list
|
wneuper@59257
|
215 |
*)
|
Walther@60736
|
216 |
|
Walther@60736
|
217 |
(** -------- fun dsc_valT -------------------------------------- **)
|
wneuper@59257
|
218 |
"----------- fun dsc_valT ----------------------------------------";
|
wneuper@59257
|
219 |
"----------- fun dsc_valT ----------------------------------------";
|
walther@60340
|
220 |
(*> val t = (Thm.term_of o the o (TermC.parse thy)) "equality";
|
wneuper@59257
|
221 |
> val T = type_of t;
|
wneuper@59257
|
222 |
val T = "bool => Tools.una" : typ
|
wneuper@59257
|
223 |
> val dsc = dsc_valT t;
|
wneuper@59257
|
224 |
val dsc = "una" : string
|
wneuper@59257
|
225 |
|
walther@60340
|
226 |
> val t = (Thm.term_of o the o (TermC.parse thy)) "fixedValues";
|
wneuper@59257
|
227 |
> val T = type_of t;
|
wneuper@59257
|
228 |
val T = "bool List.list => Tools.nam" : typ
|
wneuper@59257
|
229 |
> val dsc = dsc_valT t;
|
wneuper@59257
|
230 |
val dsc = "nam" : string*)
|
Walther@60736
|
231 |
|
Walther@60736
|
232 |
(** -------- fun arguments_from_model ------------------------------------- **)
|
walther@59848
|
233 |
"----------- fun arguments_from_model ---------------------------------------";
|
walther@59848
|
234 |
"----------- fun arguments_from_model ---------------------------------------";
|
wneuper@59257
|
235 |
(*
|
wneuper@59257
|
236 |
> val sc = ... Solve_root_equation ...
|
walther@59997
|
237 |
> val mI = ("Program", "sqrt-equ-test");
|
Walther@60586
|
238 |
> val PblObj{meth={model=itms,...},...} = get_obj I pt [];
|
walther@59848
|
239 |
> val ts = arguments_from_model thy mI itms;
|
walther@59870
|
240 |
> map (UnparseC.term_in_thy thy) ts;
|
walther@59997
|
241 |
["sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x)", "x", "#0"] : string list
|
wneuper@59257
|
242 |
*)
|
Walther@60736
|
243 |
;
|
wneuper@59539
|
244 |
|
Walther@60736
|
245 |
(** -------- fun init_pstate --------------------------------------------------------------- **);
|
wneuper@59583
|
246 |
"----------- fun init_pstate -----------------------------------------------------------------";
|
wneuper@59583
|
247 |
"----------- fun init_pstate -----------------------------------------------------------------";
|
Walther@60712
|
248 |
(*
|
Walther@60712
|
249 |
This test is deeply nested (down into details of creating environments).
|
Walther@60712
|
250 |
In order to make Sidekick show the structure add to each
|
Walther@60712
|
251 |
* (*/...\*) and (*\.../*)
|
Walther@60729
|
252 |
* a companion > ML < (*/...\*) and > ML < (*\.../*)
|
Walther@60729
|
253 |
Note the wrong ^----^ delimiters.
|
Walther@60712
|
254 |
*)
|
walther@59997
|
255 |
val fmz = ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
|
Walther@60736
|
256 |
"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
|
Walther@60736
|
257 |
(*
|
Walther@60736
|
258 |
Now follow items for ALL SubProblems,
|
Walther@60736
|
259 |
since ROOT MethodC must provide values for "actuals" of ALL SubProblems.
|
Walther@60736
|
260 |
See Biegelinie.thy subsection \<open>Survey on Methods\<close>.
|
Walther@60736
|
261 |
*)
|
Walther@60736
|
262 |
(*
|
Walther@60736
|
263 |
Items for MethodC "IntegrierenUndKonstanteBestimmen2"
|
Walther@60736
|
264 |
*)
|
Walther@60736
|
265 |
"FunktionsVariable x",
|
Walther@60736
|
266 |
(*"Biegelinie y", ..already input for Problem above*)
|
Walther@60736
|
267 |
"AbleitungBiegelinie y'",
|
Walther@60736
|
268 |
"Biegemoment M_b",
|
Walther@60736
|
269 |
"Querkraft Q",
|
Walther@60736
|
270 |
(*
|
Walther@60736
|
271 |
Item for Problem "LINEAR/system", which by [''no_met''] involves refinement
|
Walther@60736
|
272 |
*)
|
Walther@60736
|
273 |
"GleichungsVariablen [c, c_2, c_3, c_4]"
|
Walther@60736
|
274 |
];
|
wneuper@59539
|
275 |
val (dI',pI',mI') = ("Biegelinie", ["Biegelinien"],
|
wneuper@59539
|
276 |
["IntegrierenUndKonstanteBestimmen2"]);
|
wneuper@59539
|
277 |
val p = e_pos'; val c = [];
|
Walther@60729
|
278 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(fmz, (dI',pI',mI'))]; val Model_Problem = nxt
|
Walther@60729
|
279 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Traegerlaenge L" = nxt
|
Walther@60729
|
280 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Streckenlast q_0" = nxt
|
Walther@60729
|
281 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "Biegelinie y" = nxt
|
Walther@60729
|
282 |
(*/---broken elementwise input to lists---\* )
|
walther@59957
|
283 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Relation "Randbedingungen [y 0 = 0]", ERROR MISSING step: M_b 0 = 0*)
|
Walther@60729
|
284 |
(*isa* ) val Add_Relation "Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0]" = nxt
|
Walther@60729
|
285 |
( *isa2*) val Add_Relation "Randbedingungen [y 0 = 0]" = nxt
|
walther@59957
|
286 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Relation "Randbedingungen [y L = 0, M_b 0 = 0, M_b L = 0]"*)
|
Walther@60729
|
287 |
(*isa*) val Specify_Theory "Biegelinie" = nxt
|
Walther@60729
|
288 |
(*isa2* ) val Add_Relation "Randbedingungen [y L = 0, M_b 0 = 0, M_b L = 0]" = nxt( **)
|
Walther@60729
|
289 |
( *\---broken elementwise input to lists---/*)
|
Walther@60729
|
290 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0]" = nxt
|
Walther@60729
|
291 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Specify_Theory "Biegelinie" = nxt
|
Walther@60729
|
292 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Specify_Problem ["Biegelinien"] = nxt
|
Walther@60729
|
293 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Specify_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt
|
Walther@60729
|
294 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "FunktionsVariable x" = nxt
|
Walther@60736
|
295 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "AbleitungBiegelinie y'" = nxt
|
Walther@60736
|
296 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Biegemoment M_b" = nxt
|
Walther@60736
|
297 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Querkraft Q" = nxt
|
Walther@60729
|
298 |
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "GleichungsVariablen [c, c_2, c_3, c_4]" = nxt
|
wneuper@59539
|
299 |
|
Walther@60736
|
300 |
(*[], Met*)val return_me_Add_Given_GleichungsVariablen
|
Walther@60736
|
301 |
= me nxt p c pt; (*val Apply_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt*)
|
Walther@60736
|
302 |
(*/------------------- step into me_Add_Given_GleichungsVariablen --------------------------\\*)
|
wneuper@59539
|
303 |
|
Walther@60712
|
304 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
|
Walther@60712
|
305 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60712
|
306 |
val ("ok", (_, _, ptp as (pt, p))) =
|
Walther@60712
|
307 |
(*case*) Step.by_tactic tac (pt, p) (*of*);
|
Walther@60712
|
308 |
|
Walther@60712
|
309 |
(*case*)
|
Walther@60712
|
310 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60712
|
311 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
|
Walther@60712
|
312 |
(p, ((pt, Pos.e_pos'), []) );
|
Walther@60712
|
313 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60712
|
314 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60712
|
315 |
val _ =
|
Walther@60712
|
316 |
(*case*) tacis (*of*);
|
Walther@60712
|
317 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60712
|
318 |
|
Walther@60712
|
319 |
switch_specify_solve p_ (pt, ip);
|
Walther@60712
|
320 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60712
|
321 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60712
|
322 |
|
Walther@60712
|
323 |
specify_do_next (pt, input_pos);
|
Walther@60712
|
324 |
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
|
Walther@60712
|
325 |
val (_, (p_', tac)) = Specify.find_next_step ptp
|
Walther@60712
|
326 |
val ist_ctxt = Ctree.get_loc pt (p, p_)
|
Walther@60712
|
327 |
val Tactic.Apply_Method mI =
|
Walther@60712
|
328 |
(*case*) tac (*of*);
|
Walther@60712
|
329 |
|
Walther@60712
|
330 |
LI.by_tactic (Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty))
|
Walther@60712
|
331 |
ist_ctxt (pt, (p, p_'));
|
Walther@60712
|
332 |
"~~~~~ fun by_tactic , args:"; val ((Tactic.Apply_Method' (mI, _, _, _)), (_, ctxt), (pt, pos as (p, _))) =
|
Walther@60712
|
333 |
((Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty)), ist_ctxt, (pt, (p, p_')));
|
Walther@60712
|
334 |
val (itms, oris, probl) = case get_obj I pt p of (*STILL asms=[]*)
|
Walther@60712
|
335 |
PblObj {meth = itms, origin = (oris, _, _), probl, ...} => (itms, oris, probl)
|
Walther@60712
|
336 |
| _ => raise ERROR "LI.by_tactic Apply_Method': uncovered case get_obj"
|
Walther@60712
|
337 |
val {model, ...} = MethodC.from_store ctxt mI;
|
Walther@60712
|
338 |
val itms = if itms <> [] then itms else I_Model.complete oris probl [] model
|
Walther@60712
|
339 |
;
|
Walther@60712
|
340 |
(*+*)if (itms |> I_Model.to_string @{context}) = "[\n" ^
|
Walther@60739
|
341 |
"(1 ,[1] ,true ,#Given ,Cor Traegerlaenge L , pen2str), \n" ^
|
Walther@60739
|
342 |
"(2 ,[1] ,true ,#Given ,Cor Streckenlast q_0 , pen2str), \n" ^
|
Walther@60739
|
343 |
"(3 ,[1] ,true ,#Find ,Cor Biegelinie y , pen2str), \n" ^
|
Walther@60739
|
344 |
"(4 ,[1] ,true ,#Relate ,Cor Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0] , pen2str), \n" ^
|
Walther@60739
|
345 |
"(5 ,[1] ,true ,#Given ,Cor FunktionsVariable x , pen2str), \n" ^
|
Walther@60739
|
346 |
"(6 ,[1] ,true ,#Given ,Cor AbleitungBiegelinie y' , pen2str), \n" ^
|
Walther@60739
|
347 |
"(7 ,[1] ,true ,#Given ,Cor Biegemoment M_b , pen2str), \n" ^
|
Walther@60739
|
348 |
"(8 ,[1] ,true ,#Given ,Cor Querkraft Q , pen2str), \n" ^
|
Walther@60739
|
349 |
"(9 ,[1] ,true ,#Given ,Cor GleichungsVariablen [c, c_2, c_3, c_4] , pen2str)]"
|
Walther@60712
|
350 |
(*+*)then () else error "init_pstate: initial i_model changed";
|
Walther@60739
|
351 |
|
Walther@60712
|
352 |
(*case*)
|
Walther@60712
|
353 |
LItool.init_pstate ctxt (I_Model.OLD_to_TEST itms) mI (*of*);
|
Walther@60729
|
354 |
(*//------------------ step into init_pstate -----------------------------------------------\\*)
|
Walther@60712
|
355 |
"~~~~~ fun init_pstate , args:"; val (ctxt, i_model, met_id) = (ctxt, (I_Model.OLD_to_TEST itms), mI);
|
Walther@60712
|
356 |
val (model_patt, program, prog, prog_rls, where_, where_rls) =
|
Walther@60712
|
357 |
case MethodC.from_store ctxt met_id of
|
Walther@60729
|
358 |
{model = model_patt, program = program as Rule.Prog prog, prog_rls, where_, where_rls,...}=>
|
Walther@60712
|
359 |
(model_patt, program, prog, prog_rls, where_, where_rls)
|
Walther@60712
|
360 |
|
Walther@60729
|
361 |
val return_of_max_variant =
|
Walther@60729
|
362 |
of_max_variant model_patt i_model;
|
Walther@60729
|
363 |
(*///----------------- step into of_max_variant --------------------------------------------\\*)
|
Walther@60712
|
364 |
"~~~~~ fun of_max_variant , args:"; val (model_patt, i_model) = (model_patt, i_model);
|
Walther@60712
|
365 |
val all_variants =
|
Walther@60712
|
366 |
map (fn (_, variants, _, _, _) => variants) i_model
|
Walther@60712
|
367 |
|> flat
|
Walther@60712
|
368 |
|> distinct op =
|
Walther@60729
|
369 |
val variants_separated = map (filter_variants' i_model) all_variants
|
Walther@60729
|
370 |
val sums_corr = map (cnt_corrects) variants_separated
|
Walther@60741
|
371 |
val sum_variant_s = arrange_args sums_corr (1, all_variants)
|
Walther@60712
|
372 |
val (_, max_variant) = hd (*..crude decision, up to improvement *)
|
Walther@60712
|
373 |
(sort (fn ((i, _), (j, _)) => int_ord (i, j)) sum_variant_s)
|
Walther@60712
|
374 |
val i_model_max =
|
Walther@60712
|
375 |
filter (fn (_, variants, _ , _ ,_) => member (op =) variants max_variant) i_model
|
Walther@60729
|
376 |
val equal_descr_pairs = map (get_equal_descr i_model) model_patt |> flat
|
Walther@60729
|
377 |
;
|
Walther@60712
|
378 |
(*+*)if (equal_descr_pairs |> descr_pairs_to_string @{context}) = "[" ^
|
Walther@60736
|
379 |
(*defined: in program+model--vvvv--,----------------------------------------- in problem ---vvv*)
|
Walther@60733
|
380 |
"((#Given, (Traegerlaenge, l_l)), (1, [1], true ,#Given, " ^
|
Walther@60733
|
381 |
"(Cor_TEST Traegerlaenge L , pen2str, Position.T))), " ^
|
Walther@60712
|
382 |
"((#Given, (Streckenlast, q_q)), (2, [1], true ,#Given, " ^
|
Walther@60733
|
383 |
"(Cor_TEST Streckenlast q_0 , pen2str, Position.T))), " ^
|
Walther@60736
|
384 |
"((#Given, (Randbedingungen, r_b)), (4, [1], true ,#Relate, " ^
|
Walther@60736
|
385 |
"(Cor_TEST Randbedingungen [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0] , pen2str, Position.T))), " ^
|
Walther@60712
|
386 |
"((#Given, (FunktionsVariable, fun_var)), (5, [1], true ,#Given, " ^
|
Walther@60733
|
387 |
"(Cor_TEST FunktionsVariable x , pen2str, Position.T))), " ^
|
Walther@60736
|
388 |
"((#Given, (AbleitungBiegelinie, id_der)), (6, [1], true ,#Given, " ^
|
Walther@60736
|
389 |
"(Cor_TEST AbleitungBiegelinie y' , pen2str, Position.T))), " ^
|
Walther@60736
|
390 |
"((#Given, (Biegemoment, id_momentum)), (7, [1], true ,#Given, " ^
|
Walther@60736
|
391 |
"(Cor_TEST Biegemoment M_b , pen2str, Position.T))), " ^
|
Walther@60736
|
392 |
"((#Given, (Querkraft, id_lat_force)), (8, [1], true ,#Given, " ^
|
Walther@60736
|
393 |
"(Cor_TEST Querkraft Q , pen2str, Position.T))), " ^
|
Walther@60736
|
394 |
"((#Given, (GleichungsVariablen, vs)), (9, [1], true ,#Given, " ^
|
Walther@60733
|
395 |
"(Cor_TEST GleichungsVariablen [c, c_2, c_3, c_4] , pen2str, Position.T))), " ^
|
Walther@60736
|
396 |
"((#Find, (Biegelinie, b_b)), (3, [1], true ,#Find, (" ^
|
Walther@60736
|
397 |
"Cor_TEST Biegelinie y , pen2str, Position.T)))]"
|
Walther@60712
|
398 |
then () else error "of_max_variant: equal_descr_pairs CHANGED";
|
Walther@60712
|
399 |
|
Walther@60729
|
400 |
val return_make_env_model = make_env_model equal_descr_pairs;
|
Walther@60729
|
401 |
(*////---------------- step into make_env_model --------------------------------------------\\*)
|
Walther@60729
|
402 |
"~~~~~ fun make_env_model , args:"; val (equal_descr_pairs) = (equal_descr_pairs);
|
Walther@60729
|
403 |
"~~~~~ fun xxx , args:"; val ((_, (_, id)), (_, _, _, _, (feedb, _))) = nth 4 equal_descr_pairs;
|
Walther@60729
|
404 |
"~~~~~ fun mk_env_model , args:"; val (id, (Model_Def.Cor_TEST ((descr, ts), _))) = (id, feedb);
|
Walther@60712
|
405 |
|
Walther@60729
|
406 |
handle_lists id (descr, ts);
|
Walther@60729
|
407 |
"~~~~~ fun handle_lists , args:"; val (id, (descr, ts)) = (id, (descr, ts));
|
Walther@60736
|
408 |
|
Walther@60736
|
409 |
(*+*)val "[x]" = ts |> UnparseC.terms @{context}
|
Walther@60736
|
410 |
;
|
Walther@60736
|
411 |
(*if*) Model_Pattern.is_list_descr descr (*else*);
|
Walther@60736
|
412 |
val return_handle_lists_step = [(id, Library.the_single ts)]
|
Walther@60736
|
413 |
|
Walther@60736
|
414 |
(*+*)val "[\"\n(fun_var, x)\"]" = return_handle_lists_step |> Subst.to_string @{context}
|
Walther@60729
|
415 |
(*\\\\---------------- step into make_env_model --------------------------------------------//*)
|
Walther@60729
|
416 |
val env_model = return_make_env_model
|
Walther@60736
|
417 |
(*+*)val "[\"\n(l_l, L)\", \"\n(q_q, q_0)\", \"\n(r_b, [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0])\", \"\n(fun_var, x)\", \"\n(id_der, y')\", \"\n(id_momentum, M_b)\", \"\n(id_lat_force, Q)\", \"\n(vs, [c, c_2, c_3, c_4])\", \"\n(b_b, y)\"]"
|
Walther@60736
|
418 |
= env_model |> Subst.to_string @{context}
|
Walther@60712
|
419 |
|
Walther@60729
|
420 |
(*|||----------------- contine of_max_variant ------------------------------------------------*)
|
Walther@60729
|
421 |
val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
|
Walther@60729
|
422 |
val subst_eval_list = make_envs_preconds equal_givens
|
Walther@60729
|
423 |
val (env_subst, env_eval) = split_list subst_eval_list
|
Walther@60712
|
424 |
|
Walther@60736
|
425 |
(*bieg*)val "[\"\n(l_l, L)\", \"\n(q_q, q_0)\", \"\n(r_b, [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0])\", \"\n(fun_var, x)\", \"\n(id_der, y')\", \"\n(id_momentum, M_b)\", \"\n(id_lat_force, Q)\", \"\n(vs, [c, c_2, c_3, c_4])\", \"\n(b_b, y)\"]"
|
Walther@60736
|
426 |
= env_model |> Subst.to_string @{context}
|
Walther@60736
|
427 |
(*bieg*)val "[]" = env_subst |> Subst.to_string @{context}
|
Walther@60736
|
428 |
val return_of_max_variant_step = (i_model_max, env_model, (env_subst, env_eval))
|
Walther@60736
|
429 |
;
|
Walther@60729
|
430 |
(*+*)if return_of_max_variant_step = return_of_max_variant then () else error "<>";
|
Walther@60729
|
431 |
(*\\\----------------- step into of_max_variant --------------------------------------------//*)
|
Walther@60729
|
432 |
val (_, env_model, (env_subst, env_eval)) = return_of_max_variant
|
Walther@60712
|
433 |
|
Walther@60736
|
434 |
(*||------------------ contine init_pstate ---------------------------------------------------*)
|
Walther@60729
|
435 |
val actuals = map snd env_model
|
Walther@60736
|
436 |
(*+*) val "[L, q_0, [y 0 = 0, y L = 0, M_b 0 = 0, M_b L = 0], x, y', M_b, Q, [c, c_2, c_3, c_4], y]"
|
Walther@60736
|
437 |
(*-----------------///--------------------------------------------------------------------------^^*)
|
Walther@60736
|
438 |
= actuals |> UnparseC.terms @{context}
|
Walther@60712
|
439 |
|
Walther@60712
|
440 |
val formals = Program.formal_args prog
|
Walther@60736
|
441 |
(*+*)val "[l_l, q_q, r_b, fun_var, id_der, id_momentum, id_lat_force, vs, b_b]"
|
Walther@60736
|
442 |
= formals |> UnparseC.terms @{context}
|
Walther@60736
|
443 |
(*+*)val 9 = length formals
|
Walther@60712
|
444 |
|
Walther@60732
|
445 |
val preconds =
|
Walther@60741
|
446 |
Pre_Conds.check_envs ctxt where_rls where_ (env_model, (env_subst, env_eval))
|
Walther@60712
|
447 |
val ctxt = ctxt |> ContextC.insert_assumptions (map snd (snd preconds));
|
Walther@60712
|
448 |
val ist = Istate.e_pstate
|
Walther@60712
|
449 |
|> Istate.set_eval prog_rls
|
Walther@60712
|
450 |
|> Istate.set_env_true (relate_args [] formals actuals ctxt prog met_id formals actuals)
|
Walther@60729
|
451 |
;
|
Walther@60729
|
452 |
(*+*)(relate_args [] formals actuals ctxt prog met_id formals actuals)
|
Walther@60729
|
453 |
;
|
Walther@60712
|
454 |
val return_init_pstate = (Istate.Pstate ist, ctxt, program)
|
Walther@60729
|
455 |
(*\\------------------ step into init_pstate -----------------------------------------------//*)
|
Walther@60736
|
456 |
(*\------------------- step into me_Add_Given_GleichungsVariablen --------------------------//*)
|
Walther@60736
|
457 |
val (p,_,f,nxt,_,pt) = return_me_Add_Given_GleichungsVariablen;
|
Walther@60729
|
458 |
val Apply_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt
|
Walther@60712
|
459 |
(* final test ... ----------------------------------------------------------------------------*)
|
Walther@60712
|
460 |
(*+*)val ([], Met) = p
|
Walther@60712
|
461 |
(*+*)val Apply_Method ["IntegrierenUndKonstanteBestimmen2"] = nxt
|