Skip to content

Commit fea4334

Browse files
committed
Modify name of induction scheme hypotheses
1 parent 90e3b7e commit fea4334

File tree

9 files changed

+97
-92
lines changed

9 files changed

+97
-92
lines changed

pretyping/indrec.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ let mis_make_case_com dep env sigma (ind, u as pind) (mib, mip) s =
203203
else
204204
let cs = lift_constructor (k+1) constrs.(k) in
205205
let t = build_branch_type !!env sigma dep (mkRel (k+1)) cs in
206-
let namef = make_name env "f" relevance in
207-
let decl = LocalAssum (namef, t) in
206+
let branch_name = make_annot (Name cs.cs_name) relevance in
207+
let decl = LocalAssum (branch_name, t) in
208208
get_branches (RelEnv.push_rel decl env) (k + 1) (decl :: accu)
209209
in
210210

@@ -589,9 +589,9 @@ let mis_make_indrec env sigma ?(force_mutual=false) listdepkind mib u =
589589
true dep !!env !evdref (vargs,depPvec,i+j) indi cs recarg
590590
in
591591
let r_0 = Retyping.relevance_of_sort sfam in
592-
let namef = make_name env "f" r_0 in
593-
mkLambda (namef, p_0,
594-
(onerec (RelEnv.push_rel (LocalAssum (namef,p_0)) env)) (j+1))
592+
let case_name = make_annot (Name cs.cs_name) r_0 in
593+
mkLambda (case_name, p_0,
594+
(onerec (RelEnv.push_rel (LocalAssum (case_name,p_0)) env)) (j+1))
595595
in onerec env 0
596596
| [] ->
597597
makefix i listdepkind

pretyping/inductiveops.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ let make_case_info env ind style =
376376
(*s Useful functions *)
377377

