aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-07-07 16:33:47 +0200
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2017-07-11 14:50:47 +0200
commit0d9a91113c4112eece0680e433f435fdfb39ea4b (patch)
treecf90d290a92c02a2297b3a13b77190db9aa4db70 /kernel
parentb5ad6a80107f196fa8ffcc4f5dff58bea8c4f70e (diff)
Getting rid of simple calls to AUContext.instance.
This function breaks the abstraction barrier of abstract universe contexts, as it provides a way to observe the bound names of such a context. We remove all the uses that can be easily get rid of with the current API.
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cooking.ml11
-rw-r--r--kernel/indtypes.ml7
-rw-r--r--kernel/nativecode.ml10
-rw-r--r--kernel/reduction.ml6
-rw-r--r--kernel/term_typing.ml5
5 files changed, 17 insertions, 22 deletions
diff --git a/kernel/cooking.ml b/kernel/cooking.ml
index b9e7ec169..852f87d5e 100644
--- a/kernel/cooking.ml
+++ b/kernel/cooking.ml
@@ -184,13 +184,14 @@ let lift_univs cb subst =
if (Univ.LMap.is_empty subst) then
subst, (Polymorphic_const auctx)
else
- let inst = Univ.AUContext.instance auctx in
let len = Univ.LMap.cardinal subst in
- let subst =
- Array.fold_left_i
- (fun i acc v -> Univ.LMap.add (Level.var i) (Level.var (i + len)) acc)
- subst (Univ.Instance.to_array inst)
+ let rec gen_subst i acc =
+ if i < 0 then acc
+ else
+ let acc = Univ.LMap.add (Level.var i) (Level.var (i + len)) acc in
+ gen_subst (pred i) acc
in
+ let subst = gen_subst (Univ.AUContext.size auctx - 1) subst in
let auctx' = Univ.subst_univs_level_abstract_universe_context subst auctx in
subst, (Polymorphic_const auctx')
diff --git a/kernel/indtypes.ml b/kernel/indtypes.ml
index 04971f83d..e248436ec 100644
--- a/kernel/indtypes.ml
+++ b/kernel/indtypes.ml
@@ -961,13 +961,10 @@ let build_inductive env prv iu env_ar paramsctxt kn isrecord isfinite inds nmr r
&& pkt.mind_consnrealargs.(0) > 0 ->
(** The elimination criterion ensures that all projections can be defined. *)
let u =
- let process auctx =
- subst_univs_level_instance substunivs (Univ.AUContext.instance auctx)
- in
match aiu with
| Monomorphic_ind _ -> Univ.Instance.empty
- | Polymorphic_ind auctx -> process auctx
- | Cumulative_ind acumi -> process (Univ.ACumulativityInfo.univ_context acumi)
+ | Polymorphic_ind auctx -> Univ.make_abstract_instance auctx
+ | Cumulative_ind acumi -> Univ.make_abstract_instance (Univ.ACumulativityInfo.univ_context acumi)
in
let indsp = ((kn, 0), u) in
let rctx, indty = decompose_prod_assum (subst1 (mkIndU indsp) pkt.mind_nf_lc.(0)) in
diff --git a/kernel/nativecode.ml b/kernel/nativecode.ml
index 1acede729..9d7262206 100644
--- a/kernel/nativecode.ml
+++ b/kernel/nativecode.ml
@@ -1861,10 +1861,10 @@ and compile_named env sigma univ auxdefs id =
let compile_constant env sigma prefix ~interactive con cb =
match cb.const_proj with
| None ->
- let u =
+ let no_univs =
match cb.const_universes with
- | Monomorphic_const _ -> Univ.Instance.empty
- | Polymorphic_const ctx -> Univ.AUContext.instance ctx
+ | Monomorphic_const _ -> true
+ | Polymorphic_const ctx -> Int.equal (Univ.AUContext.size ctx) 0
in
begin match cb.const_body with
| Def t ->
@@ -1879,7 +1879,7 @@ let compile_constant env sigma prefix ~interactive con cb =
in
let l = con_label con in
let auxdefs,code =
- if Univ.Instance.is_empty u then compile_with_fv env sigma None [] (Some l) code
+ if no_univs then compile_with_fv env sigma None [] (Some l) code
else
let univ = fresh_univ () in
let (auxdefs,code) = compile_with_fv env sigma (Some univ) [] (Some l) code in
@@ -1894,7 +1894,7 @@ let compile_constant env sigma prefix ~interactive con cb =
| _ ->
let i = push_symbol (SymbConst con) in
let args =
- if Univ.Instance.is_empty u then [|get_const_code i; MLarray [||]|]
+ if no_univs then [|get_const_code i; MLarray [||]|]
else [|get_const_code i|]
in
(*
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index de4efbba9..423e0d934 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -680,8 +680,7 @@ let infer_check_conv_constructors
let check_inductive_instances cv_pb cumi u u' univs =
let length_ind_instance =
- Univ.Instance.length
- (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
+ Univ.AUContext.size (Univ.ACumulativityInfo.univ_context cumi)
in
let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
if not ((length_ind_instance = Univ.Instance.length u) &&
@@ -767,8 +766,7 @@ let infer_convert_instances ~flex u u' (univs,cstrs) =
let infer_inductive_instances cv_pb cumi u u' (univs, cstrs) =
let length_ind_instance =
- Univ.Instance.length
- (Univ.AUContext.instance (Univ.ACumulativityInfo.univ_context cumi))
+ Univ.AUContext.size (Univ.ACumulativityInfo.univ_context cumi)
in
let ind_subtypctx = Univ.ACumulativityInfo.subtyp_context cumi in
if not ((length_ind_instance = Univ.Instance.length u) &&
diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml
index 283febed2..eee227370 100644
--- a/kernel/term_typing.ml
+++ b/kernel/term_typing.ml
@@ -131,8 +131,7 @@ let inline_side_effects env body ctx side_eff =
(subst, var + 1, ctx, (cname c, b, ty, opaque) :: args)
| Polymorphic_const auctx ->
(** Inline the term to emulate universe polymorphism *)
- let data = (Univ.AUContext.instance auctx, b) in
- let subst = Cmap_env.add c (Inl data) subst in
+ let subst = Cmap_env.add c (Inl b) subst in
(subst, var, ctx, args)
in
let (subst, len, ctx, args) = List.fold_left fold (Cmap_env.empty, 1, ctx, []) side_eff in
@@ -142,7 +141,7 @@ let inline_side_effects env body ctx side_eff =
let data = try Some (Cmap_env.find c subst) with Not_found -> None in
begin match data with
| None -> t
- | Some (Inl (inst, b)) ->
+ | Some (Inl b) ->
(** [b] is closed but may refer to other constants *)
subst_const i k (Vars.subst_instance_constr u b)
| Some (Inr n) ->