2 ||M|| This file is part of HELM, an Hypertextual, Electronic
3 ||A|| Library of Mathematics, developed at the Computer Science
4 ||T|| Department, University of Bologna, Italy.
6 ||T|| HELM is free software; you can redistribute it and/or
7 ||A|| modify it under the terms of the GNU General Public License
8 \ / version 2 or (at your option) any later version.
9 \ / This software is distributed as is, NO WARRANTY.
10 V_______________________________________________________________ *)
15 let ignore_exc = false
16 let rank_all_dependencies = false
17 let trust_environment = false
21 let load_graph, get_graph =
22 let oldg = ref CicUniv.empty_ugraph in
24 let _,g = CicEnvironment.get_obj !oldg uri in
30 let do_indent () = String.make !indent ' ' in
32 | `Start_type_checking s ->
34 prerr_endline (do_indent () ^ "Start: " ^ NUri.string_of_uri s);
36 | `Type_checking_completed s ->
39 prerr_endline (do_indent () ^ "End: " ^ NUri.string_of_uri s)
40 | `Type_checking_interrupted s ->
43 prerr_endline (do_indent () ^ "Break: " ^ NUri.string_of_uri s)
44 | `Type_checking_failed s ->
47 prerr_endline (do_indent () ^ "Fail: " ^ NUri.string_of_uri s)
50 prerr_endline (do_indent () ^ "Trust: " ^ NUri.string_of_uri s))
55 [false, NUri.uri_of_string ("cic:/matita/pts/Type.univ")]
57 [false, NUri.uri_of_string ("cic:/matita/pts/Type"^string_of_int n^".univ")]
61 [false, NUri.uri_of_string ("cic:/matita/pts/CProp.univ")]
63 [false, NUri.uri_of_string ("cic:/matita/pts/CProp"^string_of_int n^".univ")]
68 let do_old_logging = ref true in
69 HelmLogger.register_log_callback
70 (fun ?append_NL html_msg ->
71 if !do_old_logging then
72 prerr_endline (HelmLogger.string_of_html_msg html_msg));
73 CicParser.impredicative_set := false;
74 NCicTypeChecker.set_logger logger;
75 NCicPp.set_ppterm NCicPp.trivial_pp_term;
76 Helm_registry.load_from "conf.xml";
79 let s = Sys.argv.(1) in
80 if s = "-alluris" then
82 let uri_re = Str.regexp ".*\\(ind\\|con\\)$" in
83 let uris = Http_getter.getalluris () in
84 let alluris = List.filter (fun u -> Str.string_match uri_re u 0) uris in
85 let oc = open_out "alluris.txt" in
86 List.iter (fun s -> output_string oc (s^"\n")) alluris;
91 with Invalid_argument _ ->
93 let ic = open_in "alluris.txt" in
94 try while true do r := input_line ic :: !r; done; []
99 (fun u -> try Some (UriManager.uri_of_string u) with _ -> None) alluris
102 prerr_endline "computing graphs to load...";
104 if not rank_all_dependencies then
107 let dbd = HSql.quick_connect (LibraryDb.parse_dbd_conf ()) in
108 MetadataTypes.ownerize_tables (Helm_registry.get "matita.owner");
110 HExtlib.list_uniq (List.sort UriManager.compare l) in
112 uniq (List.map (fun (uri,_) -> UriManager.strip_xpointer uri)
113 (MetadataDeps.inverse_deps ~dbd u)) in
116 List.fold_left (fun (acc,todo) x ->
117 let w = who_uses x in
118 if w = [] then (x::acc,todo) else (acc,uniq (todo@w)))
121 if todo = [] then uniq acc else fix acc todo
125 prerr_endline "generating Coq graphs...";
126 CicEnvironment.set_trust (fun _ -> trust_environment);
129 prerr_endline (" - " ^ UriManager.string_of_uri u);
131 ignore(CicTypeChecker.typecheck u);
133 | CicTypeChecker.AssertFailure s
134 | CicTypeChecker.TypeCheckerFailure s ->
135 prerr_endline (Lazy.force s);
138 prerr_endline "loading...";
141 prerr_endline (" - "^UriManager.string_of_uri u);
142 try load_graph u with exn -> ())
144 prerr_endline "finished....";
145 let lll = List.sort compare (CicUniv.do_rank (get_graph ())) in
148 let rec aux = function
150 NCicEnvironment.add_constraint true (mk_type a) (mk_type b);
151 NCicEnvironment.add_constraint true (mk_cprop a) (mk_cprop b);
152 NCicEnvironment.add_constraint true (mk_cprop a) (mk_type b);
153 NCicEnvironment.add_constraint true (mk_type a) (mk_cprop b);
154 NCicEnvironment.add_constraint false (mk_cprop a) (mk_type a);
155 NCicEnvironment.add_constraint false (mk_type a) (mk_cprop a);
158 NCicEnvironment.add_constraint false (mk_type a) (mk_cprop a);
159 NCicEnvironment.add_constraint false (mk_cprop a) (mk_type a);
163 with NCicEnvironment.BadConstraint s as e ->
164 prerr_endline (Lazy.force s); raise e
166 prerr_endline "ranked....";
167 prerr_endline (NCicEnvironment.pp_constraints ());
168 HExtlib.profiling_enabled := false;
170 let uu= OCic2NCic.nuri_of_ouri uu in
172 let o = NCicLibrary.get_obj uu in
173 prerr_endline (NCicPp.ppobj o);
175 NCicTypeChecker.typecheck_obj o
177 | NCicTypeChecker.AssertFailure s
178 | NCicTypeChecker.TypeCheckerFailure s
179 | NCicEnvironment.ObjectNotFound s
180 | NCicEnvironment.BadConstraint s
181 | NCicEnvironment.BadDependency s as e ->
182 prerr_endline ("######### " ^ Lazy.force s);
183 if not ignore_exc then raise e
186 NCicEnvironment.invalidate ();
188 HExtlib.profiling_enabled := true;
189 NCicTypeChecker.set_logger (fun _ -> ());
190 do_old_logging := false;
191 prerr_endline "typechecking, first with the new and then with the old kernel";
192 let prima = Unix.gettimeofday () in
195 let u= OCic2NCic.nuri_of_ouri u in
197 NCicTypeChecker.typecheck_obj (NCicLibrary.get_obj u))
199 let dopo = Unix.gettimeofday () in
201 let dopo2 = Unix.gettimeofday () in
202 Printf.eprintf "NEW typing: %3.2f, gc: %3.2f\n%!" (dopo -. prima) (dopo2 -. dopo);
203 CicEnvironment.invalidate ();
205 let prima = Unix.gettimeofday () in
206 List.iter (fun u -> ignore (CicTypeChecker.typecheck u)) alluris;
207 let dopo = Unix.gettimeofday () in
209 let dopo2 = Unix.gettimeofday () in
210 Printf.eprintf "OLD typing: %3.2f, gc: %3.2f\n%!" (dopo -. prima) (dopo2 -. dopo)