wneuper@4732
|
1 |
/*
|
wneuper@4732
|
2 |
* @author Walther Neuper
|
wneuper@4732
|
3 |
* Copyright (c) due to license terms
|
wneuper@4732
|
4 |
* Created on Jul 14, 2015
|
wneuper@4732
|
5 |
* Institute for Softwaretechnology, Graz University of Technology, Austria.
|
wneuper@4732
|
6 |
*/
|
wneuper@4732
|
7 |
package isac.bridge.xml;
|
wneuper@4732
|
8 |
|
wneuper@4772
|
9 |
import isac.bridge.xml.DataTypes;
|
wneuper@4772
|
10 |
import isac.bridge.xml.DataTypesCompanion;
|
wneuper@4772
|
11 |
import isac.bridge.xml.IsaToJava;
|
wneuper@4928
|
12 |
import isac.bridge.xml.TestsDATA;
|
wneuper@5072
|
13 |
import isac.gui.mawen.syntax.Ast;
|
wneuper@4746
|
14 |
import isac.util.formulae.CalcHead;
|
wneuper@4746
|
15 |
import isac.util.formulae.CalcHeadSimpleID;
|
wneuper@4772
|
16 |
import isac.util.formulae.Formula;
|
wneuper@4746
|
17 |
import isac.util.formulae.HierarchyKey;
|
wneuper@4734
|
18 |
import isac.util.formulae.Model;
|
wneuper@4733
|
19 |
import isac.util.formulae.ModelItem;
|
wneuper@4734
|
20 |
import isac.util.formulae.ModelItemList;
|
wneuper@4736
|
21 |
import isac.util.formulae.Specification;
|
wneuper@4892
|
22 |
import isac.util.Formalization;
|
wneuper@4892
|
23 |
import isac.util.Variant;
|
wneuper@4772
|
24 |
import isac.util.tactics.Rewrite;
|
wneuper@4772
|
25 |
import isac.util.tactics.RewriteInst;
|
wneuper@4772
|
26 |
import isac.util.tactics.StringListTactic;
|
wneuper@4772
|
27 |
import isac.util.tactics.Tactic;
|
wneuper@4772
|
28 |
import isac.util.tactics.Theorem;
|
walther@5239
|
29 |
import edu.tum.cs.isabelle.api.XML;
|
walther@5239
|
30 |
import edu.tum.cs.isabelle.pure.*; // DEFINES type Term
|
wneuper@4928
|
31 |
|
wneuper@4733
|
32 |
import java.util.Vector;
|
wneuper@4892
|
33 |
|
wneuper@4732
|
34 |
import junit.framework.TestCase;
|
wneuper@4732
|
35 |
|
wneuper@4732
|
36 |
/**
|
wneuper@4732
|
37 |
* @author Walther Neuper Jul 21, 2015
|
wneuper@4732
|
38 |
*
|
wneuper@4732
|
39 |
* Test conversion of relevant Objects to/from XML.Tree.
|
wneuper@4733
|
40 |
* This file tests isac.bridge.xml.Dataypes (which is not yet activated)
|
wneuper@4732
|
41 |
* and is analogous to isabisac/src/Tools/isac/xmlsrc/datatypes.sml.
|
wneuper@4732
|
42 |
*
|
wneuper@4746
|
43 |
* Legend:
|
wneuper@4746
|
44 |
* / * ERROR * / marks initial occurrence before start of investigation.
|
wneuper@4746
|
45 |
* / * ERR? * / marks lines inappropriate red [x] on the left margin,
|
wneuper@4746
|
46 |
* although the code compiles correctly.
|
wneuper@4732
|
47 |
*/
|
wneuper@4732
|
48 |
public class TestDataTypes extends TestCase {
|
wneuper@4732
|
49 |
|
wneuper@4746
|
50 |
public void testSpecification() throws Exception {
|
wneuper@4746
|
51 |
System.out.println(" ---------------------------------------------");
|
wneuper@4746
|
52 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#testSpecification");
|
wneuper@4746
|
53 |
|
wneuper@4746
|
54 |
XML.Tree REF_FORMULA_out = TestDataTypesDATA.create_REF_FORMULA_out();
|
wneuper@4746
|
55 |
System.out.println("REF_FORMULA_out = " + REF_FORMULA_out);
|
wneuper@4746
|
56 |
XML.Tree xml_spec = TestDataTypesDATA.create_xml_spec(REF_FORMULA_out);
|
wneuper@4746
|
57 |
System.out.println("xml_spec = " + xml_spec);
|
wneuper@4928
|
58 |
Specification spec = null;
|
wneuper@4928
|
59 |
spec = DataTypes.xml_to_Specification(xml_spec);
|
wneuper@4746
|
60 |
assertEquals(spec.getTheory().toString(), "e_domID\n");
|
wneuper@4746
|
61 |
assertEquals(spec.getProblem().toSMLString(), "[\"e_pblID\"]");
|
wneuper@4746
|
62 |
assertEquals(spec.getMethod().toSMLString(), "[\"e_metID\"]");
|
wneuper@4746
|
63 |
|
wneuper@4746
|
64 |
///-------------------------------------------------------------------
|
wneuper@4746
|
65 |
// follow scala code in IsaToJava.xml_to_Specification as close as possible
|
wneuper@4746
|
66 |
XML.Tree xml_thy = TestDataTypesDATA.create_xml_thy(xml_spec);
|
wneuper@4746
|
67 |
System.out.println("xml_thy (created in Scala) = " + xml_thy);//XML.Tree!!!
|
wneuper@4746
|
68 |
CalcHeadSimpleID thy_key = new CalcHeadSimpleID();
|
wneuper@4759
|
69 |
thy_key.setID(DataTypes.xml_to_String(xml_thy));
|
wneuper@4746
|
70 |
|
wneuper@4746
|
71 |
XML.Tree xml_pbl = TestDataTypesDATA.create_xml_pbl(xml_spec);
|
wneuper@4746
|
72 |
System.out.println("xml_pbl (created in Scala) = " + xml_pbl);
|
wneuper@4746
|
73 |
HierarchyKey pbl_key = new HierarchyKey();
|
wneuper@4759
|
74 |
/*ERR?*/pbl_key.setID(DataTypes.xml_to_VectorString(xml_pbl));
|
wneuper@4746
|
75 |
|
wneuper@4746
|
76 |
XML.Tree xml_met = TestDataTypesDATA.create_xml_met(xml_spec);
|
wneuper@4746
|
77 |
System.out.println("xml_met (created in Scala) = " + xml_met);
|
wneuper@4746
|
78 |
HierarchyKey met_key = new HierarchyKey();
|
wneuper@4759
|
79 |
/*ERR?*/met_key.setID(DataTypes.xml_to_VectorString(xml_met));
|
wneuper@4746
|
80 |
|
wneuper@4746
|
81 |
spec = new Specification(thy_key, pbl_key, met_key);
|
wneuper@4746
|
82 |
|
wneuper@4746
|
83 |
System.out.println("\\--END isac.bridge.DataTypes#testSpecification");
|
wneuper@4746
|
84 |
}
|
wneuper@4746
|
85 |
|
wneuper@4732
|
86 |
/**
|
wneuper@4928
|
87 |
*
|
wneuper@4928
|
88 |
*/
|
wneuper@4928
|
89 |
public void test_xml_to_Formula_NEW() throws Exception {
|
wneuper@4928
|
90 |
System.out.println(" ---------------------------------------------");
|
wneuper@4928
|
91 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#test_xml_to_Formula_NEW");
|
wneuper@4928
|
92 |
|
wneuper@4928
|
93 |
Term t = TestsDATA.term_mini_subpbl_1();
|
wneuper@4928
|
94 |
XML.Tree xml_tree = TestDataTypesDATA.create_Formula_NEW(t);
|
wneuper@4928
|
95 |
Formula f = DataTypes.xml_to_Formula_NEW(xml_tree);
|
wneuper@4928
|
96 |
assertEquals(f.toSMLString(), "solve (x + 1 = 2, x)");
|
wneuper@5072
|
97 |
/*ERR?*/assertEquals(Ast.math_string_of(f.getTerm()), "solve (x + 1 = 2, x)");
|
wneuper@4928
|
98 |
|
wneuper@4928
|
99 |
System.out.println("\\--END isac.bridge.DataTypes#test_xml_to_Formula_NEW");
|
wneuper@4928
|
100 |
}
|
wneuper@4928
|
101 |
|
wneuper@4928
|
102 |
/**
|
wneuper@4733
|
103 |
* Components of isac.util.formulae.CalcHead,
|
wneuper@4733
|
104 |
* investigated wrt. error found in
|
wneuper@4733
|
105 |
* https://intra.ist.tugraz.at/hg/isac/rev/9b6d305fb011:
|
wneuper@4733
|
106 |
* with (outcommented)
|
wneuper@4733
|
107 |
* // * ERROR * /IntFormHead calcid_formhead = ... ((blanks "* /" due to parsing comment))
|
wneuper@4733
|
108 |
* reaches tracing at
|
wneuper@4733
|
109 |
* https://intra.ist.tugraz.at/hg/isac/file/9b6d305fb011/isac-java/src/java-tests/isac/bridge/TestPIDE.java#l141
|
wneuper@4733
|
110 |
* https://intra.ist.tugraz.at/hg/isac/file/9b6d305fb011/isac-java/src/java/isac/bridge/xml/IsaToJava.scala#l244
|
wneuper@4733
|
111 |
* but with (NOT outcommented)
|
wneuper@4733
|
112 |
* / * ERROR * /IntFormHead calcid_formhead = ... ((blanks "* /" due to parsing comment))
|
wneuper@4733
|
113 |
* GIVES NO OUTPUT FROM THE WHOLE TEST CASE, NOT EVEN
|
wneuper@4733
|
114 |
* System.out.println("/--BEGIN isac.bridge.TestPIDE#testMini_Test");
|
wneuper@4732
|
115 |
*/
|
wneuper@4732
|
116 |
public void testCalcHead() throws Exception {
|
wneuper@4746
|
117 |
System.out.println(" ---------------------------------------------");
|
wneuper@4732
|
118 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#testCalcHead");
|
wneuper@4732
|
119 |
|
wneuper@4746
|
120 |
//top down for TestPIDE.java ----- step 6 -------------------------------------
|
wneuper@4736
|
121 |
XML.Tree REF_FORMULA_out = TestDataTypesDATA.create_REF_FORMULA_out();
|
wneuper@4736
|
122 |
System.out.println("REF_FORMULA_out = " + REF_FORMULA_out);
|
wneuper@4736
|
123 |
XML.Tree xml_calchead = TestDataTypesDATA.create_xml_calchead(REF_FORMULA_out);
|
wneuper@4746
|
124 |
System.out.println("xml_calchead (created in Scala) = " + xml_calchead);
|
wneuper@4992
|
125 |
/*CalcHead calchead =*/ DataTypes.xml_to_CalcHead(xml_calchead);
|
wneuper@4746
|
126 |
/*ERROR*/ IntFormHead calcid_formhead = IsaToJava.ref_formula_out(REF_FORMULA_out);
|
wneuper@4736
|
127 |
//^^^^^^^ CONSOLE OUTPUT WAS:
|
wneuper@4736
|
128 |
//# 6 --ref_formula_out: CALCHEAD before
|
wneuper@4736
|
129 |
//11 xml_to_CalcHead before: new CalcHead
|
wneuper@4746
|
130 |
/////////////////////////////////////////
|
wneuper@4747
|
131 |
// asserts after successful tackling error bottom up below:
|
wneuper@4747
|
132 |
CalcHead ch = (CalcHead)(calcid_formhead.getFormHead());
|
wneuper@4747
|
133 |
assertEquals(ch.getPosition().toSMLString(), "([],Pbl)");
|
wneuper@4747
|
134 |
assertEquals(ch.getHeadLine().toSMLString(), "solve (x + 1 = 2, x)");
|
wneuper@4747
|
135 |
|
wneuper@4747
|
136 |
Model model = ch.getModel();
|
wneuper@4747
|
137 |
assertEquals(model.getGiven().getItems().size(), 0);
|
wneuper@4747
|
138 |
assertEquals(model.getWhere().getItems().size(), 1);
|
wneuper@4747
|
139 |
assertEquals(((ModelItem)model.getWhere().getItems().elementAt(0)).getItemStatus(), "false");
|
wneuper@4747
|
140 |
assertEquals(((ModelItem)model.getWhere().getItems().elementAt(0)).toSMLString(), "precond_rootpbl v_v");
|
wneuper@4747
|
141 |
|
wneuper@4747
|
142 |
assertEquals(ch.getBelongsTo(), "Pbl");
|
wneuper@4747
|
143 |
|
wneuper@4747
|
144 |
Specification spec = ch.getSpecification();
|
wneuper@4747
|
145 |
assertEquals(spec.getTheory().toString(), "e_domID\n");
|
wneuper@4747
|
146 |
assertEquals(spec.getProblem().toSMLString(), "[\"e_pblID\"]");
|
wneuper@4747
|
147 |
assertEquals(spec.getMethod().toSMLString(), "[\"e_metID\"]");
|
wneuper@4748
|
148 |
|
wneuper@4746
|
149 |
///-------------------------------------------------------------------
|
wneuper@4746
|
150 |
// follow scala code in IsaToJava.xml_to_Specification as close as possible
|
wneuper@4736
|
151 |
//--------- Model ------------------------------
|
wneuper@4736
|
152 |
//create ModelItem ...
|
wneuper@4733
|
153 |
XML.Tree xml_item = TestDataTypesDATA.create_xml_item();
|
wneuper@4759
|
154 |
ModelItem mit = DataTypes.xml_to_ModelItem(xml_item);
|
wneuper@4733
|
155 |
assertEquals(mit.getItemStatus(), "false");
|
wneuper@4733
|
156 |
assertEquals(mit.getFormula().toSMLString(), "precond_rootpbl v_v");
|
wneuper@4733
|
157 |
|
wneuper@4992
|
158 |
Vector<ModelItem> mits = new Vector<>();
|
wneuper@4733
|
159 |
mits.add(mit);
|
wneuper@4734
|
160 |
//test conversion SCala List <--> Java Vector: content is invariant ...
|
wneuper@4759
|
161 |
mits = DataTypes.sList2jVectorModelItem(TestDataTypesDATA.jVector2sList(mits));
|
wneuper@4733
|
162 |
mit = mits.get(0);
|
wneuper@4733
|
163 |
assertEquals(mit.getItemStatus(), "false");
|
wneuper@4733
|
164 |
assertEquals(mit.getFormula().toSMLString(), "precond_rootpbl v_v");
|
wneuper@4732
|
165 |
|
wneuper@4736
|
166 |
//create Model bottom up ...
|
wneuper@4734
|
167 |
XML.Tree xml_model = TestDataTypesDATA.create_xml_model(REF_FORMULA_out);
|
wneuper@4746
|
168 |
System.out.println("xml_model (created in Scala) = " + xml_model);
|
wneuper@4928
|
169 |
model = DataTypes.xml_to_Model(xml_model);
|
wneuper@4734
|
170 |
|
wneuper@4736
|
171 |
Vector<ModelItem> givens = model.getGiven().getItems();
|
wneuper@4736
|
172 |
assertEquals(givens.size(), 0);
|
wneuper@4736
|
173 |
Vector<ModelItem> wheres = model.getWhere().getItems();
|
wneuper@4736
|
174 |
assertEquals(wheres.size(), 1);
|
wneuper@4736
|
175 |
assertEquals(wheres.elementAt(0).getItemStatus(), "false");
|
wneuper@4736
|
176 |
assertEquals(wheres.elementAt(0).toSMLString(), "precond_rootpbl v_v");
|
wneuper@4736
|
177 |
|
wneuper@4736
|
178 |
//another variant to create Model bottom up ...
|
wneuper@4734
|
179 |
XML.Tree xml_given = TestDataTypesDATA.create_xml_given(xml_model);
|
wneuper@4759
|
180 |
/*ERR?*/givens = DataTypes.xml_to_VectorModelItem(xml_given);
|
wneuper@4734
|
181 |
assertEquals(givens.size(), 0);
|
wneuper@4734
|
182 |
XML.Tree xml_where = TestDataTypesDATA.create_xml_where(xml_model);
|
wneuper@4759
|
183 |
/*ERR?*/wheres = DataTypes.xml_to_VectorModelItem(xml_where);
|
wneuper@4734
|
184 |
assertEquals(wheres.size(), 1);
|
wneuper@4734
|
185 |
assertEquals(wheres.elementAt(0).getItemStatus(), "false");
|
wneuper@4734
|
186 |
assertEquals(wheres.elementAt(0).toSMLString(), "precond_rootpbl v_v");
|
wneuper@4759
|
187 |
/*ERR?*/Vector<ModelItem> finds = DataTypes.xml_to_VectorModelItem(
|
wneuper@4734
|
188 |
TestDataTypesDATA.create_xml_find(xml_model));
|
wneuper@4759
|
189 |
/*ERR?*/Vector<ModelItem> relates = DataTypes.xml_to_VectorModelItem(
|
wneuper@4734
|
190 |
TestDataTypesDATA.create_xml_relate(xml_model));
|
wneuper@4734
|
191 |
|
wneuper@4734
|
192 |
model = new Model(
|
wneuper@4734
|
193 |
new ModelItemList(givens),
|
wneuper@4734
|
194 |
new ModelItemList(wheres),
|
wneuper@4734
|
195 |
new ModelItemList(finds),
|
wneuper@4734
|
196 |
new ModelItemList(relates));
|
wneuper@4734
|
197 |
assertEquals(model.toString(),
|
wneuper@4734
|
198 |
"\nModel:\nGiven:\n[]\nWhere:\n[\"false (precond_rootpbl v_v)\"]\nFind:\n[]\nRelate:\n[]");
|
wneuper@4734
|
199 |
|
wneuper@4736
|
200 |
//--------- Specification ------------------------------
|
wneuper@4736
|
201 |
XML.Tree xml_spec = TestDataTypesDATA.create_xml_spec(REF_FORMULA_out);
|
wneuper@4772
|
202 |
/*ERROR*/ spec = DataTypes.xml_to_Specification(xml_spec);
|
wneuper@4734
|
203 |
|
wneuper@4732
|
204 |
System.out.println("\\--END isac.bridge.DataTypes#testCalcHead");
|
wneuper@4732
|
205 |
}
|
wneuper@4732
|
206 |
|
wneuper@4892
|
207 |
public void testFormalization() throws Exception {
|
wneuper@4892
|
208 |
System.out.println(" ---------------------------------------------");
|
wneuper@4892
|
209 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#testFormalization");
|
wneuper@4892
|
210 |
|
wneuper@4892
|
211 |
Formalization fmz = isac.TESTUTIL.Formalization.solve_x_plus_1_equ_2();
|
wneuper@4892
|
212 |
XML.Tree intree = DataTypes.xml_of_Formalization(fmz);
|
wneuper@4892
|
213 |
assertEquals(intree.toString().substring(0,150),
|
wneuper@4892
|
214 |
"Elem((FORMALIZATION,List()),List(Elem((VARIANT,List()),List(Elem((STRINGLIST,List()),List(Elem((STRING,List()),List(Text(equality (x+1=(2::real))))), ");
|
wneuper@4892
|
215 |
|
wneuper@4892
|
216 |
System.out.println("\\--END isac.bridge.DataTypes#testFormalization");
|
wneuper@4892
|
217 |
}
|
wneuper@4892
|
218 |
|
wneuper@4892
|
219 |
/*
|
wneuper@4892
|
220 |
* from hitting <NEW>button on <code>WindowApplication</code> Isabelle/Isac expects
|
wneuper@4892
|
221 |
* -->ISA: CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))];
|
wneuper@4892
|
222 |
*/
|
wneuper@4892
|
223 |
public void testEmptyFormalization() throws Exception {
|
wneuper@4892
|
224 |
System.out.println(" ---------------------------------------------");
|
wneuper@4892
|
225 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#testEmptyFormalization");
|
wneuper@4892
|
226 |
|
wneuper@4892
|
227 |
Formalization fmz = new Formalization();
|
wneuper@4892
|
228 |
XML.Tree intree = DataTypes.xml_of_Formalization(fmz);
|
wneuper@4892
|
229 |
String intree_cut = "Elem((FORMALIZATION,List()),List(Elem((VARIANT,List()),List(Elem((STRINGLIST,List()),List()), Elem((SPECIFICATION,List()),List(Elem(("
|
wneuper@4892
|
230 |
+ "THEORYID,List()),List(Text(e_domID)))"; //.. etc.
|
wneuper@4892
|
231 |
assertEquals(intree.toString().substring(0,170), intree_cut);
|
wneuper@4892
|
232 |
|
wneuper@4892
|
233 |
// this fmz is now created by DataTypes.xml_of_Formalization:
|
wneuper@4892
|
234 |
fmz = new Formalization();
|
wneuper@4892
|
235 |
CalcHeadSimpleID thy = new CalcHeadSimpleID();
|
wneuper@4892
|
236 |
thy.setID("e_domID");
|
wneuper@4892
|
237 |
HierarchyKey pbl = new HierarchyKey();
|
wneuper@4892
|
238 |
pbl.addString("e_pblID");
|
wneuper@4892
|
239 |
HierarchyKey met = new HierarchyKey();
|
wneuper@4892
|
240 |
met.addString("e_metID");
|
wneuper@4892
|
241 |
Specification spec = new Specification();
|
wneuper@4892
|
242 |
spec.setTheory(thy);
|
wneuper@4892
|
243 |
spec.setProblem(pbl);
|
wneuper@4892
|
244 |
spec.setMethod(met);
|
wneuper@4892
|
245 |
Variant vat = new Variant();
|
wneuper@4892
|
246 |
vat.setSpecification(spec);
|
wneuper@4892
|
247 |
fmz.addNewVariant(vat);
|
wneuper@4892
|
248 |
|
wneuper@4892
|
249 |
intree = DataTypes.xml_of_Formalization(fmz);
|
wneuper@4892
|
250 |
assertEquals(intree.toString().substring(0,170), intree_cut);
|
wneuper@4892
|
251 |
|
wneuper@4892
|
252 |
System.out.println("\\--END isac.bridge.DataTypes#testEmptyFormalization");
|
wneuper@4892
|
253 |
}
|
wneuper@4892
|
254 |
|
wneuper@4772
|
255 |
public void testTactic() throws Exception {
|
wneuper@4772
|
256 |
System.out.println(" ---------------------------------------------");
|
wneuper@4772
|
257 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#testTactic");
|
wneuper@4772
|
258 |
|
wneuper@4772
|
259 |
//from java-tests-isacutil.parser.TestTactic
|
wneuper@4772
|
260 |
//------- Rewrite ----------------------------------------------
|
wneuper@4772
|
261 |
Tactic tac_built = new Rewrite();
|
wneuper@4772
|
262 |
tac_built.setName("Rewrite");
|
wneuper@4772
|
263 |
Theorem thm = new Theorem();
|
wneuper@4772
|
264 |
thm.setId("pythagoras");
|
wneuper@4772
|
265 |
Formula form = new Formula();
|
wneuper@4772
|
266 |
form.setText("[| ?l is_const; ?m is_const |] ==> "
|
wneuper@4772
|
267 |
+ "?l * ?n + ?m * ?n = (?l + ?m) * ?n");
|
wneuper@4772
|
268 |
form.setText("a^2 + b^2 = c^2");
|
wneuper@4772
|
269 |
thm.setFormula(form);
|
wneuper@4772
|
270 |
((Rewrite) tac_built).setTheorem(thm);
|
wneuper@4772
|
271 |
|
wneuper@4772
|
272 |
System.out.println("tac_built = " + ((Rewrite) tac_built).toSMLString());
|
wneuper@4772
|
273 |
XML.Tree tac_out = DataTypesCompanion.xml_of_Tactic(tac_built);
|
wneuper@4772
|
274 |
System.out.println("Tree tac_out = " + tac_out);
|
wneuper@4772
|
275 |
//<REWRITETACTIC name="Rewrite">
|
wneuper@4772
|
276 |
// <THEOREM>
|
wneuper@4772
|
277 |
// <ID>pythagoras</ID>
|
wneuper@4772
|
278 |
// <FORMULA>a^2 + b^2 = c^2</FORMULA> !!!different from Parser
|
wneuper@4772
|
279 |
// </THEOREM>
|
wneuper@4772
|
280 |
//</REWRITETACTIC>
|
wneuper@4772
|
281 |
Tactic tac_in = (Tactic)DataTypes.xml_to_Tactic(tac_out);
|
wneuper@4772
|
282 |
System.out.println("Tactic tac_in = " + tac_in.toSMLString());
|
wneuper@4772
|
283 |
assertEquals(tac_built.toSMLString(), tac_in.toSMLString());
|
wneuper@4772
|
284 |
//from java-tests-isacutil.parser.TestXMLParserDigest
|
wneuper@5037
|
285 |
@SuppressWarnings("unused") // as data to remember
|
wneuper@5037
|
286 |
String xmlString = "@@@@@begin@@@@@"// .................................
|
wneuper@4772
|
287 |
+ " 1"// ......................................................
|
wneuper@4772
|
288 |
+ " <GETTACTIC>"// ...........................................
|
wneuper@4772
|
289 |
+ " <CALCID> 1 </CALCID>"// ..................................
|
wneuper@4772
|
290 |
+ " <REWRITETACTIC name=\"Rewrite\">"// .............
|
wneuper@4772
|
291 |
+ " <THEOREM>"// .......................................
|
wneuper@4772
|
292 |
+ " <ID> Belastung_Querkraft </ID>"// ..................
|
wneuper@4772
|
293 |
+ " <FORMULA>"// .........................!!!different from XML
|
wneuper@4772
|
294 |
+ " <MATHML>"// ........................!!!different from XML
|
wneuper@4772
|
295 |
+ " <ISA> - q ?x = Q' ?x </ISA>"// ...!!!different from XML
|
wneuper@4772
|
296 |
+ " </MATHML>"// .......................!!!different from XML
|
wneuper@4772
|
297 |
+ " </FORMULA>"// ........................!!!different from XML
|
wneuper@4772
|
298 |
+ " </THEOREM>"// .......................................
|
wneuper@4772
|
299 |
+ " </REWRITETACTIC>"// ...................................
|
wneuper@4772
|
300 |
+ " </GETTACTIC>" // ........................................
|
wneuper@4772
|
301 |
+ " @@@@@end@@@@@";
|
wneuper@4772
|
302 |
|
wneuper@4772
|
303 |
//------- RewriteInst ------------------------------------------
|
wneuper@4772
|
304 |
|
wneuper@4772
|
305 |
form.setText("?a = ?a");
|
wneuper@4772
|
306 |
thm.setFormula(form);
|
wneuper@4772
|
307 |
((Rewrite) tac_built).setTheorem(thm);
|
wneuper@4772
|
308 |
assertEquals("a = a", tac_built.showToBeginner());
|
wneuper@4772
|
309 |
|
wneuper@4772
|
310 |
tac_built = null;
|
wneuper@4772
|
311 |
tac_built = new RewriteInst();
|
wneuper@4772
|
312 |
form.setText("(?k + ?bdv = ?m) = (?bdv = ?m + -1 * ?k)");
|
wneuper@4772
|
313 |
thm.setFormula(form);
|
wneuper@4772
|
314 |
((RewriteInst) tac_built).setTheorem(thm);
|
wneuper@4772
|
315 |
assertEquals("(k + bdv = m) = (bdv = m + -1 * k)", tac_built.showToBeginner());
|
wneuper@4772
|
316 |
|
wneuper@4772
|
317 |
//------- RewriteSet -------------------------------------------
|
wneuper@4772
|
318 |
|
wneuper@4772
|
319 |
//from java-tests-isacutil.parser.TestXMLParserDigest
|
wneuper@4772
|
320 |
xmlString = "@@@@@begin@@@@@"// .................................
|
wneuper@4772
|
321 |
+ " 1"// ......................................................
|
wneuper@4772
|
322 |
+ " <GETTACTIC>"// ...........................................
|
wneuper@4772
|
323 |
+ " <CALCID> 1 </CALCID>"// ..................................
|
wneuper@4772
|
324 |
+ " <REWRITESETTACTIC name= \"Rewrite_Set\">"// .............
|
wneuper@4772
|
325 |
+ " <RULESET> Test_simplify </RULESET>"// ....................
|
wneuper@4772
|
326 |
+ " </REWRITESETTACTIC>"// ...................................
|
wneuper@4772
|
327 |
+ " </GETTACTIC>" // ........................................
|
wneuper@4772
|
328 |
+ " @@@@@end@@@@@";
|
wneuper@4772
|
329 |
|
wneuper@4772
|
330 |
|
wneuper@4772
|
331 |
//------- StringListTactic -------------------------------------
|
wneuper@4992
|
332 |
Vector<String> keylist = new Vector<>();
|
wneuper@4772
|
333 |
keylist.add("normalize");
|
wneuper@4772
|
334 |
keylist.add("polynomial");
|
wneuper@4772
|
335 |
keylist.add("univariate");
|
wneuper@4772
|
336 |
keylist.add("equation");
|
wneuper@4772
|
337 |
tac_built = new StringListTactic("Specify_Problem", keylist);
|
wneuper@4772
|
338 |
System.out.println(tac_built.toSMLString());
|
wneuper@4772
|
339 |
assertEquals("Specify_Problem [\"normalize\",\"polynomial\","
|
wneuper@4772
|
340 |
+ "\"univariate\",\"equation\"]", tac_built.toSMLString());
|
wneuper@4772
|
341 |
|
wneuper@4772
|
342 |
System.out.println("\\--END isac.bridge.DataTypes#testTactic");
|
wneuper@4772
|
343 |
}
|
wneuper@4772
|
344 |
|
wneuper@4772
|
345 |
public void testTactics() throws Exception {
|
wneuper@4772
|
346 |
System.out.println(" ---------------------------------------------");
|
wneuper@4772
|
347 |
System.out.println("/--BEGIN isac.bridge.xml.DataTypes#testTactics");
|
wneuper@4772
|
348 |
|
wneuper@4772
|
349 |
//from java-tests-isacutil.parser.TestXMLParserDigest
|
wneuper@5037
|
350 |
@SuppressWarnings("unused") // as data to remember
|
wneuper@5037
|
351 |
String xmlString = "> @@@@@begin@@@@@" // ...........................
|
wneuper@4772
|
352 |
+ " 1 " // ......................................................
|
wneuper@4772
|
353 |
+ "<APPLICABLETACTICS>" // .......................................
|
wneuper@4772
|
354 |
+ " <CALCID> 1 </CALCID>" // ....................................
|
wneuper@4772
|
355 |
+ " <TACLIST>" // ...............................................
|
wneuper@4772
|
356 |
+ " <REWRITESETTACTIC name=\"Rewrite_Set\">"// .................
|
wneuper@4772
|
357 |
+ " <RULESET> norm_equation </RULESET>"// ....................
|
wneuper@4772
|
358 |
+ " </REWRITESETTACTIC>"// .....................................
|
wneuper@4772
|
359 |
+ " <REWRITESETTACTIC name=\"Rewrite_Set\">"// .................
|
wneuper@4772
|
360 |
+ " <RULESET> Test_simplify </RULESET>"// ....................
|
wneuper@4772
|
361 |
+ " </REWRITESETTACTIC>"// .....................................
|
wneuper@4772
|
362 |
+ " <SUBPROBLEMTACTIC name=\"Subproblem\">"// ..................
|
wneuper@4772
|
363 |
+ " <THEORY> Test.thy </THEORY>"// ...........................
|
wneuper@4772
|
364 |
+ " <PROBLEM>"// .............................................
|
wneuper@4772
|
365 |
+ " <STRINGLIST>"// ........................................
|
wneuper@4772
|
366 |
+ " <STRING> linear </STRING>"// .........................
|
wneuper@4772
|
367 |
+ " <STRING> univariate </STRING>"// .....................
|
wneuper@4772
|
368 |
+ " <STRING> equation </STRING>"// .......................
|
wneuper@4772
|
369 |
+ " <STRING> test </STRING>"// ...........................
|
wneuper@4772
|
370 |
+ " </STRINGLIST>"// .......................................
|
wneuper@4772
|
371 |
+ " </PROBLEM>"// ............................................
|
wneuper@4772
|
372 |
+ " </SUBPROBLEMTACTIC>"// .....................................
|
wneuper@4772
|
373 |
+ " <SIMPLETACTIC name=\"Check_elementwise\">"// ...............
|
wneuper@4772
|
374 |
+ " <MATHML>"// ............................................
|
wneuper@4772
|
375 |
+ " <ISA> Assumptions </ISA>"// ..........................
|
wneuper@4772
|
376 |
+ " </MATHML>"// ...........................................
|
wneuper@4772
|
377 |
+ " </SIMPLETACTIC>"// .........................................
|
wneuper@4772
|
378 |
+ " </TACLIST>"// ................................................
|
wneuper@4772
|
379 |
+ "</APPLICABLETACTICS>"// ........................................
|
wneuper@4772
|
380 |
+ "@@@@@end@@@@@";
|
wneuper@4772
|
381 |
// wrapper_ = xml_parser_digest_.parse(xmlString);
|
wneuper@4772
|
382 |
// tac = (Tactic) ((TacticsContainer) wrapper_.getResponse()).getTactics().elementAt(3);
|
wneuper@4772
|
383 |
// assertEquals(tac.toSMLString(), "Check_elementwise \"Assumptions\"");
|
wneuper@4772
|
384 |
|
wneuper@4772
|
385 |
System.out.println("\\--END isac.bridge.DataTypes#testTactics");
|
wneuper@4772
|
386 |
|
wneuper@4772
|
387 |
}
|
walther@5239
|
388 |
}
|