neuper@37906
|
1 |
(* convert sml-datatypes to xml
|
neuper@37906
|
2 |
authors: Walther Neuper 2003
|
neuper@37906
|
3 |
(c) due to copyright terms
|
neuper@37906
|
4 |
|
neuper@37906
|
5 |
use"xmlsrc/datatypes.sml";
|
neuper@37906
|
6 |
use"datatypes.sml";
|
neuper@37906
|
7 |
*)
|
neuper@37906
|
8 |
|
neuper@37940
|
9 |
|
neuper@37906
|
10 |
signature DATATYPES =
|
neuper@37906
|
11 |
sig
|
neuper@37906
|
12 |
val authors2xml : int -> string -> string list -> xml
|
neuper@37906
|
13 |
val calc2xml : int -> thyID * calc -> xml
|
neuper@37906
|
14 |
val calcrefs2xml : int -> thyID * calc list -> xml
|
neuper@37906
|
15 |
val contthy2xml : int -> contthy -> xml
|
neuper@37906
|
16 |
val extref2xml : int -> string -> string -> xml
|
neuper@37906
|
17 |
val filterpbl :
|
neuper@37906
|
18 |
''a -> (''a * (Term.term * Term.term)) list -> Term.term list
|
neuper@37906
|
19 |
val formula2xml : int -> Term.term -> xml
|
neuper@37906
|
20 |
val formulae2xml : int -> Term.term list -> xml
|
neuper@37906
|
21 |
val i : int
|
neuper@37906
|
22 |
val id2xml : int -> string list -> string
|
neuper@37906
|
23 |
val ints2xml : int -> int list -> string
|
neuper@37906
|
24 |
val itm_2xml : int -> SpecifyTools.itm_ -> xml
|
neuper@37906
|
25 |
val itms2xml :
|
neuper@37906
|
26 |
int ->
|
neuper@37906
|
27 |
(int * SpecifyTools.vats * bool * string * SpecifyTools.itm_) list ->
|
neuper@37906
|
28 |
string
|
neuper@37906
|
29 |
val keref2xml : int -> ketype -> kestoreID -> xml
|
neuper@37906
|
30 |
val model2xml :
|
neuper@37906
|
31 |
int -> SpecifyTools.itm list -> (bool * Term.term) list -> xml
|
neuper@37906
|
32 |
val modspec2xml : int -> ocalhd -> xml
|
neuper@37906
|
33 |
val pattern2xml :
|
neuper@37906
|
34 |
int ->
|
neuper@37906
|
35 |
(string * (Term.term * Term.term)) list -> Term.term list -> string
|
neuper@37906
|
36 |
val pos'2xml : int -> string * (int list * pos_) -> string
|
neuper@37906
|
37 |
val pos'calchead2xml : int -> pos' * ocalhd -> xml
|
neuper@37906
|
38 |
val pos_2xml : int -> pos_ -> string
|
neuper@37906
|
39 |
val posform2xml : int -> pos' * Term.term -> xml
|
neuper@37906
|
40 |
val posformhead2xml : int -> pos' * ptform -> string
|
neuper@37906
|
41 |
val posformheads2xml : int -> (pos' * ptform) list -> xml
|
neuper@37906
|
42 |
val posforms2xml : int -> (pos' * Term.term) list -> xml
|
neuper@37906
|
43 |
val posterms2xml : int -> (pos' * term) list -> xml
|
neuper@37906
|
44 |
val precond2xml : int -> bool * Term.term -> xml
|
neuper@37906
|
45 |
val preconds2xml : int -> (bool * Term.term) list -> xml
|
neuper@37906
|
46 |
val rls2xml : int -> thyID * rls -> xml
|
neuper@37906
|
47 |
val rule2xml : int -> guh -> rule -> xml
|
neuper@37906
|
48 |
val rules2xml : int -> guh -> rule list -> xml
|
neuper@37906
|
49 |
val scr2xml : int -> scr -> xml
|
neuper@37906
|
50 |
val spec2xml : int -> spec -> xml
|
neuper@37906
|
51 |
val sub2xml : int -> Term.term * Term.term -> xml
|
neuper@37906
|
52 |
val subs2xml : int -> subs -> xml
|
neuper@37906
|
53 |
val subst2xml : int -> subst -> xml
|
neuper@37906
|
54 |
val tac2xml : int -> tac -> xml
|
neuper@37906
|
55 |
val tacs2xml : int -> tac list -> xml
|
neuper@37906
|
56 |
val theref2xml : int -> thyID -> string -> xstring -> string
|
neuper@37906
|
57 |
val thm'2xml : int -> thm' -> xml
|
neuper@37906
|
58 |
val thm''2xml : int -> thm -> xml
|
neuper@37906
|
59 |
val thmstr2xml : int -> string -> xml
|
neuper@37906
|
60 |
end
|
neuper@37906
|
61 |
|
neuper@37906
|
62 |
|
neuper@37906
|
63 |
|
neuper@37906
|
64 |
(*------------------------------------------------------------------*)
|
neuper@37906
|
65 |
structure datatypes:DATATYPES =
|
neuper@37940
|
66 |
(*structure datatypes =*)
|
neuper@37906
|
67 |
struct
|
neuper@37906
|
68 |
(*------------------------------------------------------------------*)
|
neuper@37906
|
69 |
|
neuper@37906
|
70 |
val i = indentation;
|
neuper@37906
|
71 |
|
neuper@37906
|
72 |
(** general types: lists, **)
|
neuper@37906
|
73 |
|
neuper@37906
|
74 |
(*.handles string list like 'fun id2xml'.*)
|
neuper@37906
|
75 |
fun authors2xml j str auts =
|
neuper@37906
|
76 |
let fun autx _ [] = ""
|
neuper@37906
|
77 |
| autx j (s::ss) = (indt j) ^ "<STRING> " ^ s ^ " </STRING>\n" ^
|
neuper@37906
|
78 |
(autx j ss)
|
neuper@37906
|
79 |
in indt j ^ "<"^str^">\n" ^
|
neuper@37906
|
80 |
autx (j + i) auts ^
|
neuper@37906
|
81 |
indt j ^ "</"^str^">\n" : xml
|
neuper@37906
|
82 |
end;
|
neuper@38031
|
83 |
(* writeln(authors2xml 2 "MATHAUTHORS" []);
|
neuper@38031
|
84 |
writeln(authors2xml 2 "MATHAUTHORS"
|
neuper@37906
|
85 |
["isac-team 2001", "Richard Lang 2003"]);
|
neuper@37906
|
86 |
*)
|
neuper@37906
|
87 |
|
neuper@37906
|
88 |
fun id2xml j ids =
|
neuper@37906
|
89 |
let fun id2x _ [] = ""
|
neuper@37906
|
90 |
| id2x j (s::ss) = (indt j) ^ "<STRING> " ^ s ^ " </STRING>\n" ^
|
neuper@37906
|
91 |
(id2x j ss)
|
neuper@37906
|
92 |
in (indt j) ^ "<STRINGLIST>\n" ^
|
neuper@37906
|
93 |
(id2x (j + indentation) ids) ^
|
neuper@37906
|
94 |
(indt j) ^ "</STRINGLIST>\n" end;
|
neuper@38031
|
95 |
(* writeln(id2xml 8 ["linear","univariate","equation"]);
|
neuper@37906
|
96 |
<STRINGLIST>
|
neuper@37906
|
97 |
<STRING>linear</STRING>
|
neuper@37906
|
98 |
<STRING>univariate</STRING>
|
neuper@37906
|
99 |
<STRING>equation</STRING>
|
neuper@37906
|
100 |
</STRINGLIST>*)
|
neuper@37906
|
101 |
|
neuper@37906
|
102 |
fun ints2xml j ids =
|
neuper@37906
|
103 |
let fun int2x _ [] = ""
|
neuper@37906
|
104 |
| int2x j (s::ss) = (indt j) ^"<INT> "^ string_of_int s ^" </INT>\n"^
|
neuper@37906
|
105 |
(int2x j ss)
|
neuper@37906
|
106 |
in (indt j) ^ "<INTLIST>\n" ^
|
neuper@37906
|
107 |
(int2x (j + i) ids) ^
|
neuper@37906
|
108 |
(indt j) ^ "</INTLIST>\n" end;
|
neuper@38031
|
109 |
(* writeln(ints2xml 3 [1,2,3]);
|
neuper@37906
|
110 |
*)
|
neuper@37906
|
111 |
|
neuper@37906
|
112 |
|
neuper@37906
|
113 |
(** isac datatypes **)
|
neuper@37906
|
114 |
|
neuper@37906
|
115 |
fun pos_2xml j pos_ =
|
neuper@37906
|
116 |
(indt j) ^ "<POS> " ^ pos_2str pos_ ^ " </POS>\n";
|
neuper@37906
|
117 |
|
neuper@37906
|
118 |
(*.due to specialties of isac/util/parser/XMLParseDigest.java
|
neuper@37906
|
119 |
pos' requires different tags.*)
|
neuper@37906
|
120 |
fun pos'2xml j (tag, (pos, pos_)) =
|
neuper@37906
|
121 |
indt (j) ^ "<" ^ tag ^ ">\n" ^
|
neuper@37906
|
122 |
ints2xml (j+i) pos ^
|
neuper@37906
|
123 |
pos_2xml (j+i) pos_ ^
|
neuper@37906
|
124 |
indt (j) ^ "</" ^ tag ^ ">\n";
|
neuper@38031
|
125 |
(* writeln(pos'2xml 3 ("POSITION", ([1,2,3], Pbl)));
|
neuper@37906
|
126 |
*)
|
neuper@37906
|
127 |
|
neuper@37906
|
128 |
fun formula2xml j term = (*TODO.WN050211: use for _all_ <FORMULA>*)
|
neuper@37906
|
129 |
indt j ^ "<FORMULA>\n"^
|
neuper@37906
|
130 |
term2xml j term ^"\n"^
|
neuper@37906
|
131 |
indt j ^ "</FORMULA>\n" : xml;
|
neuper@38031
|
132 |
(* writeln(formula2xml 6 (str2term "1+1=2"));
|
neuper@37906
|
133 |
*)
|
neuper@37906
|
134 |
fun formulae2xml j [] = ("":xml)
|
neuper@37906
|
135 |
| formulae2xml j (r::rs) = formula2xml j r ^ formulae2xml j rs;
|
neuper@38031
|
136 |
(* writeln(formulae2xml 6 [str2term "1+1=2", str2term "1+1+1=3"]);
|
neuper@37906
|
137 |
*)
|
neuper@37906
|
138 |
|
neuper@37906
|
139 |
(*WN0502 @see ME/ctree: type asms: illdesigned, thus not used*)
|
neuper@37906
|
140 |
fun posform2xml j (p:pos', term) =
|
neuper@37906
|
141 |
indt j ^ "<POSFORM>\n" ^
|
neuper@37906
|
142 |
pos'2xml (j+i) ("POSITION", p) ^
|
neuper@37906
|
143 |
indt (j+i) ^ "<FORMULA>\n"^
|
neuper@37906
|
144 |
term2xml (j+i) term ^"\n"^
|
neuper@37906
|
145 |
indt (j+i) ^ "</FORMULA>\n"^
|
neuper@37906
|
146 |
indt j ^ "</POSFORM>\n" : xml;
|
neuper@38031
|
147 |
(* writeln(posform2xml 6 (([1,2],Frm), str2term "1+1=2"));
|
neuper@37906
|
148 |
*)
|
neuper@37906
|
149 |
fun posforms2xml j [] = ("":xml)
|
neuper@37906
|
150 |
| posforms2xml j (r::rs) = posform2xml j r ^ posforms2xml j rs;
|
neuper@38031
|
151 |
(* writeln(posforms2xml 6 [(([1],Res), str2term "1+1=2"),(([2],Res), str2term "1+1+1=3")]);
|
neuper@37906
|
152 |
*)
|
neuper@37906
|
153 |
|
neuper@37906
|
154 |
fun calcref2xml j (thyID:thyID, (scrop, (rewop, _)):calc) =
|
neuper@37906
|
155 |
indt j ^ "<CALCREF>\n" ^
|
neuper@37906
|
156 |
indt (j+i) ^ "<STRING> " ^ scrop ^ "</STRING>\n" ^
|
neuper@37906
|
157 |
indt (j+i) ^ "<GUH> " ^ cal2guh ("IsacKnowledge",
|
neuper@37906
|
158 |
thyID) scrop ^ " </GUH>\n" ^
|
neuper@37906
|
159 |
indt j ^ "</CALCREF>\n" : xml;
|
neuper@37906
|
160 |
fun calcrefs2xml _ (_,[]) = "":xml
|
neuper@37906
|
161 |
| calcrefs2xml j (thyID, cal::cs) =
|
neuper@37906
|
162 |
calcref2xml j (thyID, cal) ^ calcrefs2xml j (thyID, cs);
|
neuper@37906
|
163 |
|
neuper@37906
|
164 |
fun calc2xml j (thyID:thyID, (scrop, (rewop, _)):calc) =
|
neuper@37906
|
165 |
indt j ^ "<CALC>\n" ^
|
neuper@37906
|
166 |
indt (j+i) ^ "<STRING>\n" ^ scrop ^ "</STRING>\n" ^
|
neuper@37906
|
167 |
indt (j+i) ^ "<GUH>\n" ^ cal2guh ("IsacKnowledge",
|
neuper@37906
|
168 |
thyID) scrop ^ "</GUH>\n" ^
|
neuper@37906
|
169 |
indt (j+i) ^ "<TERMOP>\n" ^ rewop ^ "</TERMOP>\n" ^
|
neuper@37906
|
170 |
indt j ^ "</CALC>\n" : xml;
|
neuper@37906
|
171 |
|
neuper@37906
|
172 |
(*.for creating a href for a rule within an rls's rule list;
|
neuper@37906
|
173 |
the guh points to the thy of definition of the rule, NOT of use in rls.*)
|
neuper@37906
|
174 |
fun rule2xml j (thyID:thyID) Erule =
|
neuper@38031
|
175 |
error "rule2xml called with 'Erule'"
|
neuper@37906
|
176 |
(* val (j, thyID, Thm (thmID, thm)) = (j+i, thyID, nth 1 rules);
|
neuper@37906
|
177 |
val (j, thyID, Thm (thmID, thm)) = (j, thyID,r);
|
neuper@37906
|
178 |
*)
|
neuper@37906
|
179 |
| rule2xml j thyID (Thm (thmID, thm)) =
|
neuper@37906
|
180 |
indt j ^ "<RULE>\n" ^
|
neuper@37906
|
181 |
indt (j+i) ^ "<TAG> Theorem </TAG>\n" ^
|
neuper@37906
|
182 |
indt (j+i) ^ "<STRING> " ^ thmID ^ " </STRING>\n" ^
|
neuper@37906
|
183 |
indt (j+i) ^ "<GUH> " ^ thm2guh (thy_containing_thm thyID thmID)
|
neuper@37906
|
184 |
thmID ^ " </GUH>\n" ^
|
neuper@37906
|
185 |
indt j ^ "</RULE>\n" : xml
|
neuper@37906
|
186 |
(* val (j, thyID, Calc (termop, _)) = (j+i, thyID, nth 42 rules);
|
neuper@37906
|
187 |
val (j, thyID, Calc (termop, _)) = (j+i, thyID, nth 43 rules);
|
neuper@37906
|
188 |
*)
|
neuper@37906
|
189 |
| rule2xml j thyID (Calc (termop, _)) = ""
|
neuper@37906
|
190 |
(*FIXXXXXXXME.WN060714 in rls make Calc : calc -> rule [add scriptop!]
|
neuper@37906
|
191 |
see smltest/../datatypes.sml !
|
neuper@37906
|
192 |
indt j ^ "<RULE>\n" ^
|
neuper@37906
|
193 |
indt (j+i) ^ "<STRING> " ^ termop ^ " </STRING>\n" ^
|
neuper@37906
|
194 |
indt (j+i) ^ "<GUH> " ^ cal2guh (thy_containing_cal thyID termop)
|
neuper@37906
|
195 |
termop ^ " </GUH>\n" ^
|
neuper@37906
|
196 |
indt j ^ "</RULE>\n"
|
neuper@37906
|
197 |
*)
|
neuper@37906
|
198 |
| rule2xml j thyID (Cal1 (termop, _)) = ""
|
neuper@37906
|
199 |
| rule2xml j thyID (Rls_ rls) =
|
neuper@37906
|
200 |
let val rls' = (#id o rep_rls) rls
|
neuper@37906
|
201 |
in indt j ^ "<RULE>\n" ^
|
neuper@37906
|
202 |
indt (j+i) ^ "<TAG> Ruleset </TAG>\n" ^
|
neuper@37906
|
203 |
indt (j+i) ^ "<STRING> " ^ rls' ^ " </STRING>\n" ^
|
neuper@37906
|
204 |
indt (j+i) ^ "<GUH> " ^ rls2guh (thy_containing_rls thyID rls')
|
neuper@37906
|
205 |
rls' ^ " </GUH>\n" ^
|
neuper@37906
|
206 |
indt j ^ "</RULE>\n"
|
neuper@37906
|
207 |
end;
|
neuper@37906
|
208 |
(* val (j, thyID, r::rs) = (2, "Test", rules);
|
neuper@37906
|
209 |
*)
|
neuper@37906
|
210 |
fun rules2xml j thyID [] = ("":xml)
|
neuper@37906
|
211 |
| rules2xml j thyID (r::rs) = rule2xml j thyID r ^ rules2xml j thyID rs;
|
neuper@37906
|
212 |
|
neuper@37906
|
213 |
fun filterpbl str =
|
neuper@37906
|
214 |
let fun filt [] = []
|
neuper@37906
|
215 |
| filt ((s, (t1, t2)) :: ps) =
|
neuper@37906
|
216 |
if str = s then (t1 $ t2) :: filt ps else filt ps
|
neuper@37906
|
217 |
in filt end;
|
neuper@37906
|
218 |
|
neuper@37906
|
219 |
(*FIXME.WN040831 model2xml <--?--> pattern2xml*)
|
neuper@38031
|
220 |
(*WN.25.8.03: pattern2xml different output with TextIO | writeln !!!
|
neuper@37906
|
221 |
the version below is for TextIO: terms2xml makes \n !*)
|
neuper@37906
|
222 |
(* val (j, p, where_) = (i, ppc, where_);
|
neuper@37906
|
223 |
*)
|
neuper@37906
|
224 |
fun pattern2xml j p where_ =
|
neuper@37906
|
225 |
(case filterpbl "#Given" p of
|
neuper@37906
|
226 |
[] => (indt j) ^ "<GIVEN> </GIVEN>\n"
|
neuper@37906
|
227 |
(* val gis = filterpbl "#Given" p;
|
neuper@37906
|
228 |
*)
|
neuper@37906
|
229 |
| gis => (indt j) ^ "<GIVEN>\n" ^ terms2xml' j gis ^
|
neuper@37906
|
230 |
(indt j) ^ "</GIVEN>\n")
|
neuper@37906
|
231 |
^
|
neuper@37906
|
232 |
(case where_ of
|
neuper@37906
|
233 |
[] => (indt j) ^ "<WHERE> </WHERE>\n"
|
neuper@37906
|
234 |
| whs => (indt j) ^ "<WHERE>\n" ^ terms2xml' j whs ^
|
neuper@37906
|
235 |
(indt j) ^ "</WHERE>\n")
|
neuper@37906
|
236 |
^
|
neuper@37906
|
237 |
(case filterpbl "#Find" p of
|
neuper@37906
|
238 |
[] => (indt j) ^ "<FIND> </FIND>\n"
|
neuper@37906
|
239 |
| fis => (indt j) ^ "<FIND>\n" ^ terms2xml' j fis ^
|
neuper@37906
|
240 |
(indt j) ^ "</FIND>\n")
|
neuper@37906
|
241 |
^
|
neuper@37906
|
242 |
(case filterpbl "#Relate" p of
|
neuper@37906
|
243 |
[] => (indt j) ^ "<RELATE> </RELATE>\n"
|
neuper@37906
|
244 |
| res => (indt j) ^ "<RELATE>\n" ^ terms2xml' j res ^
|
neuper@37906
|
245 |
(indt j) ^ "</RELATE>\n");
|
neuper@37906
|
246 |
(*
|
neuper@38031
|
247 |
writeln(pattern2xml 3 ((#ppc o get_pbt)
|
neuper@37906
|
248 |
["squareroot","univariate","equation","test"]) []);
|
neuper@37906
|
249 |
*)
|
neuper@37906
|
250 |
|
neuper@37906
|
251 |
(*see itm_2item*)
|
neuper@37906
|
252 |
fun itm_2xml j (Cor (dts,_))=
|
neuper@37906
|
253 |
(indt j ^"<ITEM status=\"correct\">\n"^
|
neuper@37906
|
254 |
term2xml (j) (comp_dts' dts)^"\n"^
|
neuper@37906
|
255 |
indt j ^"</ITEM>\n"):xml
|
neuper@37906
|
256 |
| itm_2xml j (Syn c) =
|
neuper@37906
|
257 |
indt j ^"<ITEM status=\"syntaxerror\">\n"^
|
neuper@37906
|
258 |
indt (j) ^c^
|
neuper@37906
|
259 |
indt j ^"</ITEM>\n"
|
neuper@37906
|
260 |
| itm_2xml j (Typ c) =
|
neuper@37906
|
261 |
indt j ^"<ITEM status=\"typeerror\">\n"^
|
neuper@37906
|
262 |
indt (j) ^c^
|
neuper@37906
|
263 |
indt j ^"</ITEM>\n"
|
neuper@37906
|
264 |
(*type item also has 'False of cterm' set in preconds2xml WN 050618*)
|
neuper@37906
|
265 |
| itm_2xml j (Inc (dts,_)) =
|
neuper@37906
|
266 |
indt j ^"<ITEM status=\"incomplete\">\n"^
|
neuper@37906
|
267 |
term2xml (j) (comp_dts' dts)^"\n"^
|
neuper@37906
|
268 |
indt j ^"</ITEM>\n"
|
neuper@37906
|
269 |
| itm_2xml j (Sup dts) =
|
neuper@37906
|
270 |
indt j ^"<ITEM status=\"superfluous\">\n"^
|
neuper@37906
|
271 |
term2xml (j) (comp_dts' dts)^"\n"^
|
neuper@37906
|
272 |
indt j ^"</ITEM>\n"
|
neuper@37906
|
273 |
| itm_2xml j (Mis (d,pid)) =
|
neuper@37906
|
274 |
indt j ^"<ITEM status=\"missing\">\n"^
|
neuper@37906
|
275 |
term2xml (j) (d $ pid)^"\n"^
|
neuper@37906
|
276 |
indt j ^"</ITEM>\n";
|
neuper@37906
|
277 |
|
neuper@37906
|
278 |
(*see terms2xml' fpr \n*)
|
neuper@37906
|
279 |
fun itms2xml _ [] = ""
|
neuper@37906
|
280 |
| itms2xml j [(_,_,_,_,itm_)] = itm_2xml j itm_
|
neuper@37906
|
281 |
| itms2xml j (((_,_,_,_,itm_):itm)::itms) =
|
neuper@37906
|
282 |
itm_2xml j itm_ ^ itms2xml j itms;
|
neuper@37906
|
283 |
|
neuper@37906
|
284 |
fun precond2xml j (true, term) =
|
neuper@37906
|
285 |
(indt j ^"<ITEM status=\"correct\">\n"^
|
neuper@37906
|
286 |
term2xml (j) term^"\n"^
|
neuper@37906
|
287 |
indt j ^"</ITEM>\n"):xml
|
neuper@37906
|
288 |
| precond2xml j (false, term) =
|
neuper@37906
|
289 |
indt j ^"<ITEM status=\"false\">\n"^
|
neuper@37906
|
290 |
term2xml (j+i) term^"\n"^
|
neuper@37906
|
291 |
indt j ^"</ITEM>\n";
|
neuper@37906
|
292 |
|
neuper@37906
|
293 |
fun preconds2xml _ [] = ("":xml)
|
neuper@37906
|
294 |
| preconds2xml j (p::ps) = precond2xml j p ^ preconds2xml j ps;
|
neuper@37906
|
295 |
|
neuper@37906
|
296 |
(*FIXME.WN040831 model2xml <--?--> pattern2xml*)
|
neuper@37906
|
297 |
fun model2xml j (itms:itm list) where_ =
|
neuper@37906
|
298 |
let fun eq4 str (_,_,_,field,_) = str = field
|
neuper@37906
|
299 |
in (indt j ^"<MODEL>\n"^
|
neuper@37906
|
300 |
(case filter (eq4 "#Given") itms of
|
neuper@37906
|
301 |
[] => (indt (j+i)) ^ "<GIVEN> </GIVEN>\n"
|
neuper@37906
|
302 |
| gis => (indt (j+i)) ^ "<GIVEN>\n" ^ itms2xml (j+2*i) gis ^
|
neuper@37906
|
303 |
(indt (j+i)) ^ "</GIVEN>\n")
|
neuper@37906
|
304 |
^
|
neuper@37906
|
305 |
(case where_ of
|
neuper@37906
|
306 |
[] => (indt (j+i)) ^ "<WHERE> </WHERE>\n"
|
neuper@37906
|
307 |
| whs => (indt (j+i)) ^ "<WHERE>\n" ^ preconds2xml (j+2*i) whs ^
|
neuper@37906
|
308 |
(indt (j+i)) ^ "</WHERE>\n")
|
neuper@37906
|
309 |
^
|
neuper@37906
|
310 |
(case filter (eq4 "#Find") itms of
|
neuper@37906
|
311 |
[] => (indt (j+i)) ^ "<FIND> </FIND>\n"
|
neuper@37906
|
312 |
| fis => (indt (j+i)) ^ "<FIND>\n" ^ itms2xml (j+2*i) fis ^
|
neuper@37906
|
313 |
(indt (j+i)) ^ "</FIND>\n")
|
neuper@37906
|
314 |
^
|
neuper@37906
|
315 |
(case filter (eq4 "#Relate") itms of
|
neuper@37906
|
316 |
[] => (indt (j+i)) ^ "<RELATE> </RELATE>\n"
|
neuper@37906
|
317 |
| res => (indt (j+i)) ^ "<RELATE>\n" ^ itms2xml (j+2*i) res ^
|
neuper@37906
|
318 |
(indt (j+i)) ^ "</RELATE>\n")^
|
neuper@37906
|
319 |
indt j ^"</MODEL>\n"):xml
|
neuper@37906
|
320 |
end;
|
neuper@38031
|
321 |
(* writeln(model2xml 3 itms []);
|
neuper@37906
|
322 |
*)
|
neuper@37906
|
323 |
|
neuper@37906
|
324 |
fun spec2xml j ((dI,pI,mI):spec) =
|
neuper@37906
|
325 |
(indt j ^"<SPECIFICATION>\n"^
|
neuper@37906
|
326 |
indt (j+i) ^"<THEORYID> "^ dI ^" </THEORYID>\n"^
|
neuper@37906
|
327 |
indt (j+i) ^"<PROBLEMID>\n"^
|
neuper@37906
|
328 |
id2xml (j+2*i) pI ^
|
neuper@37906
|
329 |
indt (j+i) ^"</PROBLEMID>\n"^
|
neuper@37906
|
330 |
indt (j+i) ^"<METHODID>\n"^
|
neuper@37906
|
331 |
id2xml (j+2*i) mI ^
|
neuper@37906
|
332 |
indt (j+i) ^"</METHODID>\n"^
|
neuper@37906
|
333 |
indt j ^"</SPECIFICATION>\n"):xml;
|
neuper@37906
|
334 |
|
neuper@37906
|
335 |
fun modspec2xml j ((b, p_, head, gfr, pre, spec): ocalhd) =
|
neuper@37906
|
336 |
(indt j ^"<CALCHEAD status = "^
|
neuper@37906
|
337 |
quote (if b then "correct" else "incorrect")^">\n"^
|
neuper@37906
|
338 |
indt (j+i) ^"<HEAD>\n"^
|
neuper@37906
|
339 |
term2xml (j+i) head^"\n"^
|
neuper@37906
|
340 |
indt (j+i) ^"</HEAD>\n"^
|
neuper@37906
|
341 |
model2xml (j+i) gfr pre ^
|
neuper@37906
|
342 |
indt (j+i) ^"<BELONGSTO> "^(case p_ of Pbl => "Pbl"
|
neuper@37906
|
343 |
| Met => "Met"
|
neuper@37906
|
344 |
| _ => "Und")^" </BELONGSTO>\n"^
|
neuper@37906
|
345 |
spec2xml (j+i) spec ^
|
neuper@37906
|
346 |
indt j ^"</CALCHEAD>\n"):xml;
|
neuper@38031
|
347 |
(* writeln (modspec2xml 2 e_ocalhd);
|
neuper@37906
|
348 |
*)
|
neuper@37906
|
349 |
fun pos'calchead2xml j (p:pos', (b, p_, head, gfr, pre, spec): ocalhd) =
|
neuper@37906
|
350 |
(indt j ^"<CALCHEAD status = "^
|
neuper@37906
|
351 |
quote (if b then "correct" else "incorrect")^">\n"^
|
neuper@37906
|
352 |
pos'2xml (j+i) ("POSITION", p) ^
|
neuper@37906
|
353 |
indt (j+i) ^"<HEAD>\n"^
|
neuper@37906
|
354 |
term2xml (j+i) head^"\n"^
|
neuper@37906
|
355 |
indt (j+i) ^"</HEAD>\n"^
|
neuper@37906
|
356 |
model2xml (j+i) gfr pre ^
|
neuper@37906
|
357 |
indt (j+i) ^"<BELONGSTO> "^(case p_ of Pbl => "Pbl"
|
neuper@37906
|
358 |
| Met => "Met"
|
neuper@37906
|
359 |
| _ => "Und")^" </BELONGSTO>\n"^
|
neuper@37906
|
360 |
spec2xml (j+i) spec ^
|
neuper@37906
|
361 |
indt j ^"</CALCHEAD>\n"):xml;
|
neuper@37906
|
362 |
|
neuper@37906
|
363 |
fun sub2xml j (id, value) =
|
neuper@37906
|
364 |
(indt j ^"<PAIR>\n"^
|
neuper@37906
|
365 |
indt j ^" <VARIABLE>\n"^
|
neuper@37906
|
366 |
term2xml (j+i) id ^ "\n" ^
|
neuper@37906
|
367 |
indt j ^" </VARIABLE>\n" ^
|
neuper@37906
|
368 |
indt j ^" <VALUE>\n"^
|
neuper@37906
|
369 |
term2xml (j+i) value ^ "\n" ^
|
neuper@37906
|
370 |
indt j ^" </VALUE>\n" ^
|
neuper@37906
|
371 |
indt j ^"</PAIR>\n"):xml;
|
neuper@37906
|
372 |
fun subs2xml j (subs:subs) =
|
neuper@37906
|
373 |
(indt j ^"<SUBSTITUTION>\n"^
|
neuper@37906
|
374 |
foldl op^ ("", map (sub2xml (j+i))
|
neuper@37906
|
375 |
(subs2subst (assoc_thy "Isac.thy") subs)) ^
|
neuper@37906
|
376 |
indt j ^"</SUBSTITUTION>\n"):xml;
|
neuper@37906
|
377 |
(* val subs = [(str2term "bdv", str2term "x")];
|
neuper@37906
|
378 |
val subs = ["(bdv, x)"];
|
neuper@38031
|
379 |
writeln(subs2xml 0 subs);
|
neuper@37906
|
380 |
*)
|
neuper@37906
|
381 |
fun subst2xml j (subst:subst) =
|
neuper@37906
|
382 |
(indt j ^"<SUBSTITUTION>\n"^
|
neuper@37906
|
383 |
foldl op^ ("", map (sub2xml (j+i)) subst) ^
|
neuper@37906
|
384 |
indt j ^"</SUBSTITUTION>\n"):xml;
|
neuper@37906
|
385 |
(* val subst = [(str2term "bdv", str2term "x")];
|
neuper@38031
|
386 |
writeln(subst2xml 0 subst);
|
neuper@37906
|
387 |
*)
|
neuper@37906
|
388 |
|
neuper@37906
|
389 |
(* val (j, str) = ((j+i), form);
|
neuper@37906
|
390 |
*)
|
neuper@37906
|
391 |
fun thmstr2xml j str = ((((term2xml j) o str2term) str)^"\n"):xml;
|
neuper@37906
|
392 |
|
neuper@37906
|
393 |
(* val (j, ((ID, form):thm')) = ((j+i), thm');
|
neuper@37906
|
394 |
*)
|
neuper@37906
|
395 |
fun thm'2xml j ((ID, form):thm') =
|
neuper@37906
|
396 |
(indt j ^"<THEOREM>\n"^
|
neuper@37906
|
397 |
indt (j+i) ^"<ID> "^ID^" </ID>\n"^
|
neuper@37906
|
398 |
indt (j+i) ^"<FORMULA>\n"^
|
neuper@37906
|
399 |
thmstr2xml (j+i) form^
|
neuper@37906
|
400 |
indt (j+i) ^"</FORMULA>\n"^
|
neuper@37906
|
401 |
indt j ^"</THEOREM>\n"):xml;
|
neuper@37906
|
402 |
|
neuper@37906
|
403 |
(*WN060627 scope of thy's not considered ?!?*)
|
neuper@37906
|
404 |
fun thm''2xml j (thm:thm) =
|
neuper@37906
|
405 |
indt j ^"<THEOREM>\n"^
|
neuper@37940
|
406 |
indt (j+i) ^"<ID> "^ (strip_thy o Thm.get_name_hint) thm ^" </ID>\n"^
|
neuper@37906
|
407 |
term2xml j ((#prop o rep_thm) thm) ^ "\n" ^
|
neuper@37906
|
408 |
indt j ^"</THEOREM>\n":xml;
|
neuper@37906
|
409 |
|
neuper@37906
|
410 |
fun scr2xml j EmptyScr =
|
neuper@37906
|
411 |
indt j ^"<SCRIPT> </SCRIPT>\n" : xml
|
neuper@37906
|
412 |
| scr2xml j (Script term) =
|
neuper@37906
|
413 |
if term = e_term
|
neuper@37906
|
414 |
then indt j ^"<SCRIPT> </SCRIPT>\n"
|
neuper@37906
|
415 |
else indt j ^"<SCRIPT>\n"^
|
neuper@37906
|
416 |
term2xml j (inst_abs (assoc_thy "Isac.thy") term) ^ "\n" ^
|
neuper@37906
|
417 |
indt j ^"</SCRIPT>\n"
|
neuper@37906
|
418 |
| scr2xml j (Rfuns _) =
|
neuper@37906
|
419 |
indt j ^"<REVERSREWRITE> reverse rewrite functions </REVERSREWRITE>\n";
|
neuper@37906
|
420 |
|
neuper@37906
|
421 |
fun prepa12xml j (terms, term) =
|
neuper@37906
|
422 |
indt j ^"<PREPAT>\n"^
|
neuper@37906
|
423 |
indt (j+i) ^"<PRECONDS>\n"^
|
neuper@37906
|
424 |
terms2xml (j+2*i) terms ^
|
neuper@37906
|
425 |
indt (j+i) ^"</PRECONDS>\n"^
|
neuper@37906
|
426 |
indt (j+i) ^"<PATTERN>\n"^
|
neuper@37906
|
427 |
term2xml (j+2*i) term ^
|
neuper@37906
|
428 |
indt (j+i) ^"</PATTERN>\n"^
|
neuper@37906
|
429 |
indt j ^"</PREPAT>\n" : xml;
|
neuper@37906
|
430 |
|
neuper@37906
|
431 |
fun prepat2xml j [] = ""
|
neuper@37906
|
432 |
| prepat2xml j (p::ps) = prepa12xml j p ^ prepat2xml j ps : xml;
|
neuper@37906
|
433 |
|
neuper@37906
|
434 |
(* val (j, (thyID, seqrls, {id, preconds, rew_ord=(ord,_), erls,
|
neuper@37906
|
435 |
srls, calc, rules, scr})) =
|
neuper@37906
|
436 |
(j, (thyID, "Seq", data));
|
neuper@37906
|
437 |
*)
|
neuper@37906
|
438 |
fun rls2xm j (thyID, seqrls, {id, preconds, rew_ord=(ord,_), erls,
|
neuper@37906
|
439 |
srls, calc, rules, scr}) =
|
neuper@37906
|
440 |
indt j ^"<RULESET>\n"^
|
neuper@37906
|
441 |
indt (j+i) ^"<ID> "^ id ^" </ID>\n"^
|
neuper@37906
|
442 |
indt (j+i) ^"<TYPE> "^ seqrls ^" </TYPE>\n"^
|
neuper@37906
|
443 |
indt (j+i) ^"<RULES>\n" ^
|
neuper@37906
|
444 |
rules2xml (j+2*i) thyID rules ^
|
neuper@37906
|
445 |
indt (j+i) ^"</RULES>\n" ^
|
neuper@37906
|
446 |
indt (j+i) ^"<PRECONDS> " ^
|
neuper@37906
|
447 |
terms2xml' (j+2*i) preconds ^
|
neuper@37906
|
448 |
indt (j+i) ^"</PRECONDS>\n" ^
|
neuper@37906
|
449 |
indt (j+i) ^"<ORDER>\n" ^
|
neuper@37906
|
450 |
indt (j+2*i) ^ "<STRING> " ^ ord ^ " </STRING>\n" ^
|
neuper@37906
|
451 |
(*WN060714 thy_isac_*-ord-*.xml not yet generated ................
|
neuper@37906
|
452 |
indt (j+2*i) ^ "<GUH> " ^ ord2guh ("IsacKnowledge",
|
neuper@37906
|
453 |
thyID) ord ^ " </GUH>\n" ^
|
neuper@37906
|
454 |
..................................................................*)
|
neuper@37906
|
455 |
indt (j+i) ^"</ORDER>\n" ^
|
neuper@37906
|
456 |
indt (j+i) ^"<ERLS>\n" ^
|
neuper@37906
|
457 |
indt (j+2*i) ^ "<TAG> Ruleset </TAG>\n" ^
|
neuper@37906
|
458 |
indt (j+2*i) ^ "<STRING> " ^ id_rls erls ^ " </STRING>\n" ^
|
neuper@37906
|
459 |
indt (j+2*i) ^ "<GUH> " ^ rls2guh ("IsacKnowledge", thyID)
|
neuper@37906
|
460 |
(id_rls erls) ^ " </GUH>\n" ^
|
neuper@37906
|
461 |
indt (j+i) ^"</ERLS>\n" ^
|
neuper@37906
|
462 |
indt (j+i) ^"<SRLS>\n" ^
|
neuper@37906
|
463 |
indt (j+2*i) ^ "<TAG> Ruleset </TAG>\n" ^
|
neuper@37906
|
464 |
indt (j+2*i) ^ "<STRING> " ^ id_rls erls ^ " </STRING>\n" ^
|
neuper@37906
|
465 |
indt (j+2*i) ^ "<GUH> " ^ rls2guh ("IsacKnowledge", thyID)
|
neuper@37906
|
466 |
(id_rls srls) ^ " </GUH>\n" ^
|
neuper@37906
|
467 |
indt (j+i) ^"</SRLS>\n" ^
|
neuper@37906
|
468 |
calcrefs2xml (j+i) (thyID, calc) ^
|
neuper@37906
|
469 |
scr2xml (j+i) scr ^
|
neuper@37906
|
470 |
indt j ^"</RULESET>\n" : xml;
|
neuper@37906
|
471 |
|
neuper@37906
|
472 |
fun rls2xml j (thyID, Erls) = rls2xml j (thyID, e_rls)
|
neuper@37906
|
473 |
(* rls2xml j (thyID, Rls {id=id, preconds=preconds, rew_ord=(ord,e_rew_ord),
|
neuper@37906
|
474 |
erls=erls,srls=srls,calc=calc,rules=rules,scr=scr});
|
neuper@37906
|
475 |
val (j, (thyID, Rls {id, preconds, rew_ord=(ord,_), erls,
|
neuper@37906
|
476 |
srls, calc, rules, scr})) = (i, thy_rls);
|
neuper@37906
|
477 |
val (j, (thyID, Seq data)) = (i, thy_rls);
|
neuper@37906
|
478 |
*)
|
neuper@37906
|
479 |
| rls2xml j (thyID, Rls data) = rls2xm j (thyID, "Rls", data)
|
neuper@37906
|
480 |
(* val (j, (thyID, Seq data)) = (i, thy_rls);
|
neuper@37906
|
481 |
*)
|
neuper@37906
|
482 |
| rls2xml j (thyID, Seq data) = rls2xm j (thyID, "Seq", data)
|
neuper@37906
|
483 |
| rls2xml j (thyID, Rrls {id, prepat, rew_ord=(ord,_), erls, calc, scr}) =
|
neuper@37906
|
484 |
indt j ^"<RULESET>\n"^
|
neuper@37906
|
485 |
indt (j+i) ^"<ID> "^ id ^" </ID>\n"^
|
neuper@37906
|
486 |
indt (j+i) ^"<TYPE> Rrls </TYPE>\n"^
|
neuper@37906
|
487 |
prepat2xml (j+i) prepat ^
|
neuper@37906
|
488 |
indt (j+i) ^"<ORDER> " ^
|
neuper@37906
|
489 |
indt (j+2*i) ^ "<TAG> Rewrite order </TAG>\n" ^
|
neuper@37906
|
490 |
indt (j+2*i) ^ "<STRING> " ^ ord ^ " </STRING>\n" ^
|
neuper@37906
|
491 |
(*WN060714 thy_isac_*-ord-*.xml not yet generated ................
|
neuper@37906
|
492 |
indt (j+2*i) ^ "<GUH> " ^ ord2guh ("IsacKnowledge",
|
neuper@37906
|
493 |
thyID) ord ^ " </GUH>\n" ^
|
neuper@37906
|
494 |
.................................................................*)
|
neuper@37906
|
495 |
indt (j+i) ^"</ORDER>\n" ^
|
neuper@37906
|
496 |
indt (j+i) ^"<ERLS> " ^
|
neuper@37906
|
497 |
indt (j+2*i) ^ "<TAG> Ruleset </TAG>\n" ^
|
neuper@37906
|
498 |
indt (j+2*i) ^ "<STRING> " ^ id_rls erls ^ " </STRING>\n" ^
|
neuper@37906
|
499 |
indt (j+2*i) ^ "<GUH> " ^ rls2guh ("IsacKnowledge", thyID)
|
neuper@37906
|
500 |
(id_rls erls) ^ " </GUH>\n" ^
|
neuper@37906
|
501 |
indt (j+i) ^"</ERLS>\n" ^
|
neuper@37906
|
502 |
calcrefs2xml (j+i) (thyID, calc) ^
|
neuper@37906
|
503 |
indt (j+i) ^"<SCRIPT>\n"^
|
neuper@37906
|
504 |
scr2xml (j+2*i) scr ^
|
neuper@37906
|
505 |
indt (j+i) ^" </SCRIPT>\n"^
|
neuper@37906
|
506 |
indt j ^"</RULESET>\n" : xml;
|
neuper@37906
|
507 |
|
neuper@37906
|
508 |
(*.convert a tactic into xml-format
|
neuper@37906
|
509 |
ATTENTION: WN060513 detected faulty 'cterm2xml's with 'string's as args.*)
|
neuper@37906
|
510 |
fun tac2xml j (Subproblem (dI, pI)) =
|
neuper@37906
|
511 |
(indt j ^"<SUBPROBLEMTACTIC name=\"Subproblem\">\n"^
|
neuper@37906
|
512 |
indt (j+i) ^"<THEORY> "^ dI ^" </THEORY>\n"^
|
neuper@37906
|
513 |
indt (j+i) ^"<PROBLEM>\n"^
|
neuper@37906
|
514 |
id2xml (j+2*i) pI^
|
neuper@37906
|
515 |
indt (j+i) ^"</PROBLEM>\n"^
|
neuper@37906
|
516 |
indt j ^"</SUBPROBLEMTACTIC>\n"):xml
|
neuper@37906
|
517 |
| tac2xml j Model_Problem =
|
neuper@37906
|
518 |
(indt j ^"<STRINGLISTTACTIC name=\"Model_Problem\">"^
|
neuper@37906
|
519 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
520 |
| tac2xml j (Refine_Tacitly pI) =
|
neuper@37906
|
521 |
(indt j ^"<STRINGLISTTACTIC name=\"Refine_Tacitly\">\n"^
|
neuper@37906
|
522 |
id2xml (j+i) pI^
|
neuper@37906
|
523 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
524 |
|
neuper@37906
|
525 |
| tac2xml j (Add_Given ct) =
|
neuper@37906
|
526 |
(indt j ^"<SIMPLETACTIC name=\"Add_Given\">\n"^
|
neuper@37906
|
527 |
cterm2xml (j+i) ct^
|
neuper@37906
|
528 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
529 |
| tac2xml j (Add_Find ct) =
|
neuper@37906
|
530 |
(indt j ^"<SIMPLETACTIC name=\"Add_Find\">\n"^
|
neuper@37906
|
531 |
cterm2xml (j+i) ct^
|
neuper@37906
|
532 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
533 |
| tac2xml j (Add_Relation ct) =
|
neuper@37906
|
534 |
(indt j ^"<SIMPLETACTIC name=\"Add_Relation\">\n"^
|
neuper@37906
|
535 |
cterm2xml (j+i) ct^
|
neuper@37906
|
536 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
537 |
|
neuper@37906
|
538 |
| tac2xml j (Specify_Theory ct) =
|
neuper@37906
|
539 |
(indt j ^"<SIMPLETACTIC name=\"Specify_Theory\">\n"^
|
neuper@37906
|
540 |
cterm2xml (j+i) ct^(*WN060513 Specify_Theory = fn : domID -> tac
|
neuper@37906
|
541 |
and domID is a string, not a cterm *)
|
neuper@37906
|
542 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
543 |
| tac2xml j (Specify_Problem ct) =
|
neuper@37906
|
544 |
(indt j ^"<STRINGLISTTACTIC name=\"Specify_Problem\">\n"^
|
neuper@37906
|
545 |
id2xml (j+i) ct^
|
neuper@37906
|
546 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
547 |
| tac2xml j (Specify_Method ct) =
|
neuper@37906
|
548 |
(indt j ^"<STRINGLISTTACTIC name=\"Specify_Method\">\n"^
|
neuper@37906
|
549 |
id2xml (j+i) ct^
|
neuper@37906
|
550 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
551 |
| tac2xml j (Apply_Method mI) =
|
neuper@37906
|
552 |
(indt j ^"<STRINGLISTTACTIC name=\"Apply_Method\">\n"^
|
neuper@37906
|
553 |
id2xml (j+i) mI^
|
neuper@37906
|
554 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
555 |
|
neuper@37906
|
556 |
| tac2xml j (Take ct) =
|
neuper@37906
|
557 |
(indt j ^"<SIMPLETACTIC name=\"Take\">\n"^
|
neuper@37906
|
558 |
cterm2xml (j+i) ct^
|
neuper@37906
|
559 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
560 |
| tac2xml j (Calculate opstr) =
|
neuper@37906
|
561 |
(indt j ^"<SIMPLETACTIC name=\"Calculate\">\n"^
|
neuper@37906
|
562 |
cterm2xml (j+i) opstr^(*WN060513 Calculate = fn : string -> tac
|
neuper@37906
|
563 |
'string', _NOT_ 'cterm' ..flaw from RG*)
|
neuper@37906
|
564 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
565 |
(* val (j, Rewrite thm') = (i, tac);
|
neuper@37906
|
566 |
*)
|
neuper@37906
|
567 |
| tac2xml j (Rewrite thm') =
|
neuper@37906
|
568 |
(indt j ^"<REWRITETACTIC name=\"Rewrite\">\n"^
|
neuper@37906
|
569 |
thm'2xml (j+i) thm'^
|
neuper@37906
|
570 |
indt j ^"</REWRITETACTIC>\n"):xml
|
neuper@38031
|
571 |
(* writeln (tac2xml 2 (Rewrite ("all_left",
|
neuper@37906
|
572 |
"~ ?b =!= 0 ==> (?a = ?b) = (?a - ?b = 0)")));
|
neuper@37906
|
573 |
val (j, (Rewrite_Inst (subs, thm'))) = (i, tac);
|
neuper@37906
|
574 |
*)
|
neuper@37906
|
575 |
| tac2xml j (Rewrite_Inst (subs, thm')) =
|
neuper@37906
|
576 |
(indt j ^"<REWRITEINSTTACTIC name=\"Rewrite_Inst\">\n"^
|
neuper@37906
|
577 |
subs2xml (j+i) subs^
|
neuper@37906
|
578 |
thm'2xml (j+i) thm'^
|
neuper@37906
|
579 |
indt j ^"</REWRITEINSTTACTIC>\n"):xml
|
neuper@38031
|
580 |
(* writeln (tac2xml 2 (Rewrite_Inst
|
neuper@37906
|
581 |
(["(bdv,x)"],
|
neuper@37906
|
582 |
("all_left",
|
neuper@37906
|
583 |
"~ ?b =!= 0 ==> (?a = ?b) = (?a - ?b = 0)"))));
|
neuper@37906
|
584 |
*)
|
neuper@37906
|
585 |
| tac2xml j (Rewrite_Set rls') =
|
neuper@37906
|
586 |
(indt j ^"<REWRITESETTACTIC name=\"Rewrite_Set\">\n"^
|
neuper@37906
|
587 |
indt (j+i) ^"<RULESET> "^ rls' ^" </RULESET>\n"^
|
neuper@37906
|
588 |
indt j ^"</REWRITESETTACTIC>\n"):xml
|
neuper@37906
|
589 |
| tac2xml j (Rewrite_Set_Inst (subs, rls')) =
|
neuper@37906
|
590 |
(indt j ^"<REWRITESETINSTTACTIC name=\"Rewrite_Set_Inst\">\n"^
|
neuper@37906
|
591 |
indt (j+i) ^"<RULESET> "^ rls' ^" </RULESET>\n"^
|
neuper@37906
|
592 |
subs2xml (j+i) subs^
|
neuper@37906
|
593 |
indt j ^"</REWRITESETINSTTACTIC>\n"):xml
|
neuper@37906
|
594 |
|
neuper@37906
|
595 |
| tac2xml j (Or_to_List) =
|
neuper@37940
|
596 |
(indt j ^"<STRINGLISTTACTIC name=\"Or_to_List\"> </STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
597 |
| tac2xml j (Check_elementwise ct) =
|
neuper@37906
|
598 |
(indt j ^"<SIMPLETACTIC name=\"Check_elementwise\">\n"^
|
neuper@37906
|
599 |
cterm2xml (j+i) ct ^ "\n"^
|
neuper@37906
|
600 |
indt j ^"</SIMPLETACTIC>\n"):xml
|
neuper@37906
|
601 |
(*WN0605 quick and dirty: cterms is _NOT_ a stringlist like pblID...*)
|
neuper@37906
|
602 |
| tac2xml j (Substitute cterms) =
|
neuper@37906
|
603 |
(indt j ^"<STRINGLISTTACTIC name=\"Substitute\">\n"^
|
neuper@37906
|
604 |
(*cterms2xml (j+i) cterms^ ....should be WN060514: TODO TERMLISTTACTIC?*)
|
neuper@37906
|
605 |
id2xml (j+i) cterms^
|
neuper@37906
|
606 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
607 |
| tac2xml j (Check_Postcond pI) =
|
neuper@37906
|
608 |
(indt j ^"<STRINGLISTTACTIC name=\"Check_Postcond\">\n"^
|
neuper@37906
|
609 |
id2xml (j+i) pI^
|
neuper@37906
|
610 |
indt j ^"</STRINGLISTTACTIC>\n"):xml
|
neuper@37906
|
611 |
|
neuper@38031
|
612 |
| tac2xml j tac = error ("tac2xml: not impl. for "^tac2str tac);
|
neuper@37906
|
613 |
|
neuper@37906
|
614 |
fun tacs2xml j [] = "":xml
|
neuper@37906
|
615 |
| tacs2xml j (t::ts) = tac2xml j t ^ tacs2xml j ts;
|
neuper@37906
|
616 |
|
neuper@37906
|
617 |
|
neuper@37906
|
618 |
fun posformhead2xml j (p:pos', Form f) =
|
neuper@37906
|
619 |
indt j ^"<CALCFORMULA>\n"^
|
neuper@37906
|
620 |
pos'2xml (j+i) ("POSITION", p) ^
|
neuper@37906
|
621 |
indt (j+i) ^"<FORMULA>\n"^
|
neuper@37906
|
622 |
term2xml (j+i) f^"\n"^
|
neuper@37906
|
623 |
indt (j+i) ^"</FORMULA>\n"^
|
neuper@37906
|
624 |
indt j ^"</CALCFORMULA>\n"
|
neuper@37906
|
625 |
| posformhead2xml j (p, ModSpec c) =
|
neuper@37906
|
626 |
pos'calchead2xml (j) (p, c);
|
neuper@37906
|
627 |
|
neuper@37906
|
628 |
fun posformheads2xml j [] = ("":xml)
|
neuper@37906
|
629 |
| posformheads2xml j (r::rs) = posformhead2xml j r ^ posformheads2xml j rs;
|
neuper@37906
|
630 |
|
neuper@37940
|
631 |
val e_pblterm = (term_of o the o (parse (theory "Script")))
|
neuper@37906
|
632 |
("Problem (" ^ e_domID ^ "," ^ strs2str' e_pblID ^ ")");
|
neuper@37906
|
633 |
|
neuper@37906
|
634 |
(*WN051224 minimal adaption to exporting Formulae _only_ by getFormulaeFromTo*)
|
neuper@37906
|
635 |
fun posterm2xml j (p:pos', t) =
|
neuper@37906
|
636 |
indt j ^"<CALCFORMULA>\n"^
|
neuper@37906
|
637 |
pos'2xml (j+i) ("POSITION", p) ^
|
neuper@37906
|
638 |
indt (j+i) ^"<FORMULA>\n"^
|
neuper@37906
|
639 |
(if t = e_pblterm (*headline in pbl is e_ <- _root_pbl for CAS-command*)
|
neuper@37906
|
640 |
then cterm2xml (j+i) "________________________________________________"
|
neuper@37906
|
641 |
else term2xml (j+i) t)^"\n" ^
|
neuper@37906
|
642 |
indt (j+i) ^"</FORMULA>\n"^
|
neuper@37906
|
643 |
indt j ^"</CALCFORMULA>\n";
|
neuper@37906
|
644 |
|
neuper@37906
|
645 |
fun posterms2xml j [] = ("":xml)
|
neuper@37906
|
646 |
| posterms2xml j (r::rs) = posterm2xml j r ^ posterms2xml j rs;
|
neuper@37906
|
647 |
|
neuper@37906
|
648 |
fun asm_val2xml j (asm, vl) =
|
neuper@37906
|
649 |
indt j ^ "<ASMEVALUATED>\n" ^
|
neuper@37906
|
650 |
indt (j+i) ^ "<ASM>\n" ^
|
neuper@37906
|
651 |
term2xml (j+i) asm ^ "\n" ^
|
neuper@37906
|
652 |
indt (j+i) ^ "</ASM>\n" ^
|
neuper@37906
|
653 |
indt (j+i) ^ "<VALUE>\n" ^
|
neuper@37906
|
654 |
term2xml (j+i) vl ^ "\n" ^
|
neuper@37906
|
655 |
indt (j+i) ^ "</VALUE>\n" ^
|
neuper@37906
|
656 |
indt j ^ "</ASMEVALUATED>\n" : xml;
|
neuper@37906
|
657 |
|
neuper@37906
|
658 |
fun asm_vals2xml j [] = ("":xml)
|
neuper@37906
|
659 |
| asm_vals2xml j (asm_val::avs) = asm_val2xml j asm_val ^
|
neuper@37906
|
660 |
asm_vals2xml j avs;
|
neuper@37906
|
661 |
|
neuper@37906
|
662 |
(*.a reference to an element in the theory hierarchy;
|
neuper@37906
|
663 |
compare 'fun keref2xml'.*)
|
neuper@37906
|
664 |
(* val (j, thyID, typ, xstring) =
|
neuper@37906
|
665 |
(i+i, snd (thy_containing_rls thy' prls'), "Rulesets", prls');
|
neuper@37906
|
666 |
*)
|
neuper@37906
|
667 |
fun theref2xml j (thyID:thyID) typ (xstring:xstring) =
|
neuper@37906
|
668 |
let val guh = theID2guh ["IsacKnowledge", thyID, typ, xstring]
|
neuper@37906
|
669 |
val typ' = (implode o (drop_last_n 1) o explode) typ
|
neuper@37906
|
670 |
in indt j ^ "<KESTOREREF>\n" ^
|
neuper@37906
|
671 |
indt (j+i) ^ "<TAG> " ^ typ' ^ " </TAG>\n" ^
|
neuper@37906
|
672 |
indt (j+i) ^ "<ID> " ^ xstring ^ " </ID>\n" ^
|
neuper@37906
|
673 |
indt (j+i) ^ "<GUH> " ^ guh ^ " </GUH>\n" ^
|
neuper@37906
|
674 |
indt j ^ "</KESTOREREF>\n" : xml
|
neuper@37906
|
675 |
end;
|
neuper@37906
|
676 |
|
neuper@37906
|
677 |
(*.a reference to an element in the kestore EXCEPT theory hierarchy;
|
neuper@37906
|
678 |
compare 'fun theref2xml'.*)
|
neuper@37906
|
679 |
(* val (j, typ, kestoreID) = (i+i, Met_, hd met);
|
neuper@37906
|
680 |
*)
|
neuper@37906
|
681 |
fun keref2xml j typ (kestoreID:kestoreID) =
|
neuper@37906
|
682 |
let val id = strs2str' kestoreID
|
neuper@37906
|
683 |
val guh = kestoreID2guh typ kestoreID
|
neuper@37906
|
684 |
in indt j ^ "<KESTOREREF>\n" ^
|
neuper@37906
|
685 |
indt (j+i) ^ "<TAG> " ^ ketype2str' typ ^ "</TAG>\n" ^
|
neuper@37906
|
686 |
indt (j+i) ^ "<ID> " ^ id ^ " </ID>\n" ^
|
neuper@37906
|
687 |
indt (j+i) ^ "<GUH> " ^ guh ^ " </GUH>\n" ^
|
neuper@37906
|
688 |
indt j ^ "</KESTOREREF>\n" : xml
|
neuper@37906
|
689 |
end;
|
neuper@37906
|
690 |
|
neuper@37906
|
691 |
(*url to a source external to isac*)
|
neuper@37906
|
692 |
fun extref2xml j linktext url =
|
neuper@37906
|
693 |
indt j ^ "<EXTREF>\n" ^
|
neuper@37906
|
694 |
indt (j+i) ^ "<TEXT> " ^ linktext ^ " </TEXT>\n" ^
|
neuper@37906
|
695 |
indt (j+i) ^ "<URL> " ^ url ^ " </URL>\n" ^
|
neuper@37906
|
696 |
indt j ^ "</EXTREF>\n" : xml;
|
neuper@37906
|
697 |
|
neuper@37906
|
698 |
(* val (ContThmInst{thyID, thm, bdvs, thminst, applto, applat, reword,
|
neuper@37906
|
699 |
asms, lhs, rhs, result, resasms, asmrls}) =
|
neuper@37906
|
700 |
(context_thy (pt,pos) tac);
|
neuper@38031
|
701 |
writeln (contthy2xml 2 (context_thy (pt,pos) tac));
|
neuper@37906
|
702 |
*)
|
neuper@37906
|
703 |
fun contthy2xml j EContThy =
|
neuper@38031
|
704 |
error "contthy2xml called with EContThy"
|
neuper@37906
|
705 |
| contthy2xml j (ContThm {thyID, thm, applto, applat, reword,
|
neuper@37906
|
706 |
asms,lhs, rhs, result, resasms, asmrls}) =
|
neuper@37906
|
707 |
indt j ^ "<GUH> " ^ thm ^ " </GUH>\n" ^
|
neuper@37940
|
708 |
|
neuper@37906
|
709 |
indt j ^ "<APPLTO>\n" ^
|
neuper@37906
|
710 |
term2xml j applto ^ "\n" ^
|
neuper@37906
|
711 |
indt j ^ "</APPLTO>\n" ^
|
neuper@37906
|
712 |
indt j ^ "<APPLAT>\n" ^
|
neuper@37906
|
713 |
term2xml j applat ^ "\n" ^
|
neuper@37906
|
714 |
indt j ^ "</APPLAT>\n" ^
|
neuper@37906
|
715 |
indt j ^ "<ORDER>\n" ^ (*should be a theref2xml*)
|
neuper@37906
|
716 |
indt (j+i) ^"<ID> " ^ reword ^ " </ID>\n" ^
|
neuper@37906
|
717 |
indt j ^ "</ORDER>\n" ^
|
neuper@37906
|
718 |
indt j ^ "<ASMSEVAL>\n" ^
|
neuper@37906
|
719 |
asm_vals2xml (j+i) asms ^
|
neuper@37906
|
720 |
indt j ^ "</ASMSEVAL>\n" ^
|
neuper@37906
|
721 |
indt j ^ "<LHS>\n" ^
|
neuper@37906
|
722 |
term2xml j (fst lhs) ^ "\n" ^
|
neuper@37906
|
723 |
indt j ^ "</LHS>\n" ^
|
neuper@37906
|
724 |
indt j ^ "<LHSINST>\n" ^
|
neuper@37906
|
725 |
term2xml j (snd lhs) ^ "\n" ^
|
neuper@37906
|
726 |
indt j ^ "</LHSINST>\n" ^
|
neuper@37906
|
727 |
indt j ^ "<RHS>\n" ^
|
neuper@37906
|
728 |
term2xml j (fst rhs) ^ "\n" ^
|
neuper@37906
|
729 |
indt j ^ "</RHS>\n" ^
|
neuper@37906
|
730 |
indt j ^ "<RHSINST>\n" ^
|
neuper@37906
|
731 |
term2xml j (snd rhs) ^ "\n" ^
|
neuper@37906
|
732 |
indt j ^ "</RHSINST>\n" ^
|
neuper@37906
|
733 |
indt j ^ "<RESULT>\n" ^
|
neuper@37906
|
734 |
term2xml j result ^ "\n" ^
|
neuper@37906
|
735 |
indt j ^ "</RESULT>\n" ^
|
neuper@37906
|
736 |
indt j ^ "<ASSUMPTIONS>\n" ^
|
neuper@37906
|
737 |
terms2xml' j resasms ^
|
neuper@37906
|
738 |
indt j ^ "</ASSUMPTIONS>\n" ^
|
neuper@37906
|
739 |
indt j ^ "<EVALRLS>\n" ^
|
neuper@37906
|
740 |
theref2xml j thyID "Rulesets" asmrls ^
|
neuper@37906
|
741 |
indt j ^ "</EVALRLS>\n"
|
neuper@37906
|
742 |
| contthy2xml j (ContThmInst{thyID, thm, bdvs, thminst, applto, applat,
|
neuper@37906
|
743 |
reword, asms, lhs, rhs, result, resasms,
|
neuper@37906
|
744 |
asmrls}) =
|
neuper@37906
|
745 |
indt j ^ "<GUH> " ^ thm ^ " </GUH>\n" ^
|
neuper@37906
|
746 |
indt j ^ "<SUBSLIST>\n" ^ (*should be an environment = substitution*)
|
neuper@37906
|
747 |
indt (j+i) ^ "<MATHML>\n" ^
|
neuper@37906
|
748 |
indt (j+2*i) ^ "<ISA> " ^ subst2str' bdvs ^ " </ISA>\n" ^
|
neuper@37906
|
749 |
indt (j+i) ^ "</MATHML>\n" ^
|
neuper@37906
|
750 |
indt j ^ "</SUBSLIST>\n" ^
|
neuper@37906
|
751 |
indt j ^ "<INSTANTIATED>\n" ^
|
neuper@37906
|
752 |
term2xml j thminst ^ "\n" ^
|
neuper@37906
|
753 |
indt j ^ "</INSTANTIATED>\n" ^
|
neuper@37906
|
754 |
indt j ^ "<APPLTO>\n" ^
|
neuper@37906
|
755 |
term2xml j applto ^ "\n" ^
|
neuper@37906
|
756 |
indt j ^ "</APPLTO>\n" ^
|
neuper@37906
|
757 |
indt j ^ "<APPLAT>\n" ^
|
neuper@37906
|
758 |
term2xml j applat ^ "\n" ^
|
neuper@37906
|
759 |
indt j ^ "</APPLAT>\n" ^
|
neuper@37906
|
760 |
indt j ^ "<ORDER>\n" ^ (*should be a theref2xml*)
|
neuper@37906
|
761 |
indt (j+i) ^"<ID> " ^ reword ^ " </ID>\n" ^
|
neuper@37906
|
762 |
indt j ^ "</ORDER>\n" ^
|
neuper@37906
|
763 |
indt j ^ "<ASMSEVAL>\n" ^
|
neuper@37906
|
764 |
asm_vals2xml (j+i) asms ^
|
neuper@37906
|
765 |
indt j ^ "</ASMSEVAL>\n" ^
|
neuper@37906
|
766 |
indt j ^ "<LHS>\n" ^
|
neuper@37906
|
767 |
term2xml j (fst lhs) ^ "\n" ^
|
neuper@37906
|
768 |
indt j ^ "</LHS>\n" ^
|
neuper@37906
|
769 |
indt j ^ "<LHSINST>\n" ^
|
neuper@37906
|
770 |
term2xml j (snd lhs) ^ "\n" ^
|
neuper@37906
|
771 |
indt j ^ "</LHSINST>\n" ^
|
neuper@37906
|
772 |
indt j ^ "<RHS>\n" ^
|
neuper@37906
|
773 |
term2xml j (fst rhs) ^ "\n" ^
|
neuper@37906
|
774 |
indt j ^ "</RHS>\n" ^
|
neuper@37906
|
775 |
indt j ^ "<RHSINST>\n" ^
|
neuper@37906
|
776 |
term2xml j (snd rhs) ^ "\n" ^
|
neuper@37906
|
777 |
indt j ^ "</RHSINST>\n" ^
|
neuper@37906
|
778 |
indt j ^ "<RESULT>\n" ^
|
neuper@37906
|
779 |
term2xml j result ^ "\n" ^
|
neuper@37906
|
780 |
indt j ^ "</RESULT>\n" ^
|
neuper@37906
|
781 |
indt j ^ "<ASSUMPTOIONS>\n" ^
|
neuper@37906
|
782 |
terms2xml' j resasms ^
|
neuper@37906
|
783 |
indt j ^ "</ASSUMPTOIONS>\n" ^
|
neuper@37906
|
784 |
indt j ^ "<EVALRLS>\n" ^
|
neuper@37906
|
785 |
theref2xml j thyID "Rulesets" asmrls ^
|
neuper@37906
|
786 |
indt j ^ "</EVALRLS>\n"
|
neuper@37906
|
787 |
|
neuper@37906
|
788 |
| contthy2xml j (ContRls {thyID, rls, applto, result, asms}) =
|
neuper@37906
|
789 |
indt j ^ "<GUH> " ^ rls ^ " </GUH>\n" ^
|
neuper@37906
|
790 |
indt j ^ "<APPLTO>\n" ^
|
neuper@37906
|
791 |
term2xml j applto ^ "\n" ^
|
neuper@37906
|
792 |
indt j ^ "</APPLTO>\n" ^
|
neuper@37906
|
793 |
indt j ^ "<RESULT>\n" ^
|
neuper@37906
|
794 |
term2xml j result ^ "\n" ^
|
neuper@37906
|
795 |
indt j ^ "</RESULT>\n" ^
|
neuper@37906
|
796 |
indt j ^ "<ASSUMPTOIONS>\n" ^
|
neuper@37906
|
797 |
terms2xml' j asms ^
|
neuper@37906
|
798 |
indt j ^ "</ASSUMPTOIONS>\n"
|
neuper@37906
|
799 |
|
neuper@37906
|
800 |
| contthy2xml j (ContRlsInst {thyID, rls, bdvs, applto, result, asms}) =
|
neuper@37906
|
801 |
indt j ^ "<GUH> " ^ rls ^ " </GUH>\n" ^
|
neuper@37906
|
802 |
indt j ^ "<SUBSLIST>\n" ^ (*should be an environment = substitution*)
|
neuper@37906
|
803 |
indt (j+i) ^ "<MATHML>\n" ^
|
neuper@37906
|
804 |
indt (j+2*i) ^ "<ISA> " ^ subst2str' bdvs ^ " </ISA>\n" ^
|
neuper@37906
|
805 |
indt (j+i) ^ "</MATHML>\n" ^
|
neuper@37906
|
806 |
indt j ^ "</SUBSLIST>\n" ^
|
neuper@37906
|
807 |
indt j ^ "<APPLTO>\n" ^
|
neuper@37906
|
808 |
term2xml j applto ^ "\n" ^
|
neuper@37906
|
809 |
indt j ^ "</APPLTO>\n" ^
|
neuper@37906
|
810 |
indt j ^ "<RESULT>\n" ^
|
neuper@37906
|
811 |
term2xml j result ^ "\n" ^
|
neuper@37906
|
812 |
indt j ^ "</RESULT>\n" ^
|
neuper@37906
|
813 |
indt j ^ "<ASSUMPTOIONS>\n" ^
|
neuper@37906
|
814 |
terms2xml' j asms ^
|
neuper@37906
|
815 |
indt j ^ "</ASSUMPTOIONS>\n"
|
neuper@37906
|
816 |
|
neuper@37906
|
817 |
| contthy2xml j (ContNOrew {thyID, thm_rls, applto}) =
|
neuper@37906
|
818 |
indt j ^ "<GUH> " ^ thm_rls ^ " </GUH>\n" ^
|
neuper@37906
|
819 |
indt j ^ "<APPLTO>\n" ^
|
neuper@37906
|
820 |
term2xml j applto ^ "\n" ^
|
neuper@37906
|
821 |
indt j ^ "</APPLTO>\n"
|
neuper@37906
|
822 |
|
neuper@37906
|
823 |
| contthy2xml j (ContNOrewInst{thyID, thm_rls, bdvs, thminst, applto}) =
|
neuper@37906
|
824 |
indt j ^ "<GUH> " ^ thm_rls ^ " </GUH>\n" ^
|
neuper@37906
|
825 |
indt j ^ "<SUBSLIST>\n" ^ (*should be an environment = substitution*)
|
neuper@37906
|
826 |
indt (j+i) ^ "<MATHML>\n" ^
|
neuper@37906
|
827 |
indt (j+2*i) ^ "<ISA> " ^ subst2str' bdvs ^ " </ISA>\n" ^
|
neuper@37906
|
828 |
indt (j+i) ^ "</MATHML>\n" ^
|
neuper@37906
|
829 |
indt j ^ "</SUBSLIST>\n" ^
|
neuper@37906
|
830 |
indt j ^ "<INSTANTIATED>\n" ^
|
neuper@37906
|
831 |
term2xml j thminst ^ "\n" ^
|
neuper@37906
|
832 |
indt j ^ "</INSTANTIATED>\n" ^
|
neuper@37906
|
833 |
indt j ^ "<APPLTO>\n" ^
|
neuper@37906
|
834 |
term2xml j applto ^ "\n" ^
|
neuper@37906
|
835 |
indt j ^ "</APPLTO>\n" : xml;
|
neuper@37906
|
836 |
|
neuper@37906
|
837 |
(*------------------------------------------------------------------*)
|
neuper@37906
|
838 |
end
|
neuper@37906
|
839 |
open datatypes;
|
neuper@37906
|
840 |
(*------------------------------------------------------------------*)
|
neuper@37940
|
841 |
|
neuper@37940
|
842 |
|