Walther@60578
|
1 |
(* Title: "Minisubpbl/150a-add-given-Maximum.sml"
|
Walther@60578
|
2 |
Author: Walther Neuper 1105
|
Walther@60578
|
3 |
(c) copyright due to lincense terms.
|
Walther@60578
|
4 |
|
Walther@60705
|
5 |
ATTENTION: the file creates buffer overflow if copied in one piece !
|
Walther@60705
|
6 |
|
Walther@60659
|
7 |
Note: This test --- steps into me --- more than once, to a somewhat extreme extent;
|
Walther@60578
|
8 |
in order not to get lost while working in Test_Some etc,
|
Walther@60578
|
9 |
re-introduce ML (*--- step into XXXXX ---*) and Co.
|
Walther@60578
|
10 |
and use Sidekick for orientation.
|
Walther@60659
|
11 |
Nesting is indicated by /--- //-- ///- at the left margin of the comments.
|
Walther@60578
|
12 |
*)
|
Walther@60578
|
13 |
|
Walther@60728
|
14 |
open Ctree;
|
Walther@60728
|
15 |
open Pos;
|
Walther@60728
|
16 |
open TermC;
|
Walther@60728
|
17 |
open Istate;
|
Walther@60728
|
18 |
open Tactic;
|
Walther@60728
|
19 |
open Pre_Conds;
|
Walther@60728
|
20 |
open I_Model;
|
Walther@60728
|
21 |
open P_Model
|
Walther@60728
|
22 |
open Rewrite;
|
Walther@60728
|
23 |
open Step;
|
Walther@60728
|
24 |
open LItool;
|
Walther@60728
|
25 |
open LI;
|
Walther@60578
|
26 |
open Test_Code
|
Walther@60705
|
27 |
open Specify
|
Walther@60728
|
28 |
open ME_Misc
|
Walther@60578
|
29 |
|
Walther@60578
|
30 |
val (_(*example text*),
|
Walther@60578
|
31 |
(model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" ::
|
Walther@60578
|
32 |
"Extremum (A = 2 * u * v - u \<up> 2)" ::
|
Walther@60578
|
33 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" ::
|
Walther@60578
|
34 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" ::
|
Walther@60728
|
35 |
"SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" ::
|
Walther@60728
|
36 |
(*---------------------------------------------,(v::real) / 2 = r * cos \<alpha>]" --- ERROR in example*)
|
Walther@60578
|
37 |
"FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" ::
|
Walther@60578
|
38 |
"Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
|
Walther@60578
|
39 |
"ErrorBound (\<epsilon> = (0::real))" :: []),
|
Walther@60578
|
40 |
refs as ("Diff_App",
|
Walther@60578
|
41 |
["univariate_calculus", "Optimisation"],
|
Walther@60578
|
42 |
["Optimisation", "by_univariate_calculus"])))
|
Walther@60588
|
43 |
= Store.get (Know_Store.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
|
Walther@60578
|
44 |
|
Walther@60578
|
45 |
val c = [];
|
Walther@60728
|
46 |
val return_init_calc =
|
Walther@60728
|
47 |
Test_Code.init_calc @{context} [(model, refs)]; (*val Model_Problem = nxt;*)
|
Walther@60728
|
48 |
(*/------------------- step into init_calc -------------------------------------------------\\*)
|
Walther@60728
|
49 |
"~~~~~ fun init_calc , args:"; val (ctxt, [(model, refs as (thy_id, _, _))]) =
|
Walther@60728
|
50 |
(@{context}, [(model, refs)]);
|
Walther@60728
|
51 |
val thy = thy_id |> ThyC.get_theory ctxt
|
Walther@60728
|
52 |
val ((pt, p), tacis) = Step_Specify.initialise' thy (model, refs)
|
Walther@60728
|
53 |
val tac = case tacis of [] => Tactic.Empty_Tac | _ => (#1 o hd) tacis
|
Walther@60728
|
54 |
val f =
|
Walther@60728
|
55 |
TESTg_form ctxt (pt,p);
|
Walther@60728
|
56 |
"~~~~~ fun TESTg_form , args:"; val (ctxt, ptp) = (ctxt, (pt,p));
|
Walther@60728
|
57 |
val (form, _, _) =
|
Walther@60728
|
58 |
ME_Misc.pt_extract ctxt ptp;
|
Walther@60728
|
59 |
"~~~~~ fun pt_extract , args:"; val (ctxt, (pt, (p, p_ as Pbl(*Frm,Pbl*)))) = (ctxt, ptp);
|
Walther@60728
|
60 |
val ppobj = Ctree.get_obj I pt p
|
Walther@60728
|
61 |
val f = if Ctree.is_pblobj ppobj then pt_model ppobj p_ else Ctree.get_obj pt_form pt p;
|
Walther@60728
|
62 |
(*if*) Ctree.is_pblobj ppobj (*then*);
|
Walther@60728
|
63 |
pt_model ppobj p_ ;
|
Walther@60728
|
64 |
"~~~~~ fun pt_model , args:"; val ((Ctree.PblObj {probl, spec, origin = (_, spec', hdl), ctxt, ...}), Pbl_) =
|
Walther@60728
|
65 |
(ppobj, p_);
|
Walther@60728
|
66 |
val (_, pI, _) = Ctree.get_somespec' spec spec';
|
Walther@60728
|
67 |
(* val where_ = if pI = Problem.id_empty then []*)
|
Walther@60728
|
68 |
(*if*) pI = Problem.id_empty (*else*);
|
Walther@60728
|
69 |
val {where_rls, where_, model, ...} = Problem.from_store ctxt pI
|
Walther@60728
|
70 |
val (_, where_) =
|
Walther@60728
|
71 |
Pre_Conds.check_OLD ctxt where_rls where_
|
Walther@60728
|
72 |
(model, I_Model.OLD_to_TEST probl);
|
Walther@60728
|
73 |
"~~~~~ fun check_OLD , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
|
Walther@60728
|
74 |
(ctxt, where_rls, where_, (model, I_Model.OLD_to_TEST probl));
|
Walther@60728
|
75 |
val (_, _, (env_subst, env_eval)) =
|
Walther@60728
|
76 |
of_max_variant model_patt i_model;
|
Walther@60728
|
77 |
"~~~~~ fun of_max_variant , args:"; val (_, []) = (model_patt, i_model);
|
Walther@60728
|
78 |
(*\------------------- step into init_calc -------------------------------------------------//*)
|
Walther@60728
|
79 |
val (p,_,f,nxt,_,pt) = return_init_calc;
|
Walther@60578
|
80 |
|
Walther@60728
|
81 |
(*+*)val PblObj {ctxt, probl, ...} = get_obj I pt [];
|
Walther@60659
|
82 |
(*+*)Proof_Context.theory_of ctxt (*= {Pure, .., Diff_App}*);
|
Walther@60659
|
83 |
(*+*)val Free ("r", Type ("Real.real", [])) = Syntax.read_term ctxt "r"
|
Walther@60728
|
84 |
(*+*)val [] = probl
|
Walther@60578
|
85 |
|
Walther@60659
|
86 |
val return_me_Model_Problem =
|
Walther@60659
|
87 |
me nxt p c pt; val Add_Given "Constants [r = 7]" = #4 return_me_Model_Problem;
|
Walther@60659
|
88 |
(*/------------------- step into me Model_Problem ------------------------------------------\\*)
|
Walther@60578
|
89 |
"~~~~~ fun me , args:"; val (tac, (p:Pos.pos'), (_:Test_Code.NEW), (pt:Ctree.ctree)) = (nxt, p, c, pt);
|
Walther@60728
|
90 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60728
|
91 |
val return_by_tactic = case
|
Walther@60728
|
92 |
Step.by_tactic tac (pt,p) of
|
Walther@60578
|
93 |
("ok", (_, _, ptp)) => ptp;
|
Walther@60578
|
94 |
|
Walther@60728
|
95 |
(*//------------------ step into by_tactic -------------------------------------------------\\*)
|
Walther@60728
|
96 |
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt,p));
|
Walther@60728
|
97 |
val Applicable.Yes tac' = (*case*)
|
Walther@60728
|
98 |
Step.check tac (pt, p) (*of*);
|
Walther@60728
|
99 |
(*+*)val Model_Problem' _ = tac';
|
Walther@60728
|
100 |
"~~~~~ fun check , args:"; val (tac, (ctree, pos)) = (tac, (pt, p));
|
Walther@60728
|
101 |
(*if*) Tactic.for_specify tac (*then*);
|
Walther@60728
|
102 |
|
Walther@60728
|
103 |
Specify_Step.check tac (ctree, pos);
|
Walther@60728
|
104 |
"~~~~~ fun check , args:"; val (Tactic.Model_Problem, (pt, pos as (p, _))) =
|
Walther@60728
|
105 |
(tac, (ctree, pos));
|
Walther@60728
|
106 |
val (o_model, pI', ctxt) = case Ctree.get_obj I pt p of
|
Walther@60728
|
107 |
Ctree.PblObj {origin = (o_model, (_, pI', _), _), ctxt, ...} => (o_model, pI', ctxt)
|
Walther@60728
|
108 |
val {model = model_patt, ...} = Problem.from_store (Ctree.get_ctxt pt pos) pI'
|
Walther@60728
|
109 |
val pbl = I_Model.init_TEST o_model model_patt;
|
Walther@60728
|
110 |
|
Walther@60728
|
111 |
val return_check =
|
Walther@60728
|
112 |
Applicable.Yes (Tactic.Model_Problem' (pI', I_Model.TEST_to_OLD pbl, []));
|
Walther@60728
|
113 |
(*\\------------------ step into by_tactic -------------------------------------------------//*)
|
Walther@60728
|
114 |
val (pt, p) = return_by_tactic;
|
Walther@60728
|
115 |
|
Walther@60659
|
116 |
val return_do_next = (*case*)
|
Walther@60578
|
117 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60578
|
118 |
(*//------------------ step into do_next ---------------------------------------------------\\*)
|
Walther@60578
|
119 |
"~~~~~ fun do_next , args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):Calc.state_pre)) =
|
Walther@60578
|
120 |
(p, ((pt, e_pos'),[]));
|
Walther@60578
|
121 |
val pIopt = get_pblID (pt,ip);
|
Walther@60578
|
122 |
(*if*) ip = ([],Res); (* = false*)
|
Walther@60578
|
123 |
val _ = (*case*) tacis (*of*);
|
Walther@60578
|
124 |
val SOME _ = (*case*) pIopt (*of*);
|
Walther@60578
|
125 |
|
Walther@60578
|
126 |
val ("ok", ([(Add_Given "Constants [r = 7]", _, _)], [], _)) =
|
Walther@60578
|
127 |
Step.switch_specify_solve p_ (pt, ip);
|
Walther@60578
|
128 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60578
|
129 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60578
|
130 |
|
Walther@60578
|
131 |
val ("ok", ([(Add_Given "Constants [r = 7]", _, _)], [], _)) =
|
Walther@60578
|
132 |
Step.specify_do_next (pt, input_pos);
|
Walther@60659
|
133 |
(*///----------------- step into specify_do_next -------------------------------------------\\*)
|
Walther@60578
|
134 |
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
|
Walther@60578
|
135 |
|
Walther@60659
|
136 |
(* val (_, (p_', tac)) =*)
|
Walther@60659
|
137 |
val return_find_next_step = (*keep for continuing specify_do_next*)
|
Walther@60578
|
138 |
Specify.find_next_step ptp;
|
Walther@60659
|
139 |
(*////---------------- step into find_next_step --------------------------------------------\\*)
|
Walther@60578
|
140 |
"~~~~~ fun find_next_step , args:"; val ((pt, pos as (_, p_))) = (ptp);
|
Walther@60578
|
141 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
Walther@60578
|
142 |
spec = refs, ...} = Calc.specify_data (pt, pos);
|
Walther@60578
|
143 |
val ctxt = Ctree.get_ctxt pt pos;
|
Walther@60578
|
144 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
Walther@60578
|
145 |
(*if*) p_ = Pos.Pbl (*then*);
|
Walther@60578
|
146 |
|
Walther@60578
|
147 |
Specify.for_problem ctxt oris (o_refs, refs) (pbl, met);
|
Walther@60728
|
148 |
(*/////--------------- step into for_problem -----------------------------------------------\\*)
|
Walther@60578
|
149 |
"~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met))
|
Walther@60578
|
150 |
= (ctxt, oris, (o_refs, refs), (pbl, met));
|
Walther@60578
|
151 |
val cdI = if dI = ThyC.id_empty then dI' else dI;
|
Walther@60578
|
152 |
val cpI = if pI = Problem.id_empty then pI' else pI;
|
Walther@60578
|
153 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
Walther@60585
|
154 |
val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
|
Walther@60728
|
155 |
val {model = mpc, ...} = MethodC.from_store ctxt cmI;
|
Walther@60728
|
156 |
(*//------------------ adhoc inserted fun of_max_variant -----------------------------------\\*)
|
Walther@60728
|
157 |
(*\\------------------ adhoc inserted fun check_OLD ----------------------------------------//*)
|
Walther@60728
|
158 |
|
Walther@60728
|
159 |
val return_check_OLD =
|
Walther@60728
|
160 |
check_OLD ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
|
Walther@60728
|
161 |
(*//////-------------- step into check_OLD -------------------------------------------------\\*)
|
Walther@60728
|
162 |
"~~~~~ fun check_OLD , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
|
Walther@60728
|
163 |
(ctxt, where_rls, where_, (pbt, I_Model.OLD_to_TEST pbl));
|
Walther@60728
|
164 |
val return_of_max_variant =
|
Walther@60728
|
165 |
of_max_variant model_patt i_model;
|
Walther@60728
|
166 |
(*///// //------------ step into of_max_variant --------------------------------------------\\*)
|
Walther@60728
|
167 |
"~~~~~ fun of_max_variant , args:"; val (model_patt, i_model) =
|
Walther@60728
|
168 |
(model_patt, i_model);
|
Walther@60728
|
169 |
|
Walther@60728
|
170 |
(*with OLD code* )
|
Walther@60728
|
171 |
(*+*)val "[\n(0, [], false ,#Given, (Inc_TEST Constants [__=__, __=__], Position.T)), \n(0, [], false ,#Find, (Inc_TEST Maximum __, Position.T)), \n(0, [], false ,#Find, (Inc_TEST AdditionalValues [__, __], Position.T)), \n(0, [], false ,#Relate, (Inc_TEST Extremum (__=__), Position.T)), \n(0, [], false ,#Relate, (Inc_TEST SideConditions [__=__, __=__], Position.T))]"
|
Walther@60728
|
172 |
= i_model |> I_Model.to_string_TEST @ {context}
|
Walther@60728
|
173 |
( *with OLD code*)
|
Walther@60728
|
174 |
(*+*)val "[\n(1, [1, 2, 3], false ,#Given, (Inc_TEST Constants [__=__, __=__], Position.T)), \n(2, [1, 2, 3], false ,#Find, (Inc_TEST Maximum __, Position.T)), \n(3, [1, 2, 3], false ,#Find, (Inc_TEST AdditionalValues [__, __], Position.T)), \n(4, [1, 2, 3], false ,#Relate, (Inc_TEST Extremum (__=__), Position.T)), \n(5, [1, 2], false ,#Relate, (Inc_TEST SideConditions [__=__, __=__], Position.T))]"
|
Walther@60728
|
175 |
= i_model |> I_Model.to_string_TEST @{context}
|
Walther@60728
|
176 |
val all_variants =
|
Walther@60728
|
177 |
map (fn (_, variants, _, _, _) => variants) i_model
|
Walther@60728
|
178 |
|> flat
|
Walther@60728
|
179 |
|> distinct op =
|
Walther@60728
|
180 |
val variants_separated = map (filter_variants' i_model) all_variants
|
Walther@60728
|
181 |
val sums_corr = map (cnt_corrects) variants_separated
|
Walther@60728
|
182 |
val sum_variant_s = arrange_args1 sums_corr (1, all_variants)
|
Walther@60728
|
183 |
(*+*)val [(0, 1), (0, 2), (0, 3)] = sum_variant_s
|
Walther@60728
|
184 |
val (_, max_variant) = hd (*..crude decision, up to improvement *)
|
Walther@60728
|
185 |
(sort (fn ((i, _), (j, _)) => int_ord (i, j)) sum_variant_s)
|
Walther@60728
|
186 |
val i_model_max =
|
Walther@60728
|
187 |
filter (fn (_, variants, _ , _ ,_) => member (op =) variants max_variant) i_model
|
Walther@60728
|
188 |
val equal_descr_pairs = map (get_equal_descr i_model) model_patt |> flat
|
Walther@60728
|
189 |
(*for building make_env_s -------------------------------------------------------------------\*)
|
Walther@60728
|
190 |
(*!!!*) val ("#Given", (descr, term), pos) =
|
Walther@60728
|
191 |
Model_Pattern.split_descriptor ctxt ("#Given", @{term "Constants [r = (7::real)]"}, Position.none)
|
Walther@60728
|
192 |
(*!!!*) val patt = equal_descr_pairs |> hd |> #1
|
Walther@60728
|
193 |
(*!!!*)val equal_descr_pairs =
|
Walther@60728
|
194 |
(patt,
|
Walther@60728
|
195 |
(1, [1, 2, 3], true, "#Given", (Cor_TEST ((descr, (*!*)TermC.isalist2list(*!*) term),
|
Walther@60728
|
196 |
(TermC.empty, [])), pos)))
|
Walther@60728
|
197 |
:: tl equal_descr_pairs
|
Walther@60728
|
198 |
(*for building make_env_s -------------------------------------------------------------------/*)
|
Walther@60728
|
199 |
|
Walther@60728
|
200 |
val env_model = make_env_model equal_descr_pairs;
|
Walther@60728
|
201 |
(*///// ///----------- step into make_env_model --------------------------------------------\\*)
|
Walther@60728
|
202 |
"~~~~~ fun make_env_model , args:"; val (equal_descr_pairs) = (equal_descr_pairs);
|
Walther@60728
|
203 |
|
Walther@60728
|
204 |
val xxx = (fn ((_, (_, id)), (_, _, _, _, (feedb, _)))
|
Walther@60728
|
205 |
=> (mk_env_model id feedb));
|
Walther@60728
|
206 |
val ((_, (_, id)), (_, _, _, _, (feedb, _))) = nth 4 equal_descr_pairs;
|
Walther@60728
|
207 |
(*\\\\\ \\\----------- step into make_env_model --------------------------------------------//*)
|
Walther@60728
|
208 |
(*||||| ||------------ contine of_max_variant ------------------------------------------------*)
|
Walther@60728
|
209 |
|
Walther@60728
|
210 |
val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
|
Walther@60728
|
211 |
val subst_eval_list = make_envs_preconds equal_givens
|
Walther@60728
|
212 |
val return_make_envs_preconds =
|
Walther@60728
|
213 |
make_envs_preconds equal_givens;
|
Walther@60728
|
214 |
(*///// ///----------- step into make_envs_preconds ----------------------------------------\\*)
|
Walther@60728
|
215 |
"~~~~~ fun make_envs_preconds , args:"; val (equal_givens) = (equal_givens);
|
Walther@60728
|
216 |
val xxx = (fn ((_, (_, id)), (_, _, _, _, (feedb, _))) => discern_feedback id feedb)
|
Walther@60728
|
217 |
;
|
Walther@60728
|
218 |
xxx: (Model_Pattern.single * I_Model.single_TEST) -> ((term * term) * (term * term)) list;
|
Walther@60728
|
219 |
val return_discern_feedback =
|
Walther@60728
|
220 |
discern_feedback id feedb;
|
Walther@60728
|
221 |
(*nth 1 equal_descr_pairs* )
|
Walther@60728
|
222 |
"~~~~~ fun discern_feedback , args:"; val (id, (Model_Def.Cor_TEST ((descr, ts), _))) = (id, feedb);
|
Walther@60728
|
223 |
( *nth 2 equal_descr_pairs*)
|
Walther@60728
|
224 |
"~~~~~ fun discern_feedback , args:"; val (id, (Model_Def.Inc_TEST ((descr, ts), _))) = (id, feedb);
|
Walther@60728
|
225 |
|
Walther@60728
|
226 |
(*nth 1 equal_descr_pairs* )
|
Walther@60728
|
227 |
(*+*)val [((Const ("fixes", typ1), Free ("r", typ2)),
|
Walther@60728
|
228 |
(Free ("r", typ3), value))] = return_discern_feedback
|
Walther@60728
|
229 |
(*+*)val true = typ1 = typ2
|
Walther@60728
|
230 |
(*+*)val true = typ3 = HOLogic.realT
|
Walther@60728
|
231 |
(*+*)val "7" = UnparseC.term @{context} value
|
Walther@60728
|
232 |
( *nth 2 equal_descr_pairs*)
|
Walther@60728
|
233 |
(*+*)val [] = return_discern_feedback
|
Walther@60728
|
234 |
|
Walther@60728
|
235 |
val return_discern_typ =
|
Walther@60728
|
236 |
discern_typ id (descr, ts);
|
Walther@60728
|
237 |
"~~~~~ fun discern_typ , args:"; val (id, (descr, ts)) = (id, (descr, ts));
|
Walther@60728
|
238 |
(*nth 1 equal_descr_pairs* )
|
Walther@60728
|
239 |
(*+*)val [((Const ("fixes", typ1), Free ("r", typ2)),
|
Walther@60728
|
240 |
(Free ("r", typ3), value))] = return_discern_typ
|
Walther@60728
|
241 |
(*+*)val true = typ1 = typ2
|
Walther@60728
|
242 |
(*+*)val true = typ3 = HOLogic.realT
|
Walther@60728
|
243 |
(*+*)val "7" = UnparseC.term @{context} value
|
Walther@60728
|
244 |
( *nth 2 equal_descr_pairs*)
|
Walther@60728
|
245 |
(*+*)val [] = return_discern_typ;
|
Walther@60728
|
246 |
(**)
|
Walther@60728
|
247 |
switch_type_TEST id ts;
|
Walther@60728
|
248 |
"~~~~~ fun switch_type_TEST , args:"; val (Const (descr_string, _), ts) = (descr, ts);
|
Walther@60728
|
249 |
|
Walther@60728
|
250 |
(*nth 1 equal_descr_pairs* )
|
Walther@60728
|
251 |
val return_switch_type_TEST = Const (descr_string, ts |> hd |> TermC.lhs |> type_of)
|
Walther@60728
|
252 |
|
Walther@60728
|
253 |
(*+*)val Const ("Input_Descript.Constants", typ) = return_switch_type_TEST
|
Walther@60728
|
254 |
(*+*)val Type ("Real.real", []) = typ
|
Walther@60728
|
255 |
( *nth 2 equal_descr_pairs*)
|
Walther@60728
|
256 |
(*+*)val return_switch_type_TEST = descr
|
Walther@60728
|
257 |
(**)
|
Walther@60728
|
258 |
(*\\\\\ \\\----------- step into make_envs_preconds ----------------------------------------//*)
|
Walther@60728
|
259 |
(*||||| ||------------ contine of_max_variant ------------------------------------------------*)
|
Walther@60728
|
260 |
val subst_eval_list = make_envs_preconds equal_givens
|
Walther@60728
|
261 |
val (env_subst, env_eval) = split_list subst_eval_list
|
Walther@60728
|
262 |
val return_of_max_variant = (i_model_max, env_model, (env_subst, env_eval)); (*GOON*)
|
Walther@60728
|
263 |
(*\\\\\ \\------------ step into of_max_variant --------------------------------------------//*)
|
Walther@60728
|
264 |
val (i_model_max, env_model, (env_subst, env_eval)) = return_of_max_variant
|
Walther@60728
|
265 |
(*!!!/----- we had a helpful argument for constructing env_model and (env_subst, env_eval)---\*)
|
Walther@60728
|
266 |
val (i_max_variant, env_model, (env_subst, env_eval)) = (i_model_max, [], ([], []))
|
Walther@60728
|
267 |
(*!!!\----- we had a helpful argument for constructing env_model and (env_subst, env_eval)---/*)
|
Walther@60728
|
268 |
(*||||||-------------- contine check_OLD -----------------------------------------------------*)
|
Walther@60728
|
269 |
val pres_subst = map (TermC.subst_atomic_all env_subst) pres;
|
Walther@60728
|
270 |
val pres_subst_other = map (TermC.subst_atomic_all env_model) (map #2 pres_subst);
|
Walther@60728
|
271 |
val full_subst = if env_eval = [] then pres_subst_other
|
Walther@60728
|
272 |
else map (TermC.subst_atomic_all env_eval) (map #2 pres_subst_other)
|
Walther@60728
|
273 |
val evals = map (eval ctxt where_rls) full_subst
|
Walther@60728
|
274 |
val return_ = (i_model_max, env_subst, env_eval)
|
Walther@60728
|
275 |
(*\\\\\\\------------- step into check_OLD -------------------------------------------------//*)
|
Walther@60728
|
276 |
val (preok, _) = return_check_OLD;
|
Walther@60728
|
277 |
|
Walther@60728
|
278 |
(*|||||--------------- contine for_problem ---------------------------------------------------*)
|
Walther@60578
|
279 |
(*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
|
Walther@60578
|
280 |
(*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
|
Walther@60728
|
281 |
val NONE =
|
Walther@60728
|
282 |
(*case*) find_first (I_Model.is_error o #5) pbl (*of*);
|
Walther@60578
|
283 |
|
Walther@60578
|
284 |
(*case*)
|
Walther@60676
|
285 |
Specify.item_to_add (ThyC.get_theory ctxt
|
Walther@60578
|
286 |
(if dI = ThyC.id_empty then dI' else dI)) oris pbt pbl (*of*);
|
Walther@60578
|
287 |
"~~~~~ fun item_to_add , args:"; val (thy, oris, _, itms)
|
Walther@60676
|
288 |
= ((ThyC.get_theory ctxt (if dI = ThyC.id_empty then dI' else dI)), oris, pbt, pbl);
|
Walther@60578
|
289 |
fun false_and_not_Sup (_, _, false, _, I_Model.Sup _) = false
|
Walther@60578
|
290 |
| false_and_not_Sup (_, _, false, _, _) = true
|
Walther@60578
|
291 |
| false_and_not_Sup _ = false
|
Walther@60728
|
292 |
|
Walther@60705
|
293 |
val v = if itms = [] then 1 else Pre_Conds.max_variant itms
|
Walther@60728
|
294 |
val vors = if v = 0 then oris
|
Walther@60728
|
295 |
else filter ((fn variant =>
|
Walther@60728
|
296 |
fn (_, variants, m_field, _, _) => member op= variants variant andalso m_field <> "#undef")
|
Walther@60728
|
297 |
v) oris
|
Walther@60728
|
298 |
|
Walther@60728
|
299 |
(*+*)val "[\n(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"])]"
|
Walther@60728
|
300 |
(*+*) = vors |> O_Model.to_string @{context}
|
Walther@60728
|
301 |
|
Walther@60728
|
302 |
val vits = if v = 0 then itms (* because of dsc without dat *)
|
Walther@60728
|
303 |
else filter ((fn variant =>
|
Walther@60728
|
304 |
fn (_, variants, _, _, _) => member op= variants variant)
|
Walther@60728
|
305 |
v) itms; (* itms..vat *)
|
Walther@60728
|
306 |
|
Walther@60728
|
307 |
val icl = filter false_and_not_Sup vits; (* incomplete *)
|
Walther@60728
|
308 |
|
Walther@60578
|
309 |
(*if*) icl = [] (*else*);
|
Walther@60728
|
310 |
(*+*)val "[\n(1 ,[1, 2, 3] ,false ,#Given ,Inc Constants [] ,(Constants, [])), \n(2 ,[1, 2, 3] ,false ,#Find ,Inc Maximum ,(Maximum, [])), \n(3 ,[1, 2, 3] ,false ,#Find ,Inc AdditionalValues [] ,(AdditionalValues, [])), \n(4 ,[1, 2, 3] ,false ,#Relate ,Inc Extremum ,(Extremum, [])), \n(5 ,[1, 2] ,false ,#Relate ,Inc SideConditions [] ,(SideConditions, []))]"
|
Walther@60728
|
311 |
(*+*) = icl |> I_Model.to_string @{context}
|
Walther@60728
|
312 |
(*+*)val "(1 ,[1, 2, 3] ,false ,#Given ,Inc Constants [] ,(Constants, []))"
|
Walther@60728
|
313 |
(*+*) = hd icl |> I_Model.single_to_string @{context}
|
Walther@60728
|
314 |
|
Walther@60728
|
315 |
(*++*)val feedback = (fn (_, _, _, _, feedback) => feedback) (hd icl)
|
Walther@60728
|
316 |
(*++*)val Const ("Input_Descript.Constants", _) = I_Model.descriptor feedback
|
Walther@60728
|
317 |
(*++*)val [] = I_Model.o_model_values feedback
|
Walther@60728
|
318 |
|
Walther@60728
|
319 |
(*+*)val "[\n(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"])]"
|
Walther@60728
|
320 |
(*+*) = vors |> O_Model.to_string @{context}
|
Walther@60728
|
321 |
|
Walther@60578
|
322 |
val SOME ori =
|
Walther@60728
|
323 |
(*case*) find_first ((fn (_, _, _, _, feedback) => fn (_, _, _, d, ts) =>
|
Walther@60728
|
324 |
d = I_Model.descriptor feedback andalso subset op = (I_Model.o_model_values feedback, ts))
|
Walther@60728
|
325 |
(hd icl)) vors (*of*);
|
Walther@60728
|
326 |
|
Walther@60728
|
327 |
(*+*)val "(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"])" =
|
Walther@60728
|
328 |
(*+*) ori |> O_Model.single_to_string @{context}
|
Walther@60728
|
329 |
(*\\\\\--------------- step into for_problem -----------------------------------------------//*)
|
Walther@60659
|
330 |
(*\\\\---------------- step into find_next_step --------------------------------------------//*)
|
Walther@60659
|
331 |
(*|||----------------- continuing specify_do_next --------------------------------------------*)
|
Walther@60659
|
332 |
val (_, (p_', tac)) = return_find_next_step (*kept for continuing specify_do_next*)
|
Walther@60659
|
333 |
|
Walther@60659
|
334 |
val ist_ctxt = Ctree.get_loc pt (p, p_)
|
Walther@60659
|
335 |
(*+*)val Add_Given "Constants [r = 7]" = tac
|
Walther@60659
|
336 |
val _ =
|
Walther@60659
|
337 |
(*case*) tac (*of*);
|
Walther@60659
|
338 |
|
Walther@60659
|
339 |
Step_Specify.by_tactic_input tac (pt, (p, p_'));
|
Walther@60659
|
340 |
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Add_Given ct), ptp) =
|
Walther@60659
|
341 |
(tac, (pt, (p, p_')));
|
Walther@60659
|
342 |
|
Walther@60659
|
343 |
Specify.by_Add_ "#Given" ct ptp;
|
Walther@60659
|
344 |
"~~~~~ fun by_Add_ , args:"; val (m_field, ct ,(pt, pos as (_, p_))) =
|
Walther@60659
|
345 |
("#Given", ct, ptp);
|
Walther@60659
|
346 |
val (met, oris, (_, pI', mI'), pbl, (_, pI, mI), ctxt) = SpecificationC.get_data (pt, pos)
|
Walther@60659
|
347 |
val (i_model, m_patt) =
|
Walther@60659
|
348 |
if p_ = Pos.Met then
|
Walther@60659
|
349 |
(met,
|
Walther@60659
|
350 |
(if mI = MethodC.id_empty then mI' else mI) |> MethodC.from_store ctxt |> #model)
|
Walther@60659
|
351 |
else
|
Walther@60659
|
352 |
(pbl,
|
Walther@60659
|
353 |
(if pI = Problem.id_empty then pI' else pI) |> Problem.from_store ctxt |> #model);
|
Walther@60728
|
354 |
|
Walther@60659
|
355 |
(*case*)
|
Walther@60659
|
356 |
I_Model.check_single ctxt m_field oris i_model m_patt ct (*of*);
|
Walther@60659
|
357 |
"~~~~~ fun check_single , args:"; val (ctxt, m_field, o_model, i_model, m_patt, (str(*, pos*))) =
|
Walther@60659
|
358 |
(ctxt, m_field, oris, i_model, m_patt, ct);
|
Walther@60728
|
359 |
val (t as (descriptor $ _)) = Syntax.read_term ctxt str
|
Walther@60659
|
360 |
|
Walther@60675
|
361 |
(*+*)val "Constants [r = 7]" = UnparseC.term @{context} t;
|
Walther@60659
|
362 |
|
Walther@60728
|
363 |
val SOME m_field' =
|
Walther@60728
|
364 |
(*case*) Model_Pattern.get_field descriptor m_patt (*of*);
|
Walther@60728
|
365 |
(*if*) m_field <> m_field' (*else*);
|
Walther@60659
|
366 |
|
Walther@60659
|
367 |
(*+*)val "#Given" = m_field; val "#Given" = m_field'
|
Walther@60659
|
368 |
|
Walther@60728
|
369 |
val ("", ori', all) =
|
Walther@60728
|
370 |
(*case*) O_Model.contains ctxt m_field o_model t (*of*);
|
Walther@60659
|
371 |
|
Walther@60659
|
372 |
(*+*)val (_, _, _, _, vals) = hd o_model;
|
Walther@60675
|
373 |
(*+*)val "Constants [r = 7]" = UnparseC.term @{context} (@{term Constants} $ (hd vals));
|
Walther@60728
|
374 |
(*+*)if "[\n(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), " ^
|
Walther@60728
|
375 |
(*+*) "\n(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), " ^
|
Walther@60728
|
376 |
(*+*) "\n(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), " ^
|
Walther@60728
|
377 |
(*+*) "\n(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), " ^
|
Walther@60728
|
378 |
(*+*) "\n(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), " ^
|
Walther@60728
|
379 |
(*+*) "\n(6, [\"3\"], #Relate, SideConditions, [\"[u / 2 = r * sin \<alpha>]\", \"[2 / v = r * cos \<alpha>]\"]), " ^
|
Walther@60728
|
380 |
(*+*) "\n(7, [\"1\"], #undef, FunctionVariable, [\"a\"]), " ^
|
Walther@60728
|
381 |
(*+*) "\n(8, [\"2\"], #undef, FunctionVariable, [\"b\"]), \n(9, [\"3\"], #undef, FunctionVariable, [\"\<alpha>\"]), " ^
|
Walther@60728
|
382 |
(*+*) "\n(10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), " ^
|
Walther@60728
|
383 |
(*+*) "\n(11, [\"3\"], #undef, Input_Descript.Domain, [\"{0<..<\<pi> / 2}\"]), " ^
|
Walther@60728
|
384 |
(*+*) "\n(12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
|
Walther@60728
|
385 |
(*+*)= O_Model.to_string @{context} o_model then () else error "o_model CHANGED";
|
Walther@60578
|
386 |
|
Walther@60728
|
387 |
(*case*) is_notyet_input ctxt i_model all ori' m_patt (*of*);
|
Walther@60728
|
388 |
"~~~~~ fun is_notyet_input , args:"; val (ctxt, itms, all, (i, v, f, d, ts), pbt) =
|
Walther@60728
|
389 |
(ctxt, i_model, all, ori', m_patt);
|
Walther@60728
|
390 |
val SOME (_, (_, pid)) =
|
Walther@60728
|
391 |
(*case*) find_first (eq1 d) pbt (*of*);
|
Walther@60728
|
392 |
(*local*)fun eq3 f d (_, _, _, f', itm_) = f = f' andalso d = (I_Model.descriptor itm_);(*local*)
|
Walther@60728
|
393 |
val SOME (_, _, _, _, itm_) =
|
Walther@60728
|
394 |
(*case*) find_first (eq3 f d) itms (*of*);
|
Walther@60728
|
395 |
val ts' = inter op = (o_model_values itm_) ts;
|
Walther@60728
|
396 |
(*if*) subset op = (ts, ts') (*else*);
|
Walther@60728
|
397 |
val return_is_notyet_input = ("",
|
Walther@60728
|
398 |
ori_2itm itm_ pid all (i, v, f, d, subtract op = ts' ts));
|
Walther@60728
|
399 |
"~~~~~ fun ori_2itm , args:"; val (itm_, pid, all, (id, vt, fd, d, ts)) =
|
Walther@60728
|
400 |
(itm_, pid, all, (i, v, f, d, subtract op = ts' ts));
|
Walther@60728
|
401 |
val ts' = union op = (o_model_values itm_) ts;
|
Walther@60728
|
402 |
val pval = [Input_Descript.join'''' (d, ts')]
|
Walther@60728
|
403 |
val complete = if eq_set op = (ts', all) then true else false
|
Walther@60728
|
404 |
|
Walther@60728
|
405 |
(*+*)val "Inc Constants [] ,(Constants, [])" = itm_ |> I_Model.feedback_to_string @{context}
|
Walther@60728
|
406 |
(*\\\----------------- step into specify_do_next -------------------------------------------//*)
|
Walther@60728
|
407 |
(*\\------------------ step into do_next ---------------------------------------------------//*)
|
Walther@60728
|
408 |
val ("ok", (ts as (_, _, _) :: _, _, (pt, p))) = return_do_next
|
Walther@60728
|
409 |
|
Walther@60728
|
410 |
(*|------------------- continue with me_Model_Problem ----------------------------------------*)
|
Walther@60659
|
411 |
|
Walther@60578
|
412 |
val tacis as (_::_) =
|
Walther@60578
|
413 |
(*case*) ts (*of*);
|
Walther@60578
|
414 |
val (tac, _, _) = last_elem tacis
|
Walther@60578
|
415 |
|
Walther@60728
|
416 |
val return_Model_Problem = (p, [] : NEW, TESTg_form ctxt (pt, p), tac, Celem.Sundef, pt);
|
Walther@60728
|
417 |
(*//------------------ step into TESTg_form ------------------------------------------------\\*)
|
Walther@60578
|
418 |
"~~~~~ fun TESTg_form , args:"; val (ctxt, ptp) = (ctxt, (pt, p));
|
Walther@60728
|
419 |
|
Walther@60728
|
420 |
val (form, _, _) =
|
Walther@60728
|
421 |
ME_Misc.pt_extract ctxt ptp;
|
Walther@60728
|
422 |
"~~~~~ fun pt_extract , args:"; val (ctxt, (pt, (p, p_(*Frm,Pbl*)))) = (ctxt, ptp);
|
Walther@60728
|
423 |
val ppobj = Ctree.get_obj I pt p
|
Walther@60728
|
424 |
val f = if Ctree.is_pblobj ppobj then pt_model ppobj p_ else Ctree.get_obj pt_form pt p;
|
Walther@60728
|
425 |
(*if*) Ctree.is_pblobj ppobj (*then*);
|
Walther@60728
|
426 |
|
Walther@60728
|
427 |
pt_model ppobj p_;
|
Walther@60728
|
428 |
"~~~~~ fun pt_model , args:"; val ((Ctree.PblObj {probl, spec, origin = (_, spec', hdl), ctxt, ...}),
|
Walther@60728
|
429 |
Pbl(*Frm,Pbl*)) = (ppobj, p_);
|
Walther@60728
|
430 |
val (_, pI, _) = Ctree.get_somespec' spec spec';
|
Walther@60728
|
431 |
(*if*) pI = Problem.id_empty (*else*);
|
Walther@60728
|
432 |
(* val where_ = if pI = Problem.id_empty then []*)
|
Walther@60728
|
433 |
(* else *)
|
Walther@60728
|
434 |
(* let *)
|
Walther@60728
|
435 |
val {where_rls, where_, model, ...} = Problem.from_store ctxt pI
|
Walther@60728
|
436 |
val (_, where_) = (*Pre_Conds.*)check_OLD ctxt where_rls where_ (model, I_Model.OLD_to_TEST probl)
|
Walther@60728
|
437 |
(* in where_ end *)
|
Walther@60728
|
438 |
val allcorrect = I_Model.is_complete probl andalso foldl and_ (true, (map #1 where_))
|
Walther@60728
|
439 |
val return_pt_model = Ctree.ModSpec (allcorrect, Pos.Pbl, hdl, probl, where_, spec)
|
Walther@60728
|
440 |
|
Walther@60728
|
441 |
(*|------------------- continue with TESTg_form ----------------------------------------------*)
|
Walther@60728
|
442 |
val Ctree.ModSpec (spec as (_, p_, _, gfr, where_, _)) =
|
Walther@60578
|
443 |
(*case*) form (*of*);
|
Walther@60578
|
444 |
Test_Out.PpcKF ( (Test_Out.Problem [],
|
Walther@60586
|
445 |
P_Model.from (Proof_Context.theory_of ctxt) gfr where_));
|
Walther@60578
|
446 |
|
Walther@60586
|
447 |
P_Model.from (Proof_Context.theory_of ctxt) gfr where_;
|
Walther@60586
|
448 |
"~~~~~ fun from , args:"; val (thy, itms, where_) = ((Proof_Context.theory_of ctxt), gfr, where_);
|
Walther@60586
|
449 |
fun coll model [] = model
|
Walther@60586
|
450 |
| coll model ((_, _, _, field, itm_) :: itms) =
|
Walther@60586
|
451 |
coll (add_sel_ppc thy field model (item_from_feedback thy itm_)) itms;
|
Walther@60578
|
452 |
|
Walther@60578
|
453 |
val gfr = coll P_Model.empty itms;
|
Walther@60586
|
454 |
"~~~~~ fun coll , args:"; val (model, ((aaa, bbb_,ccc_, field, itm_) :: itms))
|
Walther@60578
|
455 |
= (P_Model.empty, itms);
|
Walther@60578
|
456 |
|
Walther@60578
|
457 |
(*+*)val 4 = length itms;
|
Walther@60578
|
458 |
(*+*)val itm = nth 1 itms;
|
Walther@60578
|
459 |
|
Walther@60578
|
460 |
coll P_Model.empty [itm];
|
Walther@60586
|
461 |
"~~~~~ fun coll , iterate:"; val (model, ((aaa, bbb_,ccc_, field, itm_) :: []))
|
Walther@60578
|
462 |
= (P_Model.empty, [itm]);
|
Walther@60578
|
463 |
|
Walther@60586
|
464 |
(add_sel_ppc thy field model (item_from_feedback thy itm_));
|
Walther@60578
|
465 |
"~~~~~ fun add_sel_ppc , args:"; val ((_: theory), sel, {Given = gi, Where = wh, Find = fi, With = wi, Relate = re}, x )
|
Walther@60586
|
466 |
= (thy, field, model, (item_from_feedback thy itm_));
|
Walther@60578
|
467 |
|
Walther@60578
|
468 |
P_Model.item_from_feedback thy itm_;
|
Walther@60578
|
469 |
"~~~~~ fun item_from_feedback , args:"; val (thy, (I_Model.Inc ((d, ts), _))) = (thy, itm_);
|
Walther@60728
|
470 |
P_Model.Incompl (UnparseC.term_in_thy thy (Input_Descript.join (d, ts)));
|
Walther@60728
|
471 |
(*\\------------------ step into TESTg_form ------------------------------------------------//*)
|
Walther@60728
|
472 |
(*\------------------- step into me Model_Problem ------------------------------------------//*)
|
Walther@60659
|
473 |
val (p, _, f, nxt, _, pt) = return_me_Model_Problem
|
Walther@60728
|
474 |
|
Walther@60728
|
475 |
(*-------------------- contine me's ----------------------------------------------------------*)
|
Walther@60728
|
476 |
val return_me_add_find_Constants = me nxt p c pt;
|
Walther@60728
|
477 |
val Add_Find "Maximum A" = #4 return_me_add_find_Constants;
|
Walther@60728
|
478 |
(*/------------------- step into me_add_find_Constants -------------------------------------\\*)
|
Walther@60728
|
479 |
"~~~~~ fun me , args:"; val (tac as Add_Given "Constants [r = 7]", p, _(*NEW remove*), pt) =
|
Walther@60728
|
480 |
(nxt, p, c, pt);
|
Walther@60728
|
481 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60728
|
482 |
(*+*)val PblObj {probl = (1, [1, 2, 3], false, "#Given", Inc
|
Walther@60728
|
483 |
((Const ("Input_Descript.Constants", _), []), _)) :: _, ...} = get_obj I pt (fst p)
|
Walther@60728
|
484 |
(*-------------------------------------------^^--*)
|
Walther@60728
|
485 |
val return_step_by_tactic = (*case*)
|
Walther@60728
|
486 |
Step.by_tactic tac (pt, p) (*of*);
|
Walther@60728
|
487 |
(*//------------------ step into Step.by_tactic --------------------------------------------\\*)
|
Walther@60728
|
488 |
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
|
Walther@60728
|
489 |
val Applicable.Yes tac' =
|
Walther@60728
|
490 |
(*case*) check tac (pt, p) (*of*);
|
Walther@60728
|
491 |
(*if*) Tactic.for_specify' tac' (*then*);
|
Walther@60728
|
492 |
Step_Specify.by_tactic tac' ptp;
|
Walther@60728
|
493 |
"~~~~~ fun by_tactic , args:"; val ((Tactic.Add_Given' (ct, _)), (pt, p)) = (tac', ptp);
|
Walther@60728
|
494 |
|
Walther@60728
|
495 |
Specify.by_Add_ "#Given" ct (pt, p);
|
Walther@60728
|
496 |
"~~~~~ fun by_Add_ , args:"; val (m_field, ct, (pt, pos as (_, p_))) = ("#Given", ct, (pt, p));
|
Walther@60728
|
497 |
val (met, oris, (_, pI', mI'), pbl, (_, pI, mI), ctxt) = SpecificationC.get_data (pt, pos);
|
Walther@60728
|
498 |
(* val (i_model, m_patt) =*)
|
Walther@60728
|
499 |
(*if*) p_ = Pos.Met (*else*);
|
Walther@60728
|
500 |
val return_by_Add_ =
|
Walther@60728
|
501 |
(pbl,
|
Walther@60728
|
502 |
(if pI = Problem.id_empty then pI' else pI) |> Problem.from_store ctxt |> #model)
|
Walther@60728
|
503 |
val I_Model.Add i_single =
|
Walther@60728
|
504 |
(*case*) I_Model.check_single ctxt m_field oris i_model m_patt ct (*of*);
|
Walther@60728
|
505 |
|
Walther@60728
|
506 |
val i_model' =
|
Walther@60728
|
507 |
I_Model.add_single (Proof_Context.theory_of ctxt) i_single i_model;
|
Walther@60728
|
508 |
"~~~~~ fun add_single , args:"; val (thy, itm, model) =
|
Walther@60728
|
509 |
((Proof_Context.theory_of ctxt), i_single, i_model);
|
Walther@60728
|
510 |
fun eq_untouched d (0, _, _, _, itm_) = (d = I_Model.descriptor itm_)
|
Walther@60728
|
511 |
| eq_untouched _ _ = false
|
Walther@60728
|
512 |
val model' = case I_Model.seek_ppc (#1 itm) model of
|
Walther@60728
|
513 |
SOME _ => overwrite_ppc thy itm model (*itm updated in is_notyet_input WN.11.03*)
|
Walther@60728
|
514 |
|
Walther@60728
|
515 |
(*||------------------ contine Step.by_tactic ------------------------------------------------*)
|
Walther@60728
|
516 |
(*\\------------------ step into Step.by_tactic --------------------------------------------//*)
|
Walther@60728
|
517 |
val ("ok", (_, _, ptp)) = return_step_by_tactic;
|
Walther@60728
|
518 |
|
Walther@60728
|
519 |
val (pt, p) = ptp;
|
Walther@60728
|
520 |
(*case*)
|
Walther@60728
|
521 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60728
|
522 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) =
|
Walther@60728
|
523 |
(p, ((pt, Pos.e_pos'), []));
|
Walther@60728
|
524 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60728
|
525 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60728
|
526 |
val _ =
|
Walther@60728
|
527 |
(*case*) tacis (*of*);
|
Walther@60728
|
528 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60728
|
529 |
|
Walther@60728
|
530 |
switch_specify_solve p_ (pt, ip);
|
Walther@60728
|
531 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60728
|
532 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60728
|
533 |
|
Walther@60728
|
534 |
specify_do_next (pt, input_pos);
|
Walther@60728
|
535 |
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
|
Walther@60728
|
536 |
val (_, (p_', tac)) =
|
Walther@60728
|
537 |
Specify.find_next_step ptp;
|
Walther@60728
|
538 |
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
|
Walther@60728
|
539 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
Walther@60728
|
540 |
spec = refs, ...} = Calc.specify_data (pt, pos);
|
Walther@60728
|
541 |
val ctxt = Ctree.get_ctxt pt pos;
|
Walther@60728
|
542 |
|
Walther@60728
|
543 |
(*+*)val (1, [1, 2, 3], true, "#Given", Cor ((Const ("Input_Descript.Constants", _), ts ), _)) :: _
|
Walther@60728
|
544 |
= pbl
|
Walther@60728
|
545 |
(*+*)val "[[r = 7]]" = UnparseC.terms @{context} ts;
|
Walther@60728
|
546 |
(*-----ML-^------^-HOL*)
|
Walther@60728
|
547 |
|
Walther@60728
|
548 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
Walther@60728
|
549 |
(*if*) p_ = Pos.Pbl (*then*);
|
Walther@60728
|
550 |
|
Walther@60728
|
551 |
for_problem ctxt oris (o_refs, refs) (pbl, met);
|
Walther@60728
|
552 |
"~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
|
Walther@60728
|
553 |
(ctxt, oris, (o_refs, refs), (pbl, met));
|
Walther@60728
|
554 |
val cpI = if pI = Problem.id_empty then pI' else pI;
|
Walther@60728
|
555 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
Walther@60728
|
556 |
val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
|
Walther@60728
|
557 |
val {model = mpc, ...} = MethodC.from_store ctxt cmI
|
Walther@60728
|
558 |
|
Walther@60728
|
559 |
val (preok, _) =
|
Walther@60728
|
560 |
Pre_Conds.check_OLD ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
|
Walther@60728
|
561 |
"~~~~~ fun check_OLD , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
|
Walther@60728
|
562 |
(ctxt, where_rls, where_, (pbt, I_Model.OLD_to_TEST pbl));
|
Walther@60728
|
563 |
|
Walther@60728
|
564 |
val (_, _, (env_subst, env_eval)) = of_max_variant model_patt i_model;
|
Walther@60728
|
565 |
"~~~~~ fun of_max_variant , args:"; val (model_patt, i_model) = (model_patt, i_model);
|
Walther@60728
|
566 |
val all_variants =
|
Walther@60728
|
567 |
map (fn (_, variants, _, _, _) => variants) i_model
|
Walther@60728
|
568 |
|> flat
|
Walther@60728
|
569 |
|> distinct op =
|
Walther@60728
|
570 |
val variants_separated = map (filter_variants' i_model) all_variants
|
Walther@60728
|
571 |
val sums_corr = map (cnt_corrects) variants_separated
|
Walther@60728
|
572 |
val sum_variant_s = arrange_args1 sums_corr (1, all_variants)
|
Walther@60728
|
573 |
val (_, max_variant) = hd (*..crude decision, up to improvement *)
|
Walther@60728
|
574 |
(sort (fn ((i, _), (j, _)) => int_ord (i, j)) sum_variant_s)
|
Walther@60728
|
575 |
val i_model_max =
|
Walther@60728
|
576 |
filter (fn (_, variants, _ , _ ,_) => member (op =) variants max_variant) i_model
|
Walther@60728
|
577 |
val equal_descr_pairs = map (get_equal_descr i_model) model_patt |> flat
|
Walther@60728
|
578 |
val env_model = make_env_model equal_descr_pairs
|
Walther@60728
|
579 |
val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
|
Walther@60728
|
580 |
|
Walther@60728
|
581 |
val subst_eval_list =
|
Walther@60728
|
582 |
make_envs_preconds equal_givens;
|
Walther@60728
|
583 |
"~~~~~ fun make_envs_preconds , args:"; val (equal_givens) = (equal_givens);
|
Walther@60728
|
584 |
val xxx = (fn ((_, (_, id)), (_, _, _, _, (feedb, _))) =>
|
Walther@60728
|
585 |
discern_feedback id feedb)
|
Walther@60728
|
586 |
val ((_, (_, id)), (_, _, _, _, (feedb, _))) = nth 1 equal_givens;
|
Walther@60728
|
587 |
"~~~~~ fun discern_feedback , args:"; val (id, (Model_Def.Cor_TEST ((descr, ts), _))) = (id, feedb);
|
Walther@60728
|
588 |
|
Walther@60728
|
589 |
discern_typ id (descr, ts);
|
Walther@60728
|
590 |
"~~~~~ fun discern_typ , args:"; val (id, (descr, ts)) = (id, (descr, ts));
|
Walther@60728
|
591 |
(*|------------------- contine me_add_find_Constants -----------------------------------------*)
|
Walther@60728
|
592 |
(*\------------------- step into me_add_find_Constants -------------------------------------//*)
|
Walther@60728
|
593 |
val (p,_,f,nxt,_,pt) = return_me_add_find_Constants;
|
Walther@60728
|
594 |
(*/########################## before destroying elementwise input of lists ##################\* )
|
Walther@60578
|
595 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "AdditionalValues [u]" = nxt;
|
Walther@60578
|
596 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "AdditionalValues [v]" = nxt;
|
Walther@60728
|
597 |
( *\########################## before destroying elementwise input of lists ##################/*)
|
Walther@60728
|
598 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Find "AdditionalValues [u, v]" = nxt;
|
Walther@60728
|
599 |
|
Walther@60578
|
600 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "Extremum (A = 2 * u * v - u \<up> 2)" = nxt;
|
Walther@60578
|
601 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Relation "SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" = nxt;
|
Walther@60705
|
602 |
val return_me_Add_Relation_SideConditions
|
Walther@60705
|
603 |
= me nxt p c pt;
|
Walther@60728
|
604 |
(*+*)val (_, _, _, Specify_Theory "Diff_App", _, _) = return_me_Add_Relation_SideConditions; (*###############*)
|
Walther@60705
|
605 |
(*/------------------- step into me Add_Relation_SideConditions ----------------------------\\*)
|
Walther@60705
|
606 |
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
|
Walther@60728
|
607 |
val ctxt = Ctree.get_ctxt pt p;
|
Walther@60728
|
608 |
(**) val (pt, p) = (**)
|
Walther@60728
|
609 |
(**)case(**) Step.by_tactic tac (pt, p) (**)of(**)
|
Walther@60728
|
610 |
(**) ("ok", (_, _, ptp)) => ptp (**) ;
|
Walther@60728
|
611 |
|
Walther@60728
|
612 |
(*case*)
|
Walther@60705
|
613 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60705
|
614 |
(*//------------------ step into do_next ---------------------------------------------------\\*)
|
Walther@60705
|
615 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
|
Walther@60705
|
616 |
= (p, ((pt, Pos.e_pos'), [])) (*of*);
|
Walther@60705
|
617 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60705
|
618 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60705
|
619 |
(*case*) tacis (*of*);
|
Walther@60705
|
620 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60705
|
621 |
|
Walther@60705
|
622 |
Step.switch_specify_solve p_ (pt, ip);
|
Walther@60705
|
623 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60705
|
624 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60705
|
625 |
Step.specify_do_next (pt, input_pos);
|
Walther@60705
|
626 |
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
|
Walther@60728
|
627 |
(*isa------ERROR: Refine_Problem INSTEAD
|
Walther@60728
|
628 |
isa2: Specify_Theory "Diff_App"*)
|
Walther@60728
|
629 |
val (_, (p_', tac as Specify_Theory "Diff_App")) =
|
Walther@60728
|
630 |
(*ERROR------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
|
Walther@60728
|
631 |
Specify.find_next_step ptp;
|
Walther@60705
|
632 |
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
|
Walther@60705
|
633 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
Walther@60705
|
634 |
spec = refs, ...} = Calc.specify_data (pt, pos);
|
Walther@60705
|
635 |
val ctxt = Ctree.get_ctxt pt pos;
|
Walther@60705
|
636 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
Walther@60705
|
637 |
(*if*) p_ = Pos.Pbl (*then*);
|
Walther@60705
|
638 |
|
Walther@60728
|
639 |
val ("dummy", (Pbl, tac as Specify_Theory "Diff_App")) =
|
Walther@60728
|
640 |
(*ERROR------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
|
Walther@60728
|
641 |
for_problem ctxt oris (o_refs, refs) (pbl, met);
|
Walther@60705
|
642 |
"~~~~~ fun for_problem , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
|
Walther@60705
|
643 |
(ctxt, oris, (o_refs, refs), (pbl, met));
|
Walther@60705
|
644 |
val cpI = if pI = Problem.id_empty then pI' else pI;
|
Walther@60705
|
645 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
Walther@60705
|
646 |
val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
|
Walther@60705
|
647 |
val {model = mpc, ...} = MethodC.from_store ctxt cmI
|
Walther@60705
|
648 |
|
Walther@60705
|
649 |
(*+*)val [Const ("Orderings.ord_class.less", _) $ Const ("Groups.zero_class.zero", _) $
|
Walther@60705
|
650 |
Free ("fixes", _)] = where_
|
Walther@60728
|
651 |
|
Walther@60728
|
652 |
val (preok, _) =
|
Walther@60728
|
653 |
Pre_Conds.check_OLD ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
|
Walther@60728
|
654 |
(*///----------------- step into check_OLD -------------------------------------------------\\*)
|
Walther@60728
|
655 |
"~~~~~ fun check_OLD , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
|
Walther@60728
|
656 |
(ctxt, where_rls, where_, (pbt, I_Model.OLD_to_TEST pbl));
|
Walther@60728
|
657 |
(*+*)val "[0 < fixes]" = pres |> UnparseC.terms @{context}
|
Walther@60728
|
658 |
(*+*)val "[\"(#Given, (Constants, fixes))\", \"(#Find, (Maximum, maxx))\", \"(#Find, (AdditionalValues, vals))\", \"(#Relate, (Extremum, extr))\", \"(#Relate, (SideConditions, sideconds))\"]"
|
Walther@60728
|
659 |
(*+*) = model_patt |> Model_Pattern.to_string @{context}
|
Walther@60728
|
660 |
(*+*)val "[\n(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] ,(fixes, [[r = 7]]), Position.T)), \n(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A ,(maxx, [A]), Position.T)), \n(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] ,(vals, [[u, v]]), Position.T)), \n(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) ,(extr, [A = 2 * u * v - u \<up> 2]), Position.T)), \n(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] ,(sideconds, [[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]]), Position.T))]"
|
Walther@60728
|
661 |
(*+*) = i_model |> I_Model.to_string_TEST @{context}
|
Walther@60728
|
662 |
|
Walther@60728
|
663 |
val return_of_max_variant as (_, _, (env_subst, env_eval)) =
|
Walther@60728
|
664 |
of_max_variant model_patt i_model
|
Walther@60728
|
665 |
|
Walther@60728
|
666 |
(*+*)val [(Free ("fixes", T1), Free ("r", T2))] = env_subst (*?!? Const*)
|
Walther@60728
|
667 |
(*+*)val Type ("Real.real", []) = T1
|
Walther@60728
|
668 |
(*+*)val Type ("Real.real", []) = T2
|
Walther@60728
|
669 |
|
Walther@60728
|
670 |
(*+*)val [(Free ("r", T2), Const ("Num.numeral_class.numeral", _) $ _)] = env_eval
|
Walther@60728
|
671 |
(*+*)val Type ("Real.real", []) = T2
|
Walther@60728
|
672 |
|
Walther@60728
|
673 |
val (_, _, (env_subst, env_eval)) = return_of_max_variant;
|
Walther@60728
|
674 |
(*|||----------------- contine check_OLD -----------------------------------------------------*)
|
Walther@60728
|
675 |
val pres_subst = map (TermC.subst_atomic_all env_subst) pres;
|
Walther@60728
|
676 |
|
Walther@60728
|
677 |
(*|||----------------- contine check_OLD -----------------------------------------------------*)
|
Walther@60728
|
678 |
(*+*)val [(true, Const ("Orderings.ord_class.less", _) $
|
Walther@60728
|
679 |
Const ("Groups.zero_class.zero", _) $ Free ("r", _))] = pres_subst
|
Walther@60728
|
680 |
|
Walther@60728
|
681 |
val full_subst = map (fn (bool, t) => (bool, subst_atomic env_eval t)) pres_subst
|
Walther@60728
|
682 |
(*+*)val [(true,
|
Walther@60728
|
683 |
Const ("Orderings.ord_class.less", _) $ Const ("Groups.zero_class.zero", _) $
|
Walther@60728
|
684 |
(Const ("Num.numeral_class.numeral", _) $ _))] = full_subst
|
Walther@60728
|
685 |
|
Walther@60728
|
686 |
val evals = map (eval ctxt where_rls) full_subst
|
Walther@60728
|
687 |
val return_check_OLD = (foldl and_ (true, map fst evals), pres_subst)
|
Walther@60728
|
688 |
(*\\\----------------- step into check_OLD -------------------------------------------------\\*)
|
Walther@60728
|
689 |
|
Walther@60728
|
690 |
val (preok as true, _) = return_check_OLD
|
Walther@60728
|
691 |
(*+---------------^^^^*)
|
Walther@60728
|
692 |
(*\\------------------ step into do_next ---------------------------------------------------\\*)
|
Walther@60728
|
693 |
(*\------------------- step into me_Add_Relation_SideConditions ----------------------------//*)
|
Walther@60705
|
694 |
val (p, _, f, nxt, _, pt) = return_me_Add_Relation_SideConditions
|
Walther@60705
|
695 |
val Specify_Theory "Diff_App" = nxt;
|
Walther@60705
|
696 |
|
Walther@60659
|
697 |
val return_me_Specify_Theory
|
Walther@60659
|
698 |
= me nxt p c pt; val Specify_Problem ["univariate_calculus", "Optimisation"] = #4 return_me_Specify_Theory;
|
Walther@60659
|
699 |
(*/------------------- step into me Specify_Theory -----------------------------------------\\*)
|
Walther@60578
|
700 |
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
|
Walther@60728
|
701 |
val ctxt = Ctree.get_ctxt pt p;
|
Walther@60728
|
702 |
(* val (pt, p) = *)
|
Walther@60728
|
703 |
(*case*) Step.by_tactic tac (pt, p) (*of*);
|
Walther@60728
|
704 |
(* ("ok", (_, _, ptp)) => ptp *)
|
Walther@60728
|
705 |
val return_Step_by_tactic =
|
Walther@60728
|
706 |
Step.by_tactic tac (pt, p);
|
Walther@60728
|
707 |
(*//------------------ step into Step_by_tactic --------------------------------------------\\*)
|
Walther@60728
|
708 |
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
|
Walther@60728
|
709 |
(*case*) check tac (pt, p) (*of*);
|
Walther@60728
|
710 |
|
Walther@60728
|
711 |
(*||------------------ contine Step_by_tactic ------------------------------------------------*)
|
Walther@60728
|
712 |
(*\\------------------ step into Step_by_tactic --------------------------------------------//*)
|
Walther@60728
|
713 |
|
Walther@60728
|
714 |
val ("ok", (_, _, ptp)) = return_Step_by_tactic;
|
Walther@60728
|
715 |
(*|------------------- continue me Specify_Theory --------------------------------------------*)
|
Walther@60578
|
716 |
|
Walther@60578
|
717 |
val ("ok", (ts as (_, _, _) :: _, _, _)) =
|
Walther@60578
|
718 |
(*case*)
|
Walther@60578
|
719 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60578
|
720 |
(*//------------------ step into do_next ---------------------------------------------------\\*)
|
Walther@60578
|
721 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis))
|
Walther@60578
|
722 |
= (p, ((pt, Pos.e_pos'), [])) (*of*);
|
Walther@60578
|
723 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60578
|
724 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60578
|
725 |
val _ =
|
Walther@60578
|
726 |
(*case*) tacis (*of*);
|
Walther@60578
|
727 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60578
|
728 |
|
Walther@60578
|
729 |
Step.switch_specify_solve p_ (pt, ip);
|
Walther@60578
|
730 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60578
|
731 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60578
|
732 |
|
Walther@60578
|
733 |
Step.specify_do_next (pt, input_pos);
|
Walther@60578
|
734 |
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
|
Walther@60578
|
735 |
val (_, (p_', tac)) = Specify.find_next_step ptp
|
Walther@60578
|
736 |
val ist_ctxt = Ctree.get_loc pt (p, p_);
|
Walther@60578
|
737 |
(*case*) tac (*of*);
|
Walther@60578
|
738 |
|
Walther@60728
|
739 |
Step_Specify.by_tactic_input tac (pt, (p, p_'));
|
Walther@60728
|
740 |
(*+*)val Specify_Theory "Diff_App" = tac;
|
Walther@60728
|
741 |
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Theory dI), (pt, pos as (_, Pbl)))
|
Walther@60578
|
742 |
= (tac, (pt, (p, p_')));
|
Walther@60578
|
743 |
val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
|
Walther@60578
|
744 |
PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
|
Walther@60578
|
745 |
(oris, dI, dI', pI', probl, ctxt)
|
Walther@60676
|
746 |
val thy = ThyC.get_theory ctxt (if dI' = ThyC.id_empty then dI else dI');
|
Walther@60585
|
747 |
val {model, where_, where_rls,...} = Problem.from_store (Ctree.get_ctxt pt pos) pI
|
Walther@60659
|
748 |
(*\\------------------ step into do_next ---------------------------------------------------//*)
|
Walther@60659
|
749 |
(*\------------------- step into me Specify_Theory -----------------------------------------//*)
|
Walther@60659
|
750 |
val (p,_,f,nxt,_,pt) = return_me_Specify_Theory;
|
Walther@60578
|
751 |
|
Walther@60659
|
752 |
val return_me_Specify_Problem (* keep for continuing me *)
|
Walther@60659
|
753 |
= me nxt p c pt; val Specify_Method ["Optimisation", "by_univariate_calculus"] = #4 return_me_Specify_Problem;
|
Walther@60659
|
754 |
(*/------------------- step into me Specify_Problem ----------------------------------------\\*)
|
Walther@60659
|
755 |
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
|
Walther@60578
|
756 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60578
|
757 |
|
Walther@60659
|
758 |
(** ) val ("ok", (_, _, ptp as (pt, p))) =( **)
|
Walther@60659
|
759 |
(**) val return_by_tactic =(**) (*case*)
|
Walther@60578
|
760 |
Step.by_tactic tac (pt, p) (*of*);
|
Walther@60659
|
761 |
(*//------------------ step into by_tactic -------------------------------------------------\\*)
|
Walther@60578
|
762 |
"~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (tac, (pt, p));
|
Walther@60578
|
763 |
|
Walther@60578
|
764 |
(*case*)
|
Walther@60578
|
765 |
Step.check tac (pt, p) (*of*);
|
Walther@60578
|
766 |
"~~~~~ fun check , args:"; val (tac, (ctree, pos)) = (tac, (pt, p));
|
Walther@60578
|
767 |
(*if*) Tactic.for_specify tac (*then*);
|
Walther@60578
|
768 |
|
Walther@60578
|
769 |
Specify_Step.check tac (ctree, pos);
|
Walther@60578
|
770 |
"~~~~~ fun check , args:"; val ((Tactic.Specify_Problem pID), (pt, pos as (p, _)))
|
Walther@60578
|
771 |
= (tac, (ctree, pos));
|
Walther@60578
|
772 |
val (oris, dI, pI, dI', pI', itms) = case Ctree.get_obj I pt p of
|
Walther@60578
|
773 |
Ctree.PblObj {origin = (oris, (dI, pI, _), _), spec = (dI', pI', _), probl = itms, ...}
|
Walther@60578
|
774 |
=> (oris, dI, pI, dI', pI', itms)
|
Walther@60676
|
775 |
val thy = ThyC.get_theory ctxt (if dI' = ThyC.id_empty then dI else dI');
|
Walther@60659
|
776 |
(*\\------------------ step into by_tactic -------------------------------------------------//*)
|
Walther@60659
|
777 |
val ("ok", (_, _, ptp as (pt, p))) = return_by_tactic (* kept for continuing me *);
|
Walther@60578
|
778 |
|
Walther@60578
|
779 |
(*case*)
|
Walther@60578
|
780 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60578
|
781 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
|
Walther@60578
|
782 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60578
|
783 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60578
|
784 |
val _ =
|
Walther@60578
|
785 |
(*case*) tacis (*of*);
|
Walther@60578
|
786 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60578
|
787 |
|
Walther@60578
|
788 |
Step.switch_specify_solve p_ (pt, ip);
|
Walther@60578
|
789 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60578
|
790 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60578
|
791 |
|
Walther@60578
|
792 |
Step.specify_do_next (pt, input_pos);
|
Walther@60578
|
793 |
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = ((pt, input_pos));
|
Walther@60578
|
794 |
val (_, (p_', tac)) = Specify.find_next_step ptp
|
Walther@60578
|
795 |
val ist_ctxt = Ctree.get_loc pt (p, p_)
|
Walther@60578
|
796 |
val _ =
|
Walther@60578
|
797 |
(*case*) tac (*of*);
|
Walther@60578
|
798 |
|
Walther@60578
|
799 |
Step_Specify.by_tactic_input tac (pt, (p, p_'));
|
Walther@60578
|
800 |
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Specify_Method id), (pt, pos))
|
Walther@60578
|
801 |
= (tac, (pt, (p, p_')));
|
Walther@60578
|
802 |
|
Walther@60578
|
803 |
val (o_model, ctxt, i_model) =
|
Walther@60578
|
804 |
Specify_Step.complete_for id (pt, pos);
|
Walther@60578
|
805 |
"~~~~~ fun complete_for , args:"; val (mID, (ctree, pos)) = (id, (pt, pos));
|
Walther@60578
|
806 |
val {origin = (o_model, o_refs, _), spec = refs, probl = i_prob, ctxt,
|
Walther@60578
|
807 |
...} = Calc.specify_data (ctree, pos);
|
Walther@60578
|
808 |
val ctxt = Ctree.get_ctxt ctree pos
|
Walther@60578
|
809 |
val (dI, _, _) = References.select_input o_refs refs;
|
Walther@60586
|
810 |
val {model = m_patt, where_, where_rls, ...} = MethodC.from_store ctxt mID
|
Walther@60578
|
811 |
val {origin = (root_model, _, _), ...} = Calc.specify_data (ctree, ([], Pos.Und))
|
Walther@60578
|
812 |
val (o_model', ctxt') = O_Model.complete_for m_patt root_model (o_model, ctxt)
|
Walther@60676
|
813 |
val thy = ThyC.get_theory ctxt dI
|
Walther@60590
|
814 |
val (_, (i_model, _)) = M_Match.match_itms_oris ctxt i_prob (m_patt, where_, where_rls) o_model';
|
Walther@60659
|
815 |
(*\------------------- step into me Specify_Problem ----------------------------------------//*)
|
Walther@60659
|
816 |
val (p,_,f,nxt,_,pt) = return_me_Specify_Problem
|
Walther@60578
|
817 |
|
Walther@60659
|
818 |
val return_me_Add_Given_FunctionVariable
|
Walther@60659
|
819 |
= me nxt p c pt; val Add_Given "FunctionVariable a" = #4 return_me_Add_Given_FunctionVariable;
|
Walther@60659
|
820 |
(*/------------------- step into me Specify_Method -----------------------------------------\\*)
|
Walther@60659
|
821 |
"~~~~~ fun me , args:"; val (tac, p, _, pt) = (nxt, p, c, pt);
|
Walther@60578
|
822 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60578
|
823 |
val (pt, p) =
|
Walther@60578
|
824 |
(*Step.by_tactic is here for testing by me; do_next would suffice in me*)
|
Walther@60578
|
825 |
case Step.by_tactic tac (pt, p) of
|
Walther@60578
|
826 |
("ok", (_, _, ptp)) => ptp;
|
Walther@60578
|
827 |
|
Walther@60578
|
828 |
(*case*)
|
Walther@60578
|
829 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60578
|
830 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
|
Walther@60578
|
831 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60578
|
832 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60578
|
833 |
val _ =
|
Walther@60578
|
834 |
(*case*) tacis (*of*);
|
Walther@60578
|
835 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60578
|
836 |
|
Walther@60578
|
837 |
Step.switch_specify_solve p_ (pt, ip);
|
Walther@60578
|
838 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60578
|
839 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60578
|
840 |
|
Walther@60578
|
841 |
Step.specify_do_next (pt, input_pos);
|
Walther@60578
|
842 |
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = (pt, input_pos);
|
Walther@60578
|
843 |
|
Walther@60578
|
844 |
val (_, (p_', tac)) =
|
Walther@60578
|
845 |
Specify.find_next_step ptp;
|
Walther@60578
|
846 |
"~~~~~ fun find_next_step , args:"; val ((pt, pos as (_, p_))) = (ptp);
|
Walther@60578
|
847 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
Walther@60578
|
848 |
spec = refs, ...} = Calc.specify_data (pt, pos);
|
Walther@60578
|
849 |
val ctxt = Ctree.get_ctxt pt pos;
|
Walther@60578
|
850 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
Walther@60578
|
851 |
(*if*) p_ = Pos.Pbl (*else*);
|
Walther@60578
|
852 |
|
Walther@60578
|
853 |
Specify.for_method ctxt oris (o_refs, refs) (pbl, met);
|
Walther@60578
|
854 |
"~~~~~ fun for_method , args:"; val (ctxt, oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met))
|
Walther@60578
|
855 |
= (ctxt, oris, (o_refs, refs), (pbl, met));
|
Walther@60578
|
856 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
Walther@60586
|
857 |
val {model = mpc, where_rls, where_, ...} = MethodC.from_store ctxt cmI; (*..MethodC ?*)
|
Walther@60590
|
858 |
val (preok, _) = Pre_Conds.check ctxt where_rls where_ pbl 0;
|
Walther@60578
|
859 |
val NONE =
|
Walther@60578
|
860 |
(*case*) find_first (I_Model.is_error o #5) met (*of*);
|
Walther@60578
|
861 |
|
Walther@60578
|
862 |
(*case*)
|
Walther@60676
|
863 |
Specify.item_to_add (ThyC.get_theory ctxt
|
Walther@60578
|
864 |
(if dI = ThyC.id_empty then dI' else dI)) oris mpc met (*of*);
|
Walther@60578
|
865 |
"~~~~~ fun item_to_add , args:"; val (thy, oris, _, itms)
|
Walther@60676
|
866 |
= ((ThyC.get_theory ctxt (if dI = ThyC.id_empty then dI' else dI)), oris, mpc, met);
|
Walther@60659
|
867 |
(*\------------------- step into me Specify_Method -----------------------------------------//*)
|
Walther@60659
|
868 |
val (p,_,f,nxt,_,pt) = return_me_Add_Given_FunctionVariable
|
Walther@60578
|
869 |
|
Walther@60659
|
870 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "Input_Descript.Domain {0<..<r}" = nxt;
|
Walther@60578
|
871 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; val Add_Given "ErrorBound (\<epsilon> = 0)" = nxt;
|
Walther@60728
|
872 |
|
Walther@60728
|
873 |
(* ------------------- step into UNTIL A PROGRAM IS REQUIRED (not yet impl. ---------------- )*)
|
Walther@60728
|
874 |
(*/------------------- step into me_Add_Given_ErrorBound------------------------------------\\*)
|
Walther@60728
|
875 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
|
Walther@60728
|
876 |
val ctxt = Ctree.get_ctxt pt p
|
Walther@60728
|
877 |
val (pt, p) =
|
Walther@60728
|
878 |
(*Step.by_tactic is here for testing by me; do_next would suffice in me*)
|
Walther@60728
|
879 |
case Step.by_tactic tac (pt, p) of
|
Walther@60728
|
880 |
("ok", (_, _, ptp)) => ptp;
|
Walther@60728
|
881 |
(*ERROR due to missing program in creating the environment from formal args* )
|
Walther@60728
|
882 |
(*case*)
|
Walther@60728
|
883 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
Walther@60728
|
884 |
( *ERROR*)
|
Walther@60728
|
885 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis) ) =
|
Walther@60728
|
886 |
(p, ((pt, Pos.e_pos'), []));
|
Walther@60728
|
887 |
(*if*) Pos.on_calc_end ip (*else*);
|
Walther@60728
|
888 |
val (_, probl_id, _) = Calc.references (pt, p);
|
Walther@60728
|
889 |
val _ =
|
Walther@60728
|
890 |
(*case*) tacis (*of*);
|
Walther@60728
|
891 |
(*if*) probl_id = Problem.id_empty (*else*);
|
Walther@60728
|
892 |
|
Walther@60728
|
893 |
(*ERROR due to missing program in creating the environment from formal args* )
|
Walther@60728
|
894 |
switch_specify_solve p_ (pt, ip);
|
Walther@60728
|
895 |
( *ERROR*)
|
Walther@60728
|
896 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
Walther@60728
|
897 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
Walther@60728
|
898 |
|
Walther@60728
|
899 |
(*ERROR due to missing program in creating the environment from formal args* )
|
Walther@60728
|
900 |
specify_do_next (pt, input_pos)
|
Walther@60728
|
901 |
( *ERROR*)
|
Walther@60728
|
902 |
"~~~~~ fun specify_do_next , args:"; val ((ptp as (pt, (p, p_)))) = ((pt, input_pos));
|
Walther@60728
|
903 |
val (_, (p_', tac as Apply_Method ["Optimisation", "by_univariate_calculus"])) =
|
Walther@60728
|
904 |
(*-------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not yet impl.*)
|
Walther@60728
|
905 |
Specify.find_next_step ptp
|
Walther@60728
|
906 |
val ist_ctxt = Ctree.get_loc pt (p, p_)
|
Walther@60728
|
907 |
|
Walther@60728
|
908 |
val Tactic.Apply_Method (mI as ["Optimisation", "by_univariate_calculus"]) =
|
Walther@60728
|
909 |
(*case*) tac (*of*);
|
Walther@60728
|
910 |
(*ERROR due to missing program in creating the environment from formal args* )
|
Walther@60728
|
911 |
LI.by_tactic (Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty))
|
Walther@60728
|
912 |
ist_ctxt (pt, (p, p_'))
|
Walther@60728
|
913 |
( *ERROR*)
|
Walther@60728
|
914 |
"~~~~~ fun by_tactic , args:"; val ((Tactic.Apply_Method' (mI, _, _, _)), (_, ctxt), (pt, pos as (p, _))) =
|
Walther@60728
|
915 |
((Tactic.Apply_Method' (mI, NONE, Istate.empty, ContextC.empty)), ist_ctxt, (pt, (p, p_')));
|
Walther@60728
|
916 |
val (itms, oris, probl) = case get_obj I pt p of
|
Walther@60728
|
917 |
PblObj {meth = itms, origin = (oris, _, _), probl, ...} => (itms, oris, probl)
|
Walther@60728
|
918 |
val {model, ...} = MethodC.from_store ctxt mI;
|
Walther@60728
|
919 |
(*if*) itms <> [] (*then*);
|
Walther@60728
|
920 |
val itms = I_Model.complete oris probl [] model
|
Walther@60728
|
921 |
|
Walther@60728
|
922 |
(*+*)val "[\n(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] ,(fixes, [[r = 7]])), \n(2 ,[1, 2, 3] ,true ,#Find ,Cor Maximum A ,(maxx, [A])), \n(3 ,[1, 2, 3] ,true ,#Find ,Cor AdditionalValues [u, v] ,(vals, [[u, v]])), \n(4 ,[1, 2, 3] ,true ,#Relate ,Cor Extremum (A = 2 * u * v - u \<up> 2) ,(extr, [A = 2 * u * v - u \<up> 2])), \n(5 ,[1, 2] ,true ,#Relate ,Cor SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] ,(sideconds, [[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]])), \n(7 ,[1] ,true ,#Given ,Cor FunctionVariable a ,(funvar, [a])), \n(10 ,[1, 2] ,true ,#Given ,Cor Input_Descript.Domain {0<..<r} ,(doma, [{0<..<r}])), \n(12 ,[1, 2, 3] ,true ,#Given ,Cor ErrorBound (\<epsilon> = 0) ,(err, [\<epsilon> = 0]))]"
|
Walther@60728
|
923 |
= itms |> I_Model.to_string @{context}
|
Walther@60728
|
924 |
(*+*)val 8 = length itms
|
Walther@60728
|
925 |
(*+*)val 8 = length model
|
Walther@60728
|
926 |
(*\------------------- step into me_Add_Given_ErrorBound------------------------------------//*)
|
Walther@60728
|
927 |
|