Walther@60468
|
1 |
(* Title: "BridgeJEdit/vscode-example.sml"
|
Walther@60468
|
2 |
Author: Walther Neuper
|
Walther@60468
|
3 |
(c) due to copyright terms
|
Walther@60468
|
4 |
*)
|
Walther@60468
|
5 |
|
Walther@60468
|
6 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60468
|
7 |
"table of contents -----------------------------------------------------------------------------";
|
Walther@60468
|
8 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60468
|
9 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60468
|
10 |
"----------- VSCode example with Step.specify_do_next ------------------------------------------";
|
Walther@60468
|
11 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60468
|
12 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60468
|
13 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60468
|
14 |
|
Walther@60468
|
15 |
(**** VSCode example with Step.specify_do_next ########################################### ****)
|
Walther@60468
|
16 |
"----------- VSCode example with Step.specify_do_next ------------------------------------------";
|
Walther@60468
|
17 |
"----------- VSCode example with Step.specify_do_next ------------------------------------------";
|
Walther@60468
|
18 |
val c = []:cid;
|
Walther@60468
|
19 |
val fmz = [
|
Walther@60468
|
20 |
(*Problem model:*)
|
Walther@60468
|
21 |
"Constants [r = (7::real)]", "Maximum A", "AdditionalValues [u, v]",
|
Walther@60468
|
22 |
"Extremum (A = 2 * u * v - u \<up> 2)",
|
Walther@60468
|
23 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]",
|
Walther@60468
|
24 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]",
|
Walther@60468
|
25 |
"SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]",
|
Walther@60508
|
26 |
(*MethodC model:*)
|
Walther@60468
|
27 |
"FunctionVariable a", "FunctionVariable b", "FunctionVariable \<alpha>",
|
Walther@60468
|
28 |
"Domain {0 <..< r}",
|
Walther@60468
|
29 |
"Domain {0 <..< r}",
|
Walther@60468
|
30 |
"Domain {0 <..< \<pi> / 2}",
|
Walther@60468
|
31 |
"ErrorBound (\<epsilon> = (0::real))"
|
Walther@60468
|
32 |
]: TermC.as_string list;
|
Walther@60468
|
33 |
if (fmz |> map (TermC.parseNEW @{context}) |> filter is_some |> length) = 14
|
Walther@60468
|
34 |
then () else error "Formalise.model not parsed completely";
|
Walther@60468
|
35 |
|
Walther@60493
|
36 |
val refs =
|
Walther@60468
|
37 |
("Diff_App", ["univariate_calculus", "Optimisation"], ["Optimisation", "by_univariate_calculus"]);
|
Walther@60493
|
38 |
|
Walther@60493
|
39 |
(*/------- start example as usual in tests ---------------------------------------------------* )
|
Walther@60468
|
40 |
val (p,_,f, nxt,_,pt) = CalcTreeTEST [(fmz, refs)];
|
Walther@60493
|
41 |
val ptp = (pt, p);
|
Walther@60493
|
42 |
( *-------- outcomment EITHER above OR below --------------------------------------------------*)
|
Walther@60506
|
43 |
case Store.get (KEStore_Elems.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"] of
|
Walther@60493
|
44 |
(_, ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: _,
|
Walther@60493
|
45 |
("Diff_App", ["univariate_calculus", "Optimisation"] ,["Optimisation", "by_univariate_calculus"])))
|
Walther@60493
|
46 |
=> ()
|
Walther@60493
|
47 |
| _ => error "intermed. example_store CHANGED";
|
Walther@60493
|
48 |
val p = ([], Pbl);
|
Walther@60493
|
49 |
val pt = update_state (*here we have Ctree.EmptyPtree and thus call init_ctree*)
|
Walther@60506
|
50 |
("Diff_App-No.123a",
|
Walther@60493
|
51 |
(* Problem.parse_model_input results in markup, which is accepted by \<open>fun update_state\<close>, too:
|
Walther@60493
|
52 |
Constants [r = 7] *)
|
Walther@60493
|
53 |
( [("#Given", ["Constants [r = 7]"]),
|
Walther@60493
|
54 |
("#Where", ["0 < r"]),
|
Walther@60493
|
55 |
("#Find", ["Maximum A", "AdditionalValues [u, v]"]),
|
Walther@60493
|
56 |
("#Relate", ["Extremum A = 2 * u * v - u \<up> 2",
|
Walther@60493
|
57 |
"SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]"])
|
Walther@60493
|
58 |
],
|
Walther@60493
|
59 |
("Diff_App", ["univariate_calculus", "Optimisation"], ["Optimisation", "by_univariate_calculus"])
|
Walther@60493
|
60 |
(*References_Def.explode_id ^^^^^^^^^^^^^^^^^^^^^^, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
|
Walther@60493
|
61 |
)
|
Walther@60493
|
62 |
) Ctree.EmptyPtree;
|
Walther@60493
|
63 |
val ptp = (pt, p);
|
Walther@60493
|
64 |
(*\------- start example as required in VSCode_Example.thy -----------------------------------*)
|
Walther@60468
|
65 |
|
Walther@60468
|
66 |
(*** stepwise Specification: Problem model================================================= ***)
|
Walther@60493
|
67 |
(** ) we drop this step, because the user shall be presented a (empty) Model ... ( ** )
|
Walther@60468
|
68 |
val ("ok", ([(Model_Problem, Model_Problem' (["univariate_calculus", "Optimisation"], _, _), _)], _, ptp))
|
Walther@60468
|
69 |
= Step.specify_do_next ptp;
|
Walther@60493
|
70 |
( **)
|
Walther@60493
|
71 |
val ("ok", ([(Tactic.Add_Given "Constants [r = 7]", _, _)], _, ptp))
|
Walther@60468
|
72 |
= Step.specify_do_next ptp;
|
Walther@60493
|
73 |
val ("ok", ([(Tactic.Add_Find "Maximum A", _, _)], _, ptp))
|
Walther@60468
|
74 |
= Step.specify_do_next ptp;
|
Walther@60493
|
75 |
val ("ok", ([(Tactic.Add_Find "AdditionalValues [u]", _, _)], _, ptp))
|
Walther@60468
|
76 |
= Step.specify_do_next ptp;
|
Walther@60493
|
77 |
val ("ok", ([(Tactic.Add_Find "AdditionalValues [v]", _, _)], _, ptp))
|
Walther@60468
|
78 |
= Step.specify_do_next ptp;
|
Walther@60493
|
79 |
val ("ok", ([(Tactic.Add_Relation "Extremum (A = 2 * u * v - u \<up> 2)", _, _)], _, ptp))
|
Walther@60493
|
80 |
= Step.specify_do_next ptp;
|
Walther@60493
|
81 |
val ("ok", ([(Tactic.Add_Relation "SideConditions [(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]", _, _)], _, ptp))
|
Walther@60468
|
82 |
= Step.specify_do_next ptp;
|
Walther@60468
|
83 |
|
Walther@60468
|
84 |
(*** Problem model is complete ============================================================ ***)
|
Walther@60468
|
85 |
val PblObj {probl, ...} = get_obj I (fst ptp) [];
|
Walther@60468
|
86 |
if I_Model.to_string @{context} probl = "[\n" ^
|
Walther@60468
|
87 |
"(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] ,(fixes, [[r = 7]])), \n" ^
|
Walther@60468
|
88 |
"(2 ,[1, 2, 3] ,true ,#Find ,Cor Maximum A ,(maxx, [A])), \n" ^
|
Walther@60468
|
89 |
"(3 ,[1, 2, 3] ,true ,#Find ,Cor AdditionalValues [u, v] ,(vals, [[u, v]])), \n" ^
|
Walther@60468
|
90 |
"(4 ,[1, 2, 3] ,true ,#Relate ,Cor Extremum (A = 2 * u * v - u \<up> 2) ,(extr, [A = 2 * u * v - u \<up> 2])), \n" ^
|
Walther@60468
|
91 |
"(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]]))]"
|
Walther@60468
|
92 |
then () else error "I_Model.to_string probl CHANGED";
|
Walther@60468
|
93 |
|
Walther@60493
|
94 |
(*//---------------- adhoc inserted ------------------------------------------------\\*)
|
Walther@60493
|
95 |
(*with update_state*)
|
Walther@60493
|
96 |
(* already been input -------vvvvvvvvvvvvvvvvvvv: code in check_input is missing*)
|
Walther@60493
|
97 |
(*+*)val ("ok", ([(Tactic.Add_Given "Constants [r = 7]", _, _)], _, ptp))
|
Walther@60493
|
98 |
= (**) Step.specify_do_next ptp;
|
Walther@60493
|
99 |
(*with update_state*)
|
Walther@60493
|
100 |
(*+*)val ("ERROR I_Model.check_single: \"Maximum A\"\" not for field \"#Find\"", ([], [], ptp))
|
Walther@60493
|
101 |
= (**) Step.specify_do_next ptp;
|
Walther@60493
|
102 |
(*\\---------------- adhoc inserted ------------------------------------------------//*)
|
Walther@60493
|
103 |
|
Walther@60493
|
104 |
(*** Specification of References ========================================================== *** )
|
Walther@60468
|
105 |
val ("ok", ([(Specify_Theory "Diff_App", _, _)], _, ptp))
|
Walther@60468
|
106 |
= Step.specify_do_next ptp;
|
Walther@60468
|
107 |
val ("ok", ([(Specify_Problem ["univariate_calculus", "Optimisation"], _, _)], _, ptp))
|
Walther@60468
|
108 |
= Step.specify_do_next ptp;
|
Walther@60468
|
109 |
val ("ok", ([(Specify_Method ["Optimisation", "by_univariate_calculus"], _, _)], _, ptp))
|
Walther@60468
|
110 |
= Step.specify_do_next ptp;
|
Walther@60493
|
111 |
---------------------------------------------------------------------- trace from CalcTreeTEST*)
|
Walther@60468
|
112 |
|
Walther@60493
|
113 |
(*** stepwise Specification: MethodC model ================================================ ***
|
Walther@60493
|
114 |
)
|
Walther@60468
|
115 |
val ("ok", ([(Add_Given "FunctionVariable a", _, _)], _, ptp))
|
Walther@60468
|
116 |
= Step.specify_do_next ptp;
|
Walther@60468
|
117 |
val ("ok", ([(Add_Given "Input_Descript.Domain {0<..<r}", _, _)], _, ptp))
|
Walther@60468
|
118 |
= Step.specify_do_next ptp;
|
Walther@60468
|
119 |
val ("ok", ([(Add_Given "ErrorBound (\<epsilon> = 0)", _, _)], _, ptp))
|
Walther@60468
|
120 |
= Step.specify_do_next ptp;
|
Walther@60493
|
121 |
---------------------------------------------------------------------- trace from CalcTreeTEST*)
|
Walther@60468
|
122 |
|
Walther@60468
|
123 |
(*** Specification of Problem and MethodC model is complete =============================== ***)
|
Walther@60468
|
124 |
val PblObj {meth, ...} = get_obj I (fst ptp) [];
|
Walther@60493
|
125 |
(*with update_state*)
|
Walther@60493
|
126 |
if I_Model.to_string @{context} meth = ("[\n" ^
|
Walther@60493
|
127 |
"(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] ,(fixes, [[r = 7]]))]"
|
Walther@60493
|
128 |
) then () else error "ERROR output CHANGED";
|
Walther@60493
|
129 |
|
Walther@60493
|
130 |
(*with CalcTreeTEST* )
|
Walther@60493
|
131 |
if I_Model.to_string @ {context} meth = "[\n" ^
|
Walther@60468
|
132 |
"(1 ,[1, 2, 3] ,true ,#Given ,Cor Constants [r = 7] ,(fixes, [[r = 7]])), \n" ^
|
Walther@60468
|
133 |
"(2 ,[1, 2, 3] ,true ,#Find ,Cor Maximum A ,(maxx, [A])), \n" ^
|
Walther@60468
|
134 |
"(3 ,[1, 2, 3] ,true ,#Find ,Cor AdditionalValues [u, v] ,(vals, [[u, v]])), \n" ^
|
Walther@60468
|
135 |
"(4 ,[1, 2, 3] ,true ,#Relate ,Cor Extremum (A = 2 * u * v - u \<up> 2) ,(extr, [A = 2 * u * v - u \<up> 2])), \n" ^
|
Walther@60468
|
136 |
"(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" ^
|
Walther@60468
|
137 |
"(7 ,[1] ,true ,#Given ,Cor FunctionVariable a ,(funvar, [a])), \n" ^
|
Walther@60468
|
138 |
"(10 ,[1, 2] ,true ,#Given ,Cor Input_Descript.Domain {0<..<r} ,(doma, [{0<..<r}])), \n" ^
|
Walther@60468
|
139 |
"(12 ,[1, 2, 3] ,true ,#Given ,Cor ErrorBound (\<epsilon> = 0) ,(err, [\<epsilon> = 0]))]"
|
Walther@60468
|
140 |
then () else error "I_Model.to_string meth CHANGED";
|
Walther@60493
|
141 |
---------------------------------------------------------------------- trace from CalcTreeTEST*)
|
Walther@60468
|
142 |
|
Walther@60468
|
143 |
(*** Solution starts ====================================================================== ***)
|
Walther@60468
|
144 |
(*---
|
Walther@60468
|
145 |
Step.specify_do_next ptp;
|
Walther@60482
|
146 |
(*ERinROR in creating the environment from formal args. of partial_function "Diff_App.univar_optimisation"
|
Walther@60468
|
147 |
and the actual args., ie. items of the guard of "["Optimisation", "by_univariate_calculus"]" by "assoc_by_type":
|
Walther@60468
|
148 |
formal arg "err" of type "bool" doesn't mach an actual arg.
|
Walther@60468
|
149 |
with:
|
Walther@60468
|
150 |
7 formal args: ["fixes", "maxx", "extr", "sideconds", "funvar", "doma", "err"]
|
Walther@60468
|
151 |
7 actual args: ["[r = 7]", "A", "[(u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]", "a", "{0<..<r}", "\<epsilon> = 0", "[u, v]"]
|
Walther@60468
|
152 |
with types: ["bool list", "real", "bool list", "real", "real set", "bool", "real list"]*)
|
Walther@60468
|
153 |
---*)
|