2 (* Copyright (C) 2000, HELM Team.
4 * This file is part of HELM, an Hypertextual, Electronic
5 * Library of Mathematics, developed at the Computer Science
6 * Department, University of Bologna, Italy.
8 * HELM is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * HELM is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with HELM; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 * For details, see the HELM World-Wide-Web page,
24 * http://cs.unibo.it/helm/.
27 (*CSC codice cut & paste da cicPp e xmlcommand *)
29 exception ImpossiblePossible;;
30 exception NotImplemented;;
31 let dtdname = "http://localhost:8081/getdtd?url=cic.dtd";;
33 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
38 let module U = UriManager in
41 X.xml_empty "REL" ["value",(string_of_int n);"binder",b;"id",id]
43 let vdepth = U.depth_of_uri uri
44 and cdepth = U.depth_of_uri curi in
46 ["relUri",(string_of_int (cdepth - vdepth)) ^ "," ^
50 X.xml_empty "META" ["no",(string_of_int n) ; "id",id]
58 X.xml_empty "SORT" ["value",(string_of_sort s) ; "id",id]
59 | C.AImplicit _ -> raise NotImplemented
60 | C.AProd (id,C.Anonimous,s,t) ->
61 X.xml_nempty "PROD" ["id",id]
62 [< X.xml_nempty "source" [] (aux s) ;
63 X.xml_nempty "target" [] (aux t)
65 | C.AProd (xid,C.Name id,s,t) ->
66 X.xml_nempty "PROD" ["id",xid]
67 [< X.xml_nempty "source" [] (aux s) ;
68 X.xml_nempty "target" ["binder",id] (aux t)
71 X.xml_nempty "CAST" ["id",id]
72 [< X.xml_nempty "term" [] (aux v) ;
73 X.xml_nempty "type" [] (aux t)
75 | C.ALambda (id,C.Anonimous,s,t) ->
76 X.xml_nempty "LAMBDA" ["id",id]
77 [< X.xml_nempty "source" [] (aux s) ;
78 X.xml_nempty "target" [] (aux t)
80 | C.ALambda (xid,C.Name id,s,t) ->
81 X.xml_nempty "LAMBDA" ["id",xid]
82 [< X.xml_nempty "source" [] (aux s) ;
83 X.xml_nempty "target" ["binder",id] (aux t)
85 | C.ALetIn (xid,C.Anonimous,s,t) ->
86 assert false (*CSC: significa che e' sbagliato il tipo di LetIn!!!*)
87 | C.ALetIn (xid,C.Name id,s,t) ->
88 X.xml_nempty "LETIN" ["id",xid]
89 [< X.xml_nempty "term" [] (aux s) ;
90 X.xml_nempty "letintarget" ["binder",id] (aux t)
93 X.xml_nempty "APPLY" ["id",id]
94 [< (List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>])
96 | C.AConst (id,uri,_) ->
97 X.xml_empty "CONST" ["uri", (U.string_of_uri uri) ; "id",id]
98 | C.AMutInd (id,uri,_,i) ->
100 ["uri", (U.string_of_uri uri) ;
101 "noType",(string_of_int i) ;
103 | C.AMutConstruct (id,uri,_,i,j) ->
104 X.xml_empty "MUTCONSTRUCT"
105 ["uri", (U.string_of_uri uri) ;
106 "noType",(string_of_int i) ; "noConstr",(string_of_int j) ;
108 | C.AMutCase (id,uri,_,typeno,ty,te,patterns) ->
109 X.xml_nempty "MUTCASE"
110 ["uriType",(U.string_of_uri uri) ;
111 "noType", (string_of_int typeno) ;
113 [< X.xml_nempty "patternsType" [] [< (aux ty) >] ;
114 X.xml_nempty "inductiveTerm" [] [< (aux te) >] ;
116 (fun x i -> [< X.xml_nempty "pattern" [] [< aux x >] ; i>])
119 | C.AFix (id, no, funs) ->
120 X.xml_nempty "FIX" ["noFun", (string_of_int no) ; "id",id]
122 (fun (fi,ai,ti,bi) i ->
123 [< X.xml_nempty "FixFunction"
124 ["name", fi; "recIndex", (string_of_int ai)]
125 [< X.xml_nempty "type" [] [< aux ti >] ;
126 X.xml_nempty "body" [] [< aux bi >]
132 | C.ACoFix (id,no,funs) ->
133 X.xml_nempty "COFIX" ["noFun", (string_of_int no) ; "id",id]
136 [< X.xml_nempty "CofixFunction" ["name", fi]
137 [< X.xml_nempty "type" [] [< aux ti >] ;
138 X.xml_nempty "body" [] [< aux bi >]
154 string_of_int n ^ ": " ^
155 String.concat " " (List.map UriManager.name_of_uri l) ^
160 let print_mutual_inductive_type curi (typename,inductive,arity,constructors) =
161 let module C = Cic in
162 let module X = Xml in
163 [< X.xml_nempty "InductiveType"
165 "inductive",(string_of_bool inductive)
167 [< X.xml_nempty "arity" [] (print_term curi arity) ;
169 (fun (name,ty,_) i ->
170 [< X.xml_nempty "Constructor" ["name",name]
171 (print_term curi ty) ;
182 let module C = Cic in
183 let module X = Xml in
185 C.ADefinition (xid, id, te, ty, params) ->
186 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
187 X.xml_cdata ("<!DOCTYPE Definition SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
188 X.xml_nempty "Definition"
189 (["name", id ; "id",xid] @
191 C.Possible _ -> raise ImpossiblePossible
192 (*CSC params are kept in inverted order in the internal *)
193 (* representation (the order of application) *)
194 | C.Actual fv' -> ["params",(encode (List.rev fv'))])
195 [< X.xml_nempty "body" [] (print_term curi te) ;
196 X.xml_nempty "type" [] (print_term curi ty) >]
198 | C.AAxiom (xid, id, ty, params) ->
199 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
200 X.xml_cdata ("<!DOCTYPE Axiom SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
202 (*CSC params are kept in inverted order in the internal *)
203 (* representation (the order of application) *)
204 ["name",id ; "params",(encode (List.rev params)) ; "id",xid]
205 [< X.xml_nempty "type" [] (print_term curi ty) >]
207 | C.AVariable (xid, name, bo, ty) ->
208 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
209 X.xml_cdata ("<!DOCTYPE Variable SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
210 X.xml_nempty "Variable" ["name",name ; "id",xid]
213 | Some bo -> X.xml_nempty "body" [] (print_term curi bo)
215 X.xml_nempty "type" [] (print_term curi ty)
218 | C.ACurrentProof (xid, name, conjs, bo, ty) ->
219 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
220 X.xml_cdata ("<!DOCTYPE CurrentProof SYSTEM \"" ^ dtdname ^ "\">\n\n");
221 X.xml_nempty "CurrentProof" ["name",name ; "id",xid]
224 [< X.xml_nempty "Conjecture" ["no",(string_of_int j)]
225 [< print_term curi t >] ; i >])
227 X.xml_nempty "body" [] [< print_term curi bo >] ;
228 X.xml_nempty "type" [] [< print_term curi ty >]
231 | C.AInductiveDefinition (xid, tys, params, paramsno) ->
234 (fun (typename,_,_,_) -> typename)
237 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
238 X.xml_cdata ("<!DOCTYPE InductiveDefinition SYSTEM \"" ^
239 dtdname ^ "\">\n\n") ;
240 X.xml_nempty "InductiveDefinition"
241 (*CSC params are kept in inverted order in the internal *)
242 (* representation (the order of application) *)
243 ["noParams",string_of_int paramsno ;
244 "params",(encode (List.rev params)) ;
247 (fun x i -> [< print_mutual_inductive_type curi x ; i >])