aboutsummaryrefslogtreecommitdiffhomepage
path: root/pretyping
diff options
context:
space:
mode:
authorGravatar Gaetan Gilbert <gaetan.gilbert@ens-lyon.fr>2017-04-06 22:48:32 +0200
committerGravatar Gaetan Gilbert <gaetan.gilbert@ens-lyon.fr>2017-05-03 13:37:56 +0200
commite9b745af47ba3386724b874e3fd74b6dad33b015 (patch)
tree2d6953e463d5d0dad13a29e4340b16671681a731 /pretyping
parent4bff930da2c029a66eaf5378e5abd2cc35554f8f (diff)
Allow flexible anonymous universes in instances and sorts.
The addition to the test suite showcases the usage.
Diffstat (limited to 'pretyping')
-rw-r--r--pretyping/detyping.ml7
-rw-r--r--pretyping/miscops.ml2
-rw-r--r--pretyping/pretyping.ml61
3 files changed, 39 insertions, 31 deletions
diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml
index 483e2b432..8a90a3f9b 100644
--- a/pretyping/detyping.ml
+++ b/pretyping/detyping.ml
@@ -422,7 +422,9 @@ let detype_sort sigma = function
| Type u ->
GType
(if !print_universes
- then [dl, Pp.string_of_ppcmds (Univ.Universe.pr_with (Termops.pr_evd_level sigma) u)]
+ then
+ let u = Pp.string_of_ppcmds (Univ.Universe.pr_with (Termops.pr_evd_level sigma) u) in
+ [dl, Name.mk_name (Id.of_string_soft u)]
else [])
type binder_kind = BProd | BLambda | BLetIn
@@ -434,7 +436,8 @@ let detype_anonymous = ref (fun loc n -> anomaly ~label:"detype" (Pp.str "index
let set_detype_anonymous f = detype_anonymous := f
let detype_level sigma l =
- GType (Some (dl, Pp.string_of_ppcmds (Termops.pr_evd_level sigma l)))
+ let l = Pp.string_of_ppcmds (Termops.pr_evd_level sigma l) in
+ GType (Some (dl, Name.mk_name (Id.of_string_soft l)))
let detype_instance sigma l =
let l = EInstance.kind sigma l in
diff --git a/pretyping/miscops.ml b/pretyping/miscops.ml
index 7fe81c9a4..1669f8334 100644
--- a/pretyping/miscops.ml
+++ b/pretyping/miscops.ml
@@ -30,7 +30,7 @@ let smartmap_cast_type f c =
let glob_sort_eq g1 g2 = match g1, g2 with
| GProp, GProp -> true
| GSet, GSet -> true
-| GType l1, GType l2 -> List.equal (fun x y -> CString.equal (snd x) (snd y)) l1 l2
+| GType l1, GType l2 -> List.equal (fun x y -> Names.Name.equal (snd x) (snd y)) l1 l2
| _ -> false
let intro_pattern_naming_eq nam1 nam2 = match nam1, nam2 with
diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml
index 68ef97659..767e4be35 100644
--- a/pretyping/pretyping.ml
+++ b/pretyping/pretyping.ml
@@ -192,45 +192,50 @@ let _ =
optwrite = (:=) Universes.set_minimization })
(** Miscellaneous interpretation functions *)
-let interp_universe_level_name evd (loc,s) =
- let names, _ = Global.global_universe_names () in
- if CString.string_contains ~where:s ~what:"." then
- match List.rev (CString.split '.' s) with
- | [] -> anomaly (str"Invalid universe name " ++ str s)
- | n :: dp ->
- let num = int_of_string n in
- let dp = DirPath.make (List.map Id.of_string dp) in
- let level = Univ.Level.make dp num in
- let evd =
- try Evd.add_global_univ evd level
- with UGraph.AlreadyDeclared -> evd
- in evd, level
- else
- try
- let level = Evd.universe_of_name evd s in
- evd, level
- with Not_found ->
- try
- let id = try Id.of_string s with _ -> raise Not_found in
- evd, snd (Idmap.find id names)
- with Not_found ->
- if not (is_strict_universe_declarations ()) then
- new_univ_level_variable ~loc ~name:s univ_rigid evd
- else user_err ~loc ~hdr:"interp_universe_level_name"
- (Pp.(str "Undeclared universe: " ++ str s))
+let interp_universe_level_name ~anon_rigidity evd (loc,s) =
+ match s with
+ | Anonymous ->
+ new_univ_level_variable ~loc anon_rigidity evd
+ | Name s ->
+ let s = Id.to_string s in
+ let names, _ = Global.global_universe_names () in
+ if CString.string_contains ~where:s ~what:"." then
+ match List.rev (CString.split '.' s) with
+ | [] -> anomaly (str"Invalid universe name " ++ str s)
+ | n :: dp ->
+ let num = int_of_string n in
+ let dp = DirPath.make (List.map Id.of_string dp) in
+ let level = Univ.Level.make dp num in
+ let evd =
+ try Evd.add_global_univ evd level
+ with UGraph.AlreadyDeclared -> evd
+ in evd, level
+ else
+ try
+ let level = Evd.universe_of_name evd s in
+ evd, level
+ with Not_found ->
+ try
+ let id = try Id.of_string s with _ -> raise Not_found in
+ evd, snd (Idmap.find id names)
+ with Not_found ->
+ if not (is_strict_universe_declarations ()) then
+ new_univ_level_variable ~loc ~name:s univ_rigid evd
+ else user_err ~loc ~hdr:"interp_universe_level_name"
+ (Pp.(str "Undeclared universe: " ++ str s))
let interp_universe ?loc evd = function
| [] -> let evd, l = new_univ_level_variable ?loc univ_rigid evd in
evd, Univ.Universe.make l
| l ->
List.fold_left (fun (evd, u) l ->
- let evd', l = interp_universe_level_name evd l in
+ let evd', l = interp_universe_level_name ~anon_rigidity:univ_flexible_alg evd l in
(evd', Univ.sup u (Univ.Universe.make l)))
(evd, Univ.Universe.type0m) l
let interp_level_info loc evd : Misctypes.level_info -> _ = function
| None -> new_univ_level_variable ~loc univ_rigid evd
- | Some (loc,s) -> interp_universe_level_name evd (loc,s)
+ | Some (loc,s) -> interp_universe_level_name ~anon_rigidity:univ_flexible evd (loc,s)
let interp_sort ?loc evd = function
| GProp -> evd, Prop Null