Skip to content

Commit d8aed29

Browse files
committed
Fix Scheme Equality with template poly
1 parent 29d1ff5 commit d8aed29

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

vernac/auto_ind_decl.ml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,9 @@ let build_beq_scheme env handle kn =
666666

667667
(* Setting universes *)
668668
let auctx = Declareops.universes_context mib.mind_universes in
669-
let u, uctx = UnivGen.fresh_instance_from auctx None in
670-
let uctx = UState.of_context_set uctx in
669+
let u, ctx = UnivGen.fresh_instance_from auctx None in
670+
let uctx = UState.from_env env in
671+
let uctx = UState.merge_sort_context ~sideff:false UState.univ_rigid uctx ctx in
671672

672673
(* number of inductives in the mutual *)
673674
let nb_ind = Array.length mib.mind_packets in
@@ -851,6 +852,21 @@ let build_beq_scheme env handle kn =
851852
if not (Sorts.family_leq InSet kelim) then raise (NonSingletonProp (kn,0));
852853
[|Term.it_mkLambda_or_LetIn (make_one_eq 0) recparams_ctx_with_eqs|]
853854
in
855+
856+
let uctx =
857+
(* infer univ constraints
858+
For instance template poly inductive produces a univ monomorphic scheme
859+
which when applied needs to constrain the universe of its argument
860+
*)
861+
let sigma = Evd.from_ctx uctx in
862+
let sigma = Array.fold_left (fun sigma c ->
863+
fst @@ Typing.type_of env sigma (EConstr.of_constr c))
864+
sigma
865+
res
866+
in
867+
Evd.evar_universe_context sigma
868+
in
869+
854870
res, uctx
855871

856872
let beq_scheme_kind =

0 commit comments

Comments
 (0)