walther@59967
|
1 |
(* Title: "Specify/refine.sml"
|
walther@59967
|
2 |
Author: Walther Neuper
|
walther@59967
|
3 |
(c) due to copyright terms
|
walther@59967
|
4 |
*)
|
walther@59967
|
5 |
|
walther@59967
|
6 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
7 |
"table of contents -----------------------------------------------------------------------------";
|
walther@59967
|
8 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
9 |
"refine.thy: store test-pbtyps by 'setup' ------------------------------------------------------";
|
Walther@60742
|
10 |
"----------- testdata for check_match, Refine.by_o_model --------------------------------------------";
|
Walther@60742
|
11 |
(*"----------- check_match test-pbtyps -------requires specific 'setup'-------------------------------";*)
|
Walther@60742
|
12 |
"----------- Refine.by_o_model test-pbtyps --requires 'setup'-----------------------------------";
|
walther@59967
|
13 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
Walther@60742
|
14 |
"----------- by_o_model' [0 = - 1 * c_4 / - 1, 0 =\n (- 24 * c_4.., ..] ------------------------";
|
walther@60021
|
15 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
Walther@60556
|
16 |
"----------- equation with CalcTree [ = 6 / 5] for timing: with/out adapt_to_type --------------";
|
Walther@60556
|
17 |
"----------- refine ad-hoc equation for timing: with/out adapt_to_type -------------------------";
|
walther@59967
|
18 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
19 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
20 |
"-----------------------------------------------------------------------------------------------";
|
Walther@60736
|
21 |
open Test_Tool;
|
walther@59967
|
22 |
|
Walther@60742
|
23 |
(** -------- testdata for check_match, Refine.by_o_model ------------------------------------------ **)
|
Walther@60742
|
24 |
"----------- testdata for check_match, Refine.by_o_model --------------------------------------------";
|
Walther@60742
|
25 |
"----------- testdata for check_match, Refine.by_o_model --------------------------------------------";
|
walther@59971
|
26 |
Test_Tool.show_ptyps();
|
walther@59967
|
27 |
val thy = @{theory "Isac_Knowledge"};
|
walther@59967
|
28 |
val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"};
|
walther@59967
|
29 |
|
walther@59967
|
30 |
(*case 1: no refinement *)
|
Walther@60663
|
31 |
val (d1,ts1) = Input_Descript.split (ParseC.parse_test ctxt "fixedValues [aaa = 0]");
|
Walther@60663
|
32 |
val (d2,ts2) = Input_Descript.split (ParseC.parse_test ctxt "errorBound (ddd = 0)");
|
walther@59967
|
33 |
val ori1 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]: O_Model.T;
|
walther@59967
|
34 |
|
walther@59967
|
35 |
(*case 2: refined to pbt without children *)
|
Walther@60663
|
36 |
val (d2,ts2) = Input_Descript.split (ParseC.parse_test ctxt "relations [aaa333]");
|
walther@59967
|
37 |
val ori2 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]:O_Model.T;
|
walther@59967
|
38 |
|
walther@59967
|
39 |
(*case 3: refined to pbt with children *)
|
Walther@60663
|
40 |
val (d2,ts2) = Input_Descript.split (ParseC.parse_test ctxt "valuesFor [aaa222]");
|
walther@59967
|
41 |
val ori3 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]:O_Model.T;
|
walther@59967
|
42 |
|
walther@59967
|
43 |
(*case 4: refined to children (without child)*)
|
Walther@60663
|
44 |
val (d3,ts3) = Input_Descript.split (ParseC.parse_test ctxt "boundVariable aaa222yyy");
|
walther@59967
|
45 |
val ori4 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2), (3,[1],"#Given",d3,ts3)]:O_Model.T;
|
walther@59967
|
46 |
|
walther@59967
|
47 |
(*=================================================================
|
walther@59967
|
48 |
This test expects pbls at a certain position in the tree.
|
walther@59967
|
49 |
Since parallel evaluation (i.e. Theory_Data) this cannot be expected.
|
walther@59967
|
50 |
Solutions would be
|
walther@59967
|
51 |
* provide an access function for a branch (not only leaves)
|
walther@59967
|
52 |
* sort the tree of pbls.
|
Walther@60736
|
53 |
|
Walther@60742
|
54 |
(** -------- check_match test-pbtyps -------requires specific 'setup'----------------------------- **)
|
Walther@60742
|
55 |
"----------- check_match test-pbtyps -------requires specific 'setup'-------------------------------";
|
Walther@60742
|
56 |
"----------- check_match test-pbtyps -------requires specific 'setup'-------------------------------";
|
walther@59967
|
57 |
(* fragile test setup: expects ptyps as fixed *)
|
Walther@60496
|
58 |
val level_1 = case nth 9 (get_pbls ()) of
|
Walther@60742
|
59 |
Store.Node ("test", _, level_1) => level_1 | _ => error "check_match broken: root-branch in ptyps changed?"
|
walther@59967
|
60 |
val level_2 = case nth 4 level_1 of
|
Walther@60742
|
61 |
Store.Node ("refine", _, level_2) => level_2 | _ => error "check_match broken: lev1-branch in ptyps changed?"
|
walther@59967
|
62 |
val pbla_branch = case level_2 of
|
Walther@60742
|
63 |
[Store.Node ("pbla", _, _)] => level_2 | _ => error "check_match broken: lev2-branch in ptyps changed?";
|
walther@59967
|
64 |
|
walther@59967
|
65 |
(*case 1: no refinement *)
|
Walther@60742
|
66 |
case check_match [] ori1 (hd pbla_branch) of
|
Walther@60742
|
67 |
SOME ["pbla"] => () | _ => error "check_match case 1 broken";
|
walther@59967
|
68 |
|
walther@59967
|
69 |
(*case 2: refined to pbt without children *)
|
Walther@60742
|
70 |
case check_match [] ori2 (hd pbla_branch) of
|
Walther@60742
|
71 |
SOME ["pbla", "pbla3"] => () | _ => error "check_match case 2 broken";
|
walther@59967
|
72 |
|
walther@59967
|
73 |
(*case 3: refined to pbt with children *)
|
Walther@60742
|
74 |
case check_match [] ori3 (hd pbla_branch) of
|
Walther@60742
|
75 |
SOME ["pbla", "pbla2"] => () | _ => error "check_match case 3 broken";
|
walther@59967
|
76 |
|
walther@59967
|
77 |
(*case 4: refined to children (without child)*)
|
Walther@60742
|
78 |
case check_match [] ori4 (hd pbla_branch) of
|
Walther@60742
|
79 |
SOME ["pbla", "pbla2", "pbla2y"] => () | _ => error "check_match case 4 broken";
|
walther@59967
|
80 |
|
walther@59967
|
81 |
(*case 5: start refinement somewhere in ptyps*)
|
walther@59967
|
82 |
val [Store.Node ("pbla",_,[_, ppp as Store.Node ("pbla2",_,_), _])] = pbla_branch;
|
Walther@60742
|
83 |
case check_match ["pbla"] ori4 ppp of
|
Walther@60742
|
84 |
SOME ["pbla", "pbla2", "pbla2y"] => () | _ => error "check_match case 5 broken";
|
walther@59967
|
85 |
==================================================================*)
|
walther@59967
|
86 |
|
walther@59967
|
87 |
|
Walther@60742
|
88 |
(** -------- Refine.by_o_model test-pbtyps --requires 'setup'-------------------------------- **)
|
Walther@60742
|
89 |
"----------- Refine.by_o_model test-pbtyps --requires 'setup'----------------------------------";
|
Walther@60742
|
90 |
"----------- Refine.by_o_model test-pbtyps --requires 'setup'----------------------------------";
|
walther@59967
|
91 |
(*case 1: no refinement *)
|
Walther@60742
|
92 |
case Refine.by_o_model @{context} ori1 ["pbla", "refine", "test"] of
|
Walther@60742
|
93 |
NONE => () | _ => error "Refine.by_o_model case 1 broken";
|
walther@59967
|
94 |
|
walther@59967
|
95 |
(*case 2: refined to pbt without children *)
|
Walther@60742
|
96 |
case Refine.by_o_model @{context} ori2 ["pbla", "refine", "test"] of
|
Walther@60742
|
97 |
SOME ["pbla3", "pbla", "refine", "test"] => () | _ => error "Refine.by_o_model case 2 broken";
|
walther@59967
|
98 |
|
walther@59967
|
99 |
(*case 3: refined to pbt with children *)
|
Walther@60742
|
100 |
case Refine.by_o_model @{context} ori3 ["pbla", "refine", "test"] of
|
Walther@60742
|
101 |
SOME ["pbla2", "pbla", "refine", "test"] => () | _ => error "Refine.by_o_model case 3 broken";
|
walther@59967
|
102 |
|
walther@59967
|
103 |
(*case 4: refined to children (without child)*)
|
Walther@60742
|
104 |
case Refine.by_o_model @{context} ori4 ["pbla", "refine", "test"] of
|
Walther@60742
|
105 |
SOME ["pbla2y", "pbla2", "pbla", "refine", "test"] => () | _ => error "Refine.by_o_model case 4 broken";
|
walther@59967
|
106 |
|
walther@59967
|
107 |
(*case 5: start refinement somewhere in ptyps*)
|
Walther@60742
|
108 |
case Refine.by_o_model @{context} ori4 ["pbla2", "pbla", "refine", "test"] of
|
Walther@60742
|
109 |
SOME ["pbla2y", "pbla2", "pbla", "refine", "test"] => () | _ => error "Refine.by_o_model case 5 broken";
|
walther@59967
|
110 |
|
walther@59967
|
111 |
|
Walther@60736
|
112 |
(** -------- refine test-pbtyps ------requires 'setup'---------------------------------------- **)
|
walther@59967
|
113 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
walther@59967
|
114 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
walther@59997
|
115 |
val fmz1 = ["fixedValues [aaa=0]", "errorBound (ddd=0)"];
|
walther@59997
|
116 |
val fmz2 = ["fixedValues [aaa=0]", "relations aaa333"];
|
walther@59997
|
117 |
val fmz3 = ["fixedValues [aaa=0]", "valuesFor [aaa222]"];
|
walther@59997
|
118 |
val fmz4 = ["fixedValues [aaa=0]", "valuesFor [aaa222]",
|
walther@59967
|
119 |
"boundVariable aaa222yyy"];
|
walther@59967
|
120 |
|
walther@59967
|
121 |
(*case 1: no refinement *)
|
Walther@60742
|
122 |
case Refine.by_formalise @{context} fmz1 ["pbla", "refine", "test"] of
|
walther@59984
|
123 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
124 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
125 |
M_Match.NoMatch (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
126 |
M_Match.NoMatch (["pbla3", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
127 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 1";
|
walther@59967
|
128 |
(*
|
walther@59967
|
129 |
*** pass ["pbla"]
|
walther@59997
|
130 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
131 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
132 |
*** pass ["pbla", "pbla3"]
|
walther@59967
|
133 |
val it =
|
walther@59984
|
134 |
[M_Match.Matches
|
walther@59967
|
135 |
(["pbla"],
|
walther@59967
|
136 |
{Find=[],
|
walther@59967
|
137 |
Given=[Correct "fixedValues [aaa = #0]",
|
walther@59967
|
138 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
139 |
M_Match.NoMatch
|
walther@59997
|
140 |
(["pbla1", "pbla"],
|
walther@59967
|
141 |
{Find=[],
|
walther@59967
|
142 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
143 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
144 |
M_Match.NoMatch
|
walther@59997
|
145 |
(["pbla2", "pbla"],
|
walther@59967
|
146 |
{Find=[],
|
walther@59967
|
147 |
Given=[Correct "fixedValues [aaa = #0]",Missing "valuesFor a2_",
|
walther@59967
|
148 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
149 |
M_Match.NoMatch
|
walther@59997
|
150 |
(["pbla3", "pbla"],
|
walther@59967
|
151 |
{Find=[],
|
walther@59967
|
152 |
Given=[Correct "fixedValues [aaa = #0]",Missing "relations a3_",
|
walther@59967
|
153 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
154 |
: match list*)
|
walther@59967
|
155 |
|
walther@59967
|
156 |
(*case 2: refined to pbt without children *)
|
Walther@60742
|
157 |
case Refine.by_formalise @{context} fmz2 ["pbla", "refine", "test"] of
|
walther@59984
|
158 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
159 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
160 |
M_Match.NoMatch (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
161 |
M_Match.Matches (["pbla3", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
162 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 2";
|
walther@59967
|
163 |
(*
|
walther@59967
|
164 |
*** pass ["pbla"]
|
walther@59997
|
165 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
166 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
167 |
*** pass ["pbla", "pbla3"]
|
walther@59967
|
168 |
val it =
|
walther@59984
|
169 |
[M_Match.Matches
|
walther@59967
|
170 |
(["pbla"],
|
walther@59967
|
171 |
{Find=[],
|
walther@59967
|
172 |
Given=[Correct "fixedValues [aaa = #0]",Superfl "relations aaa333"],
|
walther@59967
|
173 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
174 |
M_Match.NoMatch
|
walther@59997
|
175 |
(["pbla1", "pbla"],
|
walther@59967
|
176 |
{Find=[],
|
walther@59967
|
177 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
178 |
Superfl "relations aaa333"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
179 |
M_Match.NoMatch
|
walther@59997
|
180 |
(["pbla2", "pbla"],
|
walther@59967
|
181 |
{Find=[],
|
walther@59967
|
182 |
Given=[Correct "fixedValues [aaa = #0]",Missing "valuesFor a2_",
|
walther@59967
|
183 |
Superfl "relations aaa333"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
184 |
M_Match.Matches
|
walther@59997
|
185 |
(["pbla3", "pbla"],
|
walther@59967
|
186 |
{Find=[],
|
walther@59967
|
187 |
Given=[Correct "fixedValues [aaa = #0]",Correct "relations aaa333"],
|
walther@59967
|
188 |
Relate=[],Where=[],With=[]})] : match list*)
|
walther@59967
|
189 |
|
walther@59967
|
190 |
(*case 3: refined to pbt with children *)
|
Walther@60742
|
191 |
case Refine.by_formalise @{context} fmz3 ["pbla", "refine", "test"] of
|
walther@59984
|
192 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
193 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
194 |
M_Match.Matches (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
195 |
M_Match.NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
196 |
M_Match.NoMatch (["pbla2y", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
197 |
M_Match.NoMatch (["pbla2z", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
198 |
M_Match.NoMatch (["pbla3", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
199 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 3";
|
walther@59967
|
200 |
(*
|
walther@59967
|
201 |
*** pass ["pbla"]
|
walther@59997
|
202 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
203 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
204 |
*** pass ["pbla", "pbla2", "pbla2x"]
|
walther@59997
|
205 |
*** pass ["pbla", "pbla2", "pbla2y"]
|
walther@59997
|
206 |
*** pass ["pbla", "pbla2", "pbla2z"]
|
walther@59997
|
207 |
*** pass ["pbla", "pbla3"]
|
walther@59967
|
208 |
val it =
|
walther@59984
|
209 |
[M_Match.Matches
|
walther@59967
|
210 |
(["pbla"],
|
walther@59967
|
211 |
{Find=[],
|
walther@59967
|
212 |
Given=[Correct "fixedValues [aaa = #0]",Superfl "valuesFor aaa222"],
|
walther@59967
|
213 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
214 |
M_Match.NoMatch
|
walther@59997
|
215 |
(["pbla1", "pbla"],
|
walther@59967
|
216 |
{Find=[],
|
walther@59967
|
217 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
218 |
Superfl "valuesFor aaa222"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
219 |
M_Match.Matches
|
walther@59997
|
220 |
(["pbla2", "pbla"],
|
walther@59967
|
221 |
{Find=[],
|
walther@59967
|
222 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222"],
|
walther@59967
|
223 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
224 |
M_Match.NoMatch
|
walther@59997
|
225 |
(["pbla2x", "pbla2", "pbla"],
|
walther@59967
|
226 |
{Find=[],
|
walther@59967
|
227 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
228 |
Missing "functionOf a2x_"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
229 |
M_Match.NoMatch
|
walther@59997
|
230 |
(["pbla2y", "pbla2", "pbla"],
|
walther@59967
|
231 |
{Find=[],
|
walther@59967
|
232 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
233 |
Missing "boundVariable a2y_"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
234 |
M_Match.NoMatch
|
walther@59997
|
235 |
(["pbla2z", "pbla2", "pbla"],
|
walther@59967
|
236 |
{Find=[],
|
walther@59967
|
237 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
238 |
Missing "interval a2z_"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
239 |
M_Match.NoMatch
|
walther@59997
|
240 |
(["pbla3", "pbla"],
|
walther@59967
|
241 |
{Find=[],
|
walther@59967
|
242 |
Given=[Correct "fixedValues [aaa = #0]",Missing "relations a3_",
|
walther@59967
|
243 |
Superfl "valuesFor aaa222"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
244 |
: match list*)
|
walther@59967
|
245 |
|
walther@59967
|
246 |
(*case 4: refined to children (without child)*)
|
Walther@60742
|
247 |
case Refine.by_formalise @{context} fmz4 ["pbla", "refine", "test"] of
|
walther@59984
|
248 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
249 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
250 |
M_Match.Matches (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
251 |
M_Match.NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
252 |
M_Match.Matches (["pbla2y", "pbla2", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
253 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 4";
|
walther@59967
|
254 |
(*
|
walther@59967
|
255 |
*** pass ["pbla"]
|
walther@59997
|
256 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
257 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
258 |
*** pass ["pbla", "pbla2", "pbla2x"]
|
walther@59997
|
259 |
*** pass ["pbla", "pbla2", "pbla2y"]
|
walther@59967
|
260 |
val it =
|
walther@59984
|
261 |
[M_Match.Matches
|
walther@59967
|
262 |
(["pbla"],
|
walther@59967
|
263 |
{Find=[],
|
walther@59967
|
264 |
Given=[Correct "fixedValues [aaa = #0]",Superfl "valuesFor aaa222",
|
walther@59967
|
265 |
Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
266 |
M_Match.NoMatch
|
walther@59997
|
267 |
(["pbla1", "pbla"],
|
walther@59967
|
268 |
{Find=[],
|
walther@59967
|
269 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
270 |
Superfl "valuesFor aaa222",Superfl "boundVariable aaa222yyy"],
|
walther@59967
|
271 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
272 |
M_Match.Matches
|
walther@59997
|
273 |
(["pbla2", "pbla"],
|
walther@59967
|
274 |
{Find=[],
|
walther@59967
|
275 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
276 |
Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
277 |
M_Match.NoMatch
|
walther@59997
|
278 |
(["pbla2x", "pbla2", "pbla"],
|
walther@59967
|
279 |
{Find=[],
|
walther@59967
|
280 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
281 |
Missing "functionOf a2x_",Superfl "boundVariable aaa222yyy"],
|
walther@59967
|
282 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
283 |
M_Match.Matches
|
walther@59997
|
284 |
(["pbla2y", "pbla2", "pbla"],
|
walther@59967
|
285 |
{Find=[],
|
walther@59967
|
286 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
287 |
Correct "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
288 |
: match list*)
|
walther@59967
|
289 |
|
walther@59967
|
290 |
(*case 5: start refinement somewhere in ptyps*)
|
Walther@60742
|
291 |
case Refine.by_formalise @{context} fmz4 ["pbla2", "pbla", "refine", "test"] of
|
walther@59984
|
292 |
[M_Match.Matches (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
293 |
M_Match.NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
294 |
M_Match.Matches (["pbla2y", "pbla2", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
295 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 5";
|
walther@59967
|
296 |
(*
|
walther@59997
|
297 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
298 |
*** pass ["pbla", "pbla2", "pbla2x"]
|
walther@59997
|
299 |
*** pass ["pbla", "pbla2", "pbla2y"]
|
walther@59967
|
300 |
val it =
|
walther@59984
|
301 |
[M_Match.Matches
|
walther@59997
|
302 |
(["pbla2", "pbla"],
|
walther@59967
|
303 |
{Find=[],
|
walther@59967
|
304 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
305 |
Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
306 |
M_Match.NoMatch
|
walther@59997
|
307 |
(["pbla2x", "pbla2", "pbla"],
|
walther@59967
|
308 |
{Find=[],
|
walther@59967
|
309 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
310 |
Missing "functionOf a2x_",Superfl "boundVariable aaa222yyy"],
|
walther@59967
|
311 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
312 |
M_Match.Matches
|
walther@59997
|
313 |
(["pbla2y", "pbla2", "pbla"],
|
walther@59967
|
314 |
{Find=[],
|
walther@59967
|
315 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
316 |
Correct "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
317 |
: match list*)
|
walther@59967
|
318 |
|
walther@59967
|
319 |
|
Walther@60742
|
320 |
(** -------- by_o_model' [0 = - 1 * c_4 / - 1, 0 =\n (- 24 * c_4.., ..] ---------------------- **)
|
Walther@60742
|
321 |
"----------- by_o_model' [0 = - 1 * c_4 / - 1, 0 =\n (- 24 * c_4.., ..] ------------------------";
|
Walther@60742
|
322 |
"----------- by_o_model' [0 = - 1 * c_4 / - 1, 0 =\n (- 24 * c_4.., ..] ------------------------";
|
Walther@60729
|
323 |
(*overwrites NEW funs in Test_Theory ABOVE* )
|
Walther@60729
|
324 |
open Refine
|
Walther@60729
|
325 |
open M_Match
|
Walther@60729
|
326 |
open Pre_Conds
|
Walther@60729
|
327 |
( *overwrites NEW funs in Test_Theory ABOVE*)
|
Walther@60729
|
328 |
(*
|
Walther@60729
|
329 |
refinement of the first eqsystem in Biegelinie, IntegrierenUndKonstanteBestimmen2;
|
Walther@60729
|
330 |
this example was the demonstrator;
|
Walther@60729
|
331 |
respective data are in ~/proto4/../exp_Statics_Biegel_Timischl_7-70.xml.
|
Walther@60729
|
332 |
Data for this test are from biegelinie-5.sml, --- me IntegrierenUndKonstanteBestimmen2 ALL ---
|
Walther@60729
|
333 |
*)
|
Walther@60729
|
334 |
(*+*)val o_model = [
|
Walther@60729
|
335 |
(1, [1], "#Given", @{term "equalities"},
|
Walther@60729
|
336 |
[@{term "[(0::real) = - 1 * c_4 / - 1]"},
|
Walther@60729
|
337 |
@{term "[(0::real) = (- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / - 24]"},
|
Walther@60729
|
338 |
@{term "[(0::real) = c_2]"},
|
Walther@60729
|
339 |
@{term "[(0::real) = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]"}] ),
|
Walther@60729
|
340 |
(*Const ("List.list.Cons", "real \<Rightarrow> real list \<Rightarrow> real list") $ Free ("c", "real") $ Const ("List.list.Nil", "real list"),*)
|
Walther@60729
|
341 |
(2, [1], "#Given", @{term "solveForVars"},
|
Walther@60729
|
342 |
[@{term "[c] ::real list"},
|
Walther@60729
|
343 |
@{term "[c_2]::real list"},
|
Walther@60729
|
344 |
@{term "[c_3]::real list"},
|
Walther@60729
|
345 |
@{term "[c_4]::real list"}] ),
|
Walther@60729
|
346 |
(3, [1], "#Find", @{term "solution"}, [@{term "ss'''::bool list"}] )]
|
Walther@60729
|
347 |
;
|
Walther@60729
|
348 |
val SOME ["normalise", "4x4", "LINEAR", "system"] =
|
Walther@60742
|
349 |
by_o_model @{context} o_model ["LINEAR", "system"];
|
Walther@60742
|
350 |
"~~~~~ fun by_o_model , args:"; val (ctxt, oris, pblID) =
|
Walther@60729
|
351 |
(@{context}, o_model, ["LINEAR", "system"]);
|
Walther@60729
|
352 |
|
Walther@60729
|
353 |
val opt as SOME ["system", "LINEAR", "4x4", "normalise"]
|
Walther@60742
|
354 |
= find_node_elem (check_match ctxt ((rev o tl) pblID) oris) pblID (rev pblID);
|
Walther@60729
|
355 |
(*
|
Walther@60742
|
356 |
find_node_elem works strangely, parameter passing is awkward.
|
Walther@60742
|
357 |
Present check_match knows structure of Store.T, thus we bypass find_node_elem
|
Walther@60729
|
358 |
*)
|
Walther@60729
|
359 |
(*!*)val pblID = ["LINEAR", "system"];(**)
|
Walther@60729
|
360 |
val return_refin as SOME ["system", "LINEAR", "LINEAR", "4x4", "normalise"] = (**)
|
Walther@60742
|
361 |
check_match ctxt (rev pblID) oris (Store.get_node (rev pblID) pblID (get_pbls ()));
|
Walther@60742
|
362 |
"~~~~~ fun check_match , args:"; val (ctxt, pblRD, ori, (Store.Node (pI, [py], pys)))
|
Walther@60729
|
363 |
= (ctxt, (rev pblID), oris, Store.get_node (rev pblID) pblID (get_pbls ()));
|
Walther@60729
|
364 |
val {where_rls, model, where_, ...} = py: Problem.T
|
Walther@60729
|
365 |
val model = map (Model_Pattern.adapt_to_type ctxt) model
|
Walther@60729
|
366 |
val where_ = map (ParseC.adapt_term_to_type ctxt) where_;
|
Walther@60729
|
367 |
(*if*) M_Match.match_oris ctxt where_rls ori (model, where_) (*then*);
|
Walther@60729
|
368 |
val return_refin as SOME ["system", "LINEAR"] = SOME (pblRD (** )@ [pI]( **))
|
Walther@60729
|
369 |
|
Walther@60742
|
370 |
(*follow the trace created in parallel by writeln in Store.get_node and Refine.check_match*)
|
Walther@60729
|
371 |
(*!*)val pblID = ["4x4", "LINEAR", "system"];(**)
|
Walther@60730
|
372 |
val return_refin as SOME ["system", "LINEAR", "4x4", "4x4", "normalise"] =
|
Walther@60742
|
373 |
check_match ctxt (rev pblID) oris (Store.get_node (rev pblID) pblID (get_pbls ()));
|
Walther@60742
|
374 |
"~~~~~ fun check_match , args:"; val (ctxt, pblRD, ori, (Store.Node (pI, [py], pys)))
|
Walther@60729
|
375 |
= (ctxt, (rev pblID), oris, Store.get_node (rev pblID) pblID (get_pbls ()));
|
Walther@60729
|
376 |
val {where_rls, model, where_, ...} = py: Problem.T
|
Walther@60729
|
377 |
val model = map (Model_Pattern.adapt_to_type ctxt) model
|
Walther@60729
|
378 |
val where_ = map (ParseC.adapt_term_to_type ctxt) where_
|
Walther@60729
|
379 |
|
Walther@60729
|
380 |
(*+*)val (**)true(** )false( **) = (*if*)
|
Walther@60729
|
381 |
M_Match.match_oris ctxt where_rls o_model (model, where_);
|
Walther@60729
|
382 |
"~~~~~ fun match_oris , args:"; val (ctxt, where_rls, o_model, (model_pattern, where_)) =
|
Walther@60729
|
383 |
(ctxt, where_rls, o_model, (model, where_));
|
Walther@60729
|
384 |
val i_model = (flat o (map (chk1_ model_pattern))) o_model;
|
Walther@60729
|
385 |
|
Walther@60729
|
386 |
(*+*)val "[\n(1, [\"1\"], #Given, equalities, [\"[0 = - 1 * c_4 / - 1]\", \"[0 =\n (- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c +\n - 1 * L \<up> 4 * q_0) /\n - 24]\", \"[0 = c_2]\", \"[0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]\"]), \n(2, [\"1\"], #Given, solveForVars, [\"[c]\", \"[c_2]\", \"[c_3]\", \"[c_4]\"]), \n(3, [\"1\"], #Find, solution, [\"ss'''\"])]"
|
Walther@60729
|
387 |
= o_model |> O_Model.to_string @{context};
|
Walther@60739
|
388 |
(*+*)if (i_model |> I_Model.to_string @{context}) = "[\n" ^
|
Walther@60739
|
389 |
"(1 ,[1] ,true ,#Given ,Cor equalities\n [0 = - 1 * c_4 / - 1,\n 0 =\n (- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c +\n - 1 * L \<up> 4 * q_0) /\n - 24,\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2] , pen2str), \n" ^
|
Walther@60739
|
390 |
"(2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2, c_3, c_4] , pen2str), \n" ^
|
Walther@60739
|
391 |
"(3 ,[1] ,true ,#Find ,Cor solution ss''' , pen2str)]"
|
Walther@60739
|
392 |
(*+*)then () else raise error "i_model CAHNGED";
|
Walther@60729
|
393 |
(*+*)val "[\"(#Given, (equalities, e_s))\", \"(#Given, (solveForVars, v_s))\", \"(#Find, (solution, ss'''))\"]"
|
Walther@60729
|
394 |
= model_pattern |> Model_Pattern.to_string @{context}
|
Walther@60729
|
395 |
(*+*)val "[Length e_s = 4, Length v_s = 4]" = where_ |> UnparseC.terms @{context}
|
Walther@60729
|
396 |
|
Walther@60741
|
397 |
val mvat = I_Model.variables model_pattern (I_Model.OLD_to_TEST i_model)
|
Walther@60729
|
398 |
val complete = chk1_mis mvat i_model model_pattern;
|
Walther@60729
|
399 |
|
Walther@60729
|
400 |
val (pb as true, (** )_( **)where_'(**)) =
|
Walther@60741
|
401 |
Pre_Conds.check ctxt where_rls where_ (model_pattern, I_Model.OLD_to_TEST i_model);
|
Walther@60741
|
402 |
"~~~~~ fun check , args:"; val (ctxt, where_rls, pres, (model_patt, i_model)) =
|
Walther@60729
|
403 |
(ctxt, where_rls, where_, (model_pattern, I_Model.OLD_to_TEST i_model));
|
Walther@60729
|
404 |
|
Walther@60729
|
405 |
(*+*)val [(true, xxx), (true, yyy)] = where_'
|
Walther@60729
|
406 |
(*+*)val "[Length\n [0 = - 1 * c_4 / - 1,\n 0 =\n (- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c +\n - 1 * L \<up> 4 * q_0) /\n - 24,\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2] =\n4, Length [c, c_2, c_3, c_4] = 4]"
|
Walther@60729
|
407 |
= where_' |> map #2 |> UnparseC.terms @{context}
|
Walther@60729
|
408 |
|
Walther@60758
|
409 |
val (env_model, (env_subst, env_eval)) =
|
Walther@60758
|
410 |
make_environments model_patt i_model;
|
Walther@60758
|
411 |
"~~~~~ fun make_environments , args:"; val (model_patt, i_model) = (model_patt, i_model);
|
Walther@60758
|
412 |
val equal_descr_pairs = map (get_equal_descr i_model) model_patt
|
Walther@60758
|
413 |
|> flat
|
Walther@60729
|
414 |
val env_model = make_env_model equal_descr_pairs
|
Walther@60729
|
415 |
val equal_givens = filter (fn ((m_field, _), _) => m_field = "#Given") equal_descr_pairs
|
Walther@60729
|
416 |
|
Walther@60729
|
417 |
val subst_eval_list =
|
Walther@60729
|
418 |
make_envs_preconds equal_givens;
|
Walther@60729
|
419 |
"~~~~~ fun make_envs_preconds , args:"; val (equal_givens) = (equal_givens);
|
Walther@60729
|
420 |
"~~~~~ fun xxx , args:"; val ((_, (_, id)), (_, _, _, _, (feedb, _))) = (nth 1 equal_givens);
|
Walther@60750
|
421 |
"~~~~~ fun discern_feedback , args:"; val (id, (Model_Def.Cor_TEST ((descr, ts)))) =
|
Walther@60729
|
422 |
(id, feedb);
|
Walther@60729
|
423 |
|
Walther@60729
|
424 |
val return_discern_typ as [] =
|
Walther@60729
|
425 |
discern_typ id (descr, ts);
|
Walther@60729
|
426 |
"~~~~~ fun discern_typ , args:"; val (id, (descr, ts)) = (id, (descr, ts));
|
Walther@60729
|
427 |
|
Walther@60729
|
428 |
(*+*)val "[[0 = - 1 * c_4 / - 1], [0 =\n (- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c +\n - 1 * L \<up> 4 * q_0) /\n - 24], [0 = c_2], [0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]]"
|
Walther@60729
|
429 |
= ts |> UnparseC.terms @{context}
|
Walther@60729
|
430 |
|
Walther@60763
|
431 |
val ts = if Pre_Conds.is_list_descr descr
|
Walther@60729
|
432 |
then if TermC.is_list (hd ts)
|
Walther@60729
|
433 |
then ts |> map TermC.isalist2list |> flat
|
Walther@60729
|
434 |
else ts
|
Walther@60729
|
435 |
else ts
|
Walther@60729
|
436 |
|
Walther@60729
|
437 |
(*+*)val "[0 = - 1 * c_4 / - 1, 0 =\n(- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c +\n - 1 * L \<up> 4 * q_0) /\n- 24, 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]"
|
Walther@60729
|
438 |
= ts |> UnparseC.terms @{context};
|
Walther@60729
|
439 |
|
Walther@60729
|
440 |
(*if*) Model_Pattern.typ_of_element descr = HOLogic.boolT (*then*);
|
Walther@60729
|
441 |
|
Walther@60729
|
442 |
(*+*)val false = all_lhs_atoms ts
|
Walther@60741
|
443 |
(*-------------------- contine check -----------------------------------------------------*)
|
Walther@60729
|
444 |
|
Walther@60730
|
445 |
val pres_subst = map (TermC.subst_atomic_all env_subst) where_;
|
Walther@60729
|
446 |
|
Walther@60729
|
447 |
(*+*)if "[\"\n" ^
|
Walther@60729
|
448 |
"(e_s, [0 = - 1 * c_4 / - 1,\n 0 =\n (- 24 * c_4 + - 24 * L * c_3 + 12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c +\n - 1 * L \<up> 4 * q_0) /\n - 24,\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2])\", \"\n" ^
|
Walther@60729
|
449 |
"(v_s, [c, c_2, c_3, c_4])\", \"\n(ss''', ss''')\"]"
|
Walther@60729
|
450 |
= (env_model |> Subst.to_string @{context}) then () else error "env_model CAHNGED";
|
Walther@60729
|
451 |
(*+*)val "[]" = env_eval |> Subst.to_string @{context} (*GOON \<rightarrow> []*)
|
Walther@60729
|
452 |
|
Walther@60729
|
453 |
val pres_subst_other = map (TermC.subst_atomic_all env_model) (map #2 pres_subst);
|
Walther@60729
|
454 |
val full_subst = if env_eval = [] then pres_subst_other
|
Walther@60729
|
455 |
else map (TermC.subst_atomic_all env_eval) (map #2 pres_subst_other)
|
Walther@60729
|
456 |
val evals = map (eval ctxt where_rls) full_subst
|
Walther@60729
|
457 |
val return_check_OLD = (foldl and_ (true, map fst evals), pres_subst_other)
|
Walther@60729
|
458 |
|
Walther@60729
|
459 |
val return_refin as SOME ["system", "LINEAR", "4x4"] = SOME (pblRD(** ) @ [pI]( **))
|
Walther@60729
|
460 |
|
Walther@60742
|
461 |
(*follow the trace created in parallel by writeln in Store.get_node and Refine.check_match*)
|
Walther@60729
|
462 |
(*!*)val pblID = ["normalise", "4x4", "LINEAR", "system"];(**)
|
Walther@60729
|
463 |
val return_refin as SOME ["system", "LINEAR", "4x4", "normalise", "normalise"] =
|
Walther@60742
|
464 |
check_match ctxt (rev pblID) oris (Store.get_node (rev pblID) pblID (get_pbls ()));
|
Walther@60729
|
465 |
|
Walther@60729
|
466 |
|
Walther@60736
|
467 |
(** -------- Refine_Problem (from subp-rooteq.sml) ------------------------------------------- **)
|
walther@60021
|
468 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
walther@60021
|
469 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
walther@60021
|
470 |
(*
|
walther@60021
|
471 |
By child of 2d962612dd0a this test case revealed an undetected failure
|
walther@60021
|
472 |
of Specify.find_next_step -- for_problem: these propose Tactic.Refine_Problem,
|
walther@60021
|
473 |
but Step_Specify.by_tactic_input (Refine_Problem ["sqroot-test", "univariate", "equation", "test"]..
|
walther@60021
|
474 |
encounters "case Refine.problem ... of NONE".
|
walther@60021
|
475 |
The failure might be caused by inappropriate problem-hierarchy.
|
walther@60021
|
476 |
*)
|
walther@59967
|
477 |
val c = [];
|
walther@60242
|
478 |
val fmz = ["equality ((x+1)*(x+2)=x \<up> 2+(8::real))", "solveFor x",
|
walther@59997
|
479 |
"errorBound (eps=0)", "solutions L"];
|
walther@59997
|
480 |
val (dI',pI',mI') = ("Test",["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
481 |
["Test", "squ-equ-test-subpbl1"]);
|
Walther@60571
|
482 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(fmz, (dI',pI',mI'))];
|
walther@59967
|
483 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
484 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
485 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Find "solutions L"*)
|
walther@59967
|
486 |
|
walther@59967
|
487 |
(*=== specify a not-matching problem ---vvvvvvvvvvvvvvvvvvvvvvvvvvvv*)
|
walther@59997
|
488 |
val nxt = (Specify_Problem ["LINEAR", "univariate", "equation", "test"]);
|
walther@60242
|
489 |
(*=== specify a not-matching problem --- \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> ^*)
|
walther@60021
|
490 |
|
walther@59967
|
491 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Find "solutions L"*)
|
walther@59967
|
492 |
|
Walther@60756
|
493 |
(*WAS at change set b817019bfda7 and before (while Test_Isac.thy was without other errors):
|
walther@59967
|
494 |
val www =
|
walther@59967
|
495 |
case f of Test_Out.PpcKF (Test_Out.Problem [],
|
walther@59967
|
496 |
{Find = [Incompl "solutions []"], With = [],
|
walther@60242
|
497 |
Given = [Correct "equality ((x + 1) * (x + 2) = x \<up> 2 + 8)", Correct "solveFor x"],
|
Walther@60729
|
498 |
Where = [Correct(*WAS False*) www(*! ! ! ! ! !*)],
|
walther@59967
|
499 |
Relate = [],...}) => www(*! ! !*)
|
walther@59967
|
500 |
| _ => error "--- Refine_Problem broken 1";
|
walther@60242
|
501 |
if www = "matches (x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8) \<or>\nmatches (?b * x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8) \<or>\nmatches (?a + x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8) \<or>\nmatches (?a + ?b * x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8)"
|
walther@59967
|
502 |
then () else error "--- Refine_Problem broken 2";
|
Walther@60756
|
503 |
*)
|
walther@59967
|
504 |
(*ML> f;
|
walther@59967
|
505 |
val it = Form' (Test_Out.PpcKF (0,EdUndef,0,Nundef,
|
walther@59997
|
506 |
(Problem ["LINEAR", "univariate", "equation", "test"], <<<<<===== diff.to above WN120313
|
walther@59967
|
507 |
{Find=[Incompl "solutions []"],
|
walther@60242
|
508 |
Given=[Correct "equality ((x + #1) * (x + #2) = x \<up> #2 + #8)",
|
walther@59967
|
509 |
Correct "solveFor x"],Relate=[],
|
walther@60242
|
510 |
Where=[False "matches (x = #0) ((x + #1) * (x + #2) = x \<up> #2 + #8)
|
walther@60242
|
511 |
|\nmatches (?b * x = #0) ((x + #1) * (x + #2) = x \<up> #2 + #8)
|
walther@60242
|
512 |
|\nmatches (?a + x = #0) ((x + #1) * (x + #2) = x \<up> #2 + #8)
|
walther@60242
|
513 |
|\nmatches (?a + ?b * x = #0) ((x + #1) * (x + #2) = x \<up> #2 + #8)"],
|
walther@59967
|
514 |
With=[]}))) : mout
|
walther@59967
|
515 |
*)
|
walther@59967
|
516 |
|
walther@60021
|
517 |
(*/------------------- step into me Add_Find "solutions L" ---------------------------------\*)
|
walther@60021
|
518 |
(*[], Pbl*)val (p''''',_,f''''',nxt''''',_,pt''''') = (me nxt p c pt);
|
walther@60021
|
519 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
|
walther@60021
|
520 |
|
walther@60021
|
521 |
(*+*)val Add_Find "solutions L" = tac;
|
walther@60021
|
522 |
|
walther@60021
|
523 |
val (pt, p) =
|
walther@60021
|
524 |
(*Step.by_tactic is here for testing by me; do_next would suffice in me*)
|
walther@60021
|
525 |
case Step.by_tactic tac (pt, p) of
|
walther@60021
|
526 |
("ok", (_, _, ptp)) => ptp
|
walther@60021
|
527 |
| ("unsafe-ok", (_, _, ptp)) => ptp
|
walther@60021
|
528 |
| ("not-applicable",_) => (pt, p)
|
walther@60021
|
529 |
| ("end-of-calculation", (_, _, ptp)) => ptp
|
walther@60021
|
530 |
| ("failure", _) => raise ERROR "sys-raise ERROR"
|
walther@60021
|
531 |
| _ => raise ERROR "me: uncovered case Step.by_tactic"
|
walther@60021
|
532 |
|
Walther@60729
|
533 |
val ("ok", ([(Add_Find "solutions L", _, _)], [], _)) = (*case*)
|
walther@60021
|
534 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
walther@60021
|
535 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
|
walther@60021
|
536 |
(*if*) Pos.on_calc_end ip (*else*);
|
walther@60021
|
537 |
val (_, probl_id, _) = Calc.references (pt, p);
|
walther@60021
|
538 |
val _ = (*case*) tacis (*of*);
|
walther@60021
|
539 |
(*if*) probl_id = Problem.id_empty (*else*);
|
walther@60021
|
540 |
|
walther@60021
|
541 |
switch_specify_solve p_ (pt, ip) (*return from Step.do_next*);
|
walther@60021
|
542 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
walther@60021
|
543 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
walther@60021
|
544 |
|
Walther@60729
|
545 |
val ("ok", ([(Add_Find "solutions L", _, _)], [], _)) =
|
walther@60021
|
546 |
specify_do_next (pt, input_pos);
|
walther@60021
|
547 |
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
|
walther@60021
|
548 |
val (_, (p_', tac)) =
|
walther@60021
|
549 |
Specify.find_next_step ptp;
|
walther@60021
|
550 |
(*/------------------- step into find_next_step --------------------------------------------\*)
|
walther@60021
|
551 |
(*+ store for continuation after find_next_step*)val (p_'_'''''_', tac'''''_') = (p_', tac);
|
walther@60021
|
552 |
|
walther@60021
|
553 |
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
|
walther@60021
|
554 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
walther@60021
|
555 |
spec = refs, ...} = Calc.specify_data (pt, pos);
|
walther@60021
|
556 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
walther@60021
|
557 |
(*if*) p_ = Pos.Pbl (*then*);
|
walther@60021
|
558 |
|
Walther@60729
|
559 |
val ("dummy", (Pbl, Add_Find "solutions L")) =
|
Walther@60763
|
560 |
for_problem ctxt oris (o_refs, refs) (pbl, I_Model.OLD_to_TEST met);
|
walther@60021
|
561 |
"~~~~~ fun for_problem , args:"; val (oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
|
walther@60021
|
562 |
(oris, (o_refs, refs), (pbl, met));
|
walther@60021
|
563 |
val cpI = if pI = Problem.id_empty then pI' else pI;
|
walther@60154
|
564 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
Walther@60586
|
565 |
val {model = pbt, where_rls, where_, ...} = Problem.from_store ctxt cpI;
|
Walther@60586
|
566 |
val {model = mpc, ...} = MethodC.from_store ctxt cmI
|
Walther@60741
|
567 |
val (preok, _) = Pre_Conds.check ctxt where_rls where_ (pbt, I_Model.OLD_to_TEST pbl);
|
walther@60021
|
568 |
(*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
|
walther@60021
|
569 |
(*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
|
walther@60021
|
570 |
val NONE = (*case*) find_first (I_Model.is_error o #5) pbl (*of*);
|
Walther@60729
|
571 |
val SOME ("#Find", "solutions L") = (*case*)
|
Walther@60763
|
572 |
item_to_add ctxt oris (I_Model.OLD_to_TEST pbl);
|
walther@60021
|
573 |
(*if*) not preok (*then*);
|
walther@60021
|
574 |
|
Walther@60673
|
575 |
(*+*)Pre_Conds.to_string @{context} xxxxx = "[\n" ^
|
walther@60242
|
576 |
"(false, matches (x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8) \<or>\n" ^
|
walther@60242
|
577 |
"matches (?b * x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8) \<or>\n" ^
|
walther@60242
|
578 |
"matches (?a + x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8) \<or>\n" ^
|
walther@60242
|
579 |
"matches (?a + ?b * x = 0) ((x + 1) * (x + 2) = x \<up> 2 + 8))]";
|
walther@60242
|
580 |
(*TermC.matches \<up> \<up> \<up> \<up> \<up> ^ NONE, ok: why then NONE = Refine.problem below?*)
|
walther@60021
|
581 |
(*-------------------- stop step into find_next_step ----------------------------------------*)
|
walther@60021
|
582 |
(*+ continue after find_next_step*)val (p_', tac) = (p_'_'''''_', tac'''''_')
|
walther@60021
|
583 |
(*\------------------- step into find_next_step --------------------------------------------/*)
|
walther@60021
|
584 |
|
walther@60021
|
585 |
(*-------------------- contiue step into specify_do_next ------------------------------------*)
|
walther@60021
|
586 |
val ist_ctxt = Ctree.get_loc pt (p, p_)
|
Walther@60729
|
587 |
val Add_Find "solutions L" =
|
walther@60021
|
588 |
(*case*) tac (*of*);
|
Walther@60729
|
589 |
|
Walther@60729
|
590 |
val ("ok", ([(Add_Find "solutions L", _, _)], [], _)) =
|
walther@60021
|
591 |
Step_Specify.by_tactic_input tac (pt, (p, p_'));
|
Walther@60729
|
592 |
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Add_Find ct), (ptp as (pt, pos as (p,_)))) =
|
walther@60021
|
593 |
(tac, (pt, (p, p_')));
|
walther@60021
|
594 |
|
Walther@60729
|
595 |
Specify.by_Add_ "#Find" ct ptp;
|
Walther@60729
|
596 |
"~~~~~ fun by_Add_ , args:"; val (m_field, ct, (pt, pos as (_, p_))) =
|
Walther@60729
|
597 |
("#Find", ct, ptp);
|
walther@60021
|
598 |
(*-------------------- stop step into -------------------------------------------------------*)
|
Walther@60729
|
599 |
val (p,f,nxt,pt) = (p''''',f''''',nxt''''',pt'''''); val Add_Find "solutions L" = nxt;
|
walther@60021
|
600 |
(*\------------------- step into me Add_Find "solutions L" ---------------------------------/*)
|
Walther@60729
|
601 |
(*
|
Walther@60729
|
602 |
WN230814
|
Walther@60729
|
603 |
repaired 'step into me Add_Find "solutions L"' above (ERROR was Tactic.Refine);
|
Walther@60729
|
604 |
But with the repair the subsequent steps repeatedly led to Add_Find "solutions L" --
|
Walther@60729
|
605 |
-- which was NOT repaird, too.
|
Walther@60729
|
606 |
So we kept the old test code below, because it leads to the correct result "[x = 2]".
|
Walther@60729
|
607 |
|
Walther@60729
|
608 |
---------------------- old test code from before above repair -------------------------------
|
walther@59967
|
609 |
|
walther@59967
|
610 |
(*=== refine problem -----vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*)
|
walther@59997
|
611 |
val nxt = (Refine_Problem ["univariate", "equation", "test"]);
|
walther@60242
|
612 |
(*=== refine problem ----- \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> ^^*)
|
walther@59967
|
613 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
614 |
(*("Specify_Problem", Specify_Problem ["normalise", "univariate", ...])*)
|
walther@59967
|
615 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
616 |
(*nxt = ("Specify_Theory", Specify_Theory "Test")*)
|
walther@59967
|
617 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
618 |
(*nxt = ("Specify_Method", Specify_Method ["Test", "squ-equ-test-subpbl1"]*)
|
walther@59967
|
619 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
620 |
(*nxt = ("Apply_Method", *)
|
walther@59967
|
621 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
622 |
(*nxt = ("Rewrite_Set", Rewrite_Set "norm_equation")*)
|
walther@59967
|
623 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
624 |
(*nxt = ("Rewrite_Set", Rewrite_Set "Test_simplify")*)
|
walther@59967
|
625 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
626 |
(*Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]*)
|
walther@59967
|
627 |
|
walther@59967
|
628 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
629 |
(*nxt = Model_Problem ["LINEAR", "univariate", "equation", "test"]*)
|
walther@59967
|
630 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
631 |
(*nxt = ("Add_Given", Add_Given "equality (-6 + 3 * x = 0)"*)
|
walther@59967
|
632 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
633 |
(**)
|
walther@59967
|
634 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
635 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
636 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
637 |
(*nxt = Specify_Problem ["LINEAR", "univariate", "equation", "test"])*)
|
walther@59967
|
638 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
639 |
(*xt = ("Specify_Method", Specify_Method ["Test", "solve_linear"])*)
|
walther@59997
|
640 |
val nxt = (Refine_Problem ["univariate", "equation", "test"]);
|
walther@59967
|
641 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
642 |
(*("Specify_Problem", Specify_Problem ["LINEAR", "univariate", ...])*)
|
walther@59967
|
643 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
644 |
(*val nxt = ("Specify_Method",Specify_Method ("Test", "solve_linear"))*)
|
walther@59967
|
645 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
646 |
(*val nxt = ("Apply_Method",Apply_Method ("Test", "solve_linear"))*)
|
walther@59967
|
647 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
648 |
(*val nxt = ("Rewrite_Set_Inst",Rewrite_Set_Inst ([#],"isolate_bdv"))*)
|
walther@59967
|
649 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
650 |
(*val nxt = ("Rewrite_Set",Rewrite_Set "Test_simplify")*)
|
walther@59967
|
651 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
652 |
(*val nxt = ("Check_Postcond",Check_Postcond ["LINEAR", "univariate", "eq*)
|
walther@59967
|
653 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
654 |
(*val nxt = ("Check_elementwise",Check_elementwise "Assumptions")*)
|
walther@59967
|
655 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
656 |
(*Check_Postcond ["normalise", "univariate", "equation", "test"])*)
|
walther@59967
|
657 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
658 |
val Test_Out.FormKF res = f;
|
walther@59967
|
659 |
|
walther@59967
|
660 |
if res = "[x = 2]"
|
walther@59967
|
661 |
then case nxt of End_Proof' => ()
|
walther@59967
|
662 |
| _ => error "new behaviour in test:refine.sml:miniscript with mini-subpb 1"
|
walther@59967
|
663 |
else error "new behaviour in test:refine.sml:miniscript with mini-subpb 2"
|
Walther@60729
|
664 |
*)
|
Walther@60556
|
665 |
|
Walther@60736
|
666 |
(** -------- equation with CalcTree [ = 6 / 5] for timing: with/out adapt_to_type ------------ **)
|
Walther@60556
|
667 |
"----------- equation with CalcTree [ = 6 / 5] for timing: with/out adapt_to_type --------------";
|
Walther@60556
|
668 |
"----------- equation with CalcTree [ = 6 / 5] for timing: with/out adapt_to_type --------------";
|
Walther@60556
|
669 |
(*for timing copy to Test_Some.thy*)
|
Walther@60556
|
670 |
States.reset ();
|
Walther@60556
|
671 |
val model = ["equality (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 2 - 3*x) =1/x)", "solveFor x", "solutions L"];
|
Walther@60556
|
672 |
val refs = ("PolyEq"(**), ["univariate", "equation"], ["no_met"]);
|
Walther@60556
|
673 |
|
Walther@60571
|
674 |
CalcTree @{context} [(model, refs)];
|
Walther@60556
|
675 |
|
Walther@60556
|
676 |
Iterator 1;
|
Walther@60556
|
677 |
moveActiveRoot 1;
|
Walther@60556
|
678 |
autoCalculate 1 CompleteCalc;
|
Walther@60556
|
679 |
|
Walther@60556
|
680 |
val ((pt, _), _) = States.get_calc 1;
|
Walther@60556
|
681 |
val p = States.get_pos 1 1;
|
Walther@60577
|
682 |
val (Form f, tac, asms) = ME_Misc.pt_extract ctxt (pt, p);
|
Walther@60675
|
683 |
if UnparseC.term @{context} f = "[x = 6 / 5]" then () else error "equation for timing CHANGED"
|
Walther@60556
|
684 |
|
Walther@60736
|
685 |
(** -------- refine ad-hoc equation for timing: with/out adapt_to_type ----------------------- **)
|
Walther@60556
|
686 |
"----------- refine ad-hoc equation for timing: with/out adapt_to_type -------------------------";
|
Walther@60556
|
687 |
"----------- refine ad-hoc equation for timing: with/out adapt_to_type -------------------------";
|
Walther@60556
|
688 |
(*for timing copy to Test_Some.thy*)
|
Walther@60556
|
689 |
val model = ["equality ((x \<up> 2 - 6*x+9) - (x \<up> 2 - 3*x) = x)", "solveFor x", "solutions L"];
|
Walther@60556
|
690 |
val (_, pbl_id, _) = ("PolyEq", ["univariate", "equation"], ["no_met"]);
|
Walther@60556
|
691 |
|
Walther@60742
|
692 |
Refine.by_formalise @{context} model pbl_id;
|
Walther@60556
|
693 |
(*
|
Walther@60556
|
694 |
*** pass ["equation", "univariate"]
|
Walther@60556
|
695 |
*** pass ["equation", "univariate", "rootX"]
|
Walther@60556
|
696 |
*** pass ["equation", "univariate", "LINEAR"]
|
Walther@60556
|
697 |
*** pass ["equation", "univariate", "rational"]
|
Walther@60556
|
698 |
*** pass ["equation", "univariate", "polynomial"]
|
Walther@60556
|
699 |
*** pass ["equation", "univariate", "polynomial", "degree_0"]
|
Walther@60556
|
700 |
*** pass ["equation", "univariate", "polynomial", "degree_1"]
|
Walther@60556
|
701 |
*** pass ["equation", "univariate", "polynomial", "degree_2"]
|
Walther@60556
|
702 |
*** pass ["equation", "univariate", "polynomial", "degree_3"]
|
Walther@60556
|
703 |
*** pass ["equation", "univariate", "polynomial", "degree_4"]
|
Walther@60556
|
704 |
*** pass ["equation", "univariate", "polynomial", "normalise"]
|
Walther@60729
|
705 |
*)
|