wneuper@4757
|
1 |
/*
|
wneuper@4757
|
2 |
* @author Walther Neuper
|
wneuper@4757
|
3 |
* Copyright (c) due to license terms
|
wneuper@4757
|
4 |
* Created on Jul 14, 2015
|
wneuper@4757
|
5 |
* Institute for Softwaretechnology, Graz University of Technology, Austria.
|
wneuper@4757
|
6 |
*
|
wneuper@4757
|
7 |
* When ConvertXML.scala was not recognized switiching "Scala Nature"
|
wneuper@4757
|
8 |
* off and on again helped.
|
wneuper@4757
|
9 |
*/
|
wneuper@4757
|
10 |
|
wneuper@4757
|
11 |
package isac.bridge.xml
|
wneuper@4757
|
12 |
|
wneuper@4759
|
13 |
import isac.bridge.CChanged
|
wneuper@4788
|
14 |
import isac.bridge.CEvent
|
wneuper@4788
|
15 |
import isac.bridge.CMessage
|
wneuper@4759
|
16 |
import isac.util.Formalization
|
wneuper@4759
|
17 |
import isac.util.formulae.CalcFormula
|
wneuper@4759
|
18 |
import isac.util.formulae.CalcHead
|
wneuper@4759
|
19 |
import isac.util.formulae.CalcHeadSimpleID
|
wneuper@4825
|
20 |
import isac.util.formulae.ContextMethod
|
wneuper@4825
|
21 |
import isac.util.formulae.ContextProblem
|
wneuper@4789
|
22 |
import isac.util.formulae.ContextTheory
|
wneuper@4759
|
23 |
import isac.util.formulae.Formula
|
wneuper@4789
|
24 |
import isac.util.formulae.FormulaPair
|
wneuper@4759
|
25 |
import isac.util.formulae.HierarchyKey
|
wneuper@4789
|
26 |
import isac.util.formulae.KEStoreKey
|
wneuper@4759
|
27 |
import isac.util.formulae.ModelItem
|
wneuper@4759
|
28 |
import isac.util.formulae.ModelItemList
|
wneuper@4759
|
29 |
import isac.util.formulae.Model
|
wneuper@4757
|
30 |
import isac.util.formulae.Position
|
wneuper@4789
|
31 |
import isac.util.formulae.Reference
|
wneuper@4758
|
32 |
import isac.util.formulae.Specification
|
wneuper@4810
|
33 |
import isac.util.tactics.TermTactic
|
wneuper@4771
|
34 |
import isac.util.tactics.Rewrite
|
wneuper@4771
|
35 |
import isac.util.tactics.RewriteInst
|
wneuper@4771
|
36 |
import isac.util.tactics.RewriteSet
|
wneuper@4771
|
37 |
import isac.util.tactics.RewriteSetInst
|
wneuper@4771
|
38 |
import isac.util.tactics.SimpleTactic
|
wneuper@4771
|
39 |
import isac.util.tactics.StringListTactic
|
wneuper@4771
|
40 |
import isac.util.tactics.SubProblemTactic
|
wneuper@4771
|
41 |
import isac.util.tactics.SubstituteTactic
|
wneuper@4771
|
42 |
import isac.util.tactics.Tactic
|
wneuper@4771
|
43 |
import isac.util.tactics.Theorem
|
wneuper@4757
|
44 |
|
wneuper@4757
|
45 |
import isabelle.XML
|
wneuper@4757
|
46 |
import isabelle.Markup
|
wneuper@4757
|
47 |
import java.util.ArrayList
|
wneuper@4757
|
48 |
import java.util.Vector
|
wneuper@4757
|
49 |
import java.math.BigInteger
|
wneuper@4757
|
50 |
import scala.math.BigInt
|
wneuper@4757
|
51 |
import scala.collection.JavaConverters._
|
wneuper@4757
|
52 |
|
wneuper@4758
|
53 |
/**
|
wneuper@4758
|
54 |
* conversion XML <--> Java-objects in isac-java used by libisabelle;
|
wneuper@4758
|
55 |
* analogous to isabisac/src/Tools/isac/xmlsrc/datatypes.sml.
|
wneuper@4758
|
56 |
*/
|
wneuper@4757
|
57 |
object DataTypes {
|
wneuper@4758
|
58 |
|
wneuper@4759
|
59 |
/**
|
wneuper@4759
|
60 |
* auxiliary methods, both directions
|
wneuper@4759
|
61 |
**/
|
wneuper@4757
|
62 |
|
wneuper@4757
|
63 |
def xml_of_int (i: scala.math.BigInt): XML.Tree = {
|
wneuper@4771
|
64 |
XML.Elem(Markup("INT", Nil), List(XML.Text(i.toString)))
|
wneuper@4757
|
65 |
}
|
wneuper@4757
|
66 |
def xml_to_int (t: XML.Tree): scala.math.BigInt = t match {
|
wneuper@4757
|
67 |
case XML.Elem(Markup("INT", Nil), List(XML.Text(i))) => BigInt(i)
|
wneuper@4757
|
68 |
case _ => throw new IllegalArgumentException("xml_to_int exn")
|
wneuper@4757
|
69 |
}
|
wneuper@4758
|
70 |
def xml_of_ints (is: List[scala.math.BigInt]): XML.Tree = {
|
wneuper@4757
|
71 |
XML.Elem(Markup("INTLIST", Nil), is map xml_of_int)
|
wneuper@4757
|
72 |
}
|
wneuper@4758
|
73 |
def xml_to_ints (t: XML.Tree): List[scala.math.BigInt] = t match {
|
wneuper@4757
|
74 |
case XML.Elem(Markup("INTLIST", Nil), is) => is map xml_to_int
|
wneuper@4757
|
75 |
case _ => throw new IllegalArgumentException("xml_to_ints exn")
|
wneuper@4757
|
76 |
}
|
wneuper@4757
|
77 |
def xml_of_pos (ints: List[scala.math.BigInt], kind: String ): XML.Tree = {
|
wneuper@4757
|
78 |
XML.Elem(Markup("POSITION", Nil), List(
|
wneuper@4757
|
79 |
xml_of_ints(ints),
|
wneuper@4757
|
80 |
XML.Elem(Markup("POS", Nil), List(XML.Text(kind)))))
|
wneuper@4757
|
81 |
}
|
wneuper@4757
|
82 |
def xml_to_pos (t: XML.Tree): (List[scala.math.BigInt], String) = t match {
|
wneuper@4757
|
83 |
case XML.Elem(Markup("POSITION", Nil), List(
|
wneuper@4757
|
84 |
is, XML.Elem(Markup("POS", Nil), List(XML.Text(kind))))) => (xml_to_ints(is), kind)
|
wneuper@4757
|
85 |
case _ => throw new IllegalArgumentException("xml_to_pos exn")
|
wneuper@4757
|
86 |
}
|
wneuper@4758
|
87 |
def xml_to_VectorString (t: XML.Tree): Vector[java.lang.String] = t match {
|
wneuper@4759
|
88 |
case XML.Elem(Markup("STRINGLIST", Nil), is) => {
|
wneuper@4758
|
89 |
val v = new java.util.Vector[java.lang.String];
|
wneuper@4759
|
90 |
is.foreach {
|
wneuper@4759
|
91 |
case (XML.Elem(Markup("STRING", Nil), List(XML.Text(str))))
|
wneuper@4759
|
92 |
=> v.add(str)
|
wneuper@4759
|
93 |
case _ => throw new IllegalArgumentException("xml_to_VectorString 1 wrong arg: " + t)
|
wneuper@4759
|
94 |
}
|
wneuper@4758
|
95 |
v
|
wneuper@4758
|
96 |
}
|
wneuper@4759
|
97 |
case _ => throw new IllegalArgumentException("xml_to_VectorString 2 wrong arg: " + t)
|
wneuper@4758
|
98 |
}
|
wneuper@4771
|
99 |
def xml_of_VectorString(strs: Vector[java.lang.String]): XML.Tree = {
|
wneuper@4771
|
100 |
XML.Elem(Markup("STRINGLIST", Nil),
|
wneuper@4771
|
101 |
strs.asScala.toList map xml_of_str)
|
wneuper@4771
|
102 |
}
|
wneuper@4787
|
103 |
def xml_to_VectorTactic (t: XML.Tree): Vector[Tactic] = t match {
|
wneuper@4787
|
104 |
case XML.Elem(Markup("TACLIST", Nil), tacs_xml) => {
|
wneuper@4787
|
105 |
val v = new java.util.Vector[Tactic];
|
wneuper@4787
|
106 |
tacs_xml.foreach { tac_xml => v.add(xml_to_Tactic(tac_xml)) }
|
wneuper@4787
|
107 |
v
|
wneuper@4787
|
108 |
}
|
wneuper@4787
|
109 |
case _ => throw new IllegalArgumentException("xml_to_VectorTactic wrong arg: " + t)
|
wneuper@4787
|
110 |
}
|
wneuper@4787
|
111 |
|
wneuper@4758
|
112 |
// Note: java.int-->scala.BigInt not done here, because "int" is unknown in Scala.
|
wneuper@4758
|
113 |
def Integer_to_BigInt (i: java.lang.Integer): scala.math.BigInt = {
|
wneuper@4771
|
114 |
new scala.math.BigInt(new BigInteger(i.toString)) //TODO: improve conversion ?
|
wneuper@4758
|
115 |
}
|
wneuper@4758
|
116 |
// UNUSED conversion scala.math.BigInt --> java.lang.Integer
|
wneuper@4758
|
117 |
def BigInt_to_Integer (i: scala.math.BigInt): java.lang.Integer = {
|
wneuper@4771
|
118 |
new java.lang.Integer(i.toString) //TODO: improve conversion ?
|
wneuper@4758
|
119 |
}
|
wneuper@4757
|
120 |
def xml_of_str (s: String): XML.Tree = {
|
wneuper@4757
|
121 |
XML.Elem(Markup("STRING", Nil), List(XML.Text(s)))
|
wneuper@4757
|
122 |
}
|
wneuper@4757
|
123 |
def xml_to_str (t: XML.Tree): String = t match {
|
wneuper@4757
|
124 |
case XML.Elem(Markup("STRING", Nil), List(XML.Text(s))) => s
|
wneuper@4757
|
125 |
case _ => throw new IllegalArgumentException("xml_to_str exn")
|
wneuper@4757
|
126 |
}
|
wneuper@4757
|
127 |
def xml_of_strs (ss: List[String]): XML.Tree = {
|
wneuper@4757
|
128 |
XML.Elem(Markup("STRINGLIST", Nil), ss map xml_of_str)
|
wneuper@4757
|
129 |
}
|
wneuper@4757
|
130 |
def xml_to_strs (t: XML.Tree): List[String] = t match {
|
wneuper@4757
|
131 |
case XML.Elem(Markup("STRINGLIST", Nil), ss) => ss map xml_to_str
|
wneuper@4757
|
132 |
case _ => throw new IllegalArgumentException("xml_to_strs exn")
|
wneuper@4757
|
133 |
}
|
wneuper@4757
|
134 |
def xml_of_spec (thy: String, pbl: ArrayList[String], met: ArrayList[String]): XML.Tree = {
|
wneuper@4757
|
135 |
XML.Elem(Markup("SPECIFICATION", Nil), List(
|
wneuper@4757
|
136 |
XML.Elem(Markup("THEORYID", Nil), List(XML.Text(thy))),
|
wneuper@4757
|
137 |
XML.Elem(Markup("PROBLEMID", Nil), List(xml_of_strs(pbl.asScala.toList))),
|
wneuper@4757
|
138 |
XML.Elem(Markup("METHODID", Nil), List(xml_of_strs(met.asScala.toList)))))
|
wneuper@4757
|
139 |
}
|
wneuper@4757
|
140 |
def xml_to_spec (t: XML.Tree) = t match {
|
wneuper@4757
|
141 |
case XML.Elem(Markup("SPECIFICATION", Nil), List(
|
wneuper@4757
|
142 |
XML.Elem(Markup("THEORYID", Nil), List(XML.Text(thy))),
|
wneuper@4757
|
143 |
XML.Elem(Markup("PROBLEMID", Nil), List(pbl)),
|
wneuper@4758
|
144 |
XML.Elem(Markup("METHODID", Nil), List(met)))) =>
|
wneuper@4759
|
145 |
(thy, DataTypes.xml_to_strs(pbl), xml_to_strs(met))
|
wneuper@4757
|
146 |
case _ => throw new IllegalArgumentException("xml_to_spec exn")
|
wneuper@4757
|
147 |
}
|
wneuper@4759
|
148 |
def xml_to_VectorInteger (t: XML.Tree): Vector[java.lang.Integer] = t match {
|
wneuper@4759
|
149 |
case XML.Elem(Markup("INTLIST", Nil), is) => {
|
wneuper@4759
|
150 |
val v = new java.util.Vector[java.lang.Integer];
|
wneuper@4759
|
151 |
is.foreach {
|
wneuper@4759
|
152 |
case (XML.Elem(Markup("INT", Nil), List(XML.Text(i))))
|
wneuper@4759
|
153 |
=> v.add(new java.lang.Integer(i))
|
wneuper@4759
|
154 |
case _ => throw new IllegalArgumentException("xml_to_VectorInteger 1 wrong arg: " + t)
|
wneuper@4759
|
155 |
}
|
wneuper@4759
|
156 |
v
|
wneuper@4759
|
157 |
}
|
wneuper@4759
|
158 |
case _ => throw new IllegalArgumentException("xml_to_VectorInteger 2 wrong arg: " + t)
|
wneuper@4759
|
159 |
}
|
wneuper@4759
|
160 |
def sListToVectorCalcFormula (forms: List[CalcFormula]): Vector[CalcFormula] = {
|
wneuper@4759
|
161 |
val v = new java.util.Vector[CalcFormula];
|
wneuper@4759
|
162 |
forms.foreach { form => v.add(form) }
|
wneuper@4759
|
163 |
v
|
wneuper@4759
|
164 |
}
|
wneuper@4787
|
165 |
def sListToVectorFormula (forms: List[Formula]): Vector[Formula] = {
|
wneuper@4787
|
166 |
val v = new java.util.Vector[Formula];
|
wneuper@4787
|
167 |
forms.foreach { form => v.add(form) }
|
wneuper@4787
|
168 |
v
|
wneuper@4787
|
169 |
}
|
wneuper@4789
|
170 |
def sListToVectorFormulaPair (forms: List[FormulaPair]): Vector[FormulaPair] = {
|
wneuper@4789
|
171 |
val v = new java.util.Vector[FormulaPair];
|
wneuper@4789
|
172 |
forms.foreach { form => v.add(form) }
|
wneuper@4789
|
173 |
v
|
wneuper@4789
|
174 |
}
|
wneuper@4759
|
175 |
def xml_to_String (t: XML.Tree): java.lang.String = t match {
|
wneuper@4759
|
176 |
case XML.Text(str) => str
|
wneuper@4789
|
177 |
case _ => throw new IllegalArgumentException("xml_to_String wrong arg: " + t)
|
wneuper@4759
|
178 |
}
|
wneuper@4789
|
179 |
def xml_of_term (str: String): XML.Tree = {
|
wneuper@4771
|
180 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
181 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(str)))))
|
wneuper@4771
|
182 |
}
|
wneuper@4789
|
183 |
def xml_to_term (t: XML.Tree): java.lang.String = t match {
|
wneuper@4789
|
184 |
case
|
wneuper@4789
|
185 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4789
|
186 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(str)))))
|
wneuper@4789
|
187 |
=> str
|
wneuper@4789
|
188 |
case _ => throw new IllegalArgumentException("xml_to_term wrong arg: " + t)
|
wneuper@4789
|
189 |
}
|
wneuper@4771
|
190 |
|
wneuper@4759
|
191 |
/**
|
wneuper@4759
|
192 |
* conversion XML <--> Java-objects in isac-java used by libisabelle
|
wneuper@4759
|
193 |
**/
|
wneuper@4758
|
194 |
|
wneuper@4781
|
195 |
// <--ISA carries a "status" computed by Math_Engine
|
wneuper@4781
|
196 |
def xml_to_ModelItem(t: XML.Tree): isac.util.formulae.ModelItem = t match {
|
wneuper@4759
|
197 |
case
|
wneuper@4759
|
198 |
XML.Elem(Markup("ITEM", List(("status", status))), List(
|
wneuper@4759
|
199 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4759
|
200 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(form_isa)))))))
|
wneuper@4759
|
201 |
=> new ModelItem(status, form_isa)
|
wneuper@4759
|
202 |
case _ => throw new IllegalArgumentException("xml_to_ModelItem wrong arg: " + t)
|
wneuper@4759
|
203 |
}
|
wneuper@4781
|
204 |
// -->ISA carries NO "status" coming from user.
|
wneuper@4770
|
205 |
def xml_of_ModelItem(item: ModelItem): XML.Tree = {
|
wneuper@4781
|
206 |
XML.Elem(Markup("ITEM", Nil), List(
|
wneuper@4770
|
207 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
208 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(item.getFormula.toSMLString)))))))
|
wneuper@4770
|
209 |
}
|
wneuper@4759
|
210 |
def sList2jVectorModelItem(ilist: List[ModelItem]): Vector[ModelItem] = {
|
wneuper@4771
|
211 |
val ivect = new Vector[ModelItem]
|
wneuper@4759
|
212 |
for (n <- 0 to ilist.size - 1) ivect.add(ilist(n))
|
wneuper@4759
|
213 |
ivect
|
wneuper@4759
|
214 |
}
|
wneuper@4759
|
215 |
//for test on console:
|
wneuper@4759
|
216 |
def sList2jVector(ilist: List[Integer]): Vector[Integer] = {
|
wneuper@4771
|
217 |
val ivect = new Vector[Integer]
|
wneuper@4759
|
218 |
for (n <- 0 to ilist.size - 1) ivect.add(ilist(n))
|
wneuper@4759
|
219 |
ivect
|
wneuper@4759
|
220 |
}
|
wneuper@4759
|
221 |
def xml_to_VectorModelItem(t: XML.Tree): java.util.Vector[ModelItem] = t match {
|
wneuper@4759
|
222 |
case
|
wneuper@4759
|
223 |
XML.Elem(Markup("GIVEN", Nil), list_xml)
|
wneuper@4759
|
224 |
=> sList2jVectorModelItem(list_xml map xml_to_ModelItem)
|
wneuper@4759
|
225 |
case
|
wneuper@4759
|
226 |
XML.Elem(Markup("WHERE", Nil), list_xml)
|
wneuper@4759
|
227 |
=> sList2jVectorModelItem(list_xml map xml_to_ModelItem)
|
wneuper@4759
|
228 |
case
|
wneuper@4759
|
229 |
XML.Elem(Markup("FIND", Nil), list_xml)
|
wneuper@4759
|
230 |
=> sList2jVectorModelItem(list_xml map xml_to_ModelItem)
|
wneuper@4759
|
231 |
case
|
wneuper@4759
|
232 |
XML.Elem(Markup("RELATE", Nil), list_xml)
|
wneuper@4759
|
233 |
=> sList2jVectorModelItem(list_xml map xml_to_ModelItem)
|
wneuper@4759
|
234 |
case _ => throw new IllegalArgumentException("xml_to_VectorModelItem wrong arg: " + t)
|
wneuper@4759
|
235 |
}
|
wneuper@4759
|
236 |
def xml_to_Model(t: XML.Tree): Model = t match {
|
wneuper@4759
|
237 |
case
|
wneuper@4759
|
238 |
XML.Elem(Markup("MODEL", Nil), List(xml_given, xml_where, xml_find, xml_relate))
|
wneuper@4759
|
239 |
=> new Model(
|
wneuper@4759
|
240 |
new ModelItemList(xml_to_VectorModelItem(xml_given)),
|
wneuper@4759
|
241 |
new ModelItemList(xml_to_VectorModelItem(xml_where)),
|
wneuper@4759
|
242 |
new ModelItemList(xml_to_VectorModelItem(xml_find)),
|
wneuper@4759
|
243 |
new ModelItemList(xml_to_VectorModelItem(xml_relate)))
|
wneuper@4759
|
244 |
case _ => throw new IllegalArgumentException("xml_to_Model wrong arg: " + t)
|
wneuper@4759
|
245 |
}
|
wneuper@4781
|
246 |
//
|
wneuper@4781
|
247 |
// status (coming from user) is irrelevant: status is computed by Math_Engine
|
wneuper@4781
|
248 |
def xml_of_Item(item: ModelItem): XML.Tree = {
|
wneuper@4781
|
249 |
XML.Elem(Markup("ITEM", Nil), List(
|
wneuper@4781
|
250 |
xml_of_term(item.getFormula.toString)))
|
wneuper@4781
|
251 |
}
|
wneuper@4781
|
252 |
def xml_of_items(tag: String, items: java.util.Vector[ModelItem]): XML.Tree = {
|
wneuper@4781
|
253 |
var xml: List[XML.Tree] = List()
|
wneuper@4781
|
254 |
for (n <- 0 to items.size - 1) { ((xml_of_Item(items.elementAt(n))) :: xml) }
|
wneuper@4781
|
255 |
XML.Elem(Markup(tag, Nil), xml.reverse)
|
wneuper@4781
|
256 |
}
|
wneuper@4781
|
257 |
// status (coming from user) is irrelevant: status is computed by Math_Engine
|
wneuper@4781
|
258 |
def xml_of_Model(model: Model): XML.Tree = {
|
wneuper@4781
|
259 |
XML.Elem(Markup("MODEL", Nil), List(
|
wneuper@4781
|
260 |
xml_of_items("GIVEN", model.getGiven.getItems),
|
wneuper@4781
|
261 |
// xml_where, is never input by user
|
wneuper@4781
|
262 |
xml_of_items("FIND", model.getFind.getItems),
|
wneuper@4781
|
263 |
xml_of_items("RELATE", model.getRelate.getItems)
|
wneuper@4781
|
264 |
))
|
wneuper@4781
|
265 |
}
|
wneuper@4759
|
266 |
|
wneuper@4759
|
267 |
def xml_to_Specification(t: XML.Tree): isac.util.formulae.Specification = t match {
|
wneuper@4759
|
268 |
case
|
wneuper@4759
|
269 |
XML.Elem(Markup("SPECIFICATION", Nil), List(
|
wneuper@4759
|
270 |
XML.Elem(Markup("THEORYID", Nil), List(xml_thy)),
|
wneuper@4759
|
271 |
XML.Elem(Markup("PROBLEMID", Nil), List(xml_pbl)),
|
wneuper@4759
|
272 |
XML.Elem(Markup("METHODID", Nil), List(xml_met))))
|
wneuper@4771
|
273 |
=> { val thy_key = new CalcHeadSimpleID
|
wneuper@4759
|
274 |
thy_key.setID(DataTypes.xml_to_String(xml_thy))
|
wneuper@4771
|
275 |
val pbl_key = new HierarchyKey
|
wneuper@4771
|
276 |
pbl_key.setID(xml_to_VectorString(xml_pbl))
|
wneuper@4771
|
277 |
val met_key = new HierarchyKey
|
wneuper@4771
|
278 |
met_key.setID(xml_to_VectorString(xml_met))
|
wneuper@4759
|
279 |
new Specification(thy_key, pbl_key, met_key)
|
wneuper@4759
|
280 |
}
|
wneuper@4759
|
281 |
case _ => throw new IllegalArgumentException("xml_to_Specification wrong arg: " + t)
|
wneuper@4759
|
282 |
}
|
wneuper@4759
|
283 |
|
wneuper@4759
|
284 |
def xml_to_CalcHead(t: XML.Tree): CalcHead = t match {
|
wneuper@4759
|
285 |
case
|
wneuper@4759
|
286 |
XML.Elem(Markup("CALCHEAD", List(("status", status))), List(
|
wneuper@4759
|
287 |
xml_pos, xml_head, xml_model,
|
wneuper@4759
|
288 |
XML.Elem(Markup("BELONGSTO", Nil), List(XML.Text(pbl_met))),
|
wneuper@4759
|
289 |
xml_spec))
|
wneuper@4759
|
290 |
=> {
|
wneuper@4787
|
291 |
new CalcHead(DataTypes.xml_to_Position(xml_pos),
|
wneuper@4787
|
292 |
DataTypes.xml_to_Formula(xml_head), xml_to_Model(xml_model),
|
wneuper@4759
|
293 |
pbl_met, xml_to_Specification(xml_spec), status)
|
wneuper@4759
|
294 |
}
|
wneuper@4759
|
295 |
case _ => throw new IllegalArgumentException("xml_to_CalcHead wrong arg: " + t)
|
wneuper@4759
|
296 |
}
|
wneuper@4770
|
297 |
def xml_of_CalcHead(chead: CalcHead): XML.Tree = {
|
wneuper@4771
|
298 |
XML.Elem(Markup("CALCHEAD", List(("status", chead.getStatusString))), List(
|
wneuper@4771
|
299 |
xml_of_Position(chead.getPosition),
|
wneuper@4788
|
300 |
xml_of_HeadForm(chead.getHeadLine),
|
wneuper@4781
|
301 |
xml_of_Model(chead.getModel),
|
wneuper@4771
|
302 |
XML.Elem(Markup("BELONGSTO", Nil), List(XML.Text(chead.getBelongsTo))),
|
wneuper@4771
|
303 |
xml_of_Specification(chead.getSpecification)))
|
wneuper@4770
|
304 |
}
|
wneuper@4787
|
305 |
def xml_to_Formula(t: XML.Tree): isac.util.formulae.Formula = t match {
|
wneuper@4759
|
306 |
case
|
wneuper@4759
|
307 |
XML.Elem(Markup("FORMULA", Nil), List(
|
wneuper@4759
|
308 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4759
|
309 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(form_isa)))))))
|
wneuper@4787
|
310 |
=> new Formula(form_isa)
|
wneuper@4759
|
311 |
case
|
wneuper@4759
|
312 |
XML.Elem(Markup("HEAD", Nil), List(
|
wneuper@4759
|
313 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4759
|
314 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(head_isa)))))))
|
wneuper@4787
|
315 |
=> new Formula(head_isa)
|
wneuper@4759
|
316 |
case _ => throw new IllegalArgumentException("xml_to_Formula wrong arg: " + t)
|
wneuper@4759
|
317 |
}
|
wneuper@4787
|
318 |
def xml_of_Formula(form_isa: Formula): XML.Tree = {
|
wneuper@4767
|
319 |
XML.Elem(Markup("FORMULA", Nil), List(
|
wneuper@4767
|
320 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4787
|
321 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(form_isa.toString)))))))
|
wneuper@4767
|
322 |
}
|
wneuper@4788
|
323 |
def xml_of_HeadForm(head_isa: Formula): XML.Tree = {
|
wneuper@4767
|
324 |
XML.Elem(Markup("HEAD", Nil), List(
|
wneuper@4767
|
325 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4788
|
326 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(head_isa.toString)))))))
|
wneuper@4767
|
327 |
}
|
wneuper@4759
|
328 |
def xml_to_CalcFormula(t: XML.Tree): CalcFormula = t match {
|
wneuper@4759
|
329 |
case
|
wneuper@4759
|
330 |
XML.Elem(Markup("CALCFORMULA", Nil), List(pos, form))
|
wneuper@4767
|
331 |
=> new CalcFormula(xml_to_Position(pos), xml_to_Formula(form))
|
wneuper@4759
|
332 |
case _ => throw new IllegalArgumentException("xml_to_CalcFormula wrong arg: " + t)
|
wneuper@4759
|
333 |
}
|
wneuper@4767
|
334 |
def xml_of_CalcFormula(calc_form: CalcFormula): XML.Tree = {
|
wneuper@4768
|
335 |
XML.Elem(Markup("CALCFORMULA", Nil), List(
|
wneuper@4771
|
336 |
xml_of_Position(calc_form.getPosition),
|
wneuper@4771
|
337 |
xml_of_Formula(calc_form.getFormula)))
|
wneuper@4767
|
338 |
}
|
wneuper@4758
|
339 |
def xml_of_Formalization(fmz: Formalization): XML.Tree = {
|
wneuper@4771
|
340 |
XML.Elem(Markup("FORMALIZATION", Nil), fmz.getVariants.asScala.toList map xml_of_Variant)
|
wneuper@4758
|
341 |
}
|
wneuper@4758
|
342 |
def xml_of_Position(pos: Position): XML.Tree = {
|
wneuper@4771
|
343 |
val is: List[Integer] = pos.getIntList.asInstanceOf[Vector[Integer]].asScala.toList
|
wneuper@4771
|
344 |
xml_of_pos(is map Integer_to_BigInt, pos.getKind)
|
wneuper@4758
|
345 |
}
|
wneuper@4759
|
346 |
def xml_to_Position(t: XML.Tree): Position = t match {
|
wneuper@4759
|
347 |
case
|
wneuper@4759
|
348 |
XML.Elem(Markup("POSITION", Nil), List(
|
wneuper@4759
|
349 |
ints, XML.Elem(Markup("POS", Nil), List(XML.Text(kind)))))
|
wneuper@4759
|
350 |
=> new Position(xml_to_VectorInteger(ints), kind)
|
wneuper@4759
|
351 |
case _ => throw new IllegalArgumentException("xml_to_Position wrong arg: " + t)
|
wneuper@4759
|
352 |
}
|
wneuper@4758
|
353 |
def xml_of_Specification(spec: Specification): XML.Tree = {
|
wneuper@4758
|
354 |
XML.Elem(Markup("SPECIFICATION", Nil), List(
|
wneuper@4771
|
355 |
XML.Elem(Markup("THEORYID", Nil), List(XML.Text(spec.getTheory.getID))),
|
wneuper@4758
|
356 |
XML.Elem(Markup("PROBLEMID", Nil), List(
|
wneuper@4771
|
357 |
DataTypes.xml_of_strs(spec.getProblem.getID.asScala.toList))),
|
wneuper@4758
|
358 |
XML.Elem(Markup("METHODID", Nil), List(
|
wneuper@4771
|
359 |
DataTypes.xml_of_strs(spec.getMethod.getID.asScala.toList)))))
|
wneuper@4758
|
360 |
}
|
wneuper@4758
|
361 |
def xml_of_Variant(vat: isac.util.Variant): isabelle.XML.Tree = {
|
wneuper@4758
|
362 |
XML.Elem(Markup("VARIANT", Nil), List(
|
wneuper@4771
|
363 |
DataTypes.xml_of_strs(vat.getIsaStrings.asScala.toList),
|
wneuper@4771
|
364 |
xml_of_Specification(vat.getSpecification)))
|
wneuper@4758
|
365 |
}
|
wneuper@4770
|
366 |
def xml_of_ContextType(ctxt_typ: isac.wsdialog.IContextProvider.ContextType): isabelle.XML.Tree = {
|
wneuper@4771
|
367 |
XML.Elem(Markup("KETYPE", Nil), List(XML.Text(ctxt_typ.toString)))
|
wneuper@4771
|
368 |
}
|
wneuper@4771
|
369 |
|
wneuper@4771
|
370 |
// repair for MathML: use term instead String
|
wneuper@4771
|
371 |
def xml_of_Theorem(thm: Theorem): isabelle.XML.Tree = {
|
wneuper@4771
|
372 |
XML.Elem(Markup("THEOREM", Nil), List(
|
wneuper@4771
|
373 |
XML.Elem(Markup("ID", Nil), List(XML.Text(thm.getId))),
|
wneuper@4771
|
374 |
XML.Elem(Markup("FORMULA", Nil), List(
|
wneuper@4771
|
375 |
XML.Text(thm.getFormula))))) // term instead String for MathML
|
wneuper@4771
|
376 |
}
|
wneuper@4771
|
377 |
def xml_to_Theorem(t: XML.Tree): Theorem = t match {
|
wneuper@4771
|
378 |
case
|
wneuper@4771
|
379 |
XML.Elem(Markup("THEOREM", Nil), List(
|
wneuper@4771
|
380 |
XML.Elem(Markup("ID", Nil), List(XML.Text(id))),
|
wneuper@4771
|
381 |
XML.Elem(Markup("FORMULA", Nil), List(
|
wneuper@4771
|
382 |
XML.Text(form))))) // term instead String for MathML
|
wneuper@4771
|
383 |
=> new Theorem(id, form)
|
wneuper@4771
|
384 |
case x => throw new IllegalArgumentException("xml_to_Theorem WRONG arg = " + x)
|
wneuper@4771
|
385 |
}
|
wneuper@4771
|
386 |
|
wneuper@4771
|
387 |
//----- FOR xml_of_Tactic --------------------------------------------*)
|
wneuper@4772
|
388 |
def xml_of_SubProblemTactic(tac: SubProblemTactic): isabelle.XML.Tree = {
|
wneuper@4772
|
389 |
XML.Elem(Markup("SUBPROBLEMTACTIC", List(("name", tac.getName))), List(
|
wneuper@4772
|
390 |
XML.Elem(Markup("THEORY", Nil), List(XML.Text(tac.getTheoryID))),
|
wneuper@4772
|
391 |
XML.Elem(Markup("PROBLEM", Nil), List(xml_of_VectorString(tac.getProblemID)))))
|
wneuper@4771
|
392 |
}
|
wneuper@4771
|
393 |
// Substitute see //----- STRINGLISTTACTIC below
|
wneuper@4771
|
394 |
|
wneuper@4771
|
395 |
//----- Rewrite* -----------------------------------------------------*)
|
wneuper@4771
|
396 |
def xml_of_Rewrite(tac: Rewrite): isabelle.XML.Tree = {
|
wneuper@4771
|
397 |
XML.Elem(Markup("REWRITETACTIC", List(("name", tac.getName))), List(
|
wneuper@4771
|
398 |
xml_of_Theorem(tac.getTheorem)))
|
wneuper@4771
|
399 |
}
|
wneuper@4771
|
400 |
def xml_of_RewriteInst(tac: RewriteInst): isabelle.XML.Tree = {
|
wneuper@4771
|
401 |
XML.Elem(Markup("REWRITEINSTTACTIC", List(("name", tac.getName))), List(
|
wneuper@4771
|
402 |
//this will be generalised at introduction of MathML
|
wneuper@4771
|
403 |
XML.Elem(Markup("PAIR", Nil), List(
|
wneuper@4771
|
404 |
XML.Elem(Markup("VARIABLE", Nil), List(
|
wneuper@4771
|
405 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
406 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(tac.getVariable))))))),
|
wneuper@4771
|
407 |
XML.Elem(Markup("VALUE", Nil), List(
|
wneuper@4771
|
408 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
409 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(tac.getValue))))))))),
|
wneuper@4771
|
410 |
xml_of_Theorem(tac.getTheorem)))
|
wneuper@4771
|
411 |
}
|
wneuper@4771
|
412 |
def xml_of_RewriteSet(tac: RewriteSet): isabelle.XML.Tree = {
|
wneuper@4771
|
413 |
XML.Elem(Markup("REWRITESETTACTIC", List(("name", tac.getName))), List(
|
wneuper@4771
|
414 |
XML.Text(tac.getRuleSet)))
|
wneuper@4771
|
415 |
}
|
wneuper@4771
|
416 |
def xml_of_RewriteSetInst(tac: RewriteSetInst): isabelle.XML.Tree = {
|
wneuper@4771
|
417 |
XML.Elem(Markup("REWRITESETINSTTACTIC", List(("name", tac.getName))), List(
|
wneuper@4771
|
418 |
//this will be generalised at introduction of MathML
|
wneuper@4771
|
419 |
XML.Elem(Markup("PAIR", Nil), List(
|
wneuper@4771
|
420 |
XML.Elem(Markup("VARIABLE", Nil), List(
|
wneuper@4771
|
421 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
422 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(tac.getVariable))))))),
|
wneuper@4771
|
423 |
XML.Elem(Markup("VALUE", Nil), List(
|
wneuper@4771
|
424 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
425 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(tac.getValue))))))))),
|
wneuper@4771
|
426 |
XML.Text(tac.getRuleSet)))
|
wneuper@4770
|
427 |
}
|
wneuper@4758
|
428 |
|
wneuper@4771
|
429 |
//----- FORMTACTIC ---------------------------------------------------*)
|
wneuper@4810
|
430 |
def xml_of_TermTactic(formtac: TermTactic): isabelle.XML.Tree = {
|
wneuper@4771
|
431 |
XML.Elem(Markup("FORMTACTIC", List(("name", formtac.getName))), List(
|
wneuper@4810
|
432 |
xml_of_term(formtac.getTerm)))
|
wneuper@4771
|
433 |
}
|
wneuper@4771
|
434 |
//----- SIMPLETACTIC -------------------------------------------------*)
|
wneuper@4771
|
435 |
def xml_of_SimpleTactic(tac: SimpleTactic): isabelle.XML.Tree = {
|
wneuper@4771
|
436 |
XML.Elem(Markup("SIMPLETACTIC", List(("name", tac.getName))), List(
|
wneuper@4771
|
437 |
xml_of_term(tac.getArgument)))
|
wneuper@4771
|
438 |
}
|
wneuper@4771
|
439 |
//----- STRINGLISTTACTIC ---------------------------------------------*)
|
wneuper@4771
|
440 |
def dest_eq(equality: String): (String, String) = {
|
wneuper@4771
|
441 |
val pair = equality.split("=")
|
wneuper@4771
|
442 |
if (pair.length == 2) (pair(0), pair(1))
|
wneuper@4771
|
443 |
else throw new IllegalArgumentException("dest_eq WRONG arg = " + equality)
|
wneuper@4771
|
444 |
}
|
wneuper@4771
|
445 |
def xml_of_val_var_pair(vv: (String, String)): XML.Tree = {
|
wneuper@4771
|
446 |
XML.Elem(Markup("PAIR", Nil), List(
|
wneuper@4771
|
447 |
XML.Elem(Markup("VARIABLE", Nil), List(
|
wneuper@4771
|
448 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
449 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(vv._1))))))),
|
wneuper@4771
|
450 |
XML.Elem(Markup("VALUE", Nil), List(
|
wneuper@4771
|
451 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
452 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(vv._2)))))))))
|
wneuper@4771
|
453 |
}
|
wneuper@4771
|
454 |
def xml_of_sube(equs: Vector[String]): XML.Tree = {
|
wneuper@4771
|
455 |
XML.Elem(Markup("SUBSTITUTION", Nil),
|
wneuper@4771
|
456 |
(equs.asScala.toList map dest_eq) map xml_of_val_var_pair)
|
wneuper@4771
|
457 |
}
|
wneuper@4771
|
458 |
def xml_of_StringListTactic(strs_tac: StringListTactic): isabelle.XML.Tree = {
|
wneuper@4771
|
459 |
var xml = XML.Text("DUMMY"): XML.Tree
|
wneuper@4771
|
460 |
if (strs_tac.getName == "Substitute")
|
wneuper@4771
|
461 |
xml = xml_of_VectorString(strs_tac.getStrings)
|
wneuper@4771
|
462 |
else
|
wneuper@4771
|
463 |
xml = xml_of_VectorString(strs_tac.getStrings)
|
wneuper@4771
|
464 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", strs_tac.getName))), List(
|
wneuper@4771
|
465 |
xml))
|
wneuper@4771
|
466 |
}
|
wneuper@4781
|
467 |
// def xml_of_Tactic(tac: Tactic): isabelle.XML.Tree = tac.getClass match {
|
wneuper@4781
|
468 |
// was shifted to DataTypesCompanion.java
|
wneuper@4771
|
469 |
def xml_to_Tactic(t: XML.Tree): Tactic = t match {
|
wneuper@4771
|
470 |
case
|
wneuper@4771
|
471 |
XML.Elem(Markup("SUBPROBLEMTACTIC", List(("name", "Subproblem"))), List(
|
wneuper@4810
|
472 |
XML.Elem(Markup("THEORY", Nil), List(XML.Text(thy))),
|
wneuper@4810
|
473 |
XML.Elem(Markup("PROBLEM", Nil), List(pbl))))
|
wneuper@4771
|
474 |
=> new SubProblemTactic("Subproblem", thy, xml_to_VectorString(pbl))
|
wneuper@4771
|
475 |
case
|
wneuper@4771
|
476 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Substitute"))), List(
|
wneuper@4771
|
477 |
XML.Elem(Markup("PAIR", Nil), List(
|
wneuper@4771
|
478 |
XML.Elem(Markup("VARIABLE", Nil), List(
|
wneuper@4771
|
479 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
480 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(variable))))))),
|
wneuper@4771
|
481 |
XML.Elem(Markup("VALUE", Nil), List(
|
wneuper@4771
|
482 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
483 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(value)))))))))))
|
wneuper@4771
|
484 |
=> new SubstituteTactic("Substitute", variable, value)
|
wneuper@4771
|
485 |
|
wneuper@4771
|
486 |
//----- Rewrite* -----------------------------------------------------*)
|
wneuper@4771
|
487 |
case
|
wneuper@4771
|
488 |
XML.Elem(Markup("REWRITETACTIC", List(("name", "Rewrite"))), List(
|
wneuper@4771
|
489 |
thm))
|
wneuper@4771
|
490 |
=> new Rewrite("Rewrite", xml_to_Theorem(thm))
|
wneuper@4771
|
491 |
case // faked until introduction of MathML
|
wneuper@4771
|
492 |
XML.Elem(Markup("REWRITEINSTTACTIC", List(("name", "Rewrite_Inst"))), List(
|
wneuper@4771
|
493 |
XML.Elem(Markup("SUBSTITUTION", Nil), List(
|
wneuper@4771
|
494 |
XML.Elem(Markup("PAIR", Nil), List(
|
wneuper@4771
|
495 |
XML.Elem(Markup("VARIABLE", Nil), List(
|
wneuper@4771
|
496 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
497 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(variable))))))),
|
wneuper@4771
|
498 |
XML.Elem(Markup("VALUE", Nil), List(
|
wneuper@4771
|
499 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
500 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(value)))))))
|
wneuper@4771
|
501 |
)))),
|
wneuper@4771
|
502 |
thm))
|
wneuper@4771
|
503 |
=> new RewriteInst("Rewrite_Inst", variable, value, xml_to_Theorem(thm))
|
wneuper@4771
|
504 |
case
|
wneuper@4771
|
505 |
XML.Elem(Markup("REWRITESETTACTIC", List(("name", "Rewrite_Set"))), List(
|
wneuper@4771
|
506 |
XML.Text(rule_set)))
|
wneuper@4771
|
507 |
=> new RewriteSet("Rewrite_Set", rule_set)
|
wneuper@4810
|
508 |
case // faked Term by String until introduction of MathML
|
wneuper@4771
|
509 |
XML.Elem(Markup("REWRITESETINSTTACTIC", List(("name", "Rewrite_Set_Inst"))), List(
|
wneuper@4810
|
510 |
XML.Elem(Markup("SUBSTITUTION", Nil), List(
|
wneuper@4771
|
511 |
XML.Elem(Markup("PAIR", Nil), List(
|
wneuper@4771
|
512 |
XML.Elem(Markup("VARIABLE", Nil), List(
|
wneuper@4771
|
513 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
514 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(variable))))))),
|
wneuper@4771
|
515 |
XML.Elem(Markup("VALUE", Nil), List(
|
wneuper@4771
|
516 |
XML.Elem(Markup("MATHML", Nil), List(
|
wneuper@4771
|
517 |
XML.Elem(Markup("ISA", Nil), List(XML.Text(value))))))))))),
|
wneuper@4810
|
518 |
XML.Elem(Markup("RULESET", Nil), List(XML.Text(rule_set)))))
|
wneuper@4810
|
519 |
// ATTENTION: args--vv are shuffled wrt. RewriteInst
|
wneuper@4771
|
520 |
=> new RewriteSetInst("Rewrite_Set_Inst", rule_set, variable, value)
|
wneuper@4771
|
521 |
|
wneuper@4771
|
522 |
//----- FORMTACTIC ---------------------------------------------------*)
|
wneuper@4771
|
523 |
case
|
wneuper@4771
|
524 |
XML.Elem(Markup("FORMTACTIC", List(("name", "Add_Find"))), List(
|
wneuper@4810
|
525 |
term))
|
wneuper@4810
|
526 |
=> new TermTactic("Add_Find", xml_to_term(term))
|
wneuper@4771
|
527 |
case
|
wneuper@4771
|
528 |
XML.Elem(Markup("FORMTACTIC", List(("name", "Add_Given"))), List(
|
wneuper@4810
|
529 |
term))
|
wneuper@4810
|
530 |
=> new TermTactic("Add_Given", xml_to_term(term))
|
wneuper@4771
|
531 |
case
|
wneuper@4771
|
532 |
XML.Elem(Markup("FORMTACTIC", List(("name", "Add_Relation"))), List(
|
wneuper@4810
|
533 |
term))
|
wneuper@4810
|
534 |
=> new TermTactic("Add_Relation", xml_to_term(term))
|
wneuper@4771
|
535 |
case
|
wneuper@4771
|
536 |
XML.Elem(Markup("FORMTACTIC", List(("name", "Check_elementwise"))), List(
|
wneuper@4810
|
537 |
term))
|
wneuper@4810
|
538 |
=> new TermTactic("Check_elementwise", xml_to_term(term))
|
wneuper@4771
|
539 |
case
|
wneuper@4771
|
540 |
XML.Elem(Markup("FORMTACTIC", List(("name", "Take"))), List(
|
wneuper@4810
|
541 |
term))
|
wneuper@4810
|
542 |
=> new TermTactic("Take", xml_to_term(term))
|
wneuper@4771
|
543 |
|
wneuper@4771
|
544 |
//----- SIMPLETACTIC -------------------------------------------------*)
|
wneuper@4771
|
545 |
case
|
wneuper@4771
|
546 |
XML.Elem(Markup("SIMPLETACTIC", List(("name", "Or_to_List"))), List(
|
wneuper@4771
|
547 |
XML.Text(_)))
|
wneuper@4787
|
548 |
=> new SimpleTactic("Or_to_List", "DUMMY")
|
wneuper@4771
|
549 |
case
|
wneuper@4771
|
550 |
XML.Elem(Markup("SIMPLETACTIC", List(("name", "Specify_Theory"))), List(
|
wneuper@4771
|
551 |
XML.Text(str)))
|
wneuper@4787
|
552 |
=> new SimpleTactic("Specify_Theory", str)
|
wneuper@4771
|
553 |
|
wneuper@4771
|
554 |
//----- STRINGLISTTACTIC ---------------------------------------------*)
|
wneuper@4771
|
555 |
case
|
wneuper@4771
|
556 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Apply_Method"))), List(
|
wneuper@4771
|
557 |
strs))
|
wneuper@4771
|
558 |
=> new StringListTactic("Apply_Method", xml_to_VectorString(strs))
|
wneuper@4771
|
559 |
case
|
wneuper@4771
|
560 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Check_Postcond"))), List(
|
wneuper@4771
|
561 |
strs))
|
wneuper@4771
|
562 |
=> new StringListTactic("Check_Postcond", xml_to_VectorString(strs))
|
wneuper@4771
|
563 |
case
|
wneuper@4771
|
564 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Model_Problem"))), List(
|
wneuper@4771
|
565 |
strs))
|
wneuper@4771
|
566 |
=> new StringListTactic("Model_Problem", xml_to_VectorString(strs))
|
wneuper@4771
|
567 |
case
|
wneuper@4771
|
568 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Refine_Tacitly"))), List(
|
wneuper@4771
|
569 |
strs))
|
wneuper@4771
|
570 |
=> new StringListTactic("Refine_Tacitly", xml_to_VectorString(strs))
|
wneuper@4771
|
571 |
case
|
wneuper@4771
|
572 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Specify_Method"))), List(
|
wneuper@4771
|
573 |
strs))
|
wneuper@4771
|
574 |
=> new StringListTactic("Specify_Method", xml_to_VectorString(strs))
|
wneuper@4771
|
575 |
case
|
wneuper@4771
|
576 |
XML.Elem(Markup("STRINGLISTTACTIC", List(("name", "Specify_Problem"))), List(
|
wneuper@4771
|
577 |
strs))
|
wneuper@4771
|
578 |
=> new StringListTactic("Specify_Problem", xml_to_VectorString(strs))
|
wneuper@4771
|
579 |
case x => throw new IllegalArgumentException("xml_to_Tactic WRONG arg = " + x)
|
wneuper@4771
|
580 |
}
|
wneuper@4771
|
581 |
|
wneuper@4787
|
582 |
//------- for xml_of_contthy
|
wneuper@4787
|
583 |
//--- see Isabelle/Isac:../datatypes.sml
|
wneuper@4789
|
584 |
def xml_to_Reference(t: XML.Tree): Reference = t match {
|
wneuper@4787
|
585 |
case
|
wneuper@4789
|
586 |
XML.Elem(Markup("KESTOREREF", Nil), List(
|
wneuper@4789
|
587 |
XML.Elem(Markup("TAG", Nil), List(XML.Text(tag))),
|
wneuper@4789
|
588 |
XML.Elem(Markup("ID", Nil), List(XML.Text(xstring))),
|
wneuper@4789
|
589 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(guh)))))
|
wneuper@4789
|
590 |
=> new Reference(tag, xstring, new KEStoreKey(guh))
|
wneuper@4789
|
591 |
case t => throw new IllegalArgumentException("xml_to_Reference wrong arg: " + t)
|
wneuper@4787
|
592 |
}
|
wneuper@4757
|
593 |
|
wneuper@4789
|
594 |
def xml_to_asm_val(t: XML.Tree): FormulaPair = t match {
|
wneuper@4787
|
595 |
case
|
wneuper@4789
|
596 |
XML.Elem(Markup("ASMEVALUATED", Nil), List(
|
wneuper@4789
|
597 |
XML.Elem(Markup("ASM", Nil), List(asm)),
|
wneuper@4789
|
598 |
XML.Elem(Markup("VALUE", Nil), List(vl))))
|
wneuper@4789
|
599 |
=> new FormulaPair(new Formula(xml_to_term(asm)), /*new Formula((xml_to_term(vl)))*/true)
|
wneuper@4789
|
600 |
case t => throw new IllegalArgumentException("xml_to_asm_val wrong arg: " + t)
|
wneuper@4789
|
601 |
}
|
wneuper@4825
|
602 |
def xml_to_ContextTheory(t: XML.Tree): ContextTheory = t match {
|
wneuper@4789
|
603 |
// | xml_of_contthy (ContThm {thyID, thm, applto, applat, reword,
|
wneuper@4789
|
604 |
// asms,lhs, rhs, result, resasms, asmrls}) =
|
wneuper@4789
|
605 |
case
|
wneuper@4825
|
606 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4789
|
607 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(thm))),
|
wneuper@4789
|
608 |
XML.Elem(Markup("APPLTO", Nil), List(applto_xml)),
|
wneuper@4789
|
609 |
XML.Elem(Markup("APPLAT", Nil), List(applat_xml)),
|
wneuper@4789
|
610 |
XML.Elem(Markup("ORDER", Nil), List(
|
wneuper@4789
|
611 |
XML.Elem(Markup("ID", Nil), List(XML.Text(reword))))),
|
wneuper@4825
|
612 |
XML.Elem(Markup("ASMSEVAL", Nil), asmevs_xml), //Nil is possible
|
wneuper@4789
|
613 |
XML.Elem(Markup("LHS", Nil), List(lhs_xml)),
|
wneuper@4789
|
614 |
XML.Elem(Markup("LHSINST", Nil), List(lhsinst_xml)),
|
wneuper@4789
|
615 |
XML.Elem(Markup("RHS", Nil), List(rhs_xml)),
|
wneuper@4789
|
616 |
XML.Elem(Markup("RHSINST", Nil), List(rhsinst_xml)),
|
wneuper@4789
|
617 |
XML.Elem(Markup("RESULT", Nil), List(result_xml)),
|
wneuper@4825
|
618 |
XML.Elem(Markup("ASSUMPTIONS", Nil), asms_xml), //Nil is possible
|
wneuper@4825
|
619 |
XML.Elem(Markup("EVALRLS", Nil), List(rlskey_xml))))
|
wneuper@4789
|
620 |
=> new ContextTheory(/*WN150820 GUH unused?!?*/
|
wneuper@4789
|
621 |
null, null,
|
wneuper@4789
|
622 |
new Formula(xml_to_term(applto_xml)), new Formula(xml_to_term(applat_xml)),
|
wneuper@4789
|
623 |
reword,
|
wneuper@4789
|
624 |
sListToVectorFormulaPair(asmevs_xml map xml_to_asm_val), //WN150820 bug: Boolean form_2
|
wneuper@4789
|
625 |
new Formula(xml_to_term(lhs_xml)), new Formula(xml_to_term(lhsinst_xml)),
|
wneuper@4789
|
626 |
new Formula(xml_to_term(rhs_xml)), new Formula(xml_to_term(rhsinst_xml)),
|
wneuper@4789
|
627 |
new Formula(xml_to_term(result_xml)), "xml_to_ContextTheory: ASSUMPTIONS wrong type",
|
wneuper@4789
|
628 |
xml_to_Reference(rlskey_xml))
|
wneuper@4789
|
629 |
// | xml_of_contthy (ContThmInst {thyID, thm, bdvs, thminst, applto, applat,
|
wneuper@4789
|
630 |
// reword, asms, lhs, rhs, result, resasms, asmrls}) =
|
wneuper@4789
|
631 |
case
|
wneuper@4825
|
632 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4789
|
633 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(thm))),
|
wneuper@4789
|
634 |
XML.Elem(Markup("SUBSLIST", Nil), List(subst_xml)), // WRONG type
|
wneuper@4789
|
635 |
XML.Elem(Markup("INSTANTIATED", Nil), List(thminst_xml)),
|
wneuper@4789
|
636 |
XML.Elem(Markup("APPLTO", Nil), List(applto_xml)),
|
wneuper@4789
|
637 |
XML.Elem(Markup("APPLAT", Nil), List(applat_xml)),
|
wneuper@4789
|
638 |
XML.Elem(Markup("ORDER", Nil), List(
|
wneuper@4789
|
639 |
XML.Elem(Markup("ID", Nil), List(XML.Text(reword))))),
|
wneuper@4825
|
640 |
XML.Elem(Markup("ASMSEVAL", Nil), asmevs_xml), //Nil is possible
|
wneuper@4789
|
641 |
XML.Elem(Markup("LHS", Nil), List(lhs_xml)),
|
wneuper@4789
|
642 |
XML.Elem(Markup("LHSINST", Nil), List(lhsinst_xml)),
|
wneuper@4789
|
643 |
XML.Elem(Markup("RHS", Nil), List(rhs_xml)),
|
wneuper@4789
|
644 |
XML.Elem(Markup("RHSINST", Nil), List(rhsinst_xml)),
|
wneuper@4789
|
645 |
XML.Elem(Markup("RESULT", Nil), List(result_xml)),
|
wneuper@4825
|
646 |
XML.Elem(Markup("ASSUMPTIONS", Nil), asms_xml), //Nil is possible
|
wneuper@4825
|
647 |
XML.Elem(Markup("EVALRLS", Nil), List(rlskey_xml))))
|
wneuper@4789
|
648 |
=> new ContextTheory(/*WN150820 GUH unused?!?*/
|
wneuper@4789
|
649 |
new Formula(xml_to_term(subst_xml)), new Formula(xml_to_term(thminst_xml)),
|
wneuper@4789
|
650 |
new Formula(xml_to_term(applto_xml)), new Formula(xml_to_term(applat_xml)),
|
wneuper@4789
|
651 |
reword,
|
wneuper@4789
|
652 |
sListToVectorFormulaPair(asmevs_xml map xml_to_asm_val),
|
wneuper@4789
|
653 |
new Formula(xml_to_term(lhs_xml)), new Formula(xml_to_term(lhsinst_xml)),
|
wneuper@4789
|
654 |
new Formula(xml_to_term(rhs_xml)), new Formula(xml_to_term(rhsinst_xml)),
|
wneuper@4789
|
655 |
new Formula(xml_to_term(result_xml)), "xml_to_ContextTheory: ASSUMPTIONS wrong type",
|
wneuper@4789
|
656 |
xml_to_Reference(rlskey_xml))
|
wneuper@4789
|
657 |
// | xml_of_contthy (ContRls {thyID = _, rls, applto, result, asms}) =
|
wneuper@4789
|
658 |
case
|
wneuper@4825
|
659 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4789
|
660 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(thm))),
|
wneuper@4789
|
661 |
XML.Elem(Markup("APPLTO", Nil), List(applto_xml)),
|
wneuper@4789
|
662 |
XML.Elem(Markup("RESULT", Nil), List(result_xml)),
|
wneuper@4825
|
663 |
XML.Elem(Markup("ASSUMPTIONS", Nil), asms_xml))) //Nil is possible
|
wneuper@4789
|
664 |
=> new ContextTheory(/*WN150820 GUH unused?!?*/
|
wneuper@4789
|
665 |
null, null,
|
wneuper@4789
|
666 |
new Formula(xml_to_term(applto_xml)), null,
|
wneuper@4789
|
667 |
null,
|
wneuper@4789
|
668 |
null,
|
wneuper@4789
|
669 |
null, null,
|
wneuper@4789
|
670 |
null, null,
|
wneuper@4789
|
671 |
new Formula(xml_to_term(result_xml)), "xml_to_ContextTheory: ASSUMPTIONS wrong type",
|
wneuper@4789
|
672 |
null)
|
wneuper@4789
|
673 |
// | xml_of_contthy (ContRlsInst {thyID = _, rls, bdvs, applto, result, asms}) =
|
wneuper@4789
|
674 |
case
|
wneuper@4825
|
675 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4789
|
676 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(thm))),
|
wneuper@4789
|
677 |
XML.Elem(Markup("SUBSLIST", Nil), List(subst_xml)), // WRONG type
|
wneuper@4789
|
678 |
XML.Elem(Markup("INSTANTIATED", Nil), List(thminst_xml)),
|
wneuper@4789
|
679 |
XML.Elem(Markup("APPLTO", Nil), List(applto_xml)),
|
wneuper@4789
|
680 |
XML.Elem(Markup("RESULT", Nil), List(result_xml)),
|
wneuper@4825
|
681 |
XML.Elem(Markup("ASSUMPTIONS", Nil), List(asms_xml))))
|
wneuper@4789
|
682 |
=> new ContextTheory(/*WN150820 GUH unused?!?*/
|
wneuper@4789
|
683 |
new Formula(xml_to_term(subst_xml)), new Formula(xml_to_term(thminst_xml)),
|
wneuper@4789
|
684 |
new Formula(xml_to_term(applto_xml)), null,
|
wneuper@4789
|
685 |
null,
|
wneuper@4789
|
686 |
null,
|
wneuper@4789
|
687 |
null, null,
|
wneuper@4789
|
688 |
null, null,
|
wneuper@4789
|
689 |
new Formula(xml_to_term(result_xml)), "xml_to_ContextTheory: ASSUMPTIONS wrong type",
|
wneuper@4789
|
690 |
null)
|
wneuper@4789
|
691 |
// | xml_of_contthy (ContNOrew {thyID = _, thm_rls, applto}) =
|
wneuper@4789
|
692 |
case
|
wneuper@4825
|
693 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4789
|
694 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(thm))),
|
wneuper@4825
|
695 |
XML.Elem(Markup("APPLTO", Nil), List(applto_xml))))
|
wneuper@4789
|
696 |
=> new ContextTheory(/*WN150820 GUH unused?!?*/
|
wneuper@4789
|
697 |
null, null,
|
wneuper@4789
|
698 |
new Formula(xml_to_term(applto_xml)), null,
|
wneuper@4789
|
699 |
null,
|
wneuper@4789
|
700 |
null,
|
wneuper@4789
|
701 |
null, null,
|
wneuper@4789
|
702 |
null, null,
|
wneuper@4789
|
703 |
null, null,
|
wneuper@4789
|
704 |
null)
|
wneuper@4789
|
705 |
// | xml_of_contthy (ContNOrewInst{thyID = _, thm_rls, bdvs, thminst, applto}) =
|
wneuper@4789
|
706 |
case
|
wneuper@4825
|
707 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4789
|
708 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(thm))),
|
wneuper@4789
|
709 |
XML.Elem(Markup("SUBSLIST", Nil), List(subst_xml)), // WRONG type
|
wneuper@4789
|
710 |
XML.Elem(Markup("INSTANTIATED", Nil), List(thminst_xml)),
|
wneuper@4825
|
711 |
XML.Elem(Markup("APPLTO", Nil), List(applto_xml))))
|
wneuper@4789
|
712 |
=> new ContextTheory(/*WN150820 GUH unused?!?*/
|
wneuper@4789
|
713 |
new Formula(xml_to_term(subst_xml)), new Formula(xml_to_term(thminst_xml)),
|
wneuper@4789
|
714 |
new Formula(xml_to_term(applto_xml)), null,
|
wneuper@4789
|
715 |
null,
|
wneuper@4789
|
716 |
null,
|
wneuper@4789
|
717 |
null, null,
|
wneuper@4789
|
718 |
null, null,
|
wneuper@4789
|
719 |
null, null,
|
wneuper@4789
|
720 |
null)
|
wneuper@4789
|
721 |
case _ => throw new IllegalArgumentException("xml_to_ContextTheory wrong arg: " + t)
|
wneuper@4789
|
722 |
}
|
wneuper@4789
|
723 |
|
wneuper@4825
|
724 |
def xml_to_ContextProblem(t: XML.Tree): ContextProblem = t match {
|
wneuper@4825
|
725 |
case
|
wneuper@4825
|
726 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4825
|
727 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(guh))),
|
wneuper@4825
|
728 |
XML.Elem(Markup("STATUS", Nil), List(XML.Text(status))),
|
wneuper@4825
|
729 |
XML.Elem(Markup("HEAD", Nil), List(head_xml)),
|
wneuper@4825
|
730 |
model_xml))
|
wneuper@4825
|
731 |
=> new ContextProblem(/*WN150820 GUH unused?!?*/
|
wneuper@4825
|
732 |
status, new Formula(xml_to_term(head_xml)), xml_to_Model(model_xml))
|
wneuper@4825
|
733 |
case _ => throw new IllegalArgumentException("xml_to_ContextProblem wrong arg: " + t)
|
wneuper@4825
|
734 |
}
|
wneuper@4825
|
735 |
|
wneuper@4825
|
736 |
def xml_to_ContextMethod(t: XML.Tree): ContextMethod = t match {
|
wneuper@4825
|
737 |
case
|
wneuper@4825
|
738 |
XML.Elem(Markup("CONTEXTDATA", Nil), List(
|
wneuper@4825
|
739 |
XML.Elem(Markup("GUH", Nil), List(XML.Text(guh))),
|
wneuper@4825
|
740 |
XML.Elem(Markup("STATUS", Nil), List(XML.Text(status))),
|
wneuper@4825
|
741 |
XML.Elem(Markup("PROGRAM", Nil), List(prog_xml)),
|
wneuper@4825
|
742 |
model_xml))
|
wneuper@4825
|
743 |
=> new ContextMethod(/*WN150820 GUH unused?!?*/
|
wneuper@4825
|
744 |
status, new Formula(xml_to_term(prog_xml)), xml_to_Model(model_xml))
|
wneuper@4825
|
745 |
case _ => throw new IllegalArgumentException("xml_to_ContextMethod wrong arg: " + t)
|
wneuper@4825
|
746 |
}
|
wneuper@4825
|
747 |
|
wneuper@4788
|
748 |
def xml_to_CEvent(t: XML.Tree): CEvent = t match {
|
wneuper@4788
|
749 |
case
|
wneuper@4788
|
750 |
XML.Elem(Markup("CALCCHANGED", Nil), List(
|
wneuper@4788
|
751 |
XML.Elem(Markup("UNCHANGED", Nil), List(
|
wneuper@4788
|
752 |
unc_is, XML.Elem(Markup("POS", Nil), List(XML.Text(unc_kind))))),
|
wneuper@4788
|
753 |
XML.Elem(Markup("DELETED", Nil), List(
|
wneuper@4788
|
754 |
del_is, XML.Elem(Markup("POS", Nil), List(XML.Text(del_kind))))),
|
wneuper@4788
|
755 |
XML.Elem(Markup("GENERATED", Nil), List(
|
wneuper@4788
|
756 |
gen_is, XML.Elem(Markup("POS", Nil), List(XML.Text(gen_kind)))))))
|
wneuper@4788
|
757 |
=> new CChanged(
|
wneuper@4788
|
758 |
new Position(DataTypes.xml_to_VectorInteger(unc_is), unc_kind),
|
wneuper@4788
|
759 |
new Position(DataTypes.xml_to_VectorInteger(del_is), del_kind),
|
wneuper@4788
|
760 |
new Position(DataTypes.xml_to_VectorInteger(gen_is), gen_kind))
|
wneuper@4788
|
761 |
case
|
wneuper@4788
|
762 |
XML.Elem(Markup("CALCMESSAGE", Nil), List(XML.Text(msg)))
|
wneuper@4788
|
763 |
=> new CMessage(msg)
|
wneuper@4788
|
764 |
case _ => throw new IllegalArgumentException("xml_to_CChanged wrong arg: " + t)
|
wneuper@4788
|
765 |
}
|
wneuper@4825
|
766 |
|
wneuper@4757
|
767 |
} |