Skip to content

Commit cc26b15

Browse files
authored
Merge pull request #942 from mattam82/sort-poly-flags
Adapt to rocq-prover/rocq#21419
2 parents 8869ee6 + 3dd598f commit cc26b15

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

src/rocq_elpi_HOAS.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,8 +3088,7 @@ let comInductive_interp_mutual_inductive_constr ~cumulative ~poly ~template ~fin
30883088
[%%else]
30893089
let comInductive_interp_mutual_inductive_constr ~cumulative ~poly ~template ~finite ~ctx_params ~env_ar_params =
30903090
let flags = {
3091-
ComInductive.poly;
3092-
cumulative;
3091+
ComInductive.poly = PolyFlags.make ~univ_poly:poly ~cumulative ~collapse_sort_variables:true;
30933092
template = Some false;
30943093
finite;
30953094
mode = None;

src/rocq_elpi_arg_HOAS.ml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ let univpoly_of ~poly ~cumulative =
242242
| true, false -> Poly
243243
| false, _ -> Mono
244244

245+
[%%if coq = "9.0" || coq = "9.1"]
246+
let univpoly_of_flags flags =
247+
univpoly_of ~poly:flags.ComInductive.poly ~cumulative:flags.ComInductive.cumulative
248+
[%%else]
249+
let univpoly_of_flags flags =
250+
univpoly_of ~poly:(PolyFlags.univ_poly flags.ComInductive.poly) ~cumulative:(PolyFlags.cumulative flags.poly)
251+
[%%endif]
252+
245253
let of_coq_inductive_definition id =
246254
let open Vernacentries.Preprocessed_Mind_decl in
247255
let { flags; udecl; typing_flags; private_ind; uniform; inductives } = id in
@@ -254,7 +262,7 @@ let of_coq_inductive_definition id =
254262
List.map (function (Vernacexpr.(_,NoCoercion,NoInstance),c) -> c
255263
| _ -> CErrors.user_err Pp.(str "coercion and instance flags not supported"))
256264
constructors in
257-
let { ComInductive.template; cumulative; poly; finite } = flags in
265+
let { ComInductive.template; finite } = flags in
258266
if template <> None then nYI "raw template polymorphic inductives";
259267
if udecl <> None then nYI "raw universe polymorphic inductives with universe declaration";
260268
{
@@ -264,7 +272,7 @@ let of_coq_inductive_definition id =
264272
non_uniform_parameters;
265273
arity;
266274
constructors;
267-
univpoly = univpoly_of ~poly ~cumulative
275+
univpoly = univpoly_of_flags flags
268276
}
269277

270278
let of_coq_record_definition id =
@@ -279,7 +287,7 @@ let of_coq_record_definition id =
279287
match sort.CAst.v with
280288
| Constrexpr.CSort s -> s
281289
| _ -> CErrors.user_err ?loc:sort.CAst.loc Pp.(str "only explicits sorts are supported")) in
282-
let { ComInductive.template; cumulative; poly; finite } = flags in
290+
let { ComInductive.template; finite } = flags in
283291
if template <> None then nYI "raw template polymorphic inductives";
284292
if udecl <> None then nYI "raw universe polymorphic inductives with universe declaration";
285293
{
@@ -288,7 +296,7 @@ let of_coq_record_definition id =
288296
sort;
289297
constructor = Some idbuild.v;
290298
fields = cfs;
291-
univpoly = univpoly_of ~poly ~cumulative
299+
univpoly = univpoly_of_flags flags
292300
}
293301

294302
let intern_record_decl glob_sign (it : raw_record_decl) = glob_sign, it
@@ -461,6 +469,16 @@ let raw_decl_name_to_glob name =
461469

462470
let interp_red_expr = Redexpr.interp_redexp_no_ltac
463471

