aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/reduction.ml
diff options
context:
space:
mode:
authorGravatar Gaëtan Gilbert <gaetan.gilbert@skyskimmer.net>2017-11-09 17:27:58 +0100
committerGravatar Gaëtan Gilbert <gaetan.gilbert@skyskimmer.net>2018-02-10 01:34:19 +0100
commit35fba70509d9fb219b2a88f8e7bd246b2671b39b (patch)
tree21cdb9aa905ef8f6375aa6cd119254794233d0ac /kernel/reduction.ml
parent10d3d803e6b57024dd15df7d61670ce42260948a (diff)
Simplification: cumulativity information is variance information.
Since cumulativity of an inductive type is the universe constraints which make a term convertible with its universe-renamed copy, the only constraints we can get are between a universe and its copy. As such we do not need to be able to represent arbitrary constraints between universes and copied universes in a double-sized ucontext, instead we can just keep around an array describing whether a bound universe is covariant, invariant or irrelevant (CIC has no contravariant conversion rule). Printing is fairly obtuse and should be improved: when we print the CumulativityInfo we add marks to the universes of the instance: = for invariant, + for covariant and * for irrelevant. ie Record Foo@{i j k} := { foo : Type@{i} -> Type@{j} }. Print Foo. gives Cumulative Record Foo : Type@{max(i+1, j+1)} := Build_Foo { foo : Type@{i} -> Type@{j} } (* =i +j *k |= *)
Diffstat (limited to 'kernel/reduction.ml')
-rw-r--r--kernel/reduction.ml27
1 files changed, 7 insertions, 20 deletions
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index dc46ac01b..083692e91 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -219,26 +219,13 @@ let convert_instances ~flex u u' (s, check) =
(check.compare_instances ~flex u u' s, check)
let get_cumulativity_constraints cv_pb cumi u u' =
- let length_ind_instance =
- 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) &&
- (length_ind_instance = Univ.Instance.length u')) then
- anomaly (Pp.str "Invalid inductive subtyping encountered!")
- else
- let comp_cst =
- let comp_subst = (Univ.Instance.append u u') in
- Univ.AUContext.instantiate comp_subst ind_subtypctx
- in
- match cv_pb with
- | CONV ->
- let comp_cst' =
- let comp_subst = (Univ.Instance.append u' u) in
- Univ.AUContext.instantiate comp_subst ind_subtypctx
- in
- Univ.Constraint.union comp_cst comp_cst'
- | CUMUL -> comp_cst
+ match cv_pb with
+ | CONV ->
+ Univ.Variance.eq_constraints (Univ.ACumulativityInfo.variance cumi)
+ u u' Univ.Constraint.empty
+ | CUMUL ->
+ Univ.Variance.leq_constraints (Univ.ACumulativityInfo.variance cumi)
+ u u' Univ.Constraint.empty
let convert_inductives_gen cmp_instances cmp_cumul cv_pb (mind,ind) nargs u1 u2 s =
match mind.Declarations.mind_universes with