1 (*CSC codice cut & paste da cicPp e xmlcommand *)
3 exception ImpossiblePossible;;
4 exception NotImplemented;;
5 exception BinderNotSpecified;;
7 let dtdname = "http://localhost:8081/getdtd?url=cic.dtd";;
9 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
14 let module U = UriManager in
16 C.ARel (id,_,n,Some b) ->
17 X.xml_empty "REL" ["value",(string_of_int n);"binder",b;"id",id]
18 | C.ARel _ -> raise BinderNotSpecified
19 | C.AVar (id,_,uri) ->
20 let vdepth = U.depth_of_uri uri
21 and cdepth = U.depth_of_uri curi in
23 ["relUri",(string_of_int (cdepth - vdepth)) ^ "," ^
27 X.xml_empty "META" ["no",(string_of_int n) ; "id",id]
35 X.xml_empty "SORT" ["value",(string_of_sort s) ; "id",id]
36 | C.AImplicit _ -> raise NotImplemented
37 | C.AProd (id,_,C.Anonimous,s,t) ->
38 X.xml_nempty "PROD" ["id",id]
39 [< X.xml_nempty "source" [] (aux s) ;
40 X.xml_nempty "target" [] (aux t)
42 | C.AProd (xid,_,C.Name id,s,t) ->
43 X.xml_nempty "PROD" ["id",xid]
44 [< X.xml_nempty "source" [] (aux s) ;
45 X.xml_nempty "target" ["binder",id] (aux t)
47 | C.ACast (id,_,v,t) ->
48 X.xml_nempty "CAST" ["id",id]
49 [< X.xml_nempty "term" [] (aux v) ;
50 X.xml_nempty "type" [] (aux t)
52 | C.ALambda (id,_,C.Anonimous,s,t) ->
53 X.xml_nempty "LAMBDA" ["id",id]
54 [< X.xml_nempty "source" [] (aux s) ;
55 X.xml_nempty "target" [] (aux t)
57 | C.ALambda (xid,_,C.Name id,s,t) ->
58 X.xml_nempty "LAMBDA" ["id",xid]
59 [< X.xml_nempty "source" [] (aux s) ;
60 X.xml_nempty "target" ["binder",id] (aux t)
62 | C.ALetIn (xid,_,C.Anonimous,s,t) ->
63 assert false (*CSC: significa che e' sbagliato il tipo di LetIn!!!*)
64 | C.ALetIn (xid,_,C.Name id,s,t) ->
65 X.xml_nempty "LETIN" ["id",xid]
66 [< X.xml_nempty "term" [] (aux s) ;
67 X.xml_nempty "letintarget" ["binder",id] (aux t)
69 | C.AAppl (id,_,li) ->
70 X.xml_nempty "APPLY" ["id",id]
71 [< (List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>])
73 | C.AConst (id,_,uri,_) ->
74 X.xml_empty "CONST" ["uri", (U.string_of_uri uri) ; "id",id]
75 | C.AAbst (id,_,uri) -> raise NotImplemented
76 | C.AMutInd (id,_,uri,_,i) ->
78 ["uri", (U.string_of_uri uri) ;
79 "noType",(string_of_int i) ;
81 | C.AMutConstruct (id,_,uri,_,i,j) ->
82 X.xml_empty "MUTCONSTRUCT"
83 ["uri", (U.string_of_uri uri) ;
84 "noType",(string_of_int i) ; "noConstr",(string_of_int j) ;
86 | C.AMutCase (id,_,uri,_,typeno,ty,te,patterns) ->
87 X.xml_nempty "MUTCASE"
88 ["uriType",(U.string_of_uri uri) ;
89 "noType", (string_of_int typeno) ;
91 [< X.xml_nempty "patternsType" [] [< (aux ty) >] ;
92 X.xml_nempty "inductiveTerm" [] [< (aux te) >] ;
94 (fun x i -> [< X.xml_nempty "pattern" [] [< aux x >] ; i>])
97 | C.AFix (id, _, no, funs) ->
98 X.xml_nempty "FIX" ["noFun", (string_of_int no) ; "id",id]
100 (fun (fi,ai,ti,bi) i ->
101 [< X.xml_nempty "FixFunction"
102 ["name", fi; "recIndex", (string_of_int ai)]
103 [< X.xml_nempty "type" [] [< aux ti >] ;
104 X.xml_nempty "body" [] [< aux bi >]
110 | C.ACoFix (id,_,no,funs) ->
111 X.xml_nempty "COFIX" ["noFun", (string_of_int no) ; "id",id]
114 [< X.xml_nempty "CofixFunction" ["name", fi]
115 [< X.xml_nempty "type" [] [< aux ti >] ;
116 X.xml_nempty "body" [] [< aux bi >]
132 string_of_int n ^ ": " ^
133 String.concat " " (List.map UriManager.name_of_uri l) ^
138 let print_mutual_inductive_type curi (typename,inductive,arity,constructors) =
139 let module C = Cic in
140 let module X = Xml in
141 [< X.xml_nempty "InductiveType"
143 "inductive",(string_of_bool inductive)
145 [< X.xml_nempty "arity" [] (print_term curi arity) ;
147 (fun (name,ty,_) i ->
148 [< X.xml_nempty "Constructor" ["name",name]
149 (print_term curi ty) ;
160 let module C = Cic in
161 let module X = Xml in
163 C.ADefinition (xid, _, id, te, ty, params) ->
164 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
165 X.xml_cdata ("<!DOCTYPE Definition SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
166 X.xml_nempty "Definition"
167 (["name", id ; "id",xid] @
169 C.Possible _ -> raise ImpossiblePossible
170 (*CSC params are kept in inverted order in the internal *)
171 (* representation (the order of application) *)
172 | C.Actual fv' -> ["params",(encode (List.rev fv'))])
173 [< X.xml_nempty "body" [] (print_term curi te) ;
174 X.xml_nempty "type" [] (print_term curi ty) >]
176 | C.AAxiom (xid, _, id, ty, params) ->
177 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
178 X.xml_cdata ("<!DOCTYPE Axiom SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
180 (*CSC params are kept in inverted order in the internal *)
181 (* representation (the order of application) *)
182 ["name",id ; "params",(encode (List.rev params)) ; "id",xid]
183 [< X.xml_nempty "type" [] (print_term curi ty) >]
185 | C.AVariable (xid, _, name, bo, ty) ->
186 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
187 X.xml_cdata ("<!DOCTYPE Variable SYSTEM \"" ^ dtdname ^ "\">\n\n") ;
188 X.xml_nempty "Variable" ["name",name ; "id",xid]
191 | Some bo -> X.xml_nempty "body" [] (print_term curi bo)
193 X.xml_nempty "type" [] (print_term curi ty)
196 | C.ACurrentProof (xid, _, name, conjs, bo, ty) ->
197 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
198 X.xml_cdata ("<!DOCTYPE CurrentProof SYSTEM \"" ^ dtdname ^ "\">\n\n");
199 X.xml_nempty "CurrentProof" ["name",name ; "id",xid]
202 [< X.xml_nempty "Conjecture" ["no",(string_of_int j)]
203 [< print_term curi t >] ; i >])
205 X.xml_nempty "body" [] [< print_term curi bo >] ;
206 X.xml_nempty "type" [] [< print_term curi ty >]
209 | C.AInductiveDefinition (xid, _, tys, params, paramsno) ->
212 (fun (typename,_,_,_) -> typename)
215 [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
216 X.xml_cdata ("<!DOCTYPE InductiveDefinition SYSTEM \"" ^
217 dtdname ^ "\">\n\n") ;
218 X.xml_nempty "InductiveDefinition"
219 (*CSC params are kept in inverted order in the internal *)
220 (* representation (the order of application) *)
221 ["noParams",string_of_int paramsno ;
222 "params",(encode (List.rev params)) ;
225 (fun x i -> [< print_mutual_inductive_type curi x ; i >])