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@59968
|
10 |
"----------- testdata for refin, Refine.refine_ori --------------------------------------------";
|
walther@59967
|
11 |
(*"----------- refin test-pbtyps -------requires specific 'setup'-------------------------------";*)
|
walther@59968
|
12 |
"----------- Refine.refine_ori test-pbtyps --requires 'setup'----------------------------------";
|
walther@59967
|
13 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
walther@60021
|
14 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
walther@59967
|
15 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
16 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
17 |
"-----------------------------------------------------------------------------------------------";
|
walther@59967
|
18 |
|
walther@59967
|
19 |
|
walther@59968
|
20 |
"----------- testdata for refin, Refine.refine_ori --------------------------------------------";
|
walther@59968
|
21 |
"----------- testdata for refin, Refine.refine_ori --------------------------------------------";
|
walther@59968
|
22 |
"----------- testdata for refin, Refine.refine_ori --------------------------------------------";
|
walther@59971
|
23 |
Test_Tool.show_ptyps();
|
walther@59967
|
24 |
val thy = @{theory "Isac_Knowledge"};
|
walther@59967
|
25 |
val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"};
|
walther@59967
|
26 |
|
walther@59967
|
27 |
(*case 1: no refinement *)
|
walther@59967
|
28 |
val (d1,ts1) = Input_Descript.split ((Thm.term_of o the o (TermC.parse thy)) "fixedValues [aaa = 0]");
|
walther@59967
|
29 |
val (d2,ts2) = Input_Descript.split ((Thm.term_of o the o (TermC.parse thy)) "errorBound (ddd = 0)");
|
walther@59967
|
30 |
val ori1 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]: O_Model.T;
|
walther@59967
|
31 |
|
walther@59967
|
32 |
(*case 2: refined to pbt without children *)
|
walther@59967
|
33 |
val (d2,ts2) = Input_Descript.split ((Thm.term_of o the o (TermC.parse thy)) "relations [aaa333]");
|
walther@59967
|
34 |
val ori2 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]:O_Model.T;
|
walther@59967
|
35 |
|
walther@59967
|
36 |
(*case 3: refined to pbt with children *)
|
walther@59967
|
37 |
val (d2,ts2) = Input_Descript.split ((Thm.term_of o the o (TermC.parse thy)) "valuesFor [aaa222]");
|
walther@59967
|
38 |
val ori3 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2)]:O_Model.T;
|
walther@59967
|
39 |
|
walther@59967
|
40 |
(*case 4: refined to children (without child)*)
|
walther@59967
|
41 |
val (d3,ts3) = Input_Descript.split ((Thm.term_of o the o (TermC.parse thy)) "boundVariable aaa222yyy");
|
walther@59967
|
42 |
val ori4 = [(1,[1],"#Given",d1,ts1), (2,[1],"#Given",d2,ts2), (3,[1],"#Given",d3,ts3)]:O_Model.T;
|
walther@59967
|
43 |
|
walther@59967
|
44 |
(*=================================================================
|
walther@59967
|
45 |
This test expects pbls at a certain position in the tree.
|
walther@59967
|
46 |
Since parallel evaluation (i.e. Theory_Data) this cannot be expected.
|
walther@59967
|
47 |
Solutions would be
|
walther@59967
|
48 |
* provide an access function for a branch (not only leaves)
|
walther@59967
|
49 |
* sort the tree of pbls.
|
walther@59967
|
50 |
"----------- refin test-pbtyps -------requires specific 'setup'-------------------------------";
|
walther@59967
|
51 |
"----------- refin test-pbtyps -------requires specific 'setup'-------------------------------";
|
walther@59967
|
52 |
"----------- refin test-pbtyps -------requires specific 'setup'-------------------------------";
|
walther@59967
|
53 |
(* fragile test setup: expects ptyps as fixed *)
|
walther@59967
|
54 |
val level_1 = case nth 9 (get_ptyps ()) of
|
walther@59967
|
55 |
Store.Node ("test", _, level_1) => level_1 | _ => error "refin broken: root-branch in ptyps changed?"
|
walther@59967
|
56 |
val level_2 = case nth 4 level_1 of
|
walther@59967
|
57 |
Store.Node ("refine", _, level_2) => level_2 | _ => error "refin broken: lev1-branch in ptyps changed?"
|
walther@59967
|
58 |
val pbla_branch = case level_2 of
|
walther@59967
|
59 |
[Store.Node ("pbla", _, _)] => level_2 | _ => error "refin broken: lev2-branch in ptyps changed?";
|
walther@59967
|
60 |
|
walther@59967
|
61 |
(*case 1: no refinement *)
|
walther@59967
|
62 |
case refin [] ori1 (hd pbla_branch) of
|
walther@59967
|
63 |
SOME ["pbla"] => () | _ => error "refin case 1 broken";
|
walther@59967
|
64 |
|
walther@59967
|
65 |
(*case 2: refined to pbt without children *)
|
walther@59967
|
66 |
case refin [] ori2 (hd pbla_branch) of
|
walther@59967
|
67 |
SOME ["pbla", "pbla3"] => () | _ => error "refin case 2 broken";
|
walther@59967
|
68 |
|
walther@59967
|
69 |
(*case 3: refined to pbt with children *)
|
walther@59967
|
70 |
case refin [] ori3 (hd pbla_branch) of
|
walther@59967
|
71 |
SOME ["pbla", "pbla2"] => () | _ => error "refin case 3 broken";
|
walther@59967
|
72 |
|
walther@59967
|
73 |
(*case 4: refined to children (without child)*)
|
walther@59967
|
74 |
case refin [] ori4 (hd pbla_branch) of
|
walther@59967
|
75 |
SOME ["pbla", "pbla2", "pbla2y"] => () | _ => error "refin case 4 broken";
|
walther@59967
|
76 |
|
walther@59967
|
77 |
(*case 5: start refinement somewhere in ptyps*)
|
walther@59967
|
78 |
val [Store.Node ("pbla",_,[_, ppp as Store.Node ("pbla2",_,_), _])] = pbla_branch;
|
walther@59967
|
79 |
case refin ["pbla"] ori4 ppp of
|
walther@59967
|
80 |
SOME ["pbla", "pbla2", "pbla2y"] => () | _ => error "refin case 5 broken";
|
walther@59967
|
81 |
==================================================================*)
|
walther@59967
|
82 |
|
walther@59967
|
83 |
|
walther@59968
|
84 |
"----------- Refine.refine_ori test-pbtyps --requires 'setup'----------------------------------";
|
walther@59968
|
85 |
"----------- Refine.refine_ori test-pbtyps --requires 'setup'----------------------------------";
|
walther@59968
|
86 |
"----------- Refine.refine_ori test-pbtyps --requires 'setup'----------------------------------";
|
walther@59967
|
87 |
(*case 1: no refinement *)
|
walther@59968
|
88 |
case Refine.refine_ori ori1 ["pbla", "refine", "test"] of
|
walther@59968
|
89 |
NONE => () | _ => error "Refine.refine_ori case 1 broken";
|
walther@59967
|
90 |
|
walther@59967
|
91 |
(*case 2: refined to pbt without children *)
|
walther@59968
|
92 |
case Refine.refine_ori ori2 ["pbla", "refine", "test"] of
|
walther@59968
|
93 |
SOME ["pbla3", "pbla", "refine", "test"] => () | _ => error "Refine.refine_ori case 2 broken";
|
walther@59967
|
94 |
|
walther@59967
|
95 |
(*case 3: refined to pbt with children *)
|
walther@59968
|
96 |
case Refine.refine_ori ori3 ["pbla", "refine", "test"] of
|
walther@59968
|
97 |
SOME ["pbla2", "pbla", "refine", "test"] => () | _ => error "Refine.refine_ori case 3 broken";
|
walther@59967
|
98 |
|
walther@59967
|
99 |
(*case 4: refined to children (without child)*)
|
walther@59968
|
100 |
case Refine.refine_ori ori4 ["pbla", "refine", "test"] of
|
walther@59997
|
101 |
SOME ["pbla2y", "pbla2", "pbla", "refine", "test"] => () | _ => error "Refine.refine_ori case 4 broken";
|
walther@59967
|
102 |
|
walther@59967
|
103 |
(*case 5: start refinement somewhere in ptyps*)
|
walther@59997
|
104 |
case Refine.refine_ori ori4 ["pbla2", "pbla", "refine", "test"] of
|
walther@59968
|
105 |
SOME ["pbla2y", "pbla2", "pbla", "refine", "test"] => () | _ => error "Refine.refine_ori case 5 broken";
|
walther@59967
|
106 |
|
walther@59967
|
107 |
|
walther@59967
|
108 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
walther@59967
|
109 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
walther@59967
|
110 |
"----------- refine test-pbtyps ------requires 'setup'------------------------------------------";
|
walther@59997
|
111 |
val fmz1 = ["fixedValues [aaa=0]", "errorBound (ddd=0)"];
|
walther@59997
|
112 |
val fmz2 = ["fixedValues [aaa=0]", "relations aaa333"];
|
walther@59997
|
113 |
val fmz3 = ["fixedValues [aaa=0]", "valuesFor [aaa222]"];
|
walther@59997
|
114 |
val fmz4 = ["fixedValues [aaa=0]", "valuesFor [aaa222]",
|
walther@59967
|
115 |
"boundVariable aaa222yyy"];
|
walther@59967
|
116 |
|
walther@59967
|
117 |
(*case 1: no refinement *)
|
walther@59968
|
118 |
case Refine.refine fmz1 ["pbla", "refine", "test"] of
|
walther@59984
|
119 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
120 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
121 |
M_Match.NoMatch (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
122 |
M_Match.NoMatch (["pbla3", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
123 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 1";
|
walther@59967
|
124 |
(*
|
walther@59967
|
125 |
*** pass ["pbla"]
|
walther@59997
|
126 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
127 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
128 |
*** pass ["pbla", "pbla3"]
|
walther@59967
|
129 |
val it =
|
walther@59984
|
130 |
[M_Match.Matches
|
walther@59967
|
131 |
(["pbla"],
|
walther@59967
|
132 |
{Find=[],
|
walther@59967
|
133 |
Given=[Correct "fixedValues [aaa = #0]",
|
walther@59967
|
134 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
135 |
M_Match.NoMatch
|
walther@59997
|
136 |
(["pbla1", "pbla"],
|
walther@59967
|
137 |
{Find=[],
|
walther@59967
|
138 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
139 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
140 |
M_Match.NoMatch
|
walther@59997
|
141 |
(["pbla2", "pbla"],
|
walther@59967
|
142 |
{Find=[],
|
walther@59967
|
143 |
Given=[Correct "fixedValues [aaa = #0]",Missing "valuesFor a2_",
|
walther@59967
|
144 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
145 |
M_Match.NoMatch
|
walther@59997
|
146 |
(["pbla3", "pbla"],
|
walther@59967
|
147 |
{Find=[],
|
walther@59967
|
148 |
Given=[Correct "fixedValues [aaa = #0]",Missing "relations a3_",
|
walther@59967
|
149 |
Superfl "errorBound (ddd = #0)"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
150 |
: match list*)
|
walther@59967
|
151 |
|
walther@59967
|
152 |
(*case 2: refined to pbt without children *)
|
walther@59968
|
153 |
case Refine.refine fmz2 ["pbla", "refine", "test"] of
|
walther@59984
|
154 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
155 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
156 |
M_Match.NoMatch (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
157 |
M_Match.Matches (["pbla3", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
158 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 2";
|
walther@59967
|
159 |
(*
|
walther@59967
|
160 |
*** pass ["pbla"]
|
walther@59997
|
161 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
162 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
163 |
*** pass ["pbla", "pbla3"]
|
walther@59967
|
164 |
val it =
|
walther@59984
|
165 |
[M_Match.Matches
|
walther@59967
|
166 |
(["pbla"],
|
walther@59967
|
167 |
{Find=[],
|
walther@59967
|
168 |
Given=[Correct "fixedValues [aaa = #0]",Superfl "relations aaa333"],
|
walther@59967
|
169 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
170 |
M_Match.NoMatch
|
walther@59997
|
171 |
(["pbla1", "pbla"],
|
walther@59967
|
172 |
{Find=[],
|
walther@59967
|
173 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
174 |
Superfl "relations aaa333"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
175 |
M_Match.NoMatch
|
walther@59997
|
176 |
(["pbla2", "pbla"],
|
walther@59967
|
177 |
{Find=[],
|
walther@59967
|
178 |
Given=[Correct "fixedValues [aaa = #0]",Missing "valuesFor a2_",
|
walther@59967
|
179 |
Superfl "relations aaa333"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
180 |
M_Match.Matches
|
walther@59997
|
181 |
(["pbla3", "pbla"],
|
walther@59967
|
182 |
{Find=[],
|
walther@59967
|
183 |
Given=[Correct "fixedValues [aaa = #0]",Correct "relations aaa333"],
|
walther@59967
|
184 |
Relate=[],Where=[],With=[]})] : match list*)
|
walther@59967
|
185 |
|
walther@59967
|
186 |
(*case 3: refined to pbt with children *)
|
walther@59968
|
187 |
case Refine.refine fmz3 ["pbla", "refine", "test"] of
|
walther@59984
|
188 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
189 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
190 |
M_Match.Matches (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
191 |
M_Match.NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
192 |
M_Match.NoMatch (["pbla2y", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
193 |
M_Match.NoMatch (["pbla2z", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
194 |
M_Match.NoMatch (["pbla3", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
195 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 3";
|
walther@59967
|
196 |
(*
|
walther@59967
|
197 |
*** pass ["pbla"]
|
walther@59997
|
198 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
199 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
200 |
*** pass ["pbla", "pbla2", "pbla2x"]
|
walther@59997
|
201 |
*** pass ["pbla", "pbla2", "pbla2y"]
|
walther@59997
|
202 |
*** pass ["pbla", "pbla2", "pbla2z"]
|
walther@59997
|
203 |
*** pass ["pbla", "pbla3"]
|
walther@59967
|
204 |
val it =
|
walther@59984
|
205 |
[M_Match.Matches
|
walther@59967
|
206 |
(["pbla"],
|
walther@59967
|
207 |
{Find=[],
|
walther@59967
|
208 |
Given=[Correct "fixedValues [aaa = #0]",Superfl "valuesFor aaa222"],
|
walther@59967
|
209 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
210 |
M_Match.NoMatch
|
walther@59997
|
211 |
(["pbla1", "pbla"],
|
walther@59967
|
212 |
{Find=[],
|
walther@59967
|
213 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
214 |
Superfl "valuesFor aaa222"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
215 |
M_Match.Matches
|
walther@59997
|
216 |
(["pbla2", "pbla"],
|
walther@59967
|
217 |
{Find=[],
|
walther@59967
|
218 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222"],
|
walther@59967
|
219 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
220 |
M_Match.NoMatch
|
walther@59997
|
221 |
(["pbla2x", "pbla2", "pbla"],
|
walther@59967
|
222 |
{Find=[],
|
walther@59967
|
223 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
224 |
Missing "functionOf a2x_"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
225 |
M_Match.NoMatch
|
walther@59997
|
226 |
(["pbla2y", "pbla2", "pbla"],
|
walther@59967
|
227 |
{Find=[],
|
walther@59967
|
228 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
229 |
Missing "boundVariable a2y_"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
230 |
M_Match.NoMatch
|
walther@59997
|
231 |
(["pbla2z", "pbla2", "pbla"],
|
walther@59967
|
232 |
{Find=[],
|
walther@59967
|
233 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
234 |
Missing "interval a2z_"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
235 |
M_Match.NoMatch
|
walther@59997
|
236 |
(["pbla3", "pbla"],
|
walther@59967
|
237 |
{Find=[],
|
walther@59967
|
238 |
Given=[Correct "fixedValues [aaa = #0]",Missing "relations a3_",
|
walther@59967
|
239 |
Superfl "valuesFor aaa222"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
240 |
: match list*)
|
walther@59967
|
241 |
|
walther@59967
|
242 |
(*case 4: refined to children (without child)*)
|
walther@59968
|
243 |
case Refine.refine fmz4 ["pbla", "refine", "test"] of
|
walther@59984
|
244 |
[M_Match.Matches (["pbla", "refine", "test"], _),
|
walther@59984
|
245 |
M_Match.NoMatch (["pbla1", "pbla", "refine", "test"], _),
|
walther@59984
|
246 |
M_Match.Matches (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
247 |
M_Match.NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
248 |
M_Match.Matches (["pbla2y", "pbla2", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
249 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 4";
|
walther@59967
|
250 |
(*
|
walther@59967
|
251 |
*** pass ["pbla"]
|
walther@59997
|
252 |
*** pass ["pbla", "pbla1"]
|
walther@59997
|
253 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
254 |
*** pass ["pbla", "pbla2", "pbla2x"]
|
walther@59997
|
255 |
*** pass ["pbla", "pbla2", "pbla2y"]
|
walther@59967
|
256 |
val it =
|
walther@59984
|
257 |
[M_Match.Matches
|
walther@59967
|
258 |
(["pbla"],
|
walther@59967
|
259 |
{Find=[],
|
walther@59967
|
260 |
Given=[Correct "fixedValues [aaa = #0]",Superfl "valuesFor aaa222",
|
walther@59967
|
261 |
Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
262 |
M_Match.NoMatch
|
walther@59997
|
263 |
(["pbla1", "pbla"],
|
walther@59967
|
264 |
{Find=[],
|
walther@59967
|
265 |
Given=[Correct "fixedValues [aaa = #0]",Missing "maximum a1_",
|
walther@59967
|
266 |
Superfl "valuesFor aaa222",Superfl "boundVariable aaa222yyy"],
|
walther@59967
|
267 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
268 |
M_Match.Matches
|
walther@59997
|
269 |
(["pbla2", "pbla"],
|
walther@59967
|
270 |
{Find=[],
|
walther@59967
|
271 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
272 |
Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
273 |
M_Match.NoMatch
|
walther@59997
|
274 |
(["pbla2x", "pbla2", "pbla"],
|
walther@59967
|
275 |
{Find=[],
|
walther@59967
|
276 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
277 |
Missing "functionOf a2x_",Superfl "boundVariable aaa222yyy"],
|
walther@59967
|
278 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
279 |
M_Match.Matches
|
walther@59997
|
280 |
(["pbla2y", "pbla2", "pbla"],
|
walther@59967
|
281 |
{Find=[],
|
walther@59967
|
282 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
283 |
Correct "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
284 |
: match list*)
|
walther@59967
|
285 |
|
walther@59967
|
286 |
(*case 5: start refinement somewhere in ptyps*)
|
walther@59997
|
287 |
case Refine.refine fmz4 ["pbla2", "pbla", "refine", "test"] of
|
walther@59984
|
288 |
[M_Match.Matches (["pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
289 |
M_Match.NoMatch (["pbla2x", "pbla2", "pbla", "refine", "test"], _),
|
walther@59984
|
290 |
M_Match.Matches (["pbla2y", "pbla2", "pbla", "refine", "test"], _)] => ()
|
walther@59968
|
291 |
| _ => error "--- Refine.refine test-pbtyps --- broken with case 5";
|
walther@59967
|
292 |
(*
|
walther@59997
|
293 |
*** pass ["pbla", "pbla2"]
|
walther@59997
|
294 |
*** pass ["pbla", "pbla2", "pbla2x"]
|
walther@59997
|
295 |
*** pass ["pbla", "pbla2", "pbla2y"]
|
walther@59967
|
296 |
val it =
|
walther@59984
|
297 |
[M_Match.Matches
|
walther@59997
|
298 |
(["pbla2", "pbla"],
|
walther@59967
|
299 |
{Find=[],
|
walther@59967
|
300 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
301 |
Superfl "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]}),
|
walther@59984
|
302 |
M_Match.NoMatch
|
walther@59997
|
303 |
(["pbla2x", "pbla2", "pbla"],
|
walther@59967
|
304 |
{Find=[],
|
walther@59967
|
305 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
306 |
Missing "functionOf a2x_",Superfl "boundVariable aaa222yyy"],
|
walther@59967
|
307 |
Relate=[],Where=[],With=[]}),
|
walther@59984
|
308 |
M_Match.Matches
|
walther@59997
|
309 |
(["pbla2y", "pbla2", "pbla"],
|
walther@59967
|
310 |
{Find=[],
|
walther@59967
|
311 |
Given=[Correct "fixedValues [aaa = #0]",Correct "valuesFor aaa222",
|
walther@59967
|
312 |
Correct "boundVariable aaa222yyy"],Relate=[],Where=[],With=[]})]
|
walther@59967
|
313 |
: match list*)
|
walther@59967
|
314 |
|
walther@59967
|
315 |
|
walther@60021
|
316 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
walther@60021
|
317 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
walther@60021
|
318 |
"----------- Refine_Problem (from subp-rooteq.sml) ---------------------------------------------";
|
walther@60021
|
319 |
(*
|
walther@60021
|
320 |
By child of 2d962612dd0a this test case revealed an undetected failure
|
walther@60021
|
321 |
of Specify.find_next_step -- for_problem: these propose Tactic.Refine_Problem,
|
walther@60021
|
322 |
but Step_Specify.by_tactic_input (Refine_Problem ["sqroot-test", "univariate", "equation", "test"]..
|
walther@60021
|
323 |
encounters "case Refine.problem ... of NONE".
|
walther@60021
|
324 |
The failure might be caused by inappropriate problem-hierarchy.
|
walther@60021
|
325 |
*)
|
walther@59967
|
326 |
val c = [];
|
walther@59997
|
327 |
val fmz = ["equality ((x+1)*(x+2)=x^^^2+(8::real))", "solveFor x",
|
walther@59997
|
328 |
"errorBound (eps=0)", "solutions L"];
|
walther@59997
|
329 |
val (dI',pI',mI') = ("Test",["sqroot-test", "univariate", "equation", "test"],
|
walther@59997
|
330 |
["Test", "squ-equ-test-subpbl1"]);
|
walther@59967
|
331 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = Test_Code.CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
walther@59967
|
332 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
333 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
334 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Find "solutions L"*)
|
walther@59967
|
335 |
|
walther@59967
|
336 |
(*=== specify a not-matching problem ---vvvvvvvvvvvvvvvvvvvvvvvvvvvv*)
|
walther@59997
|
337 |
val nxt = (Specify_Problem ["LINEAR", "univariate", "equation", "test"]);
|
walther@59967
|
338 |
(*=== specify a not-matching problem ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
|
walther@60021
|
339 |
|
walther@59967
|
340 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt; (*\<rightarrow>Add_Find "solutions L"*)
|
walther@59967
|
341 |
|
walther@59967
|
342 |
val www =
|
walther@59967
|
343 |
case f of Test_Out.PpcKF (Test_Out.Problem [],
|
walther@59967
|
344 |
{Find = [Incompl "solutions []"], With = [],
|
walther@59967
|
345 |
Given = [Correct "equality ((x + 1) * (x + 2) = x ^^^ 2 + 8)", Correct "solveFor x"],
|
walther@59967
|
346 |
Where = [False www(*! ! ! ! ! !*)],
|
walther@59967
|
347 |
Relate = [],...}) => www(*! ! !*)
|
walther@59967
|
348 |
| _ => error "--- Refine_Problem broken 1";
|
walther@59967
|
349 |
if www = "matches (x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\nmatches (?b * x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\nmatches (?a + x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\nmatches (?a + ?b * x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8)"
|
walther@59967
|
350 |
then () else error "--- Refine_Problem broken 2";
|
walther@59967
|
351 |
(*ML> f;
|
walther@59967
|
352 |
val it = Form' (Test_Out.PpcKF (0,EdUndef,0,Nundef,
|
walther@59997
|
353 |
(Problem ["LINEAR", "univariate", "equation", "test"], <<<<<===== diff.to above WN120313
|
walther@59967
|
354 |
{Find=[Incompl "solutions []"],
|
walther@59967
|
355 |
Given=[Correct "equality ((x + #1) * (x + #2) = x ^^^ #2 + #8)",
|
walther@59967
|
356 |
Correct "solveFor x"],Relate=[],
|
walther@59967
|
357 |
Where=[False "matches (x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)
|
walther@59967
|
358 |
|\nmatches (?b * x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)
|
walther@59967
|
359 |
|\nmatches (?a + x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)
|
walther@59967
|
360 |
|\nmatches (?a + ?b * x = #0) ((x + #1) * (x + #2) = x ^^^ #2 + #8)"],
|
walther@59967
|
361 |
With=[]}))) : mout
|
walther@59967
|
362 |
*)
|
walther@59967
|
363 |
|
walther@60021
|
364 |
(*/------------------- step into me Add_Find "solutions L" ---------------------------------\*)
|
walther@60021
|
365 |
(*[], Pbl*)val (p''''',_,f''''',nxt''''',_,pt''''') = (me nxt p c pt);
|
walther@60021
|
366 |
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, c, pt);
|
walther@60021
|
367 |
|
walther@60021
|
368 |
(*+*)val Add_Find "solutions L" = tac;
|
walther@60021
|
369 |
|
walther@60021
|
370 |
val (pt, p) =
|
walther@60021
|
371 |
(*Step.by_tactic is here for testing by me; do_next would suffice in me*)
|
walther@60021
|
372 |
case Step.by_tactic tac (pt, p) of
|
walther@60021
|
373 |
("ok", (_, _, ptp)) => ptp
|
walther@60021
|
374 |
| ("unsafe-ok", (_, _, ptp)) => ptp
|
walther@60021
|
375 |
| ("not-applicable",_) => (pt, p)
|
walther@60021
|
376 |
| ("end-of-calculation", (_, _, ptp)) => ptp
|
walther@60021
|
377 |
| ("failure", _) => raise ERROR "sys-raise ERROR"
|
walther@60021
|
378 |
| _ => raise ERROR "me: uncovered case Step.by_tactic"
|
walther@60021
|
379 |
|
walther@60021
|
380 |
val ("helpless", ([(*\<Or> should contain tac \<Or>*)], [], _)) = (*case*)
|
walther@60021
|
381 |
Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
|
walther@60021
|
382 |
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, Pos.e_pos'), []));
|
walther@60021
|
383 |
(*if*) Pos.on_calc_end ip (*else*);
|
walther@60021
|
384 |
val (_, probl_id, _) = Calc.references (pt, p);
|
walther@60021
|
385 |
val _ = (*case*) tacis (*of*);
|
walther@60021
|
386 |
(*if*) probl_id = Problem.id_empty (*else*);
|
walther@60021
|
387 |
|
walther@60021
|
388 |
switch_specify_solve p_ (pt, ip) (*return from Step.do_next*);
|
walther@60021
|
389 |
"~~~~~ fun switch_specify_solve , args:"; val (state_pos, (pt, input_pos)) = (p_, (pt, ip));
|
walther@60021
|
390 |
(*if*) Pos.on_specification ([], state_pos) (*then*);
|
walther@60021
|
391 |
|
walther@60021
|
392 |
val ("failure", ([], [], _)) =
|
walther@60021
|
393 |
specify_do_next (pt, input_pos);
|
walther@60021
|
394 |
"~~~~~ fun specify_do_next , args:"; val (ptp as (pt, (p, p_))) = (pt, input_pos);
|
walther@60021
|
395 |
val (_, (p_', tac)) =
|
walther@60021
|
396 |
Specify.find_next_step ptp;
|
walther@60021
|
397 |
(*/------------------- step into find_next_step --------------------------------------------\*)
|
walther@60021
|
398 |
(*+ store for continuation after find_next_step*)val (p_'_'''''_', tac'''''_') = (p_', tac);
|
walther@60021
|
399 |
|
walther@60021
|
400 |
"~~~~~ fun find_next_step , args:"; val (pt, pos as (_, p_)) = (ptp);
|
walther@60021
|
401 |
val {meth = met, origin = origin as (oris, o_refs as (_, pI', mI'), _), probl = pbl,
|
walther@60021
|
402 |
spec = refs, ...} = Calc.specify_data (pt, pos);
|
walther@60021
|
403 |
(*if*) Ctree.just_created (pt, pos) andalso origin <> Ctree.e_origin (*else*);
|
walther@60021
|
404 |
(*if*) p_ = Pos.Pbl (*then*);
|
walther@60021
|
405 |
|
walther@60021
|
406 |
val ("dummy", (Pbl, Refine_Problem ["sqroot-test", "univariate", "equation", "test"])) =
|
walther@60021
|
407 |
for_problem oris (o_refs, refs) (pbl, met);
|
walther@60021
|
408 |
"~~~~~ fun for_problem , args:"; val (oris, ((dI', pI', mI'), (dI, pI, mI)), (pbl, met)) =
|
walther@60021
|
409 |
(oris, (o_refs, refs), (pbl, met));
|
walther@60021
|
410 |
val cpI = if pI = Problem.id_empty then pI' else pI;
|
walther@60154
|
411 |
val cmI = if mI = MethodC.id_empty then mI' else mI;
|
walther@60021
|
412 |
val {ppc = pbt, prls, where_, ...} = Problem.from_store cpI;
|
walther@60154
|
413 |
val {ppc = mpc, ...} = MethodC.from_store cmI
|
walther@60021
|
414 |
val (preok, (*+*)xxxxx(*+*) ) = Pre_Conds.check prls where_ pbl 0;
|
walther@60021
|
415 |
(*if*) dI' = ThyC.id_empty andalso dI = ThyC.id_empty (*else*);
|
walther@60021
|
416 |
(*if*) pI' = Problem.id_empty andalso pI = Problem.id_empty (*else*);
|
walther@60021
|
417 |
val NONE = (*case*) find_first (I_Model.is_error o #5) pbl (*of*);
|
walther@60021
|
418 |
val NONE = (*case*)
|
walther@60021
|
419 |
item_to_add (ThyC.get_theory (if dI = ThyC.id_empty then dI' else dI)) oris pbt pbl (*of*);
|
walther@60021
|
420 |
(*if*) not preok (*then*);
|
walther@60021
|
421 |
|
walther@60021
|
422 |
(*+*)Pre_Conds.to_string xxxxx = "[\n" ^
|
walther@60021
|
423 |
"(false, matches (x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\n" ^
|
walther@60021
|
424 |
"matches (?b * x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\n" ^
|
walther@60021
|
425 |
"matches (?a + x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8) \<or>\n" ^
|
walther@60021
|
426 |
"matches (?a + ?b * x = 0) ((x + 1) * (x + 2) = x ^^^ 2 + 8))]";
|
walther@60021
|
427 |
(*matches ^^^^^^^^^^^^^^^^ NONE, ok: why then NONE = Refine.problem below?*)
|
walther@60021
|
428 |
(*-------------------- stop step into find_next_step ----------------------------------------*)
|
walther@60021
|
429 |
(*+ continue after find_next_step*)val (p_', tac) = (p_'_'''''_', tac'''''_')
|
walther@60021
|
430 |
(*\------------------- step into find_next_step --------------------------------------------/*)
|
walther@60021
|
431 |
|
walther@60021
|
432 |
(*-------------------- contiue step into specify_do_next ------------------------------------*)
|
walther@60021
|
433 |
val ist_ctxt = Ctree.get_loc pt (p, p_)
|
walther@60021
|
434 |
val Refine_Problem ["sqroot-test", "univariate", "equation", "test"] =
|
walther@60021
|
435 |
(*case*) tac (*of*);
|
walther@60021
|
436 |
val ("failure", ([(*\<Or> should contain tac \<Or>*)], [], _)) =
|
walther@60021
|
437 |
Step_Specify.by_tactic_input tac (pt, (p, p_'));
|
walther@60021
|
438 |
"~~~~~ fun by_tactic_input , args:"; val ((Tactic.Refine_Problem pI), (ptp as (pt, pos as (p,_)))) =
|
walther@60021
|
439 |
(tac, (pt, (p, p_')));
|
walther@60021
|
440 |
val (dI, dI', probl, ctxt) = case get_obj I pt p of
|
walther@60021
|
441 |
PblObj {origin= (_, (dI, _, _), _), spec = (dI', _, _), probl, ctxt, ...} =>
|
walther@60021
|
442 |
(dI, dI', probl, ctxt)
|
walther@60021
|
443 |
val thy = if dI' = ThyC.id_empty then dI else dI'
|
walther@60021
|
444 |
|
walther@60021
|
445 |
val NONE = (*case*) (*------------------------------- vvv*)
|
walther@60021
|
446 |
Refine.problem (ThyC.get_theory thy) pI probl (*of*);
|
walther@60021
|
447 |
"~~~~~ fun problem , args:"; val (thy, pblID, itms) = ((ThyC.get_theory thy), pI, probl);
|
walther@60021
|
448 |
(* val SOME (Refine.Match_ (["sqroot-test", "univariate", "equation", "test"], _)) =*)
|
walther@60021
|
449 |
val SOME (Refine.Match_ (rfd as (pI', _))) = (*case*)
|
walther@60021
|
450 |
Refine.refined_ ((Store.apply (get_ptyps ())) (Refine.refin'' thy ((rev o tl) pblID) itms []) pblID (rev pblID)) (*of*);
|
walther@60021
|
451 |
(*if*) pblID = pI' (*then*);
|
walther@60021
|
452 |
NONE (*return from problem*);
|
walther@60021
|
453 |
(*-------------------- stop step into -------------------------------------------------------*)
|
walther@60021
|
454 |
val (p,f,nxt,pt) = (p''''',f''''',nxt''''',pt''''');
|
walther@60021
|
455 |
(*\------------------- step into me Add_Find "solutions L" ---------------------------------/*)
|
walther@59967
|
456 |
|
walther@59967
|
457 |
(*=== refine problem -----vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*)
|
walther@59997
|
458 |
val nxt = (Refine_Problem ["univariate", "equation", "test"]);
|
walther@59967
|
459 |
(*=== refine problem -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
|
walther@59967
|
460 |
(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
461 |
(*("Specify_Problem", Specify_Problem ["normalise", "univariate", ...])*)
|
walther@59967
|
462 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
463 |
(*nxt = ("Specify_Theory", Specify_Theory "Test")*)
|
walther@59967
|
464 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
465 |
(*nxt = ("Specify_Method", Specify_Method ["Test", "squ-equ-test-subpbl1"]*)
|
walther@59967
|
466 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
467 |
(*nxt = ("Apply_Method", *)
|
walther@59967
|
468 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
469 |
(*nxt = ("Rewrite_Set", Rewrite_Set "norm_equation")*)
|
walther@59967
|
470 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
471 |
(*nxt = ("Rewrite_Set", Rewrite_Set "Test_simplify")*)
|
walther@59967
|
472 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
473 |
(*Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]*)
|
walther@59967
|
474 |
|
walther@59967
|
475 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
476 |
(*nxt = Model_Problem ["LINEAR", "univariate", "equation", "test"]*)
|
walther@59967
|
477 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
478 |
(*nxt = ("Add_Given", Add_Given "equality (-6 + 3 * x = 0)"*)
|
walther@59967
|
479 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
480 |
(**)
|
walther@59967
|
481 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
482 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
483 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
484 |
(*nxt = Specify_Problem ["LINEAR", "univariate", "equation", "test"])*)
|
walther@59967
|
485 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
486 |
(*xt = ("Specify_Method", Specify_Method ["Test", "solve_linear"])*)
|
walther@59997
|
487 |
val nxt = (Refine_Problem ["univariate", "equation", "test"]);
|
walther@59967
|
488 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
489 |
(*("Specify_Problem", Specify_Problem ["LINEAR", "univariate", ...])*)
|
walther@59967
|
490 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
491 |
(*val nxt = ("Specify_Method",Specify_Method ("Test", "solve_linear"))*)
|
walther@59967
|
492 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
493 |
(*val nxt = ("Apply_Method",Apply_Method ("Test", "solve_linear"))*)
|
walther@59967
|
494 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
495 |
(*val nxt = ("Rewrite_Set_Inst",Rewrite_Set_Inst ([#],"isolate_bdv"))*)
|
walther@59967
|
496 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
497 |
(*val nxt = ("Rewrite_Set",Rewrite_Set "Test_simplify")*)
|
walther@59967
|
498 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
499 |
(*val nxt = ("Check_Postcond",Check_Postcond ["LINEAR", "univariate", "eq*)
|
walther@59967
|
500 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
501 |
(*val nxt = ("Check_elementwise",Check_elementwise "Assumptions")*)
|
walther@59967
|
502 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59997
|
503 |
(*Check_Postcond ["normalise", "univariate", "equation", "test"])*)
|
walther@59967
|
504 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
walther@59967
|
505 |
val Test_Out.FormKF res = f;
|
walther@59967
|
506 |
|
walther@59967
|
507 |
if res = "[x = 2]"
|
walther@59967
|
508 |
then case nxt of End_Proof' => ()
|
walther@59967
|
509 |
| _ => error "new behaviour in test:refine.sml:miniscript with mini-subpb 1"
|
walther@59967
|
510 |
else error "new behaviour in test:refine.sml:miniscript with mini-subpb 2"
|