let get_universes () = List.map (fun x -> [false,x]) !universes;;
+let is_declared u =
+ match u with
+ [false,x] -> List.exists (fun y -> NUri.eq x y) !universes
+ | _ -> assert false
+;;
+
let add_constraint strict a b =
match a,b with
| [false,a2],[false,b2] ->
val type0: NCic.universe
val get_universes: unit -> NCic.universe list
+val is_declared: NCic.universe -> bool
val max: NCic.universe -> NCic.universe -> NCic.universe
(* universe_* raise BadConstraints if the second arg. is an inferred universe *)
val universe_eq: NCic.universe -> NCic.universe -> bool
with Failure _ ->
raise (TypeCheckerFailure (lazy ("unbound variable " ^ string_of_int n
^" under: " ^ NCicPp.ppcontext ~metasenv ~subst context))))
- | C.Sort (C.Type [false,u]) -> C.Sort (C.Type [true, u])
+ | C.Sort (C.Type ([false,u] as univ)) ->
+ if NCicEnvironment.is_declared univ then
+ C.Sort (C.Type [true, u])
+ else
+ raise (TypeCheckerFailure (lazy ("undeclared universe " ^
+ NUri.string_of_uri u)))
| C.Sort (C.Type _) ->
raise (AssertFailure (lazy ("Cannot type an inferred type: "^
NCicPp.ppterm ~subst ~metasenv ~context t)))
NCic.Prop -> `Prop,"ind"
| NCic.Type u ->
let u = NCicPp.ppterm ~metasenv:[] ~subst:[] ~context:[] (NCic.Sort s) in
- `NType u, "rect_" ^ u
+ (try
+ if String.sub u 0 4 = "Type" then
+ `NType (String.sub u 4 (String.length u - 4)), "rect_" ^ u
+ else if String.sub u 0 5 = "CProp" then
+ `NCProp (String.sub u 5 (String.length u - 5)), "rect_" ^ u
+ else
+ (prerr_endline u;
+ assert false)
+ with Failure _ -> assert false)
in
match obj with
NCic.Inductive (true,leftno,itl,_) ->