378378
type constructor_summary = {
379+
cs_name : Id.t;
379380
cs_cstr : constructor puniverses;
380381
cs_params : constr list;
381382
cs_nargs : int;
@@ -384,6 +385,7 @@ type constructor_summary = {
384385
}
385386

386387
let lift_constructor n cs = {
388+
cs_name = cs.cs_name;
387389
cs_cstr = cs.cs_cstr;
388390
cs_params = List.map (lift n) cs.cs_params;
389391
cs_nargs = cs.cs_nargs;
@@ -412,7 +414,9 @@ let get_constructor ((ind,u),mib,mip,params) j =
412414
let (args,ccl) = Term.decompose_prod_decls typi in
413415
let (_,allargs) = Constr.decompose_app_list ccl in
414416
let vargs = List.skipn (List.length params) allargs in
415-
{ cs_cstr = (ith_constructor_of_inductive ind j,u);
417+
let name = mip.mind_consnames.(j-1) in
418+
{ cs_name = name;
419+
cs_cstr = (ith_constructor_of_inductive ind j,u);
416420
cs_params = params;
417421
cs_nargs = Context.Rel.length args;
418422
cs_args = EConstr.of_rel_context args;

pretyping/inductiveops.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ val type_of_projection_knowing_arg : env -> evar_map -> Projection.t ->
158158
(** Extract information from an inductive family *)
159159

160160
type constructor_summary = {
161+
cs_name : Id.t; (* name of the constructor *)
161162
cs_cstr : constructor puniverses; (* internal name of the constructor plus universes *)
162163
cs_params : constr list; (* parameters of the constructor in current ctx *)
163164
cs_nargs : int; (* length of arguments signature (letin included) *)

proofs/clenv.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ and mk_arggoals ~metas env sigma goalacc funty allargs =
818818

819819
let treat_case env sigma ci lbrty accu =
820820
let open EConstr in
821-
let fold (sigma, accu) (ctx, ty) =
821+
let fold (sigma, accu) (name, ctx, ty) =
822822
let open Context.Rel.Declaration in
823823
let brctx = Array.of_list (List.rev_map get_annot ctx) in
824824
let args = Context.Rel.instance mkRel 0 ctx in
@@ -842,7 +842,7 @@ let std_refine ~metas env sigma cl r =
842842

843843
type refiner_kind =
844844
| Std of Meta.t * EConstr.t
845-
| Case of case_node * (EConstr.rel_context * EConstr.t) array
845+
| Case of case_node * (Id.t * EConstr.rel_context * EConstr.t) array
846846

847847
let refiner_gen is_case =
848848
let open Proofview.Notations in
@@ -1002,11 +1002,12 @@ let case_pf ?(with_evars=false) ~dep (indarg, typ) =
10021002
let get_branch cs =
10031003
let base = mkApp (pred, cs.cs_concl_realargs) in
10041004
let argctx = cs.cs_args in
1005+
let name = cs.cs_name in
10051006
if dep then
10061007
let argctx = Namegen.name_context env sigma argctx in
1007-
(argctx, applist (base, [build_dependent_constructor cs]))
1008+
(name, argctx, applist (base, [build_dependent_constructor cs]))
10081009
else
1009-
(argctx, base)
1010+
(name, argctx, base)
10101011
in
10111012
Array.map get_branch constrs
10121013
in
@@ -1032,7 +1033,7 @@ let case_pf ?(with_evars=false) ~dep (indarg, typ) =
10321033
Internal.Case ((ci, u, pms, (p,r), iv, c), branches)
10331034
| PrimitiveEta args ->
10341035
let mv = new_meta () in
1035-
let (ctx, t) = branches.(0) in
1036+
let (_, ctx, t) = branches.(0) in
10361037
let metas = Meta.meta_declare mv (it_mkProd_or_LetIn t ctx) metas in
10371038
Internal.Std (metas, mkApp (mkMeta mv, Array.map nf_betaiota args))
10381039
in

test-suite/output/Cases.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
t_rect =
2-
fun (P : t -> Type) (f : let x := t in forall x0 : x, P x0 -> P (k x0)) =>
2+
fun (P : t -> Type) (k : let x := t in forall x0 : x, P x0 -> P (k x0)) =>
33
fix F (t : t) : P t :=
44
match t as t0 return (P t0) with
5-
| k _ x0 => f x0 (F x0)
5+
| k _ x0 => k x0 (F x0)
66
end
77
: forall P : t -> Type,
88
(let x := t in forall x0 : x, P x0 -> P (k x0)) -> forall t : t, P t
99

10-
Arguments t_rect (P f)%_function_scope t
10+
Arguments t_rect (P k)%_function_scope t
1111
= fun d : TT => match d with
1212
| {| f3 := b |} => b
1313
end

test-suite/output/PrintInfos.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Alias.eq_ind :
127127
forall [A : Type] (x : A) (P : A -> Prop), P x -> forall y : A, x = y -> P y
128128

129129
Alias.eq_ind is not universe polymorphic
130-
Arguments Alias.eq_ind [A]%_type_scope x P%_function_scope f y e
130+
Arguments Alias.eq_ind [A]%_type_scope x P%_function_scope eq_refl y e
131131
(where some original arguments have been renamed)
132132
Alias.eq_ind is transparent
133133
Expands to: Constant PrintInfos.Alias.eq_ind (syntactically equal to

test-suite/output/PrintMatch.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
eqT_rect@{u u0} =
22
fun (A : Type@{u}) (a : A) (P : forall a0 : A, eqT@{u} a a0 -> Type@{u0})
3-
(f : P a (reflT@{u} a)) (a0 : A) (e : eqT@{u} a a0) =>
3+
(reflT : P a (reflT@{u} a)) (a0 : A) (e : eqT@{u} a a0) =>
44
match e :> eqT@{u} a _ as e0 in (eqT _ a1) return (P a1 e0) with
5-
| reflT _ => f
5+
| reflT _ => reflT
66
end
77
: forall (A : Type@{u}) (a : A)
88
(P : forall a0 : A, eqT@{u} a a0 -> Type@{u0}),
99
P a (reflT@{u} a) -> forall (a0 : A) (e : eqT@{u} a a0), P a0 e
1010
(* u u0 |= *)
1111

12-
Arguments eqT_rect A%_type_scope a P%_function_scope f a0 e
12+
Arguments eqT_rect A%_type_scope a P%_function_scope reflT a0 e
1313
seq_rect =
1414
fun (A : Type@{seq_rect.u1}) (a : A)
1515
(P : forall a0 : A, seq a a0 -> Type@{seq_rect.u0})
16-
(f : P a (srefl a)) (a0 : A) (s : seq a a0) =>
16+
(srefl : P a (srefl a)) (a0 : A) (s : seq a a0) =>
1717
match s :> seq a a0 as s0 in (seq _ a1) return (P a1 s0) with
18-
| srefl _ => f
18+
| srefl _ => srefl
1919
end
2020
: forall (A : Type@{seq_rect.u1}) (a : A)
2121
(P : forall a0 : A, seq a a0 -> Type@{seq_rect.u0}),
2222
P a (srefl a) -> forall (a0 : A) (s : seq a a0), P a0 s
2323

24-
Arguments seq_rect A%_type_scope a P%_function_scope f a0 s
24+
Arguments seq_rect A%_type_scope a P%_function_scope srefl a0 s
2525
eq_sym =
2626
fun (A : Type) (x y : A) (H : @eq A x y) =>
2727
match H in (@eq _ _ a) return (@eq A a x) with

0 commit comments

Comments
 (0)