Skip to content

Commit 0e58667

Browse files
authored
Merge pull request #123 from SkySkimmer/erelevance
Adapt to rocq-prover/rocq#18938 (EConstr.ERelevance)
2 parents a31475c + faae4dc commit 0e58667

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/debug.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ open Names
1313
open EConstr
1414
open Pp
1515

16-
let toCDecl old : (Constr.constr, Constr.constr) Context.Rel.Declaration.pt =
16+
let toCDecl old : Constr.rel_declaration =
1717
let (name,value,typ) = old in
1818
match value with
1919
| Some value -> Context.Rel.Declaration.LocalDef (name,value,typ)
@@ -25,7 +25,7 @@ let toDecl old : rel_declaration =
2525
| Some value -> Context.Rel.Declaration.LocalDef (name,value,typ)
2626
| None -> Context.Rel.Declaration.LocalAssum (name,typ)
2727

28-
let fromDecl (n: ('a, 'b) Context.Rel.Declaration.pt) =
28+
let fromDecl (n: _ Context.Rel.Declaration.pt) =
2929
match n with
3030
| Context.Rel.Declaration.LocalDef (name,value,typ) -> (name,Some value,typ)
3131
| Context.Rel.Declaration.LocalAssum (name,typ) -> (name,None,typ)

src/parametricity.ml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ let rec relation order evd env (t : constr) : constr =
291291
debug [`Relation] "input =" env !evd t;
292292
let res = match kind !evd t with
293293
| Sort s ->
294-
let r = Retyping.relevance_of_sort !evd s in
294+
let r = Retyping.relevance_of_sort s in
295295
fold_nat (fun _ -> mkArrow (mkRel order) r) (prop_or_type env evd t) order
296296
| Prod (x, a, b) ->
297297
let x = Context.map_annot (Namegen.named_hd env !evd a) x in
@@ -335,7 +335,7 @@ let rec relation order evd env (t : constr) : constr =
335335
debug_mode := false;
336336
let env_R = translate_env order evd env in
337337
let na = Namegen.named_hd env !evd t Anonymous in
338-
let lams = range (fun k -> (Context.make_annot (prime_name order k na) Sorts.Relevant, None, lift k (prime !evd order k t))) order in
338+
let lams = range (fun k -> (Context.make_annot (prime_name order k na) ERelevance.relevant, None, lift k (prime !evd order k t))) order in
339339
let env_R = push_rel_context (List.map toDecl lams) env_R in
340340
debug_mode := true;
341341
debug [`Relation] "output =" env_R !evd res;
@@ -355,7 +355,7 @@ and translate order evd env (t : constr) : constr =
355355
| Sort _ | Prod (_,_,_) ->
356356
(* [..., _ : t'', _ : t', _ : t] *)
357357
let na = Namegen.named_hd env !evd t Anonymous in
358-
let lams = range (fun k -> (Context.make_annot (prime_name order k na) Sorts.Relevant, lift k (prime !evd order k t))) order in
358+
let lams = range (fun k -> (Context.make_annot (prime_name order k na) ERelevance.relevant, lift k (prime !evd order k t))) order in
359359
compose_lam lams (relation order evd env t)
360360

361361
| App (c,l) ->
@@ -477,7 +477,7 @@ and translate_constant order (evd : Evd.evar_map ref) env cst : constr =
477477
let etyp = of_constr typ in
478478
let edef = of_constr def in
479479
let na = Namegen.named_hd env !evd etyp Anonymous in
480-
let pred = mkLambda (Context.make_annot na Sorts.Relevant, etyp, substl (range (fun _ -> mkRel 1) order) (relation order evd env etyp)) in
480+
let pred = mkLambda (Context.make_annot na ERelevance.relevant, etyp, substl (range (fun _ -> mkRel 1) order) (relation order evd env etyp)) in
481481
let res = translate order evd env edef in
482482
let uf_opaque_stmt = CoqConstants.eq env evd [| etyp; edef; fold|] in
483483
let evd', sort = Typing.sort_of env !evd etyp in
@@ -895,7 +895,7 @@ and rewrite_fixpoints order evdr env (depth : int) (fix : fixpoint) source targe
895895
let env_R =
896896
if List.exists (fun x -> List.mem x [`Fix]) debug_flag then begin
897897
let env_R = translate_env order evdr env in
898-
let rc_order = rev_range (fun k -> Context.make_annot (Name (Id.of_string (Printf.sprintf "rel_%d" k))) Sorts.Relevant, None,
898+
let rc_order = rev_range (fun k -> Context.make_annot (Name (Id.of_string (Printf.sprintf "rel_%d" k))) ERelevance.relevant, None,
899899
lift k (prime !evdr order k typ)) order in
900900
let env_R' = push_rel_context (List.map toDecl rc_order) env_R in
901901
debug [`Fix] "typ_R =" env_R' !evdr typ_R;
@@ -920,9 +920,9 @@ and rewrite_fixpoints order evdr env (depth : int) (fix : fixpoint) source targe
920920
debug [`Fix] "gen_path_type" Environ.empty_env !evdr gen_path_type;
921921
let evd, hole = new_evar_compat Environ.empty_env !evdr gen_path_type in
922922
evdr := evd;
923-
let let_gen acc = mkLetIn (Context.make_annot (Name (Id.of_string "gen_path")) Sorts.Relevant, hole, gen_path_type, acc) in
923+
let let_gen acc = mkLetIn (Context.make_annot (Name (Id.of_string "gen_path")) ERelevance.relevant, hole, gen_path_type, acc) in
924924
let env_R' =
925-
let decl_gen_path = Context.Rel.Declaration.LocalDef (Context.make_annot (Name (Id.of_string "gen_path")) Sorts.Relevant,hole,gen_path_type) in
925+
let decl_gen_path = Context.Rel.Declaration.LocalDef (Context.make_annot (Name (Id.of_string "gen_path")) ERelevance.relevant,hole,gen_path_type) in
926926
push_rel decl_gen_path env_R in
927927
let res1 =
928928
(fold_nat (fun k acc ->
@@ -1029,7 +1029,7 @@ and rewrite_cofixpoints order evdr env (depth : int) (fix : cofixpoint) source t
10291029
debug [`Fix] "gen_path_type" env !evdr gen_path;
10301030
let evd, hole = new_evar_compat Environ.empty_env !evdr gen_path in
10311031
evdr := evd;
1032-
let let_gen acc = mkLetIn (mkannot (Name (Id.of_string "gen_path")) Sorts.Relevant, hole, gen_path, acc) in
1032+
let let_gen acc = mkLetIn (mkannot (Name (Id.of_string "gen_path")) ERelevance.relevant, hole, gen_path, acc) in
10331033
let_gen @@ (fold_nat (fun k acc ->
10341034
let pred_sub =
10351035
(range (fun x -> lift 1 (prime evd order (k+1+x) target)) (order-1 - k))
@@ -1074,7 +1074,7 @@ let rec translate_mind_body name order evdr env kn b inst =
10741074
let full_arity, cst =
10751075
Inductive.constrained_type_of_inductive ((b, ind), inst)
10761076
in
1077-
let r = ind.mind_relevance in
1077+
let r = ERelevance.make ind.mind_relevance in
10781078
let env = push_rel (toDecl (mkannot (Names.Name typename) r, None, (of_constr full_arity))) env in
10791079
let env = Environ.add_constraints cst env in
10801080
env
@@ -1118,16 +1118,10 @@ let rec translate_mind_body name order evdr env kn b inst =
11181118
res
11191119

11201120

1121-
and translate_mind_param order evd env (l : (Constr.constr, Constr.constr) Context.Rel.pt) =
1122-
let ctoe c =
1123-
let x, def, typ = fromDecl c in
1124-
toDecl (x, Option.map of_constr def, of_constr typ) in
1125-
let etoc c =
1126-
let x, def, typ = fromDecl c in
1127-
toCDecl (x, Option.map (to_constr !evd) def, to_constr !evd typ) in
1128-
let l = List.map ctoe l in
1121+
and translate_mind_param order evd env (l : Constr.rel_context) =
1122+
let l = of_rel_context l in
11291123
let l = translate_rel_context order evd env l in
1130-
List.map etoc l
1124+
List.map (to_rel_decl !evd) l
11311125

11321126
and translate_mind_inductive name order evdr env ikn mut_entry inst (env_params, params, env_arities, env_arities_params) e =
11331127
let p = List.length mut_entry.mind_params_ctxt in

0 commit comments

Comments
 (0)