1 theory Test_VSCode_Example
2 imports "Isac.Calculation"
5 subsubsection \<open>Complete Specification at once\<close>
7 Just a test, that this works also in $ISABELLE_ISAC_TEST
9 Example "Diff_App-No.123a"
12 Given: \<open>Constants [r = 7]\<close>
13 Where: \<open>0 < r\<close>
14 Find: \<open>Maximum A\<close> \<open>AdditionalValues [u, v]\<close>
15 Relate: \<open>Extremum A = 2 * u * v - u \<up> 2\<close>
16 \<open>SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]\<close>
19 Theory_Ref: "Diff_App"
20 \<Otimes> Problem_Ref: "univariate_calculus/Optimisation"
21 \<Odot> Method_Ref: "Optimisation/by_univariate_calculus"
25 subsubsection \<open>Specification step by step\<close>
28 In an electronic textbook there shall be references to examples given, for instance,
29 by \<open>Example "Diff_App-No.123a"\<close>. Such a reference shall be easily "activated"
30 to start a Solution at the spot ?and?or? to open a separate window.
32 Activating the reference \<open>Example "Diff_App-No.123a"\<close> shall result in a threefold alternative,
33 where (2)=(3) for the parsers:
34 (1) the Example presents a "normal problem" with a Specification (preferred by engineers),
35 see above subsubsection \<open>Empty Specification\<close>,
36 (2) the Example presents a "normal problem" without a Specification (preferred in high-school):
37 |Example "Diff_App-No.123a"
40 | ..first formula as given by the specifid Method..
41 (3) the Example presents a "CAS_Cmd":
42 |Example "Linear_Equation/No.123 a"
45 | solve (x + 1 = 2, x)
46 \<open>Specification\<close> is always visible in order to remind of the existence.
47 \<open>Outer_Syntax.command \<^command_keyword>\<open>Example\<close>\<close> shall be able to parse all three cases
48 (while still skipping considerations about \<open>Specification\<close> and sub-problems).
50 Below is the Example with case (1):
51 * The lines \<open>text --- remove this line and make content Isar input---\\<close>
52 and ---------- remove this line and make content Isar input---/
53 will be deleted after correct implementation
54 * The \<open>ML \<open>blocks\<close>\<close> in between show, that ISAC is able of "next step guidance";
55 can be deleted as well.
56 * This Example also shows the toggle between \<open>\<Otimes>\<close> and \<open>\<Odot>\<close>.
60 # 1: ISAC starts the Example by presenting an "empty" Specification:
62 ML \<open> (* # 1: At the first call of \<open>Example\<close> ISAC initialises a calculation *)
63 val p = ([], Pos.Pbl);
64 val pt = update_state (*here we have Ctree.EmptyPtree and thus call init_ctree*)
66 (* Problem.parse_model_input results in markup, which is accepted by \<open>fun update_state\<close>, too:
67 Constants [r = 7] *)
68 ( [("#Given", ["Constants [r = 7]"]),
69 ("#Where", ["0 < r"]),
70 ("#Find", ["Maximum A", "AdditionalValues [u, v]"]),
71 ("#Relate", ["Extremum A = 2 * u * v - u \<up> 2",
72 "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]"])
74 ("Diff_App", ["univariate_calculus", "Optimisation"], ["Optimisation", "by_univariate_calculus"])
75 (*References_Def.explode_id ^^^^^^^^^^^^^^^^^^^^^^, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
80 Example "Diff_App-No.123a"
83 Given: \<open>Constants [r = 7]\<close>
84 Where: \<open>0 < r\<close>
85 Find: \<open>Maximum _\<close> \<open>AdditionalValues [_]\<close>
86 Relate: \<open>Extremum _\<close> \<open>SideConditions [_]\<close>
90 \<Otimes> Problem_Ref: "_/_"
91 \<Odot> Method_Ref: "_/_"
96 # 2: The user inputs a next item, which is marked "correct" by ISAC:
98 ML \<open> (* # 2: ISAC suggests a next item on request *)
99 val ("ok", ([(Tactic.Add_Given "Constants [r = 7]", _, _)], _, ptp))
100 = Step.specify_do_next ptp;
102 Example "Diff_App-No.123a"
105 Given: \<open>Constants r = 7\<close>
106 Where: \<open>0 < r\<close>
107 Find: \<open>Maximum _\<close> \<open>AdditionalValues [_]\<close>
108 Relate: \<open>Extremum _\<close> \<open>SideConditions [_]\<close>
112 \<Otimes> Problem_Ref: "_/_"
113 \<Odot> Method_Ref: "_/_"
118 # 3: The user inputs a next item somewhere in the \<open>Specification\<close>;
119 Since this item requests for a list, \<open>AdditionalValues\<close> is marked "incomplete":
121 ML \<open> (* 3: ISAC suggests a next item within a term list *)
122 val ("ok", ([(Tactic.Add_Find "Maximum A", _, _)], _, ptp))
123 = Step.specify_do_next ptp;
125 Example "Diff_App-No.123a"
128 Given: \<open>Constants r = 7\<close>
129 Where: \<open>0 < r\<close>
130 Find: \<open>Maximum _\<close> \<open>AdditionalValues [u]\<close>
131 Relate: \<open>Extremum _\<close> \<open>SideConditions [_]\<close>
135 \<Otimes> Problem_Ref: "_/_"
136 \<Odot> Method_Ref: "_/_"
141 # 4: The user inputs a next item, and the item \<open>AdditionalValues\<close> is marked "correct":
143 ML \<open> (* # 4: ISAC suggests a next step on request, even a next element within a list *)
144 val ("ok", ([(Tactic.Add_Find "AdditionalValues [u]", _, _)], _, ptp))
145 = Step.specify_do_next ptp;
148 Example "Diff_App-No.123a"
151 Given: \<open>Constants r = 7\<close>
152 Where: \<open>0 < r\<close>
153 Find: \<open>Maximum _\<close> \<open>AdditionalValues [u, v]\<close>
154 Relate: \<open>Extremum _\<close> \<open>SideConditions [_]\<close>
158 \<Otimes> Problem_Ref: "_/_"
159 \<Odot> Method_Ref: "_/_"
164 # 5: Input to \<open>Problem_Ref\<close> is according to the (hidden) formalisation:
166 ML \<open> (* # 5: Input to \<open>Problem_Ref\<close> might change the \<open>Model\<close> *)
168 Example "Diff_App-No.123a"
171 Given: \<open>Constants r = 7\<close>
172 Where: \<open>0 < r\<close>
173 Find: \<open>Maximum _\<close> \<open>AdditionalValues [u, v]\<close>
174 Relate: \<open>Extremum _\<close> \<open>SideConditions [_]\<close>
178 \<Otimes> Problem_Ref: "_/_"
179 \<Odot> Method_Ref: "_/_"
184 # 6: Input to \<open>Method_Ref\<close> changes the \<open>Model\<close> to the respective \<open>Method\<close>;
185 There is also a feature to change the \<open>Model\<close> according to
186 direct manipulation of \<open>\<Otimes>\<close> and \<open>\<Odot>\<close>.
188 ML \<open> (* # 6: Input to \<open>Method_Ref\<close> changes the \<open>Model\<close> to the respective \<open>Method\<close> *)
190 text \<open> --- remove this line and make content Isar input---\
191 Example "Diff_App-No.123a"
193 Model: GOON: lookup model of method GOON GOON GOON GOON GOON!
194 Given: \<open>Constants r = 7\<close>
195 Where: \<open>0 < r\<close>
196 Find: \<open>Maximum _\<close> \<open>AdditionalValues [u, v]\<close>
197 Relate: \<open>Extremum _\<close> \<open>SideConditions [_]\<close>
200 \<Odot> Problem_Ref: "univariate_calculus/Optimisation"
201 \<Otimes> Method_Ref: "Optimisation/by_univariate_calculus"
203 ---------- remove this line and make content Isar input---/
209 ML \<open> (* # 7: ISAC suggests a next step on request *)
211 text \<open> --- remove this line and make content Isar input---\
212 ---------- remove this line and make content Isar input---/
218 ML \<open> (* # 8: ISAC suggests a next step on request *)
220 text \<open> --- remove this line and make content Isar input---\
221 ---------- remove this line and make content Isar input---/
227 ML \<open> (* # 9: ISAC suggests a next step on request *)
229 text \<open> --- remove this line and make content Isar input---\
230 ---------- remove this line and make content Isar input---/