universes to be actually shared between objects and no duplication is necessary.
in this way the typechecker is more strict and unification can be an ungly beast implicitly
adding an = constranint between two universes. speedup granted!
let len = String.length s in
if not(len > 5) then parse_error ctxt "sort expected";
if not(String.sub s 0 5 = "Type:") then parse_error ctxt "sort expected";
- try
- Cic.Type
- (CicUniv.fresh
- ~uri:ctxt.uri
- ~id:(int_of_string (String.sub s 5 (len - 5))) ())
+ let s = String.sub s 5 (len - 5) in
+ let i = String.index s ':' in
+ let id = int_of_string (String.sub s 0 i) in
+ let suri = String.sub s (i+1) (len - 5 - i - 1) in
+ let uri = UriManager.uri_of_string suri in
+ try Cic.Type (CicUniv.fresh ~uri ~id ())
with
| Failure "int_of_string"
| Invalid_argument _ -> parse_error ctxt "sort expected"
let name_universe u uri =
match u with
| (i, None) -> (i, Some uri)
- | (i, Some ouri) when UriManager.eq ouri uri -> u
- | (i, Some ouri) ->
- (* inside obj living at uri 'uri' should live only
- * universes with uri None. Call Unshare.unshare ~fresh_univs:true
- * if you want to reuse a Type in another object *)
- prerr_endline ("Offending universe: " ^ string_of_universe u^
- " found inside object " ^ UriManager.string_of_uri uri);
- assert false
+ | u -> u
;;
let print_ugraph (g, _, o) =
Xml.pp ~gzip:true tokens (Some filename)
let univno = fst
+let univuri = function
+ | _,None -> assert false
+ | _,Some u -> u
let rec clean_ugraph m already_contained f =
returns the universe number (used to save it do xml)
*)
val univno: universe -> int
+val univuri: universe -> UriManager.uri
(** re-hash-cons URIs contained in the given universe so that phisicaly
* equality could be enforced. Mainly used by
let string_of_sort = function
| `Prop -> "Prop"
| `Set -> "Set"
- | `Type u -> "Type:" ^ string_of_int (CicUniv.univno u)
+ | `Type u -> "Type:" ^ string_of_int (CicUniv.univno u) ^ ":" ^ UriManager.string_of_uri (CicUniv.univuri u)
| `CProp -> "CProp"
let sort_of_sort = function
Cic.term -> CicUniv.universe_graph ->
Cic.term * CicUniv.universe_graph
-(* typechecks the obj and puts it in the environment *)
+(* typechecks the obj and puts it in the environment
+ * empty universes are filed with the given uri, thus you should
+ * get the object again after calling this *)
val typecheck_obj : UriManager.uri -> Cic.obj -> unit
(* check_allowed_sort_elimination uri i s1 s2
let typecheck_obj =
let profiler = HExtlib.profile "add_obj.typecheck_obj" in
- fun uri obj -> profiler.HExtlib.profile (CicTypeChecker.typecheck_obj uri)
- (Unshare.fresh_types obj)
+ fun uri obj -> profiler.HExtlib.profile (CicTypeChecker.typecheck_obj uri) obj
let index_obj =
let profiler = HExtlib.profile "add_obj.index_obj" in
(Printf.sprintf "QED: %%univ = %2.5f, total = %2.5f, univ = %2.5f, %s\n"
(univ_time *. 100. /. total_time) (total_time) (univ_time)
(UriManager.name_of_uri uri));*)
- let _, ugraph, univlist =
- CicEnvironment.get_cooked_obj_with_univlist CicUniv.empty_ugraph uri in
+ let obj, ugraph, univlist =
+ try CicEnvironment.get_cooked_obj_with_univlist CicUniv.empty_ugraph uri
+ with CicEnvironment.Object_not_found _ -> assert false
+ in
try
index_obj ~dbd ~uri; (* 2 must be in the env *)
try