1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (*****************************************************************************)
30 (* Enrico Tassi <tassi@cs.unibo.it> *)
33 (* This module implements the aciclic graph of universes. *)
35 (*****************************************************************************)
39 (*****************************************************************************)
41 (*****************************************************************************)
45 (*****************************************************************************)
46 (** Types and default values **)
47 (*****************************************************************************)
50 type universe = int * UriManager.uri option
54 | (id1, Some uri1),(id2, Some uri2) ->
55 id1 = id2 && UriManager.eq uri1 uri2
56 | (id1, None),(id2, None) -> id1 = id2
59 let compare (id1, uri1) (id2, uri2) =
60 let cmp = id1 - id2 in
66 | Some uri1, Some uri2 -> UriManager.compare uri1 uri2
70 module UniverseType = struct
75 module SOF = Set.Make(UniverseType)
87 module MAL = Map.Make(UniverseType)
89 type arc_type = GE | GT | EQ
91 type bag = entry MAL.t
102 let empty_bag = MAL.empty
104 let are_set_eq s1 s2 =
107 let are_entry_eq v1 v2 =
108 (are_set_eq v1.gt_closure v2.gt_closure ) &&
109 (are_set_eq v1.ge_closure v2.ge_closure ) &&
110 (are_set_eq v1.eq_closure v2.eq_closure ) &&
111 (*(are_set_eq v1.in_gegt_of v2.in_gegt_of ) &&*)
112 (are_set_eq v1.one_s_ge v2.one_s_ge ) &&
113 (are_set_eq v1.one_s_gt v2.one_s_gt ) &&
114 (are_set_eq v1.one_s_eq v2.one_s_eq )
116 let are_ugraph_eq = MAL.equal are_entry_eq
118 (*****************************************************************************)
119 (** Pretty printings **)
120 (*****************************************************************************)
122 let string_of_universe (i,u) =
125 "(" ^ ((string_of_int i) ^ "," ^ (UriManager.string_of_uri u) ^ ")")
126 | None -> "(" ^ (string_of_int i) ^ ",None)"
128 let string_of_universe_set l =
129 SOF.fold (fun x s -> s ^ (string_of_universe x) ^ " ") l ""
131 let string_of_node n =
133 "eq_c: " ^ (string_of_universe_set n.eq_closure) ^ "; " ^
134 "ge_c: " ^ (string_of_universe_set n.ge_closure) ^ "; " ^
135 "gt_c: " ^ (string_of_universe_set n.gt_closure) ^ "; " ^
136 "i_gegt: " ^ (string_of_universe_set n.in_gegt_of) ^ "}\n"
138 let string_of_arc (a,u,v) =
139 (string_of_universe u) ^ " " ^ a ^ " " ^ (string_of_universe v)
141 let string_of_mal m =
144 rc := !rc ^ sprintf "%s --> %s" (string_of_universe k)
145 (string_of_node v)) m;
148 let string_of_bag b =
151 (*****************************************************************************)
153 (*****************************************************************************)
160 Not_found -> empty_entry
162 (* FIXME: May be faster if we make it by hand *)
163 let merge_closures f nodes m =
164 SOF.fold (fun x i -> SOF.union (f (repr x m)) i ) nodes SOF.empty
167 (*****************************************************************************)
168 (** _fats implementation **)
169 (*****************************************************************************)
171 let rec closure_of_fast ru m =
172 let eq_c = closure_eq_fast ru m in
173 let ge_c = closure_ge_fast ru m in
174 let gt_c = closure_gt_fast ru m in
179 in_gegt_of = ru.in_gegt_of;
180 one_s_eq = ru.one_s_eq;
181 one_s_ge = ru.one_s_ge;
182 one_s_gt = ru.one_s_gt
185 and closure_eq_fast ru m =
187 let j = ru.one_s_eq in
188 let _Uj = merge_closures (fun x -> x.eq_closure) j m in
189 let one_step_eq = ru.one_s_eq in
190 (SOF.union one_step_eq _Uj)
194 and closure_ge_fast ru m =
196 let j = SOF.union ru.one_s_ge (SOF.union ru.one_s_gt ru.one_s_eq) in
197 let _Uj = merge_closures (fun x -> x.ge_closure) j m in
203 and closure_gt_fast ru m =
205 let j = ru.one_s_gt in
206 let k = ru.one_s_ge in
207 let l = ru.one_s_eq in
208 let _Uj = merge_closures (fun x -> x.ge_closure) j m in
209 let _Uk = merge_closures (fun x -> x.gt_closure) k m in
210 let _Ul = merge_closures (fun x -> x.gt_closure) l m in
211 let one_step_gt = ru.one_s_gt in
212 (SOF.union (SOF.union (SOF.union _Ul one_step_gt) _Uk) _Uj)
216 and print_rec_status u ru =
217 print_endline ("Aggiusto " ^ (string_of_universe u) ^
218 "e ottengo questa chiusura\n " ^ (string_of_node ru))
220 and adjust_fast_aux adjusted u m =
221 if SOF.mem u adjusted then m, adjusted else
222 let adjusted = SOF.add u adjusted in
224 let gt_c = closure_gt_fast ru m in
225 let ge_c = closure_ge_fast ru m in
226 let eq_c = closure_eq_fast ru m in
227 let changed_eq = not (are_set_eq eq_c ru.eq_closure) in
229 (not (are_set_eq gt_c ru.gt_closure)) ||
230 (not (are_set_eq ge_c ru.ge_closure))
232 if ((not changed_gegt) && (not changed_eq)) then
240 in_gegt_of = ru.in_gegt_of;
241 one_s_eq = ru.one_s_eq;
242 one_s_ge = ru.one_s_ge;
243 one_s_gt = ru.one_s_gt}
245 let m = MAL.add u ru' m in
247 SOF.fold (fun x (m,adjusted) -> MAL.add x ru' m, SOF.add x adjusted)
248 (SOF.diff ru'.eq_closure adjusted)
252 SOF.fold (fun x (m,adjusted) -> adjust_fast_aux adjusted x m)
253 (SOF.diff ru'.in_gegt_of adjusted)
260 and profiler_adj = HExtlib.profile "CicUniv.adjust_fast"
261 and adjust_fast x y = profiler_adj.HExtlib.profile (adjust_fast_aux x) y
263 and adjust_fast x y =
264 fst(adjust_fast_aux SOF.empty x y)
266 and add_gt_arc_fast u v m =
268 if SOF.mem v ru.gt_closure then m else
269 let ru' = {ru with one_s_gt = SOF.add v ru.one_s_gt} in
270 let m' = MAL.add u ru' m in
271 let rv = repr v m' in
272 let rv' = {rv with in_gegt_of = SOF.add u rv.in_gegt_of} in
273 let m'' = MAL.add v rv' m' in
276 and add_ge_arc_fast u v m =
278 if SOF.mem v ru.ge_closure then m else
279 let ru' = { ru with one_s_ge = SOF.add v ru.one_s_ge} in
280 let m' = MAL.add u ru' m in
281 let rv = repr v m' in
282 let rv' = {rv with in_gegt_of = SOF.add u rv.in_gegt_of} in
283 let m'' = MAL.add v rv' m' in
286 and add_eq_arc_fast u v m =
288 if SOF.mem v ru.eq_closure then m else
290 let ru' = {ru with one_s_eq = SOF.add v ru.one_s_eq} in
291 (*TESI: let ru' = {ru' with in_gegt_of = SOF.add v ru.in_gegt_of} in *)
292 let m' = MAL.add u ru' m in
293 let rv' = {rv with one_s_eq = SOF.add u rv.one_s_eq} in
294 (*TESI: let rv' = {rv' with in_gegt_of = SOF.add u rv.in_gegt_of} in *)
295 let m'' = MAL.add v rv' m' in
296 adjust_fast v (*(adjust_fast u*) m'' (* ) *)
301 (*****************************************************************************)
302 (** Other real code **)
303 (*****************************************************************************)
305 exception UniverseInconsistency of string Lazy.t
307 let error arc node1 closure_type node2 closure =
310 ("\n ===== Universe Inconsistency detected =====\n\n" ^
312 "\t" ^ (string_of_arc arc) ^ "\n" ^
314 "\t" ^ (string_of_universe node1) ^ "\n" ^
315 " is in the " ^ closure_type ^ " closure\n" ^
316 "\t{" ^ (string_of_universe_set closure) ^ "}\n" ^
318 "\t" ^ (string_of_universe node2) ^ "\n\n" ^
319 " ===== Universe Inconsistency detected =====\n") in
320 prerr_endline (Lazy.force s);
321 raise (UniverseInconsistency s)
324 let fill_empty_nodes_with_uri (g, already_contained,o) l uri =
325 let fill_empty_universe u =
327 (i,None) -> (i,Some uri)
328 | (i,Some _) as u -> u
330 let fill_empty_set s =
331 SOF.fold (fun e s -> SOF.add (fill_empty_universe e) s) s SOF.empty
333 let fill_empty_entry e = {
334 eq_closure = (fill_empty_set e.eq_closure) ;
335 ge_closure = (fill_empty_set e.ge_closure) ;
336 gt_closure = (fill_empty_set e.gt_closure) ;
337 in_gegt_of = (fill_empty_set e.in_gegt_of) ;
338 one_s_eq = (fill_empty_set e.one_s_eq) ;
339 one_s_ge = (fill_empty_set e.one_s_ge) ;
340 one_s_gt = (fill_empty_set e.one_s_gt) ;
345 MAL.add (fill_empty_universe k) (fill_empty_entry v) m) m MAL.empty
347 let l' = List.map fill_empty_universe l in
348 (m', already_contained,o),l'
351 (*****************************************************************************)
352 (** World interface **)
353 (*****************************************************************************)
355 type universe_graph = bag * UriManager.UriSet.t * bool
356 (* the graph , the cache of already merged ugraphs, oblivion? *)
358 let empty_ugraph = empty_bag, UriManager.UriSet.empty, false
359 let oblivion_ugraph = empty_bag, UriManager.UriSet.empty, true
361 let current_index_anon = ref (-1)
362 let current_index_named = ref (-1)
364 let restart_numbering () = current_index_named := (-1)
366 let fresh ?uri ?id () =
370 current_index_anon := !current_index_anon + 1;
372 | None, Some _ -> assert false
374 current_index_named := !current_index_named + 1;
376 | Some _, Some id -> id
380 let name_universe u uri =
382 | (i, None) -> (i, Some uri)
383 | (i, Some ouri) when UriManager.eq ouri uri -> u
385 (* inside obj living at uri 'uri' should live only
386 * universes with uri None. Call Unshare.unshare ~fresh_univs:true
387 * if you want to reuse a Type in another object *)
388 prerr_endline ("Offending universe: " ^ string_of_universe u^
389 " found inside object " ^ UriManager.string_of_uri uri);
393 let print_ugraph (g, _, o) =
394 if o then prerr_endline "oblivion universe" else
395 prerr_endline (string_of_bag g)
398 (* should we check to no add twice the same?? *)
401 if SOF.mem v ru.gt_closure then
402 error ("EQ",u,v) v "GT" u ru.gt_closure
406 if SOF.mem u rv.gt_closure then
407 error ("EQ",u,v) u "GT" v rv.gt_closure
409 add_eq_arc_fast u v b
413 (* should we check to no add twice the same?? *)
416 if SOF.mem u rv.gt_closure then
417 error ("GE",u,v) u "GT" v rv.gt_closure
419 add_ge_arc_fast u v b
422 (* should we check to no add twice the same?? *)
424 FIXME : check the thesis... no need to check GT and EQ closure since the
425 GE is a superset of both
431 error ("GT",u,v) u "==" v SOF.empty
434 (*if SOF.mem u rv.gt_closure then
435 error ("GT",u,v) u "GT" v rv.gt_closure
438 if SOF.mem u rv.ge_closure then
439 error ("GT",u,v) u "GE" v rv.ge_closure
442 if SOF.mem u rv.eq_closure then
443 error ("GT",u,v) u "EQ" v rv.eq_closure
445 add_gt_arc_fast u v b
449 (*****************************************************************************)
450 (** START: Decomment this for performance comparisons **)
451 (*****************************************************************************)
453 let add_eq u v (b,already_contained,oblivion) =
454 if oblivion then (b,already_contained,oblivion) else
455 let rc = add_eq u v b in
456 rc,already_contained,false
458 let add_ge u v (b,already_contained,oblivion) =
459 if oblivion then (b,already_contained,oblivion) else
460 let rc = add_ge u v b in
461 rc,already_contained,false
463 let add_gt u v (b,already_contained,oblivion) =
464 if oblivion then (b,already_contained,oblivion) else
465 let rc = add_gt u v b in
466 rc,already_contained,false
469 let profiler_eq = HExtlib.profile "CicUniv.add_eq"
470 let profiler_ge = HExtlib.profile "CicUniv.add_ge"
471 let profiler_gt = HExtlib.profile "CicUniv.add_gt"
473 profiler_gt.HExtlib.profile (fun _ -> add_gt u v b) ()
475 profiler_ge.HExtlib.profile (fun _ -> add_ge u v b) ()
477 profiler_eq.HExtlib.profile (fun _ -> add_eq u v b) ()
481 let rank = ref MAL.empty;;
483 let do_rank (b,_,_) =
484 (* print_ugraph ugraph; *)
485 let keys = MAL.fold (fun k _ acc -> k::acc) b [] in
489 let rec aux k seen = function
491 | x::tl when SOF.mem x seen -> aux k seen tl
493 (* prerr_endline (String.make k '.' ^ string_of_universe x); *)
494 let seen = SOF.add x seen in
495 let t1, seen = aux (k+1) seen (SOF.elements (repr x b).eq_closure) in
496 let t3, seen = aux (k+1) seen (SOF.elements (repr x b).gt_closure) in
497 let t2, seen = aux (k+1) seen (SOF.elements (repr x b).ge_closure) in
498 let t4, seen = aux k seen tl in
500 (max (if SOF.is_empty (repr x b).gt_closure then 0 else t3+1) t4),
503 let rank, _ = aux 0 SOF.empty [u] in
510 prerr_endline (string_of_universe k ^ " = " ^ string_of_int v)) !rank
516 (* if the universe is not in the graph it means there are
517 * no contraints on it! thus it can be freely set to Type0 *)
520 (*****************************************************************************)
521 (** END: Decomment this for performance comparisons **)
522 (*****************************************************************************)
524 (* TODO: uncomment l to gain a small speedup *)
525 let merge_ugraphs ~base_ugraph ~increment:(increment, uri_of_increment(*,l*)) =
526 let merge_brutal (u,a,_) v =
527 (* prerr_endline ("merging graph: "^UriManager.string_of_uri
528 * uri_of_increment); *)
535 let m = add_gt k u x in m)
536 (SOF.union v.one_s_gt v.gt_closure)
539 let m = add_ge k u x in m)
540 (SOF.union v.one_s_ge v.ge_closure)
543 let m = add_eq k u x in m)
544 (SOF.union v.one_s_eq v.eq_closure) x)))
547 let base, already_contained, oblivion = base_ugraph in
548 let inc,_,oblivion2 = increment in
551 else if oblivion2 then
553 else if MAL.is_empty base then
557 UriManager.UriSet.mem uri_of_increment already_contained
561 (fun (x,_,_) -> x) (merge_brutal increment base_ugraph),
563 List.fold_right UriManager.UriSet.add
564 (List.map (fun (_,x) -> HExtlib.unopt x) l)
566 (UriManager.UriSet.add uri_of_increment already_contained), false
568 (* profiling code; WARNING: the time spent during profiling can be
569 greater than the profiled time
570 let profiler_merge = HExtlib.profile "CicUniv.merge_ugraphs"
571 let merge_ugraphs ~base_ugraph ~increment =
572 profiler_merge.HExtlib.profile
573 (fun _ -> merge_ugraphs ~base_ugraph ~increment) ()
576 (*****************************************************************************)
577 (** Xml sesialization and parsing **)
578 (*****************************************************************************)
580 let xml_of_universe name u =
584 None,"id",(string_of_int i) ;
585 None,"uri",(UriManager.string_of_uri u)]
587 raise (Failure "we can serialize only universes with uri")
591 List.map (xml_of_universe "node") (SOF.elements s)
593 List.fold_left (fun s x -> [< s ; x >] ) [<>] l
595 let xml_of_entry_content e =
596 let stream_of_field f name =
597 let eq_c = xml_of_set f in
599 Xml.xml_nempty name [] eq_c
604 (stream_of_field e.eq_closure "eq_closure");
605 (stream_of_field e.gt_closure "gt_closure");
606 (stream_of_field e.ge_closure "ge_closure");
607 (stream_of_field e.in_gegt_of "in_gegt_of");
608 (stream_of_field e.one_s_eq "one_s_eq");
609 (stream_of_field e.one_s_gt "one_s_gt");
610 (stream_of_field e.one_s_ge "one_s_ge")
613 let xml_of_entry u e =
619 raise (Failure "we can serialize only universes (entry) with uri")
621 let ent = Xml.xml_nempty "entry" [
622 None,"id",(string_of_int i) ;
623 None,"uri",(UriManager.string_of_uri u'')] in
624 let content = xml_of_entry_content e in
627 let write_xml_of_ugraph filename (m,_,_) l =
630 Xml.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
631 Xml.xml_nempty "ugraph" []
632 ([< (MAL.fold ( fun k v s -> [< s ; (xml_of_entry k v) >]) m [<>]) ;
634 (fun s u -> [< s ; xml_of_universe "owned_node" u >]) [<>] l) >])>]
636 Xml.pp ~gzip:true tokens (Some filename)
641 let rec clean_ugraph m already_contained f =
643 MAL.fold (fun k v x -> if (f k) then MAL.add k v x else x ) m MAL.empty in
644 let m'' = MAL.fold (fun k v x ->
646 eq_closure = SOF.filter f v.eq_closure;
647 ge_closure = SOF.filter f v.ge_closure;
648 gt_closure = SOF.filter f v.gt_closure;
649 in_gegt_of = SOF.filter f v.in_gegt_of;
650 one_s_eq = SOF.filter f v.one_s_eq;
651 one_s_ge = SOF.filter f v.one_s_ge;
652 one_s_gt = SOF.filter f v.one_s_gt
654 MAL.add k v' x ) m' MAL.empty in
656 MAL.fold (fun k v l -> if v = empty_entry && not(f k) then
658 SOF.add k l end else l) m'' SOF.empty
660 if not (SOF.is_empty e_l) then
662 m'' already_contained (fun u -> (f u) && not (SOF.mem u e_l))
665 (fun k v x -> if v <> empty_entry then MAL.add k v x else x)
669 let clean_ugraph (m,a,o) l =
671 let l = List.fold_right SOF.add l SOF.empty in
672 let m, a = clean_ugraph m a (fun u -> SOF.mem u l) in
677 "ge_closure" -> (fun e u->{e with ge_closure=SOF.add u e.ge_closure})
678 | "gt_closure" -> (fun e u->{e with gt_closure=SOF.add u e.gt_closure})
679 | "eq_closure" -> (fun e u->{e with eq_closure=SOF.add u e.eq_closure})
680 | "in_gegt_of" -> (fun e u->{e with in_gegt_of =SOF.add u e.in_gegt_of})
681 | "one_s_ge" -> (fun e u->{e with one_s_ge =SOF.add u e.one_s_ge})
682 | "one_s_gt" -> (fun e u->{e with one_s_gt =SOF.add u e.one_s_gt})
683 | "one_s_eq" -> (fun e u->{e with one_s_eq =SOF.add u e.one_s_eq})
684 | s -> raise (Failure ("unsupported tag " ^ s))
688 let module XPP = XmlPushParser in
689 let current_node = ref (0,None) in
690 let current_entry = ref empty_entry in
691 let current_assign = ref (assigner_of "in_gegt_of") in
692 { XPP.default_callbacks with
693 XPP.end_element = Some( fun name ->
696 m := MAL.add !current_node !current_entry !m;
697 current_entry := empty_entry
700 XPP.start_element = Some( fun name attlist ->
704 let id = List.assoc "id" attlist in
705 let uri = List.assoc "uri" attlist in
706 current_node := (int_of_string id,Some (UriManager.uri_of_string uri))
708 let id = int_of_string (List.assoc "id" attlist) in
709 let uri = List.assoc "uri" attlist in
710 current_entry := !current_assign !current_entry
711 (id,Some (UriManager.uri_of_string uri))
713 let id = int_of_string (List.assoc "id" attlist) in
714 let uri = List.assoc "uri" attlist in
715 l := (id,Some (UriManager.uri_of_string uri)) :: !l
716 | s -> current_assign := assigner_of s
721 let ugraph_and_univlist_of_xml filename =
722 let module XPP = XmlPushParser in
723 let result_map = ref MAL.empty in
724 let result_list = ref [] in
725 let cb = cb_factory result_map result_list in
726 let xml_parser = XPP.create_parser cb in
727 let xml_source = `Gzip_file filename in
728 (try XPP.parse xml_parser xml_source
729 with (XPP.Parse_error err) as exn -> raise exn);
730 (!result_map,UriManager.UriSet.empty,false), !result_list
733 (*****************************************************************************)
734 (** the main, only for testing **)
735 (*****************************************************************************)
739 type arc = Ge | Gt | Eq ;;
741 let randomize_actionlist n m =
742 let ge_percent = 0.7 in
743 let gt_percent = 0.15 in
745 let node1 = Random.int m in
746 let node2 = Random.int m in
748 let r = Random.float 1.0 in
749 if r < ge_percent then
751 else (if r < (ge_percent +. gt_percent) then
761 | n -> (random_step ())::(aux (n-1))
765 let print_action_list l =
766 let string_of_step (op,node1,node2) =
771 "," ^ (string_of_int node1) ^ "," ^ (string_of_int node2)
777 ";" ^ (string_of_step a) ^ (aux tl)
780 let l_body = (String.length body) - 1 in
781 prerr_endline ("[" ^ (String.sub body 1 l_body))
784 let d_print_endline = if debug then print_endline else ignore
785 let d_print_ugraph = if debug then print_ugraph else ignore
788 (if Array.length Sys.argv < 2 then
789 prerr_endline ("Usage " ^ Sys.argv.(0) ^ " max_edges max_nodes"));
791 let max_edges = int_of_string Sys.argv.(1) in
792 let max_nodes = int_of_string Sys.argv.(2) in
793 let action_listR = randomize_actionlist max_edges max_nodes in
795 let action_list = [Ge,1,4;Ge,2,6;Ge,1,1;Eq,6,4;Gt,6,3] in
796 let action_list = action_listR in
798 print_action_list action_list;
799 let prform_step ?(fast=false) (t,u,v) g =
811 let g' = f ~fast (u,None) (v,None) g in
812 (*print_ugraph g' ;*)
815 let fail = ref false in
816 let time1 = Unix.gettimeofday () in
817 let n_safe = ref 0 in
820 d_print_endline "SAFE";
823 n_safe := !n_safe + 1;
825 ) empty_ugraph action_list
827 UniverseInconsistency s -> fail:=true;empty_bag
829 let time2 = Unix.gettimeofday () in
830 d_print_ugraph g_safe;
831 let time3 = Unix.gettimeofday () in
832 let n_test = ref 0 in
835 d_print_endline "FAST";
838 n_test := !n_test + 1;
839 prform_step ~fast:true e g
840 ) empty_ugraph action_list
842 UniverseInconsistency s -> empty_bag
844 let time4 = Unix.gettimeofday () in
845 d_print_ugraph g_test;
846 if are_ugraph_eq g_safe g_test && !n_test = !n_safe then
851 if e = Eq then s+1 else s
857 if e = Gt then s+1 else s
860 let num_ge = max_edges - num_gt - num_eq in
861 let time_fast = (time4 -. time3) in
862 let time_safe = (time2 -. time1) in
863 let gap = ((time_safe -. time_fast) *. 100.0) /. time_safe in
864 let fail = if !fail then 1 else 0 in
867 "OK %d safe %1.4f fast %1.4f %% %1.2f #eq %d #gt %d #ge %d %d"
868 fail time_safe time_fast gap num_eq num_gt num_ge !n_safe);
873 print_endline "FAIL";
886 i, Some (UriManager.uri_of_string (UriManager.string_of_uri uri))
888 let recons_entry entry =
890 SOF.fold (fun univ set -> SOF.add (recons_univ univ) set) set SOF.empty
893 eq_closure = recons_set entry.eq_closure;
894 ge_closure = recons_set entry.ge_closure;
895 gt_closure = recons_set entry.gt_closure;
896 in_gegt_of = recons_set entry.in_gegt_of;
897 one_s_eq = recons_set entry.one_s_eq;
898 one_s_ge = recons_set entry.one_s_ge;
899 one_s_gt = recons_set entry.one_s_gt;
902 let recons_graph (graph,uriset,o) =
904 (fun universe entry map ->
905 MAL.add (recons_univ universe) (recons_entry entry) map)
908 UriManager.UriSet.fold
910 UriManager.UriSet.add
911 (UriManager.uri_of_string (UriManager.string_of_uri u)) acc)
912 uriset UriManager.UriSet.empty, o
917 raise (UniverseInconsistency (lazy "This universe graph has a hole"))
920 let assert_univs_have_uri (graph,_,_) univlist =
922 SOF.iter (fun u -> assert_univ u) s
925 assert_set e.eq_closure;
926 assert_set e.ge_closure;
927 assert_set e.gt_closure;
928 assert_set e.in_gegt_of;
929 assert_set e.one_s_eq;
930 assert_set e.one_s_ge;
931 assert_set e.one_s_gt;
933 MAL.iter (fun k v -> assert_univ k; assert_entry v)graph;
934 List.iter assert_univ univlist
936 let is_anon = function (_,None) -> true | _ -> false