472+
[%%if coq = "9.0" || coq = "9.1"]
473+
let interp_definition ~program_mode poly = ComDefinition.interp_definition ~program_mode
474+
let interp_assumption ~program_mode poly = ComAssumption.interp_assumption ~program_mode
475+
[%%else]
476+
let interp_definition ~program_mode poly =
477+
ComDefinition.interp_definition ~program_mode ~poly:(PolyFlags.of_univ_poly poly)
478+
let interp_assumption ~program_mode poly =
479+
ComAssumption.interp_assumption ~program_mode ~poly:(PolyFlags.of_univ_poly poly)
480+
[%%endif]
481+
464482
let raw_constant_decl_to_constr ~depth coq_ctx state { name; typ = (bl,typ); body; red; udecl; atts } =
465483
let env = coq_ctx.env in
466484
let poly =
@@ -482,7 +500,7 @@ let raw_constant_decl_to_constr ~depth coq_ctx state { name; typ = (bl,typ); bod
482500
| Some body, _ ->
483501
let sigma, red = option_map_acc (interp_red_expr env) sigma red in
484502
let sigma, (body, typ), impargs =
485-
ComDefinition.interp_definition ~program_mode:false
503+
interp_definition ~program_mode:false poly
486504
env sigma Constrintern.empty_internalization_env bl red body typ
487505
in
488506
let state, gls0 = set_current_sigma ~depth state sigma in
@@ -491,7 +509,7 @@ let raw_constant_decl_to_constr ~depth coq_ctx state { name; typ = (bl,typ); bod
491509
| None, Some typ ->
492510
assert(red = None);
493511
let sigma, typ, impargs =
494-
ComAssumption.interp_assumption ~program_mode:false
512+
interp_assumption ~program_mode:false poly
495513
env sigma Constrintern.empty_internalization_env bl typ in
496514
let state, gls0 = set_current_sigma ~depth state sigma in
497515
state, udecl, typ, None, gls0

src/rocq_elpi_builtins.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,15 @@ let empty_ctxset = Univ.ContextSet.empty
359359
let univ_csts_to_list = Univ.Constraints.elements
360360
let univs_of_csts = UState.constraints
361361
let ucsts_filter = Univ.Constraints.filter
362+
let default_polyflags = false
362363
[%%else]
363364
let evd_merge_sort_context_set rigid = Evd.merge_sort_context_set rigid QGraph.Internal
364365
let check_univ_decl = UState.check_univ_decl
365366
let empty_ctxset = PConstraints.ContextSet.empty
366367
let univ_csts_to_list = Univ.UnivConstraints.elements
367368
let univs_of_csts x = PConstraints.univs @@ UState.constraints x
368369
let ucsts_filter = Univ.UnivConstraints.filter
370+
let default_polyflags = PolyFlags.default
369371
[%%endif]
370372

371373
let handle_uinst_option_for_inductive ~depth options i state =
@@ -987,6 +989,13 @@ let get_entry_context = function
987989
| UState.Monomorphic_entry x, _ -> x
988990
| _ -> Univ.ContextSet.empty
989991

992+
[%%if coq = "9.0" || coq = "9.1"]
993+
let make_polyflags poly cumul = poly
994+
[%%else]
995+
let make_polyflags poly cumul =
996+
PolyFlags.make ~univ_poly:poly ~cumulative:cumul ~collapse_sort_variables:true
997+
[%%endif]
998+
990999
let declare_definition _ using ~cinfo ~info ~opaque ~body sigma =
9911000
let using = Option.map Proof_using.using_from_string using in
9921001
let (kn, uctx) = Declare.declare_definition_full ~cinfo ~info ~opaque ~body ?using sigma in
@@ -1002,7 +1011,7 @@ let add_axiom_or_variable api id ty local_bkind options state =
10021011
err Pp.(str api ++ str": unsupported attribute @udecl-cumul! or @univpoly-cumul!");
10031012
if poly && Option.has_some local_bkind then
10041013
err Pp.(str api ++ str": section variables cannot be universe polymorphic");
1005-
let univs = check_univ_decl (Evd.ustate sigma) udecl ~poly in
1014+
let univs = check_univ_decl (Evd.ustate sigma) udecl ~poly:(make_polyflags poly cumul) in
10061015
let kind = Decls.Logical in
10071016
let impargs = [] in
10081017
let loc = to_coq_loc @@ State.get Rocq_elpi_builtins_synterp.invocation_site_loc state in
@@ -2266,7 +2275,7 @@ Supported attributes:
22662275
let hook = Declare.Hook.make (fun { Declare.Hook.S.uctx = x } -> uctx := Some (UState.context_set x)) in
22672276
(* End hack *)
22682277

2269-
let info = Declare.Info.make ~scope ~kind ~poly ~udecl ~hook () in
2278+
let info = Declare.Info.make ~scope ~kind ~poly:(make_polyflags poly cumul) ~udecl ~hook () in
22702279

22712280
let used =
22722281
Univ.Level.Set.union
@@ -4062,7 +4071,7 @@ Supported attributes:
40624071
let pv =
40634072
let vernac_state = Vernacstate.freeze_full_state () in
40644073
try
4065-
let rc = apply_proof ~name:(Id.of_string "elpi") ~poly:false proof_context.env focused_tac pv in
4074+
let rc = apply_proof ~name:(Id.of_string "elpi") ~poly:default_polyflags proof_context.env focused_tac pv in
40664075
let pstate = Vernacstate.Stm.pstate (Vernacstate.freeze_full_state ()) in
40674076
let vernac_state = Vernacstate.Stm.set_pstate vernac_state pstate in
40684077
Vernacstate.unfreeze_full_state vernac_state;

src/rocq_elpi_vernacular.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ let execution proof p loc0 args loc1 ?loc ~atts () =
748748
| _ -> Vernactypes.vtdefault (fun () -> Interp.run_program ~loc p ~atts ~syndata args)
749749
[%%else]
750750
let classifier proof _loc0 _args _loc1 ~atts =
751-
let open Vernac_classifier in
752751
match proof with
753752
| Some (Begin None) -> Vernacextend.(VtStartProof (Doesn'tGuaranteeOpacity,[]))
754753
| Some (Begin (Some a)) when has_att a atts -> Vernacextend.(VtStartProof (Doesn'tGuaranteeOpacity,[]))

0 commit comments

Comments
 (0)