wneuper@59119
|
1 |
(* use this theory for tests before Build_Isac.thy has succeeded *)
|
Walther@60576
|
2 |
theory Test_Theory imports "$ISABELLE_ISAC/Build_Isac"
|
Walther@60736
|
3 |
"$ISABELLE_ISAC_TEST/Tools/isac/Specify/refine" (* setup for refine.sml *)
|
neuper@52102
|
4 |
begin
|
wenzelm@60192
|
5 |
ML_file "$ISABELLE_ISAC/BaseDefinitions/libraryC.sml"
|
neuper@52102
|
6 |
|
wneuper@59472
|
7 |
section \<open>code for copy & paste ===============================================================\<close>
|
Walther@60737
|
8 |
text \<open>
|
Walther@60737
|
9 |
declare [[show_types]]
|
Walther@60737
|
10 |
declare [[show_sorts]]
|
Walther@60737
|
11 |
find_theorems "?a <= ?a"
|
Walther@60737
|
12 |
|
Walther@60737
|
13 |
print_theorems
|
Walther@60737
|
14 |
print_facts
|
Walther@60737
|
15 |
print_statement ""
|
Walther@60737
|
16 |
print_theory
|
Walther@60737
|
17 |
ML_command \<open>Pretty.writeln prt\<close>
|
Walther@60737
|
18 |
declare [[ML_print_depth = 999]]
|
Walther@60737
|
19 |
declare [[ML_exception_trace]]
|
Walther@60737
|
20 |
\<close>
|
Walther@60751
|
21 |
(** )
|
Walther@60751
|
22 |
(@{print} {a = "dict_cond_ord ([], [])"}; EQUAL)
|
Walther@60751
|
23 |
( **)
|
wneuper@59472
|
24 |
ML \<open>
|
Walther@60710
|
25 |
\<close> ML \<open>
|
walther@59686
|
26 |
"~~~~~ fun xxx , args:"; val () = ();
|
walther@59686
|
27 |
"~~~~~ and xxx , args:"; val () = ();
|
Walther@60576
|
28 |
"~~~~~ from fun xxx \<longrightarrow>fun yyy \<longrightarrow>fun zzz , return:"; val () = ();
|
Walther@60576
|
29 |
"~~~~~ continue fun xxx"; val () = ();
|
Walther@60729
|
30 |
(*if*) (*then*); (*else*); (*andalso*) (*case*) (*of*); (*return value*); (*in*) (*end*);
|
walther@59686
|
31 |
"xx"
|
Walther@60629
|
32 |
^ "xxx" (*+*) (*+++*) (*keep for continuing YYYYY*) (*isa*) (*isa2*) (**)
|
Walther@60729
|
33 |
\<close> ML \<open> (*//----------- build fun XXXXX -----------------------------------------------------\\*)
|
Walther@60729
|
34 |
(*//------------------ build fun XXXXX -----------------------------------------------------\\*)
|
Walther@60729
|
35 |
(*\\------------------ build fun XXXXX -----------------------------------------------------//*)
|
Walther@60729
|
36 |
\<close> ML \<open> (*\\----------- build fun XXXXX -----------------------------------------------------//*)
|
Walther@60737
|
37 |
|
Walther@60751
|
38 |
\<close> ML \<open> (*//----------- setup test data for XXXXX -------------------------------------------\\*)
|
Walther@60751
|
39 |
(*//------------------ setup test data for XXXXX -------------------------------------------\\*)
|
Walther@60751
|
40 |
(*\\------------------ setup test data for XXXXX -------------------------------------------//*)
|
Walther@60751
|
41 |
\<close> ML \<open> (*\\----------- setup test data for XXXXX -------------------------------------------//*)
|
Walther@60751
|
42 |
|
Walther@60682
|
43 |
val return_XXXXX = "XXXXX"
|
Walther@60576
|
44 |
\<close> ML \<open> (*//----------- step into XXXXX -----------------------------------------------------\\*)
|
Walther@60576
|
45 |
(*//------------------ step into XXXXX -----------------------------------------------------\\*)
|
Walther@60715
|
46 |
\<close> ML \<open> (*||----------- contine XXXXX ---------------------------------------------------------*)
|
Walther@60715
|
47 |
(*||------------------ contine XXXXX ---------------------------------------------------------*)
|
Walther@60576
|
48 |
(*\\------------------ step into XXXXX -----------------------------------------------------//*)
|
Walther@60576
|
49 |
\<close> ML \<open> (*\\----------- step into XXXXX -----------------------------------------------------//*)
|
Walther@60710
|
50 |
val "XXXXX" = return_XXXXX;
|
Walther@60576
|
51 |
|
Walther@60576
|
52 |
(* final test ... ----------------------------------------------------------------------------*)
|
Walther@60576
|
53 |
|
Walther@60576
|
54 |
\<close> ML \<open> (*//----------- inserted hidden code ------------------------------------------------\\*)
|
Walther@60576
|
55 |
(*//------------------ inserted hidden code ------------------------------------------------\\*)
|
Walther@60576
|
56 |
(*\\------------------ inserted hidden code ------------------------------------------------//*)
|
Walther@60576
|
57 |
\<close> ML \<open> (*\\----------- inserted hidden code ------------------------------------------------//*)
|
Walther@60576
|
58 |
|
walther@59723
|
59 |
\<close> ML \<open>
|
wneuper@59472
|
60 |
\<close>
|
neuper@52102
|
61 |
|
Walther@60658
|
62 |
section \<open>===================================================================================\<close>
|
Walther@60725
|
63 |
section \<open>===== ============================================================================\<close>
|
wneuper@59472
|
64 |
ML \<open>
|
wneuper@59472
|
65 |
\<close> ML \<open>
|
Walther@60733
|
66 |
|
Walther@60733
|
67 |
\<close> ML \<open>
|
Walther@60733
|
68 |
\<close>
|
Walther@60733
|
69 |
|
Walther@60733
|
70 |
section \<open>===================================================================================\<close>
|
Walther@60747
|
71 |
section \<open>===== --> src/../lucas-interpreter.sml etc ========================================\<close>
|
Walther@60746
|
72 |
ML \<open>
|
Walther@60747
|
73 |
(*T_TESTold*)
|
Walther@60747
|
74 |
(*T_TEST*)
|
Walther@60747
|
75 |
(*T_TESTnew*)
|
Walther@60747
|
76 |
|
Walther@60751
|
77 |
(**)
|
Walther@60751
|
78 |
open Ctree
|
Walther@60751
|
79 |
open Pos;
|
Walther@60751
|
80 |
open TermC;
|
Walther@60751
|
81 |
open Istate;
|
Walther@60751
|
82 |
open Tactic;
|
Walther@60751
|
83 |
open P_Model
|
Walther@60751
|
84 |
open Rewrite;
|
Walther@60751
|
85 |
open Step;
|
Walther@60751
|
86 |
open LItool;
|
Walther@60751
|
87 |
open LI;
|
Walther@60751
|
88 |
open Test_Code
|
Walther@60751
|
89 |
open Specify
|
Walther@60751
|
90 |
(**)
|
Walther@60746
|
91 |
open Model_Def
|
Walther@60751
|
92 |
(**)
|
Walther@60746
|
93 |
open Pre_Conds
|
Walther@60751
|
94 |
(**)
|
Walther@60751
|
95 |
open I_Model
|
Walther@60751
|
96 |
(**)
|
Walther@60746
|
97 |
\<close> ML \<open>
|
Walther@60747
|
98 |
\<close> ML \<open> (*\<longrightarrow> pre_conditions.sml | ? model-def.sml ?*)
|
Walther@60748
|
99 |
fun max_variants i_model =
|
Walther@60747
|
100 |
let
|
Walther@60747
|
101 |
val all_variants =
|
Walther@60747
|
102 |
map (fn (_, variants, _, _, _) => variants) i_model
|
Walther@60747
|
103 |
|> flat
|
Walther@60747
|
104 |
|> distinct op =
|
Walther@60747
|
105 |
val variants_separated = map (filter_variants' i_model) all_variants
|
Walther@60747
|
106 |
val sums_corr = map (cnt_corrects) variants_separated
|
Walther@60747
|
107 |
val sum_variant_s = arrange_args sums_corr (1, all_variants)
|
Walther@60747
|
108 |
|
Walther@60747
|
109 |
val max_first = rev (sort (fn ((i, _), (j, _)) => int_ord (i, j)) sum_variant_s)
|
Walther@60747
|
110 |
val maxes = filter (fn (cnt, _) => curry op = (fst (hd max_first)) cnt) max_first
|
Walther@60747
|
111 |
|> map snd
|
Walther@60747
|
112 |
val option_sequence = map
|
Walther@60747
|
113 |
(fn (_, vnt) => if (member (op =) maxes vnt) then SOME vnt else NONE) sum_variant_s
|
Walther@60751
|
114 |
(*das ist UNSINN'+ UNNOETIG WEGLASSEN, .., siehe (*+*)if (pbl_max_imos*)
|
Walther@60747
|
115 |
val max_i_models = map (fn (pos_in_sum_variant_s, i_model) =>
|
Walther@60747
|
116 |
if is_some pos_in_sum_variant_s then i_model else [])
|
Walther@60747
|
117 |
(option_sequence ~~ variants_separated)
|
Walther@60747
|
118 |
|> filter_out (fn place_holder => place_holder = []);
|
Walther@60747
|
119 |
(*/-- fun make_envs_preconds: 1 max_i_model can be determined only together with meth --------\ * )
|
Walther@60747
|
120 |
PROBALBY FOR RE-USE:
|
Walther@60747
|
121 |
val option_sequence = map
|
Walther@60747
|
122 |
(fn (_, vnt) => if (member (op =) maxes vnt) then SOME vnt else NONE) sum_variant_s
|
Walther@60747
|
123 |
val max_i_models = map (fn (pos_in_sum_variant_s, i_model) =>
|
Walther@60747
|
124 |
if is_some pos_in_sum_variant_s then i_model else [])
|
Walther@60747
|
125 |
(option_sequence ~~ variants_separated)
|
Walther@60747
|
126 |
|> filter_out (fn place_holder => place_holder = []);
|
Walther@60747
|
127 |
\<longrightarrow> [
|
Walther@60747
|
128 |
[(1, [1, 2, 3]), (2, [1, 2, 3]), (3, [1, 2, 3]), (4, [1, 2, 3]), (5, [1, 2])],
|
Walther@60747
|
129 |
[(1, [1, 2, 3]), (2, [1, 2, 3]), (3, [1, 2, 3]), (4, [1, 2, 3]), (5, [1, 2])]]
|
Walther@60747
|
130 |
------ ----------------------------------------------------------------------------------------
|
Walther@60747
|
131 |
val equal_descr_pairs = map (get_equal_descr (hd max_i_models)) model_patt
|
Walther@60747
|
132 |
|> flat (*a hack for continuing ------------^^-- "turn to PIDE", works for test example*)
|
Walther@60747
|
133 |
val env_model = make_env_model equal_descr_pairs
|
Walther@60747
|
134 |
val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
|
Walther@60747
|
135 |
val subst_eval_list = make_envs_preconds equal_givens
|
Walther@60747
|
136 |
val (env_subst, env_eval) = split_list subst_eval_list
|
Walther@60747
|
137 |
( *\-- fun make_envs_preconds: 1 max_i_model can be determined only together with meth --------/ *)
|
Walther@60747
|
138 |
in
|
Walther@60747
|
139 |
((maxes, max_i_models)(*, env_model, (env_subst, env_eval)*))
|
Walther@60747
|
140 |
(* (maxes, max_i_models)*)
|
Walther@60747
|
141 |
(*/-- fun make_envs_preconds: 1 max_i_model can be determined only together with meth --------\ * )
|
Walther@60747
|
142 |
(env_model, (env_subst, env_eval)
|
Walther@60747
|
143 |
( *\--fun make_envs_preconds: 1 max_i_model can be determined only together with meth --------/ *)
|
Walther@60747
|
144 |
end
|
Walther@60747
|
145 |
;
|
Walther@60751
|
146 |
(*of_max_variant*)
|
Walther@60751
|
147 |
max_variants: (*Model_Pattern.T -> *) Model_Def.i_model_TEST ->
|
Walther@60747
|
148 |
(variant list * Model_Def.i_model_TEST list)(* * Env.T * (env_subst * env_eval)*)
|
Walther@60747
|
149 |
\<close> ML \<open>
|
Walther@60747
|
150 |
\<close> ML \<open> (*\<longrightarrow> pre-conditions.sml*)
|
Walther@60747
|
151 |
\<close> ML \<open>
|
Walther@60751
|
152 |
fun get_dscr' (Cor_TEST (descr, _)) = SOME descr
|
Walther@60751
|
153 |
| get_dscr' (Inc_TEST (descr, _)) = SOME descr
|
Walther@60747
|
154 |
| get_dscr' (Sup_TEST (descr, _)) = SOME descr
|
Walther@60747
|
155 |
| get_dscr' _ = NONE
|
Walther@60747
|
156 |
(*other feedback cannot contribute to I_Model.mk_env_TEST and Pre_Conds.mk_env_TEST*)
|
Walther@60747
|
157 |
(* get_descr: I_Model.single_TEST -> descriptor option*)
|
Walther@60747
|
158 |
;
|
Walther@60747
|
159 |
get_dscr': feedback_TEST -> descriptor option
|
Walther@60747
|
160 |
\<close> ML \<open>
|
Walther@60747
|
161 |
fun get_descr (_, _, _, _, (feedb, _)) =
|
Walther@60747
|
162 |
case get_dscr' feedb of NONE => NONE | some_descr => some_descr
|
Walther@60751
|
163 |
;
|
Walther@60747
|
164 |
get_descr: single_TEST -> descriptor option;
|
Walther@60747
|
165 |
|
Walther@60747
|
166 |
\<close> ML \<open>
|
Walther@60747
|
167 |
fun get_descr_vnt descr vnts i_model =
|
Walther@60747
|
168 |
let
|
Walther@60747
|
169 |
val equal_descr = filter (fn (_, _, _, _, (feedb, _)) => case get_dscr' feedb of NONE => false
|
Walther@60747
|
170 |
| SOME descr' => if descr = descr' then true else false) i_model
|
Walther@60746
|
171 |
in
|
Walther@60751
|
172 |
case filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) equal_descr of
|
Walther@60751
|
173 |
[] => (0, [], false, "i_model_empty", (Sup_TEST (descr, []), Position.none))
|
Walther@60751
|
174 |
| items => Library.the_single items (*only applied to model_patt, which has each descr once*)
|
Walther@60746
|
175 |
end
|
Walther@60747
|
176 |
;
|
Walther@60747
|
177 |
get_descr_vnt: descriptor -> variants -> T_TEST -> single_TEST
|
Walther@60746
|
178 |
\<close> ML \<open>
|
Walther@60747
|
179 |
\<close> ML \<open> (*\<longrightarrow> i-model.sml*)
|
Walther@60746
|
180 |
\<close> ML \<open>
|
Walther@60751
|
181 |
fun transfer_terms (i, vnts, m_field, descr, ts) =
|
Walther@60751
|
182 |
(i, vnts, true, m_field, (Cor_TEST (descr, ts), Position.none))
|
Walther@60751
|
183 |
;
|
Walther@60751
|
184 |
transfer_terms: O_Model.single -> I_Model.single_TEST
|
Walther@60751
|
185 |
\<close> ML \<open>
|
Walther@60751
|
186 |
(*
|
Walther@60747
|
187 |
get an appropriate (description, variant) item from o_model;
|
Walther@60747
|
188 |
called in case of item in met_imod is_empty_single_TEST
|
Walther@60747
|
189 |
(i.e. was not transferred pbl_mod by \<open>fun get_descr_vnt\<close>).
|
Walther@60747
|
190 |
*)
|
Walther@60747
|
191 |
fun get_descr_vnt' feedb vnts o_model =
|
Walther@60751
|
192 |
filter (fn (_, vnts', _, descr', _) =>
|
Walther@60747
|
193 |
case get_dscr' feedb of
|
Walther@60747
|
194 |
SOME descr => if descr' = descr andalso inter op= vnts' vnts <> [] then true else false
|
Walther@60747
|
195 |
| NONE => false) o_model
|
Walther@60747
|
196 |
;
|
Walther@60751
|
197 |
get_descr_vnt': feedback_TEST -> variants -> O_Model.T -> O_Model.T
|
Walther@60746
|
198 |
\<close> ML \<open>
|
Walther@60747
|
199 |
fun msg vnts feedb = "get_descr_vnt' returns NONE: i.e. it does not find an item of o_model with\n" ^
|
Walther@60747
|
200 |
"variants " ^ ints2str' vnts ^ " and descriptor " ^
|
Walther@60747
|
201 |
(feedb |> get_dscr' |> the |> UnparseC.term (ContextC.for_ERROR ()))
|
Walther@60747
|
202 |
;
|
Walther@60747
|
203 |
msg: variants -> feedback_TEST -> string
|
Walther@60747
|
204 |
\<close> ML \<open>
|
Walther@60747
|
205 |
fun fill_method o_model pbl_imod met_patt =
|
Walther@60747
|
206 |
let
|
Walther@60748
|
207 |
val (pbl_max_vnts, _) = max_variants pbl_imod;
|
Walther@60747
|
208 |
val from_pbl = map (fn (_, (descr, _)) => get_descr_vnt descr pbl_max_vnts pbl_imod) met_patt
|
Walther@60747
|
209 |
val from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
|
Walther@60747
|
210 |
if is_empty_single_TEST i_single
|
Walther@60747
|
211 |
then
|
Walther@60747
|
212 |
case get_descr_vnt' feedb pbl_max_vnts o_model of
|
Walther@60751
|
213 |
[] => raise ERROR (msg pbl_max_vnts feedb)
|
Walther@60751
|
214 |
| o_singles => map transfer_terms o_singles
|
Walther@60751
|
215 |
else [i_single (*fetched before from pbl_imod*)])) from_pbl
|
Walther@60747
|
216 |
in
|
Walther@60751
|
217 |
from_o_model |> flat
|
Walther@60747
|
218 |
end
|
Walther@60747
|
219 |
;
|
Walther@60751
|
220 |
fill_method: O_Model.T -> T_TEST -> Model_Pattern.T -> T_TEST
|
Walther@60751
|
221 |
\<close> ML \<open>
|
Walther@60751
|
222 |
\<close> ML \<open>
|
Walther@60751
|
223 |
\<close> ML \<open> (* \<longrightarrow> i-model.sml*)
|
Walther@60751
|
224 |
\<close> ML \<open>
|
Walther@60751
|
225 |
fun s_make_complete o_model (pbl_imod, met_imod) (pbl_patt, met_patt) =
|
Walther@60751
|
226 |
let
|
Walther@60751
|
227 |
val (pbl_max_vnts, _) = Model_Def.max_variants pbl_imod;
|
Walther@60751
|
228 |
val i_from_pbl = map (fn (_, (descr, _)) =>
|
Walther@60751
|
229 |
(*Pre_Conds.*)get_descr_vnt descr pbl_max_vnts pbl_imod) pbl_patt
|
Walther@60751
|
230 |
val pbl_from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
|
Walther@60751
|
231 |
if is_empty_single_TEST i_single
|
Walther@60751
|
232 |
then
|
Walther@60751
|
233 |
case get_descr_vnt' feedb pbl_max_vnts o_model of
|
Walther@60751
|
234 |
[] => raise ERROR (msg pbl_max_vnts feedb)
|
Walther@60751
|
235 |
| o_singles => map transfer_terms o_singles
|
Walther@60751
|
236 |
else [i_single (*fetched before from pbl_imod*)])) i_from_pbl |> flat
|
Walther@60751
|
237 |
|
Walther@60751
|
238 |
val i_from_met = map (fn (_, (descr, _)) =>
|
Walther@60751
|
239 |
(*Pre_Conds.*)get_descr_vnt descr pbl_max_vnts met_imod) met_patt
|
Walther@60751
|
240 |
val (met_max_vnts, _) = Model_Def.max_variants i_from_met;
|
Walther@60751
|
241 |
val met_max_vnt = hd met_max_vnts (*need only one for solve-phase*)
|
Walther@60751
|
242 |
|
Walther@60751
|
243 |
val met_from_pbl = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
|
Walther@60751
|
244 |
if is_empty_single_TEST i_single
|
Walther@60751
|
245 |
then
|
Walther@60751
|
246 |
case get_descr_vnt' feedb [met_max_vnt] o_model of
|
Walther@60751
|
247 |
[] => raise ERROR (msg [met_max_vnt] feedb)
|
Walther@60751
|
248 |
| o_singles => map transfer_terms o_singles
|
Walther@60751
|
249 |
else [i_single (*fetched before from met_imod*)])) i_from_met |> flat
|
Walther@60751
|
250 |
in
|
Walther@60751
|
251 |
(pbl_from_o_model, met_from_pbl)
|
Walther@60751
|
252 |
end
|
Walther@60751
|
253 |
\<close> ML \<open>
|
Walther@60751
|
254 |
;
|
Walther@60751
|
255 |
s_make_complete: O_Model.T -> I_Model.T_TEST * I_Model.T_TEST -> Model_Pattern.T * Model_Pattern.T ->
|
Walther@60751
|
256 |
I_Model.T_TEST * I_Model.T_TEST
|
Walther@60751
|
257 |
\<close> ML \<open>
|
Walther@60751
|
258 |
\<close> ML \<open>
|
Walther@60747
|
259 |
\<close> ML \<open>
|
Walther@60747
|
260 |
\<close> ML \<open> (*\<longrightarrow> lucas-interpreter.sml*)
|
Walther@60747
|
261 |
fun by_tactic (Tactic.Apply_Method' (mI, _, _, _)) (_, ctxt) (pt, pos as (p, _)) =
|
Walther@60747
|
262 |
let
|
Walther@60747
|
263 |
(*done in src*)
|
Walther@60747
|
264 |
in
|
Walther@60747
|
265 |
("ok", Calc.state_empty_post)
|
Walther@60747
|
266 |
end
|
Walther@60747
|
267 |
;
|
Walther@60747
|
268 |
by_tactic: Tactic.T -> Istate.T * Proof.context -> Calc.T -> string * Calc.state_post
|
Walther@60746
|
269 |
\<close> ML \<open>
|
Walther@60746
|
270 |
\<close>
|
Walther@60746
|
271 |
|
Walther@60746
|
272 |
section \<open>===================================================================================\<close>
|
Walther@60751
|
273 |
section \<open>===== i-model.sml .s_complete =====================================================\<close>
|
Walther@60733
|
274 |
ML \<open>
|
Walther@60736
|
275 |
\<close> ML \<open>
|
Walther@60751
|
276 |
(* most general case: user activates some <complete specification> *)
|
Walther@60751
|
277 |
\<close> ML \<open>
|
Walther@60751
|
278 |
(*---vvvvv these would overwrite above definition ^^^* )
|
Walther@60751
|
279 |
open Ctree
|
Walther@60746
|
280 |
open Pos;
|
Walther@60746
|
281 |
open TermC;
|
Walther@60746
|
282 |
open Istate;
|
Walther@60746
|
283 |
open Tactic;
|
Walther@60746
|
284 |
open P_Model
|
Walther@60746
|
285 |
open Rewrite;
|
Walther@60746
|
286 |
open Step;
|
Walther@60746
|
287 |
open LItool;
|
Walther@60746
|
288 |
open LI;
|
Walther@60746
|
289 |
open Test_Code
|
Walther@60746
|
290 |
open Specify
|
Walther@60751
|
291 |
open Model_Def
|
Walther@60746
|
292 |
open Pre_Conds;
|
Walther@60751
|
293 |
open I_Model;
|
Walther@60751
|
294 |
( **)
|
Walther@60746
|
295 |
|
Walther@60746
|
296 |
val (_(*example text*),
|
Walther@60746
|
297 |
(model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" ::
|
Walther@60746
|
298 |
"Extremum (A = 2 * u * v - u \<up> 2)" ::
|
Walther@60746
|
299 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" ::
|
Walther@60746
|
300 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" ::
|
Walther@60746
|
301 |
"SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: (*INCORRECT 2 / v*)
|
Walther@60746
|
302 |
(*---------------------------------------------,(v::real) / 2 = r * cos \<alpha>]" --- ERROR in example*)
|
Walther@60746
|
303 |
"FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" ::
|
Walther@60746
|
304 |
"Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
|
Walther@60746
|
305 |
"ErrorBound (\<epsilon> = (0::real))" :: []),
|
Walther@60746
|
306 |
refs as ("Diff_App",
|
Walther@60746
|
307 |
["univariate_calculus", "Optimisation"],
|
Walther@60746
|
308 |
["Optimisation", "by_univariate_calculus"])))
|
Walther@60746
|
309 |
= Store.get (Know_Store.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
|
Walther@60746
|
310 |
|
Walther@60746
|
311 |
val c = [];
|
Walther@60751
|
312 |
val (p,_,f,nxt,_,pt) =
|
Walther@60751
|
313 |
Test_Code.init_calc @{context} [(model, refs)]; val Model_Problem = nxt;
|
Walther@60751
|
314 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
Walther@60751
|
315 |
\<close> ML \<open>
|
Walther@60751
|
316 |
\<close> ML \<open> (*//----------- setup test data for I_Model.s_make_complete -------------------------\\*)
|
Walther@60751
|
317 |
(*//------------------ setup test data for I_Model.s_make_complete -------------------------\\*)
|
Walther@60751
|
318 |
val (o_model, (pbl_imod, met_imod), (pI, mI)) = case get_obj I pt (fst p) of
|
Walther@60751
|
319 |
PblObj {meth = met_imod, origin = (o_model, (_, pI, mI), _), probl = pbl_imod, ...}
|
Walther@60751
|
320 |
=> (o_model, (pbl_imod, met_imod), (pI, mI))
|
Walther@60747
|
321 |
| _ => raise ERROR ""
|
Walther@60747
|
322 |
\<close> ML \<open>
|
Walther@60751
|
323 |
val {model = pbl_patt, ...} = Problem.from_store ctxt pI;
|
Walther@60751
|
324 |
val {model = met_patt, ...} = MethodC.from_store ctxt mI;
|
Walther@60747
|
325 |
\<close> ML \<open>
|
Walther@60751
|
326 |
val pbl_imod = [ (*2 items for creating code ---> variants [1, 2]*)
|
Walther@60751
|
327 |
(1, [1, 2, 3], true, "#undef", (Cor_TEST (@{term Constants},
|
Walther@60751
|
328 |
[@{term "[r = (7::real)]"}]), Position.none)),
|
Walther@60751
|
329 |
(1, [1, 2], true, "#undef", (Cor_TEST (@{term SideConditions},
|
Walther@60751
|
330 |
[@{term "[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]"}]), Position.none))]
|
Walther@60751
|
331 |
\<close> ML \<open>
|
Walther@60751
|
332 |
val met_imod = [ (*1 item for creating code*)
|
Walther@60751
|
333 |
(8, [2], true, "#undef", (Cor_TEST (@{term FunctionVariable}, [@{term "b::real"}]), Position.none))]
|
Walther@60747
|
334 |
\<close> ML \<open>
|
Walther@60747
|
335 |
(*+*)if (o_model |> O_Model.to_string @{context}) = "[\n" ^
|
Walther@60751
|
336 |
(*+*) "(1, [\"1\", \"2\", \"3\"], #Given, Constants, [\"[r = 7]\"]), \n" ^
|
Walther@60751
|
337 |
(*+*) "(2, [\"1\", \"2\", \"3\"], #Find, Maximum, [\"A\"]), \n" ^
|
Walther@60751
|
338 |
(*+*) "(3, [\"1\", \"2\", \"3\"], #Find, AdditionalValues, [\"[u]\", \"[v]\"]), \n" ^
|
Walther@60751
|
339 |
(*+*) "(4, [\"1\", \"2\", \"3\"], #Relate, Extremum, [\"A = 2 * u * v - u \<up> 2\"]), \n" ^
|
Walther@60751
|
340 |
(*+*) "(5, [\"1\", \"2\"], #Relate, SideConditions, [\"[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\"]), \n" ^
|
Walther@60751
|
341 |
(*+*) "(6, [\"3\"], #Relate, SideConditions, [\"[u / 2 = r * sin \<alpha>]\", \"[2 / v = r * cos \<alpha>]\"]), \n" ^
|
Walther@60751
|
342 |
(*+*) "(7, [\"1\"], #undef, FunctionVariable, [\"a\"]), \n" ^
|
Walther@60751
|
343 |
(*+*) "(8, [\"2\"], #undef, FunctionVariable, [\"b\"]), \n" ^
|
Walther@60751
|
344 |
(*+*) "(9, [\"3\"], #undef, FunctionVariable, [\"\<alpha>\"]), \n" ^
|
Walther@60751
|
345 |
(*+*) "(10, [\"1\", \"2\"], #undef, Input_Descript.Domain, [\"{0<..<r}\"]), \n" ^
|
Walther@60751
|
346 |
(*+*) "(11, [\"3\"], #undef, Input_Descript.Domain, [\"{0<..<\<pi> / 2}\"]), \n" ^
|
Walther@60751
|
347 |
(*+*) "(12, [\"1\", \"2\", \"3\"], #undef, ErrorBound, [\"\<epsilon> = 0\"])]"
|
Walther@60751
|
348 |
then () else error "setup test data for I_Model.s_make_complete CHANGED";
|
Walther@60751
|
349 |
(*\\------------------ setup test data for I_Model.s_make_complete -------------------------//*)
|
Walther@60751
|
350 |
\<close> ML \<open> (*\\----------- setup test data for I_Model.s_make_complete -------------------------//*)
|
Walther@60747
|
351 |
\<close> ML \<open>
|
Walther@60751
|
352 |
val return_s_make_complete =
|
Walther@60751
|
353 |
s_make_complete o_model (pbl_imod, met_imod) (pbl_patt, met_patt);
|
Walther@60751
|
354 |
\<close> ML \<open> (*/------------ step into s_make_complete -------------------------------------------\\*)
|
Walther@60751
|
355 |
(*/------------------- step into s_make_complete -------------------------------------------\\*)
|
Walther@60751
|
356 |
(*.....~~~ fill_method....*)
|
Walther@60751
|
357 |
"~~~~~ fun s_make_complete , args:"; val (o_model, (pbl_imod, met_imod), (pbl_patt, met_patt)) =
|
Walther@60751
|
358 |
(o_model, (pbl_imod, met_imod), (pbl_patt, met_patt));
|
Walther@60751
|
359 |
\<close> ML \<open>
|
Walther@60751
|
360 |
val (pbl_max_vnts, _) = Model_Def.max_variants pbl_imod;
|
Walther@60751
|
361 |
\<close> ML \<open>
|
Walther@60751
|
362 |
val i_from_pbl = map (fn (_, (descr, _)) =>
|
Walther@60751
|
363 |
(*Pre_Conds.*)get_descr_vnt descr pbl_max_vnts pbl_imod) pbl_patt;
|
Walther@60751
|
364 |
\<close> ML \<open> (*//----------- step into get_descr_vnt ---------------------------------------------\\*)
|
Walther@60751
|
365 |
(*//------------------ step into get_descr_vnt ---------------------------------------------\\*)
|
Walther@60751
|
366 |
"~~~~~ fun get_descr_vnt , args:"; val (descr, vnts, i_model) =
|
Walther@60751
|
367 |
(@{term Constants}, pbl_max_vnts, pbl_imod);
|
Walther@60751
|
368 |
\<close> ML \<open>
|
Walther@60751
|
369 |
val equal_descr = filter (fn (_, _, _, _, (feedb, _)) => case get_dscr' feedb of NONE => false
|
Walther@60751
|
370 |
| SOME descr' => if descr = descr' then true else false) i_model
|
Walther@60751
|
371 |
\<close> ML \<open>
|
Walther@60751
|
372 |
(*+*)filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) equal_descr
|
Walther@60751
|
373 |
(*+*): I_Model.T_TEST
|
Walther@60751
|
374 |
\<close> ML \<open>
|
Walther@60751
|
375 |
val return_get_descr_vnt_1 =
|
Walther@60751
|
376 |
case filter (fn (_, vnts', _, _, _) => inter op= vnts' vnts <> []) equal_descr of
|
Walther@60751
|
377 |
[] => (0, [], false, "i_model_empty", (Sup_TEST (descr, []), Position.none))
|
Walther@60751
|
378 |
| items => Library.the_single items (*only applied to model_patt, which has each descr once*)
|
Walther@60751
|
379 |
(*\\------------------ step into get_descr_vnt ---------------------------------------------//*)
|
Walther@60751
|
380 |
\<close> ML \<open> (*\\----------- step into get_descr_vnt ---------------------------------------------//*)
|
Walther@60751
|
381 |
\<close> ML \<open>
|
Walther@60751
|
382 |
\<close> ML \<open> (*|------------ continue s_make_complete ----------------------------------------------*)
|
Walther@60751
|
383 |
(*|------------------- continue s_make_complete ----------------------------------------------*)
|
Walther@60751
|
384 |
\<close> ML \<open>
|
Walther@60751
|
385 |
val pbl_from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
|
Walther@60751
|
386 |
if is_empty_single_TEST i_single
|
Walther@60751
|
387 |
then
|
Walther@60751
|
388 |
case get_descr_vnt' feedb pbl_max_vnts o_model of
|
Walther@60751
|
389 |
(*-----------^^^^^^^^^^^^^^-----------------------------*)
|
Walther@60751
|
390 |
[] => raise ERROR (msg pbl_max_vnts feedb)
|
Walther@60751
|
391 |
| o_singles => map transfer_terms o_singles
|
Walther@60751
|
392 |
else [i_single (*fetched before from pbl_imod*)])) i_from_pbl |> flat
|
Walther@60751
|
393 |
\<close> ML \<open>
|
Walther@60751
|
394 |
(*+*)val [2, 1] = vnts;
|
Walther@60751
|
395 |
(*+*)if (pbl_from_o_model |> I_Model.to_string_TEST @{context}) = "[\n" ^
|
Walther@60751
|
396 |
"(1, [1, 2, 3], true ,#undef, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n" ^
|
Walther@60747
|
397 |
"(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n" ^
|
Walther@60747
|
398 |
"(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T)), \n" ^
|
Walther@60747
|
399 |
"(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
|
Walther@60751
|
400 |
"(1, [1, 2], true ,#undef, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T))]"
|
Walther@60751
|
401 |
then () else error "pbl_from_o_model CHANGED"
|
Walther@60747
|
402 |
\<close> ML \<open>
|
Walther@60747
|
403 |
\<close> ML \<open>
|
Walther@60751
|
404 |
\<close> ML \<open> (*//----------- step into map ((fn i_single -----------------------------------------\\*)
|
Walther@60751
|
405 |
(*//------------------ step into map ((fn i_single -----------------------------------------\\*)
|
Walther@60751
|
406 |
"~~~~~ fun map ((fn i_single , args:"; val (i_single as (_, _, _, _, (feedb, _))) = (nth 1 i_from_pbl);
|
Walther@60751
|
407 |
(*if*) is_empty_single_TEST i_single (*else*);
|
Walther@60751
|
408 |
get_descr_vnt' feedb pbl_max_vnts o_model;
|
Walther@60746
|
409 |
|
Walther@60751
|
410 |
val pbl_from_o_model = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
|
Walther@60751
|
411 |
if is_empty_single_TEST i_single
|
Walther@60751
|
412 |
then
|
Walther@60751
|
413 |
case get_descr_vnt' feedb pbl_max_vnts o_model of
|
Walther@60751
|
414 |
(*---------- ^^^^^^^^^^^^^^ ----------------------------*)
|
Walther@60751
|
415 |
[] => raise ERROR (msg pbl_max_vnts feedb)
|
Walther@60751
|
416 |
| o_singles => map transfer_terms o_singles
|
Walther@60751
|
417 |
else [i_single (*fetched before from pbl_imod*)])) i_from_pbl |> flat
|
Walther@60747
|
418 |
\<close> ML \<open>
|
Walther@60751
|
419 |
\<close> ML \<open> (*\\----------- step into map ((fn i_single -----------------------------------------//*)
|
Walther@60751
|
420 |
(*\\------------------ step into map ((fn i_single -----------------------------------------//*)
|
Walther@60751
|
421 |
|
Walther@60751
|
422 |
\<close> ML \<open> (*|------------ continue s_make_complete ----------------------------------------------*)
|
Walther@60751
|
423 |
(*|------------------- continue s_make_complete ----------------------------------------------*)
|
Walther@60747
|
424 |
\<close> ML \<open>
|
Walther@60751
|
425 |
val i_from_met = map (fn (_, (descr, _)) =>
|
Walther@60751
|
426 |
(*Pre_Conds.*)get_descr_vnt descr pbl_max_vnts met_imod) met_patt
|
Walther@60747
|
427 |
\<close> ML \<open>
|
Walther@60751
|
428 |
(*+*)if (i_from_met |> I_Model.to_string_TEST @{context}) = "[\n" ^
|
Walther@60751
|
429 |
"(0, [], false ,i_model_empty, (Sup_TEST Constants [], Position.T)), \n" ^
|
Walther@60751
|
430 |
"(0, [], false ,i_model_empty, (Sup_TEST Maximum, Position.T)), \n" ^
|
Walther@60751
|
431 |
"(0, [], false ,i_model_empty, (Sup_TEST Extremum, Position.T)), \n" ^
|
Walther@60751
|
432 |
"(0, [], false ,i_model_empty, (Sup_TEST SideConditions [], Position.T)), \n" ^
|
Walther@60751
|
433 |
"(8, [2], true ,#undef, (Cor_TEST FunctionVariable b , pen2str, Position.T)), \n" ^
|
Walther@60751
|
434 |
(*---there is 1 item already input -^^^^^^^^^^^^^^^^^^*)
|
Walther@60751
|
435 |
"(0, [], false ,i_model_empty, (Sup_TEST Input_Descript.Domain, Position.T)), \n" ^
|
Walther@60751
|
436 |
"(0, [], false ,i_model_empty, (Sup_TEST ErrorBound, Position.T)), \n" ^
|
Walther@60751
|
437 |
"(0, [], false ,i_model_empty, (Sup_TEST AdditionalValues [], Position.T))]"
|
Walther@60751
|
438 |
(*+*)then () else error "s_make_complete: from_met CHANGED";
|
Walther@60747
|
439 |
\<close> ML \<open>
|
Walther@60751
|
440 |
val (met_max_vnts, _) = Model_Def.max_variants i_from_met;
|
Walther@60751
|
441 |
(*+*)val [2] = met_max_vnts
|
Walther@60747
|
442 |
\<close> ML \<open>
|
Walther@60751
|
443 |
val met_max_vnt = hd met_max_vnts (*need only one for solve-phase*)
|
Walther@60747
|
444 |
\<close> ML \<open>
|
Walther@60751
|
445 |
val met_from_pbl = map ((fn i_single as (_, _, _, _, (feedb, _)) =>
|
Walther@60751
|
446 |
if is_empty_single_TEST i_single
|
Walther@60751
|
447 |
then
|
Walther@60751
|
448 |
case get_descr_vnt' feedb [met_max_vnt] o_model of
|
Walther@60751
|
449 |
[] => raise ERROR (msg [met_max_vnt] feedb)
|
Walther@60751
|
450 |
| o_singles => map transfer_terms o_singles
|
Walther@60751
|
451 |
else [i_single (*fetched before from met_imod*)])) i_from_met |> flat
|
Walther@60747
|
452 |
\<close> ML \<open>
|
Walther@60751
|
453 |
(*+*)if (met_from_pbl |> I_Model.to_string_TEST @{context}) = "[\n" ^
|
Walther@60747
|
454 |
"(1, [1, 2, 3], true ,#Given, (Cor_TEST Constants [r = 7] , pen2str, Position.T)), \n" ^
|
Walther@60747
|
455 |
"(2, [1, 2, 3], true ,#Find, (Cor_TEST Maximum A , pen2str, Position.T)), \n" ^
|
Walther@60747
|
456 |
"(4, [1, 2, 3], true ,#Relate, (Cor_TEST Extremum (A = 2 * u * v - u \<up> 2) , pen2str, Position.T)), \n" ^
|
Walther@60747
|
457 |
"(5, [1, 2], true ,#Relate, (Cor_TEST SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2] , pen2str, Position.T)), \n" ^
|
Walther@60751
|
458 |
"(8, [2], true ,#undef, (Cor_TEST FunctionVariable b , pen2str, Position.T)), \n" ^
|
Walther@60751
|
459 |
"(10, [1, 2], true ,#undef, (Cor_TEST Input_Descript.Domain {0<..<r} , pen2str, Position.T)), \n" ^
|
Walther@60751
|
460 |
"(12, [1, 2, 3], true ,#undef, (Cor_TEST ErrorBound (\<epsilon> = 0) , pen2str, Position.T)), \n" ^
|
Walther@60747
|
461 |
"(3, [1, 2, 3], true ,#Find, (Cor_TEST AdditionalValues [u, v] , pen2str, Position.T))]"
|
Walther@60751
|
462 |
(*+*)then () else error "s_make_complete: met_from_pbl CHANGED";
|
Walther@60747
|
463 |
\<close> ML \<open>
|
Walther@60751
|
464 |
val return_s_make_complete_step = (pbl_from_o_model, met_from_pbl)
|
Walther@60751
|
465 |
\<close> ML \<open> (*\------------ step into s_make_complete -------------------------------------------//*)
|
Walther@60751
|
466 |
(*\------------------- step into s_make_complete -------------------------------------------//*)
|
Walther@60751
|
467 |
if return_s_make_complete = return_s_make_complete_step
|
Walther@60751
|
468 |
then () else error "s_make_complete: stewise construction <> value of fun"
|
Walther@60722
|
469 |
\<close> ML \<open>
|
Walther@60736
|
470 |
\<close>
|
Walther@60715
|
471 |
|
Walther@60736
|
472 |
section \<open>===================================================================================\<close>
|
Walther@60736
|
473 |
section \<open>===== ===========================================================================\<close>
|
Walther@60736
|
474 |
ML \<open>
|
Walther@60715
|
475 |
\<close> ML \<open>
|
Walther@60715
|
476 |
|
Walther@60723
|
477 |
\<close> ML \<open>
|
Walther@60736
|
478 |
\<close>
|
Walther@60736
|
479 |
|
neuper@52102
|
480 |
end
|