aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2019-06-25 17:26:44 +0200
committerPierre-Marie Pédrot2019-06-25 17:26:44 +0200
commit7dfcb0f7c817e66280ab37b6c653b5596a16c249 (patch)
treef59cbad4ef2e56070fe32fefcc5f7a3f8c6b7a4a /plugins
parent7024688c4e20fa7b70ac1c550c166d02fce8d15c (diff)
parentc2abcaefd796b7f430f056884349b9d959525eec (diff)
Merge PR #10316: [lemmas] Reify info for implicits, universe decls, and rec theorems.
Reviewed-by: SkySkimmer Ack-by: ejgallego Reviewed-by: gares Reviewed-by: ppedrot
Diffstat (limited to 'plugins')
-rw-r--r--plugins/derive/derive.ml7
-rw-r--r--plugins/funind/functional_principles_proofs.ml13
-rw-r--r--plugins/funind/functional_principles_types.ml22
-rw-r--r--plugins/funind/g_indfun.mlg2
-rw-r--r--plugins/funind/glob_term_to_relation.ml2
-rw-r--r--plugins/funind/indfun.ml8
-rw-r--r--plugins/funind/indfun_common.ml4
-rw-r--r--plugins/funind/indfun_common.mli3
-rw-r--r--plugins/funind/invfun.ml24
-rw-r--r--plugins/funind/recdef.ml21
-rw-r--r--plugins/ltac/extratactics.mlg2
-rw-r--r--plugins/ltac/rewrite.ml12
-rw-r--r--plugins/setoid_ring/newring.ml2
13 files changed, 72 insertions, 50 deletions
diff --git a/plugins/derive/derive.ml b/plugins/derive/derive.ml
index 72ca5dc8c4..e34150f2b3 100644
--- a/plugins/derive/derive.ml
+++ b/plugins/derive/derive.ml
@@ -19,7 +19,8 @@ let start_deriving f suchthat name : Lemmas.t =
let env = Global.env () in
let sigma = Evd.from_env env in
- let kind = Decl_kinds.(Global ImportDefaultBehavior,false,DefinitionBody Definition) in
+ let poly = false in
+ let kind = Decl_kinds.(DefinitionBody Definition) in
(* create a sort variable for the type of [f] *)
(* spiwack: I don't know what the rigidity flag does, picked the one
@@ -39,8 +40,8 @@ let start_deriving f suchthat name : Lemmas.t =
TNil sigma))))))
in
- let proof_ending = Lemmas.Proof_ending.(End_derive {f; name}) in
- let lemma = Lemmas.start_dependent_lemma name kind goals ~proof_ending in
+ let info = Lemmas.Info.make ~proof_ending:(Lemmas.Proof_ending.(End_derive {f; name})) ~kind () in
+ let lemma = Lemmas.start_dependent_lemma ~name ~poly ~info goals in
Lemmas.pf_map (Proof_global.map_proof begin fun p ->
Util.pi1 @@ Proof.run_tactic env Proofview.(tclFOCUS 1 2 shelve) p
end) lemma
diff --git a/plugins/funind/functional_principles_proofs.ml b/plugins/funind/functional_principles_proofs.ml
index ce3b5a82d6..a904b81d81 100644
--- a/plugins/funind/functional_principles_proofs.ml
+++ b/plugins/funind/functional_principles_proofs.ml
@@ -990,14 +990,19 @@ let generate_equation_lemma evd fnames f fun_num nb_params nb_args rec_args_num
]
in
(* Pp.msgnl (str "lemma type (2) " ++ Printer.pr_lconstr_env (Global.env ()) evd lemma_type); *)
+ let info = Lemmas.Info.make
+ ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior)
+ ~kind:(Decl_kinds.Proof Decl_kinds.Theorem) () in
+
let lemma = Lemmas.start_lemma
(*i The next call to mk_equation_id is valid since we are constructing the lemma
Ensures by: obvious
i*)
- (mk_equation_id f_id)
- Decl_kinds.(Global ImportDefaultBehavior, false, Proof Theorem)
- evd
- lemma_type
+ ~name:(mk_equation_id f_id)
+ ~poly:false
+ ~info
+ evd
+ lemma_type
in
let lemma,_ = Lemmas.by (Proofview.V82.tactic prove_replacement) lemma in
let () = Lemmas.save_lemma_proved ?proof:None ~lemma ~opaque:Proof_global.Transparent ~idopt:None in
diff --git a/plugins/funind/functional_principles_types.ml b/plugins/funind/functional_principles_types.ml
index d49d657d38..edda2f2eef 100644
--- a/plugins/funind/functional_principles_types.ml
+++ b/plugins/funind/functional_principles_types.ml
@@ -309,8 +309,8 @@ let build_functional_principle (evd:Evd.evar_map ref) interactive_proof old_prin
let hook = DeclareDef.Hook.make (hook new_principle_type) in
let lemma =
Lemmas.start_lemma
- new_princ_name
- Decl_kinds.(Global ImportDefaultBehavior,false,Proof Theorem)
+ ~name:new_princ_name
+ ~poly:false
!evd
(EConstr.of_constr new_principle_type)
in
@@ -324,10 +324,10 @@ let build_functional_principle (evd:Evd.evar_map ref) interactive_proof old_prin
(* end; *)
let open Proof_global in
- let { id; entries; persistence } = Lemmas.pf_fold (close_proof ~opaque:Transparent ~keep_body_ucst_separate:false (fun x -> x)) lemma in
+ let { name; entries } = Lemmas.pf_fold (close_proof ~opaque:Transparent ~keep_body_ucst_separate:false (fun x -> x)) lemma in
match entries with
| [entry] ->
- (id,(entry,persistence)), hook
+ name, entry, hook
| _ ->
CErrors.anomaly Pp.(str "[build_functional_principle] close_proof returned more than one proof term")
@@ -379,7 +379,7 @@ let generate_functional_principle (evd: Evd.evar_map ref)
register_with_sort InProp;
register_with_sort InSet
in
- let ((id,(entry,g_kind)),hook) =
+ let id,entry,hook =
build_functional_principle evd interactive_proof old_princ_type new_sorts funs i
proof_tac hook
in
@@ -387,7 +387,7 @@ let generate_functional_principle (evd: Evd.evar_map ref)
Don't forget to close the goal if an error is raised !!!!
*)
let uctx = Evd.evar_universe_context sigma in
- save new_princ_name entry ~hook uctx g_kind
+ save new_princ_name entry ~hook uctx (DeclareDef.Global Declare.ImportDefaultBehavior) Decl_kinds.(Proof Theorem)
with e when CErrors.noncritical e ->
raise (Defining_principle e)
@@ -518,7 +518,7 @@ let make_scheme evd (fas : (pconstant*Sorts.family) list) : Evd.side_effects Pro
s::l_schemes -> s,l_schemes
| _ -> anomaly (Pp.str "")
in
- let ((_,(const,_)),_) =
+ let _,const,_ =
try
build_functional_principle evd false
first_type
@@ -576,10 +576,10 @@ let make_scheme evd (fas : (pconstant*Sorts.family) list) : Evd.side_effects Pro
)
ta;
- (* If we reach this point, the two principle are not mutually recursive
- We fall back to the previous method
- *)
- let ((_,(const,_)),_) =
+ (* If we reach this point, the two principle are not mutually recursive
+ We fall back to the previous method
+ *)
+ let _,const,_ =
build_functional_principle
evd
false
diff --git a/plugins/funind/g_indfun.mlg b/plugins/funind/g_indfun.mlg
index ef9d91c7fa..e20d010c71 100644
--- a/plugins/funind/g_indfun.mlg
+++ b/plugins/funind/g_indfun.mlg
@@ -182,7 +182,7 @@ let is_proof_termination_interactively_checked recsl =
let classify_as_Fixpoint recsl =
Vernac_classifier.classify_vernac
- (Vernacexpr.(CAst.make @@ VernacExpr([], VernacFixpoint(Decl_kinds.NoDischarge, List.map snd recsl))))
+ (Vernacexpr.(CAst.make @@ VernacExpr([], VernacFixpoint(NoDischarge, List.map snd recsl))))
let classify_funind recsl =
match classify_as_Fixpoint recsl with
diff --git a/plugins/funind/glob_term_to_relation.ml b/plugins/funind/glob_term_to_relation.ml
index 201d953692..bb4e745fe9 100644
--- a/plugins/funind/glob_term_to_relation.ml
+++ b/plugins/funind/glob_term_to_relation.ml
@@ -1506,7 +1506,7 @@ let do_build_inductive
let _time2 = System.get_time () in
try
with_full_print
- (Flags.silently (ComInductive.do_mutual_inductive ~template:(Some false) None rel_inds false false false ~uniform:ComInductive.NonUniformParameters))
+ (Flags.silently (ComInductive.do_mutual_inductive ~template:(Some false) None rel_inds false ~poly:false false ~uniform:ComInductive.NonUniformParameters))
Declarations.Finite
with
| UserError(s,msg) as e ->
diff --git a/plugins/funind/indfun.ml b/plugins/funind/indfun.ml
index 0ecfbacb09..d305a58ccc 100644
--- a/plugins/funind/indfun.ml
+++ b/plugins/funind/indfun.ml
@@ -416,8 +416,10 @@ let register_struct is_rec (fixpoint_exprl:(Vernacexpr.fixpoint_expr * Vernacexp
let body = match body with | Some body -> body | None -> user_err ~hdr:"Function" (str "Body of Function must be given") in
ComDefinition.do_definition
~program_mode:false
- fname
- Decl_kinds.(Global ImportDefaultBehavior,false,Definition) pl
+ ~name:fname
+ ~poly:false
+ ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior)
+ ~kind:Decl_kinds.Definition pl
bl None body (Some ret_type);
let evd,rev_pconstants =
List.fold_left
@@ -434,7 +436,7 @@ let register_struct is_rec (fixpoint_exprl:(Vernacexpr.fixpoint_expr * Vernacexp
in
None, evd,List.rev rev_pconstants
| _ ->
- ComFixpoint.do_fixpoint (Global ImportDefaultBehavior) false fixpoint_exprl;
+ ComFixpoint.do_fixpoint ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior) ~poly:false fixpoint_exprl;
let evd,rev_pconstants =
List.fold_left
(fun (evd,l) ((({CAst.v=fname},_),_,_,_,_),_) ->
diff --git a/plugins/funind/indfun_common.ml b/plugins/funind/indfun_common.ml
index 17c79e0e6c..254760cb50 100644
--- a/plugins/funind/indfun_common.ml
+++ b/plugins/funind/indfun_common.ml
@@ -118,12 +118,12 @@ let refl_equal = lazy(EConstr.of_constr (coq_constant "eq_refl"))
(* Copy of the standard save mechanism but without the much too *)
(* slow reduction function *)
(*****************************************************************)
-open Decl_kinds
open Declare
+open DeclareDef
let definition_message = Declare.definition_message
-let save id const ?hook uctx (locality,_,kind) =
+let save id const ?hook uctx locality kind =
let fix_exn = Future.fix_exn_of const.Proof_global.proof_entry_body in
let r = match locality with
| Discharge ->
diff --git a/plugins/funind/indfun_common.mli b/plugins/funind/indfun_common.mli
index 1d096fa488..45d332031f 100644
--- a/plugins/funind/indfun_common.mli
+++ b/plugins/funind/indfun_common.mli
@@ -47,7 +47,8 @@ val save
-> Evd.side_effects Proof_global.proof_entry
-> ?hook:DeclareDef.Hook.t
-> UState.t
- -> Decl_kinds.goal_kind
+ -> DeclareDef.locality
+ -> Decl_kinds.goal_object_kind
-> unit
(* [with_full_print f a] applies [f] to [a] in full printing environment.
diff --git a/plugins/funind/invfun.ml b/plugins/funind/invfun.ml
index 2020881c7c..587e1fc2e8 100644
--- a/plugins/funind/invfun.ml
+++ b/plugins/funind/invfun.ml
@@ -803,11 +803,15 @@ let derive_correctness make_scheme (funs: pconstant list) (graphs:inductive list
i*)
let lem_id = mk_correct_id f_id in
let (typ,_) = lemmas_types_infos.(i) in
+ let info = Lemmas.Info.make
+ ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior)
+ ~kind:(Decl_kinds.Proof Decl_kinds.Theorem) () in
let lemma = Lemmas.start_lemma
- lem_id
- Decl_kinds.(Global ImportDefaultBehavior,false,Proof Theorem)
- !evd
- typ in
+ ~name:lem_id
+ ~poly:false
+ ~info
+ !evd
+ typ in
let lemma = fst @@ Lemmas.by
(Proofview.V82.tactic (observe_tac ("prove correctness ("^(Id.to_string f_id)^")")
(proving_tac i))) lemma in
@@ -865,12 +869,14 @@ let derive_correctness make_scheme (funs: pconstant list) (graphs:inductive list
Ensures by: obvious
i*)
let lem_id = mk_complete_id f_id in
- let lemma = Lemmas.start_lemma lem_id
- Decl_kinds.(Global ImportDefaultBehavior,false,Proof Theorem) sigma
- (fst lemmas_types_infos.(i)) in
+ let info = Lemmas.Info.make
+ ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior)
+ ~kind:Decl_kinds.(Proof Theorem) () in
+ let lemma = Lemmas.start_lemma ~name:lem_id ~poly:false ~info
+ sigma (fst lemmas_types_infos.(i)) in
let lemma = fst (Lemmas.by
- (Proofview.V82.tactic (observe_tac ("prove completeness ("^(Id.to_string f_id)^")")
- (proving_tac i))) lemma) in
+ (Proofview.V82.tactic (observe_tac ("prove completeness ("^(Id.to_string f_id)^")")
+ (proving_tac i))) lemma) in
let () = Lemmas.save_lemma_proved ?proof:None ~lemma ~opaque:Proof_global.Transparent ~idopt:None in
let finfo = find_Function_infos (fst f_as_constant) in
let _,lem_cst_constr = Evd.fresh_global
diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml
index 2647e7449b..425e498330 100644
--- a/plugins/funind/recdef.ml
+++ b/plugins/funind/recdef.ml
@@ -1367,10 +1367,13 @@ let open_new_goal ~lemma build_proof sigma using_lemmas ref_ goal_name (gls_type
in
Lemmas.save_lemma_proved ?proof:None ~lemma ~opaque:opacity ~idopt:None
in
+ let info = Lemmas.Info.make ~hook:(DeclareDef.Hook.make hook)
+ ~scope:(DeclareDef.Global Declare.ImportDefaultBehavior) ~kind:(Decl_kinds.Proof Decl_kinds.Lemma)
+ () in
let lemma = Lemmas.start_lemma
- na
- Decl_kinds.(Global ImportDefaultBehavior, false (* FIXME *), Proof Lemma)
- sigma gls_type ~hook:(DeclareDef.Hook.make hook) in
+ ~name:na
+ ~poly:false (* FIXME *) ~info
+ sigma gls_type in
let lemma = if Indfun_common.is_strict_tcc ()
then
fst @@ Lemmas.by (Proofview.V82.tactic (tclIDTAC)) lemma
@@ -1408,9 +1411,13 @@ let com_terminate
nb_args ctx
hook =
let start_proof env ctx (tac_start:tactic) (tac_end:tactic) =
- let lemma = Lemmas.start_lemma thm_name
- (Global ImportDefaultBehavior, false (* FIXME *), Proof Lemma) ~sign:(Environ.named_context_val env)
- ctx (EConstr.of_constr (compute_terminate_type nb_args fonctional_ref)) ~hook in
+ let info = Lemmas.Info.make ~hook ~scope:(DeclareDef.Global ImportDefaultBehavior) ~kind:(Proof Lemma) () in
+ let lemma = Lemmas.start_lemma ~name:thm_name
+ ~poly:false (*FIXME*)
+ ~sign:(Environ.named_context_val env)
+ ~info
+ ctx
+ (EConstr.of_constr (compute_terminate_type nb_args fonctional_ref)) in
let lemma = fst @@ Lemmas.by (Proofview.V82.tactic (observe_tac (fun _ _ -> str "starting_tac") tac_start)) lemma in
fst @@ Lemmas.by (Proofview.V82.tactic (observe_tac (fun _ _ -> str "whole_start") (whole_start tac_end nb_args is_mes fonctional_ref
input_type relation rec_arg_num ))) lemma
@@ -1455,7 +1462,7 @@ let com_eqn sign uctx nb_arg eq_name functional_ref f_ref terminate_ref equation
let evd = Evd.from_ctx uctx in
let f_constr = constr_of_monomorphic_global f_ref in
let equation_lemma_type = subst1 f_constr equation_lemma_type in
- let lemma = Lemmas.start_lemma eq_name (Global ImportDefaultBehavior, false, Proof Lemma) ~sign evd
+ let lemma = Lemmas.start_lemma ~name:eq_name ~poly:false ~sign evd
(EConstr.of_constr equation_lemma_type) in
let lemma = fst @@ Lemmas.by
(Proofview.V82.tactic (start_equation f_ref terminate_ref
diff --git a/plugins/ltac/extratactics.mlg b/plugins/ltac/extratactics.mlg
index 49d8ab4e23..1e2b23bf96 100644
--- a/plugins/ltac/extratactics.mlg
+++ b/plugins/ltac/extratactics.mlg
@@ -328,7 +328,7 @@ let add_rewrite_hint ~poly bases ort t lcsr =
if poly then ctx
else (* This is a global universe context that shouldn't be
refreshed at every use of the hint, declare it globally. *)
- (Declare.declare_universe_context false ctx;
+ (Declare.declare_universe_context ~poly:false ctx;
Univ.ContextSet.empty)
in
CAst.make ?loc:(Constrexpr_ops.constr_loc ce) ((c, ctx), ort, Option.map (in_gen (rawwit wit_ltac)) t) in
diff --git a/plugins/ltac/rewrite.ml b/plugins/ltac/rewrite.ml
index f977ba34d2..9d928232c6 100644
--- a/plugins/ltac/rewrite.ml
+++ b/plugins/ltac/rewrite.ml
@@ -1795,7 +1795,7 @@ let declare_an_instance n s args =
let declare_instance a aeq n s = declare_an_instance n s [a;aeq]
let anew_instance atts binders (name,t) fields =
- let _id = Classes.new_instance atts.polymorphic
+ let _id = Classes.new_instance ~poly:atts.polymorphic
name binders t (true, CAst.make @@ CRecord (fields))
~global:atts.global ~generalize:false Hints.empty_hint_info
in
@@ -1994,9 +1994,8 @@ let add_morphism_interactive atts m n : Lemmas.t =
let env = Global.env () in
let evd = Evd.from_env env in
let uctx, instance = build_morphism_signature env evd m in
- let kind = Decl_kinds.Global Decl_kinds.ImportDefaultBehavior, atts.polymorphic,
- Decl_kinds.DefinitionBody Decl_kinds.Instance
- in
+ let poly = atts.polymorphic in
+ let kind = Decl_kinds.DefinitionBody Decl_kinds.Instance in
let tac = make_tactic "Coq.Classes.SetoidTactics.add_morphism_tactic" in
let hook _ _ _ = function
| Globnames.ConstRef cst ->
@@ -2007,9 +2006,10 @@ let add_morphism_interactive atts m n : Lemmas.t =
| _ -> assert false
in
let hook = DeclareDef.Hook.make hook in
+ let info = Lemmas.Info.make ~hook ~kind () in
Flags.silently
(fun () ->
- let lemma = Lemmas.start_lemma ~hook instance_id kind (Evd.from_ctx uctx) (EConstr.of_constr instance) in
+ let lemma = Lemmas.start_lemma ~name:instance_id ~poly ~info (Evd.from_ctx uctx) (EConstr.of_constr instance) in
fst (Lemmas.by (Tacinterp.interp tac) lemma)) ()
let add_morphism atts binders m s n =
@@ -2023,7 +2023,7 @@ let add_morphism atts binders m s n =
in
let tac = Tacinterp.interp (make_tactic "add_morphism_tactic") in
let _id, lemma = Classes.new_instance_interactive
- ~global:atts.global atts.polymorphic
+ ~global:atts.global ~poly:atts.polymorphic
instance_name binders instance_t
~generalize:false ~tac ~hook:(declare_projection n instance_id) Hints.empty_hint_info
in
diff --git a/plugins/setoid_ring/newring.ml b/plugins/setoid_ring/newring.ml
index 9bbe339770..33798c43c8 100644
--- a/plugins/setoid_ring/newring.ml
+++ b/plugins/setoid_ring/newring.ml
@@ -153,7 +153,7 @@ let decl_constant na univs c =
let open Constr in
let vars = CVars.universes_of_constr c in
let univs = UState.restrict_universe_context univs vars in
- let () = Declare.declare_universe_context false univs in
+ let () = Declare.declare_universe_context ~poly:false univs in
let types = (Typeops.infer (Global.env ()) c).uj_type in
let univs = Monomorphic_entry Univ.ContextSet.empty in
mkConst(declare_constant (Id.of_string na)