+
+exception NotImplemented;;
+
+(*CSC ottimizzazione: al posto di curi cdepth (vedi codice) *)
+let print_object curi ids_to_inner_sorts =
+ let rec aux =
+ let module C = Cic in
+ let module X = Xml in
+ let module U = UriManager in
+ function
+ C.ACurrentProof (id,n,conjectures,bo,ty) ->
+ X.xml_nempty "CurrentProof" ["name",n ; "id", id]
+ [< List.fold_left
+ (fun i (cid,n,canonical_context,t) ->
+ [< i ;
+ X.xml_nempty "Conjecture"
+ ["id", cid ; "no",(string_of_int n)]
+ [< List.fold_left
+ (fun i (hid,t) ->
+ [< (match t with
+ Some (n,C.ADecl t) ->
+ X.xml_nempty "Decl"
+ (match n with
+ C.Name n' -> ["id",hid;"name",n']
+ | C.Anonimous -> ["id",hid])
+ (print_term curi ids_to_inner_sorts t)
+ | Some (n,C.ADef t) ->
+ X.xml_nempty "Def"
+ (match n with
+ C.Name n' -> ["id",hid;"name",n']
+ | C.Anonimous -> ["id",hid])
+ (print_term curi ids_to_inner_sorts t)
+ | None -> X.xml_empty "Hidden" ["id",hid]
+ ) ;
+ i
+ >]
+ ) [< >] canonical_context ;
+ X.xml_nempty "Goal" []
+ (print_term curi ids_to_inner_sorts t)
+ >]
+ >])
+ [<>] conjectures ;
+ X.xml_nempty "body" [] (print_term curi ids_to_inner_sorts bo) ;
+ X.xml_nempty "type" [] (print_term curi ids_to_inner_sorts ty) >]
+ | C.ADefinition (id,n,bo,ty,C.Actual params) ->
+ let params' =
+ List.fold_right
+ (fun (_,x) i ->
+ List.fold_right
+ (fun x i ->
+ U.string_of_uri x ^ match i with "" -> "" | i' -> " " ^ i'
+ ) x "" ^ match i with "" -> "" | i' -> " " ^ i'
+ ) params ""
+ in
+ X.xml_nempty "Definition" ["name",n ; "params",params' ; "id", id]
+ [< X.xml_nempty "body" [] (print_term curi ids_to_inner_sorts bo) ;
+ X.xml_nempty "type" [] (print_term curi ids_to_inner_sorts ty) >]
+ | C.ADefinition _ -> assert false
+ | _ -> raise NotImplemented
+ in
+ aux
+;;
+
+let print_inner_types curi ids_to_inner_sorts ids_to_inner_types =
+ let module X = Xml in
+ X.xml_nempty "InnerTypes" ["of",UriManager.string_of_uri curi]
+ (Hashtbl.fold
+ (fun id ty x ->
+ [< x ;
+ X.xml_nempty "TYPE" ["of",id]
+ (print_term curi ids_to_inner_sorts ty)
+ >]
+ ) ids_to_inner_types [<>]
+ )
+;;