test/Tools/isac/BridgeJEdit/Test_VSCode_Example.thy
author wneuper <Walther.Neuper@jku.at>
Thu, 04 Aug 2022 12:50:19 +0200
changeset 60510 851c82618f2e
parent 60491 045784ce9f33
child 60532 999794ca96b4
permissions -rw-r--r--
cleanup Example.id
     1 theory Test_VSCode_Example
     2   imports "Isac.Calculation"
     3 begin 
     4 
     5 subsubsection \<open>Complete Specification at once\<close>
     6 text \<open>
     7   Just a test, that this works also in $ISABELLE_ISAC_TEST
     8 \<close>
     9 Example "Diff_App-No.123a"
    10   Specification:
    11     Model:
    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>
    17     References: 
    18 (**  )
    19        Theory_Ref: "Diff_App"
    20     \<Otimes> Problem_Ref: "univariate_calculus/Optimisation"
    21     \<Odot> Method_Ref: "Optimisation/by_univariate_calculus"
    22   Solution:
    23 (  **)
    24 
    25 subsubsection \<open>Specification step by step\<close>
    26 
    27 text \<open>
    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.
    31 
    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"
    38     |  Specification:
    39     |  Solution:
    40     |    ..first formula as given by the specifid Method..
    41   (3) the Example presents a "CAS_Cmd":
    42     |Example "Linear_Equation/No.123 a"
    43     |  Specification:
    44     |  Solution:
    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).
    49 
    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>.
    57 \<close> 
    58 
    59 text \<open>
    60   # 1: ISAC starts the Example by presenting an "empty" Specification:
    61 \<close> 
    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*)
    65 ("Diff_App-No.123a", 
    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]"])
    73     ],
    74     ("Diff_App", ["univariate_calculus", "Optimisation"], ["Optimisation", "by_univariate_calculus"])
    75     (*References_Def.explode_id ^^^^^^^^^^^^^^^^^^^^^^, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
    76   )
    77 ) Ctree.EmptyPtree;
    78 val ptp = (pt, p);
    79 \<close>
    80 Example "Diff_App-No.123a"
    81   Specification:
    82     Model:
    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>
    87     References: 
    88 (**  )
    89        Theory_Ref: "_"
    90     \<Otimes> Problem_Ref: "_/_"
    91     \<Odot> Method_Ref: "_/_"
    92   Solution:
    93 (  **)
    94 
    95 text \<open>
    96   # 2: The user inputs a next item, which is marked "correct" by ISAC:
    97 \<close> 
    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;
   101 \<close>
   102 Example "Diff_App-No.123a"
   103   Specification:
   104     Model:
   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>
   109     References:
   110 (**  )
   111        Theory_Ref: "_"
   112     \<Otimes> Problem_Ref: "_/_"
   113     \<Odot> Method_Ref: "_/_"
   114   Solution:
   115 (  **)
   116 
   117 text \<open>
   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":
   120 \<close> 
   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;
   124 \<close>
   125 Example "Diff_App-No.123a"
   126   Specification:
   127     Model:
   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>
   132     References:
   133 (**  )
   134        Theory_Ref: "_"
   135     \<Otimes> Problem_Ref: "_/_"
   136     \<Odot> Method_Ref: "_/_"
   137   Solution:
   138 (  **)
   139 
   140 text \<open>
   141   # 4: The user inputs a next item, and the item \<open>AdditionalValues\<close> is marked "correct":
   142 \<close> 
   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;
   146 \<close>
   147 
   148 Example "Diff_App-No.123a"
   149   Specification:
   150     Model:
   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>
   155     References:
   156 (**  )
   157        Theory_Ref: "_"
   158     \<Otimes> Problem_Ref: "_/_"
   159     \<Odot> Method_Ref: "_/_"
   160   Solution:
   161 (  **)
   162 
   163 text \<open>
   164   # 5: Input to \<open>Problem_Ref\<close> is according to the (hidden) formalisation:
   165 \<close> 
   166 ML \<open> (* # 5: Input to \<open>Problem_Ref\<close> might change the \<open>Model\<close> *)
   167 \<close>
   168 Example "Diff_App-No.123a"
   169   Specification:
   170     Model:
   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>
   175     References:
   176 (**  )
   177        Theory_Ref: "_"
   178     \<Otimes> Problem_Ref: "_/_"
   179     \<Odot> Method_Ref: "_/_"
   180   Solution:
   181 (  **)
   182 
   183 text \<open>
   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>.
   187 \<close> 
   188 ML \<open> (* # 6: Input to \<open>Method_Ref\<close> changes the \<open>Model\<close> to the respective \<open>Method\<close> *)
   189 \<close>
   190 text \<open> --- remove this line and make content Isar input---\
   191 Example "Diff_App-No.123a"
   192   Specification:
   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>
   198     References:
   199        Theory_Ref: "_"
   200     \<Odot> Problem_Ref: "univariate_calculus/Optimisation"
   201     \<Otimes> Method_Ref: "Optimisation/by_univariate_calculus"
   202   Solution:
   203 ---------- remove this line and make content Isar input---/
   204 \<close>
   205 
   206 text \<open>
   207   # 7: xxxxx:
   208 \<close> 
   209 ML \<open> (* # 7: ISAC suggests a next step on request *)
   210 \<close>
   211 text \<open> --- remove this line and make content Isar input---\
   212 ---------- remove this line and make content Isar input---/
   213 \<close>
   214 
   215 text \<open>
   216   # 8: xxxxx:
   217 \<close> 
   218 ML \<open> (* # 8: ISAC suggests a next step on request *)
   219 \<close>
   220 text \<open> --- remove this line and make content Isar input---\
   221 ---------- remove this line and make content Isar input---/
   222 \<close>
   223 
   224 text \<open>
   225   # 9: xxxxx:
   226 \<close> 
   227 ML \<open> (* # 9: ISAC suggests a next step on request *)
   228 \<close>
   229 text \<open> --- remove this line and make content Isar input---\
   230 ---------- remove this line and make content Isar input---/
   231 \<close>
   232 
   233 ML \<open>
   234 \<close> ML \<open>
   235 \<close> ML \<open>
   236 \<close>
   237 
   238 end