walther@60044
|
1 |
(* Title: "BridgeJEdit/parseC.sml"
|
walther@60044
|
2 |
Author: Walther Neuper
|
walther@60044
|
3 |
(c) due to copyright terms
|
walther@60044
|
4 |
*)
|
walther@60044
|
5 |
|
walther@60044
|
6 |
"-----------------------------------------------------------------------------------------------";
|
walther@60044
|
7 |
"table of contents -----------------------------------------------------------------------------";
|
walther@60044
|
8 |
"-----------------------------------------------------------------------------------------------";
|
walther@60147
|
9 |
"----------- Problem headline ------------------------------------------------------------------";
|
walther@60147
|
10 |
"----------- Model -----------------------------------------------------------------------------";
|
walther@60147
|
11 |
"----------- References ------------------------------------------------------------------------";
|
walther@60147
|
12 |
"----------- Specification: References + Model -------------------------------------------------";
|
walther@60147
|
13 |
"----------- Tactics ---------------------------------------------------------------------------";
|
walther@60147
|
14 |
"----------- steps -----------------------------------------------------------------------------";
|
walther@60147
|
15 |
"----------- body ------------------------------------------------------------------------------";
|
walther@60147
|
16 |
"----------- Problem ---------------------------------------------------------------------------";
|
walther@60147
|
17 |
"----------- fun read_out_problem --------------------------------------------------------------";
|
walther@60147
|
18 |
"----------- THERE ARE TESTS with INCOMPLETE WORK IN Test_Parse_Isac.thy -----------------------";
|
walther@60147
|
19 |
"----------- parser for exp_file.str -----------------------------------------------------------";
|
walther@60044
|
20 |
"-----------------------------------------------------------------------------------------------";
|
walther@60044
|
21 |
"-----------------------------------------------------------------------------------------------";
|
walther@60044
|
22 |
"-----------------------------------------------------------------------------------------------";
|
walther@60147
|
23 |
|
walther@60147
|
24 |
Thy_Header.get_keywords' @{context};
|
walther@60147
|
25 |
(*
|
walther@60147
|
26 |
Keywords
|
walther@60147
|
27 |
{commands =
|
walther@60147
|
28 |
{(".",
|
walther@60147
|
29 |
{files = [], id = 39558, kind = "qed", pos =
|
walther@60147
|
30 |
{line=71, offset=3218, end_offset=3219, file=~~/src/Pure/Pure.thy}, tags = ["proof"]}),
|
walther@60147
|
31 |
:
|
walther@60147
|
32 |
minor =
|
walther@60147
|
33 |
{"!", "!!", "%", "(", ")", "+", ",", ":", "::", ";", "<", "<=", "=", "==", "=>", "?", "Find",
|
walther@60147
|
34 |
"Given", "Model", "Problem", "RMethod", "RProblem", "RTheory", "References", "Relate",
|
walther@60147
|
35 |
:
|
walther@60147
|
36 |
*)
|
walther@60147
|
37 |
|
walther@60147
|
38 |
"----------- Problem headline ------------------------------------------------------------------";
|
walther@60147
|
39 |
"----------- Problem headline ------------------------------------------------------------------";
|
walther@60147
|
40 |
"----------- Problem headline ------------------------------------------------------------------";
|
walther@60147
|
41 |
val problem_headline_str =
|
walther@60147
|
42 |
"( \"Biegelinie\" , [\"Biegelinien\"] )";
|
walther@60147
|
43 |
|
walther@60147
|
44 |
val toks = ParseC.tokenize problem_headline_str;
|
walther@60147
|
45 |
case ParseC.problem_headline toks of
|
walther@60147
|
46 |
((((("(", "Biegelinie"), ","), ["Biegelinien"]), ")"), [])
|
walther@60147
|
47 |
=> () | _ => error "parse problem_headline CHANGED"
|
walther@60147
|
48 |
|
walther@60147
|
49 |
|
walther@60147
|
50 |
"----------- Model -----------------------------------------------------------------------------";
|
walther@60147
|
51 |
"----------- Model -----------------------------------------------------------------------------";
|
walther@60147
|
52 |
"----------- Model -----------------------------------------------------------------------------";
|
walther@60147
|
53 |
val model_str = (
|
walther@60147
|
54 |
"Model:" ^
|
walther@60147
|
55 |
(*^^^^^^^^^^^^*)
|
walther@60147
|
56 |
"Given: \"Traegerlaenge L\", \"Streckenlast q_0\"" ^
|
walther@60147
|
57 |
"Where: \"q_0 ist_integrierbar_auf {| 0, L |}\", \"0 < L\"" ^
|
walther@60147
|
58 |
"Find: \"Biegelinie y\"" ^
|
walther@60147
|
59 |
"Relate: \"Randbedingungen [ Q_0 = q_0 * L, M_b L = 0, y_0 = 0, d_d x y_0 = 0 ]\""
|
walther@60147
|
60 |
);
|
walther@60147
|
61 |
val model_empty_str = ( (*Model before student's input"*)
|
walther@60147
|
62 |
"Model:" ^
|
walther@60147
|
63 |
(*^^^^^^^^^^^^*)
|
walther@60147
|
64 |
"Given: \"Traegerlaenge \", \"Streckenlast \"" ^
|
walther@60147
|
65 |
"Where: \"_ ist_integrierbar_auf {| |}\"" ^
|
walther@60147
|
66 |
"Find: \"Biegelinie \"" ^
|
walther@60147
|
67 |
"Relate: \"Randbedingungen [ ]\""
|
walther@60147
|
68 |
);
|
walther@60147
|
69 |
val model_str_opt = ( (*Model explicitly referring to RProblem (default), not RMethod*)
|
walther@60147
|
70 |
"Model ( RProblem ):" ^
|
walther@60147
|
71 |
(*^^^^^^^^^^^^*)
|
walther@60147
|
72 |
"Given: \"Traegerlaenge L\", \"Streckenlast q_0\"" ^
|
walther@60147
|
73 |
"Where: \"q_0 ist_integrierbar_auf {| 0, L |}\", \"0 < L\"" ^
|
walther@60147
|
74 |
"Find: \"Biegelinie y\"" ^
|
walther@60147
|
75 |
"Relate: \"Randbedingungen [ Q_0 = q_0 * L, M_b L = 0, y_0 = 0, d_d x y_0 = 0 ]\""
|
walther@60147
|
76 |
);
|
walther@60147
|
77 |
|
walther@60147
|
78 |
val toks = ParseC.tokenize model_str;
|
walther@60147
|
79 |
case ParseC.parse ParseC.model toks of
|
walther@60147
|
80 |
(((((((((((((((
|
walther@60147
|
81 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
82 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
83 |
"Where"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
84 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
85 |
"Relate"), ":"), [_(*"<markup>"*)]), [])
|
walther@60147
|
86 |
=> () | _ => error "parse model CHANGED";
|
walther@60147
|
87 |
|
walther@60147
|
88 |
"----------- Model before student's input";
|
walther@60147
|
89 |
val toks = ParseC.tokenize model_empty_str;
|
walther@60147
|
90 |
case ParseC.parse ParseC.model toks of
|
walther@60147
|
91 |
(((((((((((((((
|
walther@60147
|
92 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
93 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
94 |
"Where"), ":"), [_(*"<markup>"*) (*//, _(*"<markup>"*) //*)]),
|
walther@60147
|
95 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
96 |
"Relate"), ":"), [_(*"<markup>"*)]), [])
|
walther@60147
|
97 |
=> () | _ => error "parse model_empty_str CHANGED";
|
walther@60147
|
98 |
|
walther@60147
|
99 |
"----------- Model explicitly referring to RProblem (default), not RMethod";
|
walther@60147
|
100 |
val toks = ParseC.tokenize model_str_opt;
|
walther@60147
|
101 |
case ParseC.parse ParseC.model toks of
|
walther@60147
|
102 |
(((((((((((((((
|
walther@60147
|
103 |
"Model", (("(", "RProblem"), ")")), ":"),
|
walther@60147
|
104 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
105 |
"Where"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
106 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
107 |
"Relate"), ":"), [_(*"<markup>"*)]), [])
|
walther@60147
|
108 |
=> () | _ => error "parse model_str_opt CHANGED";
|
walther@60147
|
109 |
|
walther@60147
|
110 |
|
walther@60147
|
111 |
"----------- References ------------------------------------------------------------------------";
|
walther@60147
|
112 |
"----------- References ------------------------------------------------------------------------";
|
walther@60147
|
113 |
"----------- References ------------------------------------------------------------------------";
|
walther@60147
|
114 |
val references_collapsed_str = (
|
walther@60147
|
115 |
"References:"
|
walther@60147
|
116 |
);
|
walther@60147
|
117 |
val references_str = (
|
walther@60147
|
118 |
"References:" ^
|
walther@60147
|
119 |
"RTheory: \"Biegelinie\"" ^
|
walther@60147
|
120 |
"RProblem: [\"Biegelinien\"]" ^
|
walther@60147
|
121 |
"RMethod: [\"Integrieren\", \"KonstanteBestimmen2\"]"
|
walther@60147
|
122 |
);
|
walther@60147
|
123 |
val references_empty_str = (
|
walther@60147
|
124 |
"References:" ^
|
walther@60147
|
125 |
"RTheory: \"\"" ^
|
walther@60147
|
126 |
"RProblem: [\"\"]" ^
|
walther@60147
|
127 |
"RMethod: [\"\"]"
|
walther@60147
|
128 |
);
|
walther@60147
|
129 |
|
walther@60147
|
130 |
case ParseC.parse ParseC.references (ParseC.tokenize references_collapsed_str) of
|
walther@60147
|
131 |
((("References", ":"), (((((((("", ""), ""), ""), ""), []), ""), ""), [])), [])
|
walther@60147
|
132 |
=> () | _ => error "parse references_collapsed CHANGED";
|
walther@60147
|
133 |
|
walther@60147
|
134 |
case ParseC.parse ParseC.references (ParseC.tokenize references_str) of (((
|
walther@60147
|
135 |
"References", ":"),
|
walther@60147
|
136 |
((((((((
|
walther@60147
|
137 |
"RTheory", ":"), "Biegelinie"),
|
walther@60147
|
138 |
"RProblem"), ":"), ["Biegelinien"]),
|
walther@60147
|
139 |
"RMethod"), ":"), ["Integrieren", "KonstanteBestimmen2"])),
|
walther@60147
|
140 |
[])
|
walther@60147
|
141 |
=> () | _ => error "parse references CHANGED";
|
walther@60147
|
142 |
|
walther@60147
|
143 |
case ParseC.parse ParseC.references (ParseC.tokenize references_empty_str) of (((
|
walther@60147
|
144 |
"References", ":"), ((((((((
|
walther@60147
|
145 |
"RTheory", ":"), ""),
|
walther@60147
|
146 |
"RProblem"), ":"), [""]),
|
walther@60147
|
147 |
"RMethod"), ":"), [""])),
|
walther@60147
|
148 |
[])
|
walther@60147
|
149 |
=> () | _ => error "parse references_empty_str CHANGED"
|
walther@60147
|
150 |
|
walther@60147
|
151 |
|
walther@60147
|
152 |
"----------- Specification: References + Model -------------------------------------------------";
|
walther@60147
|
153 |
"----------- Specification: References + Model -------------------------------------------------";
|
walther@60147
|
154 |
"----------- Specification: References + Model -------------------------------------------------";
|
walther@60147
|
155 |
val specification_str = (
|
walther@60147
|
156 |
"Specification:" ^
|
walther@60147
|
157 |
model_str ^
|
walther@60147
|
158 |
references_str
|
walther@60147
|
159 |
);
|
walther@60147
|
160 |
val specification_collapsed_str = (
|
walther@60147
|
161 |
" Specification:" (** ) ^
|
walther@60147
|
162 |
" Model:"^
|
walther@60147
|
163 |
" Given: \"Traegerlaenge L\", \"Streckenlast q_0\"" ^
|
walther@60147
|
164 |
" Where: \"q_0 ist_integrierbar_auf {| 0, L |}\", \"0 < L\"" ^
|
walther@60147
|
165 |
" Find: \"Biegelinie y\"" ^
|
walther@60147
|
166 |
" Relate: \"Randbedingungen [ Q_0 = q_0 * L, M_b L = 0, y_0 = 0, d_d x y_0 = 0 ]\"" ^
|
walther@60147
|
167 |
" References:" (**) ^
|
walther@60147
|
168 |
" RTheory: \"Biegelinie\"" (**) ^
|
walther@60147
|
169 |
" RProblem: [\"Biegelinien\"]" (**) ^
|
walther@60147
|
170 |
" RMethod: [\"Integrieren\", \"KonstanteBestimmen2\"]" ( **)
|
walther@60147
|
171 |
);
|
walther@60147
|
172 |
|
walther@60147
|
173 |
case ParseC.specification (ParseC.tokenize specification_str) of (((
|
walther@60147
|
174 |
"Specification", ":"),
|
walther@60147
|
175 |
(((((((((((((((
|
walther@60147
|
176 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
177 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
178 |
"Where"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
179 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
180 |
"Relate"), ":"), [_(*"<markup>"*)]),
|
walther@60147
|
181 |
((
|
walther@60147
|
182 |
"References", ":"), ((((((((
|
walther@60147
|
183 |
"RTheory", ":"), "Biegelinie"),
|
walther@60147
|
184 |
"RProblem"), ":"), ["Biegelinien"]),
|
walther@60147
|
185 |
"RMethod"), ":"), ["Integrieren", "KonstanteBestimmen2"])))),
|
walther@60147
|
186 |
[])
|
walther@60147
|
187 |
=> () | _ => error "parse specification (expanded) changed";
|
walther@60147
|
188 |
|
walther@60147
|
189 |
"----------- Specification collapsed";
|
walther@60147
|
190 |
case ParseC.parse ParseC.specification (ParseC.tokenize specification_collapsed_str) of (((
|
walther@60147
|
191 |
"Specification", ":"),
|
walther@60147
|
192 |
(*model*)((((((((((((((("", (("", ""), "")), ""), ""), ""), []), ""), ""), []), ""), ""), ""), ""), ""), []), (("", ""),
|
walther@60147
|
193 |
(*refs?*)(((((((("", ""), ""), ""), ""), []), ""), ""), [])))),
|
walther@60147
|
194 |
[])
|
walther@60147
|
195 |
=> () | _ => error "parse specification (collapsed) changed";
|
walther@60147
|
196 |
|
walther@60147
|
197 |
|
walther@60147
|
198 |
"----------- Tactics ---------------------------------------------------------------------------";
|
walther@60147
|
199 |
"----------- Tactics ---------------------------------------------------------------------------";
|
walther@60147
|
200 |
"----------- Tactics ---------------------------------------------------------------------------";
|
walther@60147
|
201 |
val tactic_Substitute_str =
|
walther@60147
|
202 |
"Tactic Substitute \"c_4 + c_3 * x + 1 / (-1 * EI)\" \"[c, c_1, c_2, c_4]\"";
|
walther@60147
|
203 |
val tactic_Rewrite_Set_Inst_str =
|
walther@60147
|
204 |
"Tactic Rewrite_Set_Inst \"[(bdv, x)]\" \"make_ratpoly_in\"";
|
walther@60147
|
205 |
val tactic_Check_Postcond_str =
|
walther@60147
|
206 |
"Tactic Check_Postcond [\"Biegelinien\", \"xxx\"]";
|
walther@60147
|
207 |
val final_result_str = "\"y x = -6 * q_0 * L ^ 2 / (-24 * EI)\"";
|
walther@60147
|
208 |
|
walther@60147
|
209 |
val toks1 = ParseC.tokenize "Substitute \"c_4 + c_3 * x + 1 / (-1 * EI)\" \"[c, c_1, c_2, c_4]\"";
|
walther@60147
|
210 |
case ParseC.substitute toks1 of ((("Substitute", _(*<markup>*)), _(*<markup>*)), [])
|
walther@60147
|
211 |
=> () | _ => error "parse Substitute CHANGED";
|
walther@60147
|
212 |
|
walther@60147
|
213 |
val toks2 = ParseC.tokenize "Rewrite_Set_Inst \"[(bdv, x)]\" \"make_ratpoly_in\"";
|
walther@60147
|
214 |
case ParseC.rewrite_set_inst toks2 of
|
walther@60147
|
215 |
((("Rewrite_Set_Inst", _(*<markup>*)), "make_ratpoly_in"), [])
|
walther@60147
|
216 |
=> () | _ => error "parse Rewrite_Set_Inst CHANGED";
|
walther@60147
|
217 |
|
walther@60147
|
218 |
val toks3 = ParseC.tokenize "Check_Postcond [\"Biegelinien\", \"xxx\"]";
|
walther@60147
|
219 |
case ParseC.check_postcond toks3 of (("Check_Postcond", ["Biegelinien", "xxx"]), [])
|
walther@60147
|
220 |
=> () | _ => error "parse Check_Postcond CHANGED";
|
walther@60147
|
221 |
|
walther@60147
|
222 |
"----------- Tactics collected";
|
walther@60147
|
223 |
val toks1' = ParseC.tokenize tactic_Substitute_str;
|
walther@60147
|
224 |
val toks2' = ParseC.tokenize tactic_Rewrite_Set_Inst_str;
|
walther@60147
|
225 |
val toks3' = ParseC.tokenize tactic_Check_Postcond_str;
|
walther@60147
|
226 |
|
walther@60147
|
227 |
ParseC.parse ParseC.tactic toks1'; (* = (("Tactic", "EXEC IMMEDIATELY: Substitute <markup> <markup>"), [])*)
|
walther@60147
|
228 |
ParseC.parse ParseC.tactic toks2'; (* = (("Tactic", "EXEC IMMEDIATELY: Rewrite_Set_Inst <markup> make_ratpoly_in"), [])*)
|
walther@60147
|
229 |
ParseC.parse ParseC.tactic toks3'; (* = (("Tactic", "EXEC IMMEDIATELY: Check_Postcond xxxBiegelinien"), [])*)
|
walther@60147
|
230 |
|
walther@60147
|
231 |
case ParseC.parse ParseC.tactic (ParseC.tokenize tactic_Substitute_str) of
|
walther@60147
|
232 |
(("Tactic", _(*"EXEC IMMEDIATELY: Substitute <markup> <markup>"*)), [])
|
walther@60147
|
233 |
=> () | _ => error "parse Tactic Substitute CHANGED";
|
walther@60147
|
234 |
|
walther@60147
|
235 |
|
walther@60147
|
236 |
"----------- steps -----------------------------------------------------------------------------";
|
walther@60147
|
237 |
"----------- steps -----------------------------------------------------------------------------";
|
walther@60147
|
238 |
"----------- steps -----------------------------------------------------------------------------";
|
walther@60147
|
239 |
val steps_1_str = "\"[c = -1 * L * q_0 / -1, c_2 = -1 * L ^ 2 * q_0 / 2, c_3 = 0, c_4 = 0]\"";
|
walther@60147
|
240 |
val steps_term_tac_str = (
|
walther@60147
|
241 |
final_result_str ^
|
walther@60147
|
242 |
" Tactic Check_Postcond [\"Biegelinien\"]"
|
walther@60147
|
243 |
);
|
walther@60147
|
244 |
val steps_nonrec_str = (
|
walther@60147
|
245 |
"\"[c = -1 * L * q_0 / -1, c_2 = -1 * L ^ 2 * q_0 / 2, c_3 = 0, c_4 = 0]\"" (**) ^
|
walther@60147
|
246 |
"\"y x = c_4 + c_3 * x + 1 / (-1 * EI)\"" (**) ^
|
walther@60147
|
247 |
tactic_Substitute_str ^
|
walther@60147
|
248 |
"\"y x = 0 + 0 * x + 1 / (-1 * EI)\"" (**) ^
|
walther@60147
|
249 |
tactic_Rewrite_Set_Inst_str ^
|
walther@60147
|
250 |
final_result_str (**) ^
|
walther@60147
|
251 |
tactic_Check_Postcond_str ^
|
walther@60147
|
252 |
final_result_str (**)
|
walther@60147
|
253 |
);
|
walther@60147
|
254 |
|
walther@60147
|
255 |
val toks1 = ParseC.tokenize steps_1_str;
|
walther@60147
|
256 |
val toks2 = ParseC.tokenize steps_term_tac_str;
|
walther@60147
|
257 |
val toks3 = ParseC.tokenize steps_nonrec_str;
|
walther@60147
|
258 |
|
walther@60147
|
259 |
"----------- simple version";
|
walther@60147
|
260 |
ParseC.parse ParseC.steps []; (* = ([], []): (string * (string * string)) list * Token.T list *)
|
walther@60147
|
261 |
ParseC.parse ParseC.steps toks1; (* = ([("<markup>", ("", ""))], [])*)
|
walther@60147
|
262 |
ParseC.parse ParseC.steps toks2; (* = ([("<markup>", ("Tactic", "EXEC IMMEDIATELY: Check_Postcond Biegelinien"))], [])*)
|
walther@60147
|
263 |
ParseC.parse ParseC.steps toks3;
|
walther@60147
|
264 |
|
walther@60147
|
265 |
case ParseC.parse ParseC.steps toks3 of
|
walther@60147
|
266 |
([(_(*"<markup>"*), ("", "")),
|
walther@60147
|
267 |
(_(*"<markup>"*), ("Tactic", _(*"EXEC IMMEDIATELY: Substitute <markup> <markup>"*))),
|
walther@60147
|
268 |
(_(*"<markup>"*), ("Tactic", _(*"EXEC IMMEDIATELY: Rewrite_Set_Inst <markup> make_ratpoly_in"*))),
|
walther@60147
|
269 |
(_(*"<markup>"*), ("Tactic", _(*"EXEC IMMEDIATELY: Check_Postcond Biegelinien"*))),
|
walther@60147
|
270 |
(_(*"<markup>"*), ("", ""))],
|
walther@60147
|
271 |
[])
|
walther@60147
|
272 |
=> () | _ => error "parse steps, simple version, CHANGED";
|
walther@60147
|
273 |
|
walther@60147
|
274 |
"----------- version preparing subproblems";
|
walther@60147
|
275 |
case ParseC.parse ParseC.steps_subpbl toks3 of
|
walther@60147
|
276 |
([_(*"EXEC IMMEDIATELY step_term: <markup> (, )"*),
|
walther@60147
|
277 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Substitute <markup> <markup>)"*),
|
walther@60147
|
278 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Rewrite_Set_Inst <markup> make_ratpoly_in)"*),
|
walther@60147
|
279 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Check_Postcond xxxBiegelinien)"*),
|
walther@60147
|
280 |
_(*"EXEC IMMEDIATELY step_term: <markup> (, )"*)],
|
walther@60147
|
281 |
[])
|
walther@60147
|
282 |
=> () | _ => error "parse steps, with exec_step_term, CHANGED";
|
walther@60147
|
283 |
|
walther@60147
|
284 |
|
walther@60147
|
285 |
"----------- body ------------------------------------------------------------------------------";
|
walther@60147
|
286 |
"----------- body ------------------------------------------------------------------------------";
|
walther@60147
|
287 |
"----------- body ------------------------------------------------------------------------------";
|
walther@60147
|
288 |
val solution_str = (
|
walther@60147
|
289 |
"Solution:" ^
|
walther@60147
|
290 |
steps_nonrec_str
|
walther@60147
|
291 |
);
|
walther@60147
|
292 |
val body_str = specification_str ^ solution_str;
|
walther@60147
|
293 |
|
walther@60147
|
294 |
case ParseC.parse ParseC.body (ParseC.tokenize body_str) of ((((((
|
walther@60147
|
295 |
"Specification", ":"), (((((((((((((((
|
walther@60147
|
296 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
297 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
298 |
"Where"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
299 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
300 |
"Relate"), ":"), [_(*"<markup>"*)]), ((
|
walther@60147
|
301 |
"References", ":"), ((((((((
|
walther@60147
|
302 |
"RTheory", ":"), "Biegelinie"),
|
walther@60147
|
303 |
"RProblem"), ":"), ["Biegelinien"]),
|
walther@60147
|
304 |
"RMethod"), ":"), ["Integrieren", "KonstanteBestimmen2"])))),
|
walther@60147
|
305 |
"Solution"), ":"),
|
walther@60147
|
306 |
[_(*"EXEC IMMEDIATELY step_term: <markup> (, )"*),
|
walther@60147
|
307 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Substitute <markup> <markup>)"*),
|
walther@60147
|
308 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Rewrite_Set_Inst <markup> make_ratpoly_in)"*),
|
walther@60147
|
309 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Check_Postcond xxxBiegelinien)"*),
|
walther@60147
|
310 |
_(*"EXEC IMMEDIATELY step_term: <markup> (, )"*)]),
|
walther@60147
|
311 |
[])
|
walther@60147
|
312 |
=> () | _ => error "parse body CHANGED";
|
walther@60147
|
313 |
|
walther@60147
|
314 |
|
walther@60147
|
315 |
"----------- Problem ---------------------------------------------------------------------------";
|
walther@60147
|
316 |
"----------- Problem ---------------------------------------------------------------------------";
|
walther@60147
|
317 |
"----------- Problem ---------------------------------------------------------------------------";
|
walther@60147
|
318 |
"----------- whole Problem";
|
walther@60147
|
319 |
val toks = ParseC.tokenize (problem_headline_str ^ specification_str ^ solution_str);
|
walther@60147
|
320 |
|
walther@60147
|
321 |
case ParseC.parse ParseC.problem toks of (((((((
|
walther@60147
|
322 |
"(", "Biegelinie"), ","), ["Biegelinien"]), ")"), (((((
|
walther@60147
|
323 |
"Specification", ":"), (((((((((((((((
|
walther@60147
|
324 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
325 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
326 |
"Where"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
327 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
328 |
"Relate"), ":"), [_(*"<markup>"*)]), ((
|
walther@60147
|
329 |
"References", ":"), ((((((((
|
walther@60147
|
330 |
"RTheory", ":"), "Biegelinie"),
|
walther@60147
|
331 |
"RProblem"), ":"), ["Biegelinien"]),
|
walther@60147
|
332 |
"RMethod"), ":"), ["Integrieren", "KonstanteBestimmen2"])))),
|
walther@60147
|
333 |
"Solution"), ":"),
|
walther@60147
|
334 |
[_(*"EXEC IMMEDIATELY step_term: <markup> (, )"*),
|
walther@60147
|
335 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Substitute <markup> <markup>)"*),
|
walther@60147
|
336 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Rewrite_Set_Inst <markup> make_ratpoly_in)"*),
|
walther@60147
|
337 |
_(*"EXEC IMMEDIATELY step_term: <markup> (Tactic, EXEC IMMEDIATELY: Check_Postcond xxxBiegelinien)"*),
|
walther@60147
|
338 |
_(*"EXEC IMMEDIATELY step_term: <markup> (, )"*)])),
|
walther@60147
|
339 |
""),
|
walther@60147
|
340 |
[])
|
walther@60147
|
341 |
=> () | _ => error "parse problem (whole) CHANGED"
|
walther@60147
|
342 |
|
walther@60147
|
343 |
"----------- enter Specification";
|
walther@60147
|
344 |
val toks = ParseC.tokenize (
|
walther@60147
|
345 |
problem_headline_str ^
|
walther@60147
|
346 |
"Specification:" ^
|
walther@60147
|
347 |
model_empty_str ^ (* <<<----- empty *)
|
walther@60147
|
348 |
"References:" ^ (* <<<----- collapsed *)
|
walther@60147
|
349 |
"Solution:"
|
walther@60147
|
350 |
);
|
walther@60147
|
351 |
case ParseC.parse ParseC.problem toks of (((((((
|
walther@60147
|
352 |
"(", "Biegelinie"), ","), ["Biegelinien"]), ")"), (((((
|
walther@60147
|
353 |
"Specification", ":"), (((((((((((((((
|
walther@60147
|
354 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
355 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
356 |
"Where"), ":"), [_(*"<markup>"*)]),
|
walther@60147
|
357 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
358 |
"Relate"), ":"), [_(*"<markup>"*)]), ((
|
walther@60147
|
359 |
"References", ":"), (((((((("", ""), ""), ""), ""), []), ""), ""), [])))),
|
walther@60147
|
360 |
"Solution"), ":"), [])),
|
walther@60147
|
361 |
""),
|
walther@60147
|
362 |
[])
|
walther@60147
|
363 |
=> () | _ => error "parse enter Specification CHANGED"
|
walther@60147
|
364 |
|
walther@60147
|
365 |
"----------- Problem-headline only";
|
walther@60147
|
366 |
val toks = ParseC.tokenize problem_headline_str;
|
walther@60147
|
367 |
|
walther@60147
|
368 |
case ParseC.parse ParseC.problem toks of (((((((
|
walther@60147
|
369 |
"(", "Biegelinie"), ","), ["Biegelinien"]), ")"), (((((
|
walther@60147
|
370 |
"", ""), (((((((((((((((
|
walther@60147
|
371 |
"", (("", ""), "")), ""),
|
walther@60147
|
372 |
""), ""), []),
|
walther@60147
|
373 |
""), ""), []),
|
walther@60147
|
374 |
""), ""), ""),
|
walther@60147
|
375 |
""), ""), []), ((
|
walther@60147
|
376 |
"", ""), (((((((("", ""), ""), ""), ""), []), ""), ""), [])))),
|
walther@60147
|
377 |
""), ""), [])),
|
walther@60147
|
378 |
""),
|
walther@60147
|
379 |
[])
|
walther@60147
|
380 |
=> () | _ => error "parse BEFORE enter Specification CHANGED"
|
walther@60147
|
381 |
|
walther@60147
|
382 |
"----------- finish Specification";
|
walther@60147
|
383 |
val toks = ParseC.tokenize (
|
walther@60147
|
384 |
problem_headline_str ^
|
walther@60147
|
385 |
"Specification:" ^
|
walther@60147
|
386 |
model_str ^
|
walther@60147
|
387 |
references_str ^
|
walther@60147
|
388 |
"Solution:"
|
walther@60147
|
389 |
);
|
walther@60147
|
390 |
case ParseC.parse ParseC.problem toks of ( ((((((
|
walther@60147
|
391 |
"(", "Biegelinie"), ","), ["Biegelinien"]), ")"), (((((
|
walther@60147
|
392 |
"Specification", ":"), (((((((((((((((
|
walther@60147
|
393 |
"Model", (("", ""), "")), ":"),
|
walther@60147
|
394 |
"Given"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
395 |
"Where"), ":"), [_(*"<markup>"*), _(*"<markup>"*)]),
|
walther@60147
|
396 |
"Find"), ":"), _(*"<markup>"*)),
|
walther@60147
|
397 |
"Relate"), ":"), [_(*"<markup>"*)]), ((
|
walther@60147
|
398 |
"References", ":"), ((((((((
|
walther@60147
|
399 |
"RTheory", ":"), "Biegelinie"),
|
walther@60147
|
400 |
"RProblem"), ":"), ["Biegelinien"]),
|
walther@60147
|
401 |
"RMethod"), ":"), ["Integrieren", "KonstanteBestimmen2"])))),
|
walther@60147
|
402 |
"Solution"), ":"),
|
walther@60147
|
403 |
[])),
|
walther@60147
|
404 |
""),
|
walther@60147
|
405 |
[])
|
walther@60147
|
406 |
=> () | _ => error "parse finish specification CHANGED"
|
walther@60147
|
407 |
|
walther@60147
|
408 |
"----------- Specification collapsed";
|
walther@60147
|
409 |
case ParseC.parse ParseC.problem (ParseC.tokenize problem_headline_str) of (((((((
|
walther@60147
|
410 |
"(", "Biegelinie"), ","), ["Biegelinien"]), ")"), (((((
|
walther@60147
|
411 |
(*Specification*)"", ""), (((((((((((((((
|
walther@60147
|
412 |
(*Model*)"", (("", ""), "")), ""), ""), ""), []), ""), ""), []), ""), ""), ""), ""), ""), []), (("", ""), ((((((((
|
walther@60147
|
413 |
(*References*)"", ""), ""), ""), ""), []), ""), ""), [])))),
|
walther@60147
|
414 |
(*Solution*)""), ""),
|
walther@60147
|
415 |
[])),
|
walther@60147
|
416 |
""),
|
walther@60147
|
417 |
[])
|
walther@60147
|
418 |
=> () | _ => error "parse Specification collapsed CHANGED"
|
walther@60147
|
419 |
|
walther@60147
|
420 |
"----------- Problem with final_result, all collapsed";
|
walther@60147
|
421 |
val toks = ParseC.tokenize (problem_headline_str ^ final_result_str);
|
walther@60147
|
422 |
case ParseC.parse ParseC.problem toks of (((((((
|
walther@60147
|
423 |
"(", "Biegelinie"), ","), ["Biegelinien"]), ")"), (((((
|
walther@60147
|
424 |
(*Specification*)"", ""), (((((((((((((((
|
walther@60147
|
425 |
(*Model*)"", (("", ""), "")), ""), ""), ""), []), ""), ""), []), ""), ""), ""), ""), ""), []), (("", ""), ((((((((
|
walther@60147
|
426 |
(*References*)"", ""), ""), ""), ""), []), ""), ""), [])))),
|
walther@60147
|
427 |
(*Solution*)""), ""),
|
walther@60147
|
428 |
[])),
|
walther@60147
|
429 |
_(*"<markup>"*)),
|
walther@60147
|
430 |
[])
|
walther@60147
|
431 |
=> () | _ => error "parse Problem with final_result, all collapsed CHANGED"
|
walther@60147
|
432 |
|
walther@60147
|
433 |
|
walther@60147
|
434 |
"----------- fun read_out_problem --------------------------------------------------------------";
|
walther@60147
|
435 |
"----------- fun read_out_problem --------------------------------------------------------------";
|
walther@60147
|
436 |
"----------- fun read_out_problem --------------------------------------------------------------";
|
walther@60147
|
437 |
val toks = ParseC.tokenize (
|
walther@60147
|
438 |
problem_headline_str ^
|
walther@60147
|
439 |
"Specification:" ^
|
walther@60147
|
440 |
model_str ^
|
walther@60147
|
441 |
references_str ^
|
walther@60147
|
442 |
"Solution:"
|
walther@60147
|
443 |
);
|
walther@60147
|
444 |
case ParseC.parse ParseC.problem toks |> fst |> ParseC.read_out_problem of
|
walther@60147
|
445 |
{thy_id = "Biegelinie", pbl_id = ["Biegelinien"],
|
walther@60147
|
446 |
givens = [_(*"<markup>"*), _(*"<markup>"*)], wheres = [_(*"<markup>"*), _(*"<markup>"*)],
|
walther@60147
|
447 |
find = _(*"<markup>"*), relates = [_(*"<markup>"*)],
|
walther@60147
|
448 |
rthy_id = "Biegelinie", rpbl_id = ["Biegelinien"], rmet_id = ["Integrieren", "KonstanteBestimmen2"]
|
walther@60147
|
449 |
} => ()
|
walther@60147
|
450 |
| _ => error "read_out_problem CHANGED"
|
walther@60147
|
451 |
|
walther@60147
|
452 |
|
walther@60147
|
453 |
"----------- THERE ARE TESTS with INCOMPLETE WORK IN Test_Parse_Isac.thy -----------------------";
|
walther@60147
|
454 |
"----------- THERE ARE TESTS with INCOMPLETE WORK IN Test_Parse_Isac.thy -----------------------";
|
walther@60147
|
455 |
"----------- THERE ARE TESTS with INCOMPLETE WORK IN Test_Parse_Isac.thy -----------------------";
|
walther@60147
|
456 |
(*TODO after Problem became recursive*)
|
walther@60147
|
457 |
|
walther@60147
|
458 |
"----------- parser for exp_file.str -----------------------------------------------------------";
|
walther@60147
|
459 |
"----------- parser for exp_file.str -----------------------------------------------------------";
|
walther@60147
|
460 |
"----------- parser for exp_file.str -----------------------------------------------------------";
|
walther@60147
|
461 |
(*
|
walther@60147
|
462 |
For keyword Example SPARK's lexer and parser are used. Respective Isac code was developed
|
walther@60147
|
463 |
alongside existing SPARK code, not by tests. Here are tests for code using Isabelle technologies
|
walther@60147
|
464 |
and preceeding the actual production code.
|
walther@60147
|
465 |
*)
|
walther@60147
|
466 |
val form_single =
|
walther@60147
|
467 |
Parse.$$$ "(" --
|
walther@60147
|
468 |
(Parse.$$$ "[" |-- Parse.list1 Parse.string --| Parse.$$$ "]") (* Formalise.model *) --
|
walther@60147
|
469 |
Parse.$$$ "," --
|
walther@60147
|
470 |
Parse.$$$ "(" (* begin Formalise.spec *) --
|
walther@60147
|
471 |
Parse.string -- (* ThyC.id, still not qualified *)
|
walther@60147
|
472 |
Parse.$$$ "," --
|
walther@60147
|
473 |
(Parse.$$$ "[" |-- Parse.list1 Parse.string --| Parse.$$$ "]") (* Problem.id *) --
|
walther@60147
|
474 |
Parse.$$$ "," --
|
walther@60147
|
475 |
(Parse.$$$ "[" |-- Parse.list1 Parse.string --| Parse.$$$ "]") (* Method.id *) --
|
walther@60147
|
476 |
Parse.$$$ ")" (* end Formalise.spec *) --
|
walther@60147
|
477 |
Parse.$$$ ")";
|
walther@60147
|
478 |
|
walther@60147
|
479 |
val form_single_str = (
|
walther@60147
|
480 |
"( " ^
|
walther@60147
|
481 |
" [\"Traegerlaenge L\", \"Streckenlast q_0\", \"Biegelinie y\", " ^
|
walther@60147
|
482 |
" \"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]\", " ^
|
walther@60147
|
483 |
" \"FunktionsVariable x\", \"GleichungsVariablen [c, c_2, c_3, c_4]\", " ^
|
walther@60147
|
484 |
" \"AbleitungBiegelinie dy\"], " ^
|
walther@60147
|
485 |
" (\"Biegelinie\", [\"Biegelinien\"], [\"IntegrierenUndKonstanteBestimmen2\"])" ^
|
walther@60147
|
486 |
")");
|
walther@60147
|
487 |
|
walther@60147
|
488 |
val toks = ParseC.tokenize form_single_str;
|
walther@60147
|
489 |
case ParseC.parse form_single toks of (((((((((((
|
walther@60147
|
490 |
"(",
|
walther@60147
|
491 |
["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
|
walther@60147
|
492 |
"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]", "FunktionsVariable x",
|
walther@60147
|
493 |
"GleichungsVariablen [c, c_2, c_3, c_4]", "AbleitungBiegelinie dy"]),
|
walther@60147
|
494 |
","),
|
walther@60147
|
495 |
"("), "Biegelinie"), ","), ["Biegelinien"]), ","), ["IntegrierenUndKonstanteBestimmen2"]), ")"),
|
walther@60147
|
496 |
")"),
|
walther@60147
|
497 |
[])
|
walther@60147
|
498 |
=> () | _ => error "parse form_single toks CHANGED";
|
walther@60147
|
499 |
|
walther@60147
|
500 |
(* Isac always takes a singleton here *)
|
walther@60147
|
501 |
val formalise = (Parse.$$$ "[" |-- Parse.list1 form_single --| Parse.$$$ "]");
|
walther@60147
|
502 |
type formalise =
|
walther@60147
|
503 |
((((((((((string * string list) * string) * string) * string) * string) * string list) *
|
walther@60147
|
504 |
string) * string list) * string) * string) list;
|
walther@60147
|
505 |
formalise: formalise parser;
|
walther@60147
|
506 |
|
walther@60147
|
507 |
val toks = ParseC.tokenize ("[" ^ form_single_str ^ "]");
|
walther@60147
|
508 |
case ParseC.parse formalise (ParseC.tokenize ("[" ^ form_single_str ^ "]")) of ([((((((((((
|
walther@60147
|
509 |
"(",
|
walther@60147
|
510 |
["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
|
walther@60147
|
511 |
"Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]", "FunktionsVariable x",
|
walther@60147
|
512 |
"GleichungsVariablen [c, c_2, c_3, c_4]", "AbleitungBiegelinie dy"]),
|
walther@60147
|
513 |
","),
|
walther@60147
|
514 |
"("), "Biegelinie"), ","), ["Biegelinien"]), ","), ["IntegrierenUndKonstanteBestimmen2"]), ")"),
|
walther@60147
|
515 |
")")],
|
walther@60147
|
516 |
[])
|
walther@60147
|
517 |
=> () | _ => error "parse formalise CHANGED";
|
walther@60147
|
518 |
|