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 exception BinderNotSpecified;;
33 let dtdname = "http://localhost:8081/getdtd?url=cic.dtd";;
35 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
40 let module U = UriManager in
42 C.ARel (id,_,n,Some b) ->
43 X.xml_empty "REL" ["value",(string_of_int n);"binder",b;"id",id]
44 | C.ARel _ -> raise BinderNotSpecified
45 | C.AVar (id,_,uri) ->
46 let vdepth = U.depth_of_uri uri
47 and cdepth = U.depth_of_uri curi in
49 ["relUri",(string_of_int (cdepth - vdepth)) ^ "," ^
53 X.xml_empty "META" ["no",(string_of_int n) ; "id",id]
61 X.xml_empty "SORT" ["value",(string_of_sort s) ; "id",id]
62 | C.AImplicit _ -> raise NotImplemented
63 | C.AProd (id,_,C.Anonimous,s,t) ->
64 X.xml_nempty "PROD" ["id",id]
65 [< X.xml_nempty "source" [] (aux s) ;
66 X.xml_nempty "target" [] (aux t)
68 | C.AProd (xid,_,C.Name id,s,t) ->
69 X.xml_nempty "PROD" ["id",xid]
70 [< X.xml_nempty "source" [] (aux s) ;
71 X.xml_nempty "target" ["binder",id] (aux t)
73 | C.ACast (id,_,v,t) ->
74 X.xml_nempty "CAST" ["id",id]
75 [< X.xml_nempty "term" [] (aux v) ;
76 X.xml_nempty "type" [] (aux t)
78 | C.ALambda (id,_,C.Anonimous,s,t) ->
79 X.xml_nempty "LAMBDA" ["id",id]
80 [< X.xml_nempty "source" [] (aux s) ;
81 X.xml_nempty "target" [] (aux t)
83 | C.ALambda (xid,_,C.Name id,s,t) ->
84 X.xml_nempty "LAMBDA" ["id",xid]
85 [< X.xml_nempty "source" [] (aux s) ;
86 X.xml_nempty "target" ["binder",id] (aux t)
88 | C.ALetIn (xid,_,C.Anonimous,s,t) ->
89 assert false (*CSC: significa che e' sbagliato il tipo di LetIn!!!*)
90 | C.ALetIn (xid,_,C.Name id,s,t) ->
91 X.xml_nempty "LETIN" ["id",xid]
92 [< X.xml_nempty "term" [] (aux s) ;
93 X.xml_nempty "letintarget" ["binder",id] (aux t)
95 | C.AAppl (id,_,li) ->
96 X.xml_nempty "APPLY" ["id",id]
97 [< (List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>])
99 | C.AConst (id,_,uri,_) ->
100 X.xml_empty "CONST" ["uri", (U.string_of_uri uri) ; "id",id]
101 | C.AAbst (id,_,uri) -> raise NotImplemented
102 | C.AMutInd (id,_,uri,_,i) ->
104 ["uri", (U.string_of_uri uri) ;
105 "noType",(string_of_int i) ;
107 | C.AMutConstruct (id,_,uri,_,i,j) ->
108 X.xml_empty "MUTCONSTRUCT"
109 ["uri", (U.string_of_uri uri) ;
110 "noType",(string_of_int i) ; "noConstr",(string_of_int j) ;
112 | C.AMutCase (id,_,uri,_,typeno,ty,te,patterns) ->
113 X.xml_nempty "MUTCASE"
114 ["uriType",(U.string_of_uri uri) ;
115 "noType", (string_of_int typeno) ;
117 [< X.xml_nempty "patternsType" [] [< (aux ty) >] ;
118 X.xml_nempty "inductiveTerm" [] [< (aux te) >] ;
120 (fun x i -> [< X.xml_nempty "pattern" [] [< aux x >] ; i>])
123 | C.AFix (id, _, no, funs) ->
124 X.xml_nempty "FIX" ["noFun", (string_of_int no) ; "id",id]
126 (fun (fi,ai,ti,bi) i ->
127 [< X.xml_nempty "FixFunction"
128 ["name", fi; "recIndex", (string_of_int ai)]
129 [< X.xml_nempty "type" [] [< aux ti >] ;
130 X.xml_nempty "body" [] [< aux bi >]
136 | C.ACoFix (id,_,no,funs) ->
137 X.xml_nempty "COFIX" ["noFun", (string_of_int no) ; "id",id]
140 [< X.xml_nempty "CofixFunction" ["name", fi]
141 [< X.xml_nempty "type" [] [< aux ti >] ;
142 X.xml_nempty "body" [] [< aux bi >]
158 string_of_int n ^ ": " ^
159 String.concat " " (List.map UriManager.name_of_uri l) ^
164 let print_mutual_inductive_type curi (typename,inductive,arity,constructors) =
165 let module C = Cic in
166 let module X = Xml in
167 [< X.xml_nempty "InductiveType"
169 "inductive",(string_of_bool inductive)
171 [< X.xml_nempty "arity" [] (print_term curi arity) ;
173 (fun (name,ty,_) i ->
174 [< X.xml_nempty "Constructor" ["name",name]
175 (print_term curi ty) ;
186 let module C = Cic in
187 let module X = Xml in
189 C.ADefinition (xid, _, id, te, ty, params) ->
190 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
191 X.xml_cdata ("<!DOCTYPE Definition SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
192 X.xml_nempty "Definition"
193 (["name", id ; "id",xid] @
195 C.Possible _ -> raise ImpossiblePossible
196 (*CSC params are kept in inverted order in the internal *)
197 (* representation (the order of application) *)
198 | C.Actual fv' -> ["params",(encode (List.rev fv'))])
199 [< X.xml_nempty "body" [] (print_term curi te) ;
200 X.xml_nempty "type" [] (print_term curi ty) >]
202 | C.AAxiom (xid, _, id, ty, params) ->
203 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
204 X.xml_cdata ("<!DOCTYPE Axiom SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
206 (*CSC params are kept in inverted order in the internal *)
207 (* representation (the order of application) *)
208 ["name",id ; "params",(encode (List.rev params)) ; "id",xid]
209 [< X.xml_nempty "type" [] (print_term curi ty) >]
211 | C.AVariable (xid, _, name, bo, ty) ->
212 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
213 X.xml_cdata ("<!DOCTYPE Variable SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
214 X.xml_nempty "Variable" ["name",name ; "id",xid]
217 | Some bo -> X.xml_nempty "body" [] (print_term curi bo)
219 X.xml_nempty "type" [] (print_term curi ty)
222 | C.ACurrentProof (xid, _, name, conjs, bo, ty) ->
223 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
224 X.xml_cdata ("<!DOCTYPE CurrentProof SYSTEM \"" ^ dtdname ^ "\">\n\n");
225 X.xml_nempty "CurrentProof" ["name",name ; "id",xid]
228 [< X.xml_nempty "Conjecture" ["no",(string_of_int j)]
229 [< print_term curi t >] ; i >])
231 X.xml_nempty "body" [] [< print_term curi bo >] ;
232 X.xml_nempty "type" [] [< print_term curi ty >]
235 | C.AInductiveDefinition (xid, _, tys, params, paramsno) ->
238 (fun (typename,_,_,_) -> typename)
241 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
242 X.xml_cdata ("<!DOCTYPE InductiveDefinition SYSTEM \"" ^
243 dtdname ^ "\">\n\n") ;
244 X.xml_nempty "InductiveDefinition"
245 (*CSC params are kept in inverted order in the internal *)
246 (* representation (the order of application) *)
247 ["noParams",string_of_int paramsno ;
248 "params",(encode (List.rev params)) ;
251 (fun x i -> [< print_mutual_inductive_type curi x ; i >])