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) *)
34 let print_term curi ids_to_inner_sorts =
38 let module U = UriManager in
41 let sort = Hashtbl.find ids_to_inner_sorts id in
43 ["value",(string_of_int n) ; "binder",b ; "id",id ; "sort",sort]
45 let vdepth = U.depth_of_uri uri
46 and cdepth = U.depth_of_uri curi
47 and sort = Hashtbl.find ids_to_inner_sorts id in
49 ["relUri",(string_of_int (cdepth - vdepth)) ^ "," ^
51 "id",id ; "sort",sort]
53 let sort = Hashtbl.find ids_to_inner_sorts id in
54 X.xml_empty "META" ["no",(string_of_int n) ; "id",id ; "sort",sort]
62 X.xml_empty "SORT" ["value",(string_of_sort s) ; "id",id]
63 | C.AImplicit _ -> raise NotImplemented
64 | C.AProd (id,C.Anonimous,s,t) ->
65 let ty = Hashtbl.find ids_to_inner_sorts id in
66 X.xml_nempty "PROD" ["id",id ; "type",ty]
67 [< X.xml_nempty "source" [] (aux s) ;
68 X.xml_nempty "target" [] (aux t)
70 | C.AProd (xid,C.Name id,s,t) ->
71 let ty = Hashtbl.find ids_to_inner_sorts xid in
72 X.xml_nempty "PROD" ["id",xid ; "type",ty]
73 [< X.xml_nempty "source" [] (aux s) ;
74 X.xml_nempty "target" ["binder",id] (aux t)
77 let sort = Hashtbl.find ids_to_inner_sorts id in
78 X.xml_nempty "CAST" ["id",id ; "sort",sort]
79 [< X.xml_nempty "term" [] (aux v) ;
80 X.xml_nempty "type" [] (aux t)
82 | C.ALambda (id,C.Anonimous,s,t) ->
83 let sort = Hashtbl.find ids_to_inner_sorts id in
84 X.xml_nempty "LAMBDA" ["id",id ; "sort",sort]
85 [< X.xml_nempty "source" [] (aux s) ;
86 X.xml_nempty "target" [] (aux t)
88 | C.ALambda (xid,C.Name id,s,t) ->
89 let sort = Hashtbl.find ids_to_inner_sorts xid in
90 X.xml_nempty "LAMBDA" ["id",xid ; "sort",sort]
91 [< X.xml_nempty "source" [] (aux s) ;
92 X.xml_nempty "target" ["binder",id] (aux t)
94 | C.ALetIn (xid,C.Anonimous,s,t) ->
95 assert false (*CSC: significa che e' sbagliato il tipo di LetIn!!!*)
96 | C.ALetIn (xid,C.Name id,s,t) ->
97 let sort = Hashtbl.find ids_to_inner_sorts xid in
98 X.xml_nempty "LETIN" ["id",xid ; "sort",sort]
99 [< X.xml_nempty "term" [] (aux s) ;
100 X.xml_nempty "letintarget" ["binder",id] (aux t)
103 let sort = Hashtbl.find ids_to_inner_sorts id in
104 X.xml_nempty "APPLY" ["id",id ; "sort",sort]
105 [< (List.fold_right (fun x i -> [< (aux x) ; i >]) li [<>])
107 | C.AConst (id,uri,_) ->
108 let sort = Hashtbl.find ids_to_inner_sorts id in
110 ["uri", (U.string_of_uri uri) ; "id",id ; "sort",sort]
111 | C.AAbst (id,uri) -> raise NotImplemented
112 | C.AMutInd (id,uri,_,i) ->
114 ["uri", (U.string_of_uri uri) ;
115 "noType",(string_of_int i) ;
117 | C.AMutConstruct (id,uri,_,i,j) ->
118 let sort = Hashtbl.find ids_to_inner_sorts id in
119 X.xml_empty "MUTCONSTRUCT"
120 ["uri", (U.string_of_uri uri) ;
121 "noType",(string_of_int i) ; "noConstr",(string_of_int j) ;
122 "id",id ; "sort",sort]
123 | C.AMutCase (id,uri,_,typeno,ty,te,patterns) ->
124 let sort = Hashtbl.find ids_to_inner_sorts id in
125 X.xml_nempty "MUTCASE"
126 ["uriType",(U.string_of_uri uri) ;
127 "noType", (string_of_int typeno) ;
128 "id", id ; "sort",sort]
129 [< X.xml_nempty "patternsType" [] [< (aux ty) >] ;
130 X.xml_nempty "inductiveTerm" [] [< (aux te) >] ;
132 (fun x i -> [< X.xml_nempty "pattern" [] [< aux x >] ; i>])
135 | C.AFix (id, no, funs) ->
136 let sort = Hashtbl.find ids_to_inner_sorts id in
138 ["noFun", (string_of_int no) ; "id",id ; "sort",sort]
140 (fun (fi,ai,ti,bi) i ->
141 [< X.xml_nempty "FixFunction"
142 ["name", fi; "recIndex", (string_of_int ai)]
143 [< X.xml_nempty "type" [] [< aux ti >] ;
144 X.xml_nempty "body" [] [< aux bi >]
150 | C.ACoFix (id,no,funs) ->
151 let sort = Hashtbl.find ids_to_inner_sorts id in
153 ["noFun", (string_of_int no) ; "id",id ; "sort",sort]
156 [< X.xml_nempty "CofixFunction" ["name", fi]
157 [< X.xml_nempty "type" [] [< aux ti >] ;
158 X.xml_nempty "body" [] [< aux bi >]
168 exception NotImplemented;;
170 (*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
171 let print_object curi ids_to_inner_sorts =
173 let module C = Cic in
174 let module X = Xml in
175 let module U = UriManager in
177 C.ACurrentProof (id,n,conjectures,bo,ty) ->
178 X.xml_nempty "CurrentProof" ["name",n ; "id", id]
182 X.xml_nempty "Conjecture" ["no",(string_of_int n)]
183 (print_term curi ids_to_inner_sorts t)
186 X.xml_nempty "body" [] (print_term curi ids_to_inner_sorts bo) ;
187 X.xml_nempty "type" [] (print_term curi ids_to_inner_sorts ty) >]
188 | C.ADefinition (id,n,bo,ty,C.Actual params) ->
194 U.string_of_uri x ^ match i with "" -> "" | i' -> " " ^ i'
195 ) x "" ^ match i with "" -> "" | i' -> " " ^ i'
198 X.xml_nempty "Definition" ["name",n ; "params",params' ; "id", id]
199 [< X.xml_nempty "body" [] (print_term curi ids_to_inner_sorts bo) ;
200 X.xml_nempty "type" [] (print_term curi ids_to_inner_sorts ty) >]
201 | C.ADefinition _ -> assert false
202 | _ -> raise NotImplemented
207 let print_inner_types curi ids_to_inner_sorts ids_to_inner_types =
208 let module X = Xml in
209 X.xml_nempty "InnerTypes" ["of",UriManager.string_of_uri curi]
213 X.xml_nempty "TYPE" ["of",id]
214 (print_term curi ids_to_inner_sorts ty)
216 ) ids_to_inner_types [<>]