aboutsummaryrefslogtreecommitdiff
path: root/kernel/cooking.ml
diff options
context:
space:
mode:
authorGaëtan Gilbert2019-06-17 22:57:33 +0200
committerGaëtan Gilbert2019-06-17 22:57:33 +0200
commit459fc67f4a40ff82a7694f9afafb3ac303d74554 (patch)
tree9c1607700b3689c36de0daf0427f5e95aeb5b55c /kernel/cooking.ml
parentd886dff0857702fc4524779980ee6b7e9688c1d4 (diff)
parent621201858125632496fd11f431529187d69cfdc6 (diff)
Merge PR #10362: Kernel-side delaying of polymorphic opaque constants
Reviewed-by: SkySkimmer Reviewed-by: gares
Diffstat (limited to 'kernel/cooking.ml')
-rw-r--r--kernel/cooking.ml31
1 files changed, 17 insertions, 14 deletions
diff --git a/kernel/cooking.ml b/kernel/cooking.ml
index 750bc6181c..0951b07d49 100644
--- a/kernel/cooking.ml
+++ b/kernel/cooking.ml
@@ -159,7 +159,6 @@ type 'opaque result = {
cook_body : (constr Mod_subst.substituted, 'opaque) constant_def;
cook_type : types;
cook_universes : universes;
- cook_private_univs : Univ.ContextSet.t option;
cook_relevance : Sorts.relevance;
cook_inline : inline;
cook_context : Constr.named_context option;
@@ -202,21 +201,30 @@ let lift_univs cb subst auctx0 =
let subst, auctx = discharge_abstract_universe_context subst auctx0 auctx in
subst, (Polymorphic auctx)
-let cook_constr { Opaqueproof.modlist ; abstract } (univs, c) =
+let cook_constr { Opaqueproof.modlist ; abstract } (c, priv) =
let cache = RefTable.create 13 in
let abstract, usubst, abs_ctx = abstract in
- let ainst = Instance.of_array (Array.init univs Level.var) in
- let usubst = Instance.append usubst ainst in
+ let usubst, priv = match priv with
+ | Opaqueproof.PrivateMonomorphic () ->
+ let () = assert (AUContext.is_empty abs_ctx) in
+ let () = assert (Instance.is_empty usubst) in
+ usubst, priv
+ | Opaqueproof.PrivatePolymorphic (univs, ctx) ->
+ let ainst = Instance.of_array (Array.init univs Level.var) in
+ let usubst = Instance.append usubst ainst in
+ let ctx = on_snd (Univ.subst_univs_level_constraints (Univ.make_instance_subst usubst)) ctx in
+ let univs = univs + AUContext.size abs_ctx in
+ usubst, Opaqueproof.PrivatePolymorphic (univs, ctx)
+ in
let expmod = expmod_constr_subst cache modlist usubst in
let hyps = Context.Named.map expmod abstract in
let hyps = abstract_context hyps in
let c = abstract_constant_body (expmod c) hyps in
- univs + AUContext.size abs_ctx, c
+ (c, priv)
-let cook_constr infos univs c =
- let fold info (univs, c) = cook_constr info (univs, c) in
- let (_, c) = List.fold_right fold infos (univs, c) in
- c
+let cook_constr infos c =
+ let fold info c = cook_constr info c in
+ List.fold_right fold infos c
let cook_constant { from = cb; info } =
let { Opaqueproof.modlist; abstract } = info in
@@ -240,15 +248,10 @@ let cook_constant { from = cb; info } =
hyps)
hyps0 ~init:cb.const_hyps in
let typ = abstract_constant_type (expmod cb.const_type) hyps in
- let private_univs = Option.map (on_snd (Univ.subst_univs_level_constraints
- (Univ.make_instance_subst usubst)))
- cb.const_private_poly_univs
- in
{
cook_body = body;
cook_type = typ;
cook_universes = univs;
- cook_private_univs = private_univs;
cook_relevance = cb.const_relevance;
cook_inline = cb.const_inline_code;
cook_context = Some const_hyps;