Walther@60433
|
1 |
(* Title: src/Tools/isac/BridgeJEdit/Demo_Example.thy
|
Walther@60433
|
2 |
Author: Walther Neuper, JKU Linz
|
Walther@60433
|
3 |
(c) due to copyright terms
|
Walther@60433
|
4 |
|
Walther@60433
|
5 |
Runnig example for developing Isabelle/Isac via Isabelle/PIDE in BridgeJEdit
|
Walther@60433
|
6 |
*)
|
Walther@60433
|
7 |
|
Walther@60433
|
8 |
theory Demo_Example
|
Walther@60433
|
9 |
imports Calculation
|
Walther@60433
|
10 |
begin
|
Walther@60433
|
11 |
|
Walther@60434
|
12 |
section \<open>Boilerplate, the example from Isabelle Workshop 2022\<close>
|
Walther@60433
|
13 |
|
Walther@60433
|
14 |
subsection \<open>Specification Phase\<close>
|
Walther@60433
|
15 |
text \<open>Goal for Isabelle Workshop 2022: this part of the example should be ready for demonstration:
|
Walther@60434
|
16 |
1. The keyword \<open>Example\<close> inserts the template underneath
|
Walther@60433
|
17 |
2. The template is filled from a (hidden) formalisation with the following items in the
|
Walther@60434
|
18 |
2.1. \<open>Model\<close>:
|
Walther@60433
|
19 |
* Constants _ ("_" indicates some kind of place holder for input)
|
Walther@60433
|
20 |
* the complete Where-field (the pre-condition), items marked as True | False
|
Walther@60433
|
21 |
* Maximum _, AdditionalValues _
|
Walther@60433
|
22 |
* Extremum _, SideCondition _
|
Walther@60434
|
23 |
2.2 \<open>References\<close>:
|
Walther@60433
|
24 |
* place holders "_" for input
|
Walther@60444
|
25 |
* The toggle switch before \<open>Problem_Ref\<close> | \<open>Method_Ref\<close> is set to \<open>Problem_Ref\<close>
|
Walther@60433
|
26 |
This might be postponed after the Isabelle Workshop.
|
Walther@60433
|
27 |
3. Input to 2.1 is
|
Walther@60433
|
28 |
* type checked and marked as Type-Error
|
Walther@60433
|
29 |
* marked as Correct | Superfluous | Incomplete | Unknown (compare Specify/p-model.sml)
|
Walther@60433
|
30 |
4. Input to 2.2 by selection from a list / tree
|
Walther@60444
|
31 |
5. On update of \<open>Problem_Ref\<close> (in the root problem) also \<open>Problem\<close> is updated;
|
Walther@60434
|
32 |
The argument of \<open>Problem\<close> comes with the template and is read-only.
|
Walther@60444
|
33 |
|
Walther@60444
|
34 |
The specific representation of the Demo_Example demonstrate different situations
|
Walther@60444
|
35 |
in educational settings.
|
Walther@60433
|
36 |
\<close>
|
Walther@60433
|
37 |
|
Walther@60433
|
38 |
subsubsection \<open>Complete Specification\<close>
|
Walther@60433
|
39 |
text \<open>
|
Walther@60444
|
40 |
* This is one correct result of interactive Specification.
|
Walther@60444
|
41 |
* Or this might be presented to the student in one go in order to start Solution immediately
|
Walther@60444
|
42 |
(and nevertheless make the Specification explicit)
|
Walther@60444
|
43 |
Note that \<open>Problem "univariate_calculus/Optimisation"\<close> and
|
Walther@60444
|
44 |
\<open>Problem_Ref: "univariate_calculus/Optimisation"\<close> are redundant; the latter is for input,
|
Walther@60444
|
45 |
the former is given initially and needs to be updated in accordance to \<open>Problem_Ref\<close>.
|
Walther@60444
|
46 |
\<close>
|
Walther@60444
|
47 |
text \<open> (*.. remove as soon as this works as Isabelle/Isar commands ..*)
|
Walther@60444
|
48 |
|
Walther@60444
|
49 |
Example "Diff_App/No.123 a"
|
Walther@60444
|
50 |
Problem "univariate_calculus/Optimisation"
|
Walther@60433
|
51 |
Specification:
|
Walther@60433
|
52 |
Model:
|
Walther@60444
|
53 |
Given: \<open>Constants r = 7\<close>
|
Walther@60444
|
54 |
Where: \<open>0 < r\<close>
|
Walther@60444
|
55 |
Find: \<open>Maximum A\<close> \<open>AdditionalValues u, v\<close>
|
Walther@60444
|
56 |
Relate: \<open>Extremum A = 2 \<sqdot> u \<sqdot> v − u \<up> 2\<close> \<open>SideCondition (u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2\<close>
|
Walther@60433
|
57 |
References:
|
Walther@60444
|
58 |
Theory_Ref: "Diff_App"
|
Walther@60444
|
59 |
\<Otimes> Problem_Ref: "univariate_calculus/Optimisation"
|
Walther@60444
|
60 |
\<Odot> Method_Ref: "Optimisation/by_univariate_calculus"
|
Walther@60433
|
61 |
Solution:
|
Walther@60444
|
62 |
|
Walther@60444
|
63 |
(* remove as soon as this ^^^ works as Isabelle/Isar commands ..*) \<close>
|
Walther@60433
|
64 |
|
Walther@60433
|
65 |
subsubsection \<open>Empty Specification\<close>
|
Walther@60433
|
66 |
text \<open>
|
Walther@60444
|
67 |
This is presented to the student in one go in order to start interactive Specification.
|
Walther@60444
|
68 |
\<close>
|
Walther@60444
|
69 |
text \<open> (*.. remove as soon as this works as Isabelle/Isar commands ..*)
|
Walther@60444
|
70 |
|
Walther@60444
|
71 |
Example "Diff_App/No.123 a"
|
Walther@60444
|
72 |
Problem "univariate_calculus/Optimisation"
|
Walther@60433
|
73 |
Specification:
|
Walther@60433
|
74 |
Model:
|
Walther@60444
|
75 |
Given: \<open>Constants _\<close>
|
Walther@60444
|
76 |
Where: \<open>0 < r\<close>
|
Walther@60444
|
77 |
Find: \<open>Maximum _\<close> \<open>AdditionalValues _\<close>
|
Walther@60444
|
78 |
Relate: \<open>Extremum _\<close> \<open>SideCondition _\<close>
|
Walther@60433
|
79 |
References:
|
Walther@60444
|
80 |
Theory_Ref: "_"
|
Walther@60444
|
81 |
\<Otimes> Problem_Ref: "_"
|
Walther@60444
|
82 |
\<Odot> Method_Ref: "_"
|
Walther@60433
|
83 |
Solution:
|
Walther@60444
|
84 |
|
Walther@60444
|
85 |
(* remove as soon as this ^^^ works as Isabelle/Isar commands ..*) \<close>
|
Walther@60444
|
86 |
|
Walther@60444
|
87 |
subsubsection \<open>Plain Example\<close>
|
Walther@60444
|
88 |
text \<open>
|
Walther@60444
|
89 |
This can occur in between text offering to start an interactive Calculation by using
|
Walther@60444
|
90 |
"Diff_App/No.123 a" as a link.
|
Walther@60433
|
91 |
\<close>
|
Walther@60444
|
92 |
text \<open> (*.. remove as soon as this works as Isabelle/Isar commands ..*)
|
Walther@60444
|
93 |
|
Walther@60444
|
94 |
Example "Diff_App/No.123 a"
|
Walther@60444
|
95 |
|
Walther@60444
|
96 |
(* remove as soon as this ^^^ works as Isabelle/Isar commands ..*) \<close>
|
Walther@60444
|
97 |
|
Walther@60444
|
98 |
subsubsection \<open>Immediate Start of Interactive Solving\<close>
|
Walther@60444
|
99 |
text \<open>
|
Walther@60444
|
100 |
This
|
Walther@60444
|
101 |
\<close>
|
Walther@60444
|
102 |
text \<open> (*.. remove as soon as this works as Isabelle/Isar commands ..*)
|
Walther@60444
|
103 |
|
Walther@60444
|
104 |
Example "Diff_App/No.123 a"
|
Walther@60444
|
105 |
Problem "univariate_calculus/Optimisation"
|
Walther@60444
|
106 |
Specification:
|
Walther@60444
|
107 |
Solution:
|
Walther@60444
|
108 |
|
Walther@60444
|
109 |
(* remove as soon as this ^^^ works as Isabelle/Isar commands ..*) \<close>
|
Walther@60444
|
110 |
|
Walther@60444
|
111 |
subsubsection \<open>Show the Model associated to Method_Ref\<close>
|
Walther@60444
|
112 |
text \<open>
|
Walther@60444
|
113 |
The Model of a method usually comprises more items than the model of a Problem: all these
|
Walther@60444
|
114 |
are required to run the program such that it automatically generates a Solution. For instance,
|
Walther@60444
|
115 |
compare \<open>problem pbl_bieg\<close> and \<open>method met_biege_2\<close> in \<open>Biegelinie.thy\<close>
|
Walther@60444
|
116 |
(TODO: method/program for \<open>Problem "univariate_calculus/Optimisation"\<close>)
|
Walther@60444
|
117 |
The Model of a method is usually called a guard.
|
Walther@60444
|
118 |
\<close>
|
Walther@60444
|
119 |
text \<open> (*.. remove as soon as this works as Isabelle/Isar commands ..*)
|
Walther@60444
|
120 |
|
Walther@60444
|
121 |
Example "Diff_App/No.123 a"
|
Walther@60444
|
122 |
Problem "univariate_calculus/Optimisation"
|
Walther@60444
|
123 |
Specification:
|
Walther@60444
|
124 |
Model:
|
Walther@60444
|
125 |
Given: \<open>Constants r = 7\<close>
|
Walther@60444
|
126 |
Where: \<open>0 < r\<close>
|
Walther@60444
|
127 |
Find: \<open>Maximum A\<close> \<open>AdditionalValues u, v\<close>
|
Walther@60444
|
128 |
Relate: \<open>Extremum A = 2 \<sqdot> u \<sqdot> v − u \<up> 2\<close> \<open>SideCondition (u / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2\<close>
|
Walther@60444
|
129 |
References:
|
Walther@60444
|
130 |
Theory_Ref: "Diff_App"
|
Walther@60444
|
131 |
\<Odot> Problem_Ref: "univariate_calculus/Optimisation"
|
Walther@60444
|
132 |
\<Otimes> Method_Ref: "Optimisation/by_univariate_calculus"
|
Walther@60444
|
133 |
Solution:
|
Walther@60444
|
134 |
|
Walther@60444
|
135 |
(* remove as soon as this ^^^ works as Isabelle/Isar commands ..*) \<close>
|
Walther@60444
|
136 |
|
Walther@60433
|
137 |
|
Walther@60433
|
138 |
section \<open>Stepwise Development\<close>
|
Walther@60434
|
139 |
|
Walther@60433
|
140 |
subsection \<open>Specification Phase\<close>
|
Walther@60441
|
141 |
text \<open>
|
Walther@60444
|
142 |
Stepwise development of \<open>Outer_Syntax.command \<^command_keyword>\<open>Example\<close>\<close> begins with
|
Walther@60444
|
143 |
the changeset https://hg.risc.uni-linz.ac.at/wneuper/isa/rev/9d98791b4080
|
Walther@60444
|
144 |
in the repository.
|
Walther@60444
|
145 |
|
Walther@60444
|
146 |
The intermediate steps below will be deleted as soon as all above representations
|
Walther@60444
|
147 |
of \<open>Example "Diff_App/No.123 a"\<close> work out.
|
Walther@60434
|
148 |
\<close>
|
Walther@60433
|
149 |
|
Walther@60438
|
150 |
Example pbl_bieg : "Biegelinien" =
|
Walther@60434
|
151 |
Method: "IntegrierenUndKonstanteBestimmen2"
|
Walther@60434
|
152 |
Given: "Traegerlaenge l_l" "Streckenlast q_q"
|
Walther@60434
|
153 |
(* Where: "0 < l_l" ...wait for < and handling Arbfix*)
|
Walther@60434
|
154 |
Find: "Biegelinie b_b"
|
Walther@60434
|
155 |
Relate: "Randbedingungen r_b"
|
Walther@60433
|
156 |
|
Walther@60439
|
157 |
ML \<open>
|
Walther@60443
|
158 |
val state = the_data @{theory};
|
Walther@60443
|
159 |
|
Walther@60443
|
160 |
if Ctree.get_obj Ctree.g_spec state [] =
|
Walther@60443
|
161 |
("empty_thy_id", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]) then ()
|
Walther@60443
|
162 |
else error "Example's values not stored correctly";
|
Walther@60436
|
163 |
\<close> ML \<open>
|
Walther@60434
|
164 |
\<close> ML \<open>
|
Walther@60434
|
165 |
\<close> ML \<open>
|
Walther@60434
|
166 |
\<close>
|
Walther@60433
|
167 |
|
Walther@60433
|
168 |
end |