From 54788df72ce79998ee27db362401a56bda4daceb Mon Sep 17 00:00:00 2001 From: Emilio Jesus Gallego Arias Date: Sun, 15 Mar 2020 17:52:16 -0400 Subject: [obligations] Functionalize Program state In our quest to unify all the declaration paths, an important step is to account for the state pertaining to `Program` declarations. Whereas regular proofs keep are kept in a stack-like structure; obligations for constants defined by `Program` are stored in a global map which is manipulated by almost regular open/close proof primitives. We make this manipulation explicit by handling the program state functionally, in a similar way than we already do for lemmas. This requires to extend the proof DSL a bit; but IMO changes are acceptable given the gain. Most of the PR is routine; only remarkable change is that the hook is called explicitly in `finish_admitted` as it had to learn about the different types of proof_endings. Note that we could have gone deeper and use the type system to refine the core proof type; IMO it is still too preliminary so it is better to do this step as an intermediate one towards a deeper unification. --- plugins/funind/functional_principles_proofs.ml | 6 ++++-- plugins/funind/gen_principle.ml | 10 ++++++---- plugins/funind/recdef.ml | 18 +++++++++++++----- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'plugins/funind') diff --git a/plugins/funind/functional_principles_proofs.ml b/plugins/funind/functional_principles_proofs.ml index 14d0c04212..b743329e7d 100644 --- a/plugins/funind/functional_principles_proofs.ml +++ b/plugins/funind/functional_principles_proofs.ml @@ -863,8 +863,10 @@ let generate_equation_lemma evd fnames f fun_num nb_params nb_args rec_args_num let lemma, _ = Declare.Proof.by (Proofview.V82.tactic prove_replacement) lemma in - let (_ : _ list) = - Declare.Proof.save ~proof:lemma ~opaque:Vernacexpr.Transparent ~idopt:None + let pm = Declare.OblState.empty in + let _pm, _ = + Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent + ~idopt:None in evd diff --git a/plugins/funind/gen_principle.ml b/plugins/funind/gen_principle.ml index ffce2f8c85..730cf42fe8 100644 --- a/plugins/funind/gen_principle.ml +++ b/plugins/funind/gen_principle.ml @@ -1526,8 +1526,9 @@ let derive_correctness (funs : Constr.pconstant list) (graphs : inductive list) let lemma = fst @@ Declare.Proof.by (Proofview.V82.tactic (proving_tac i)) lemma in - let (_ : GlobRef.t list) = - Declare.Proof.save ~proof:lemma ~opaque:Vernacexpr.Transparent + let pm = Declare.OblState.empty in + let _pm, _ = + Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent ~idopt:None in let finfo = @@ -1598,8 +1599,9 @@ let derive_correctness (funs : Constr.pconstant list) (graphs : inductive list) (proving_tac i))) lemma) in - let (_ : _ list) = - Declare.Proof.save ~proof:lemma ~opaque:Vernacexpr.Transparent + let pm = Declare.OblState.empty in + let _pm, _ = + Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent ~idopt:None in let finfo = diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml index 64f62ba1fb..7b00191026 100644 --- a/plugins/funind/recdef.ml +++ b/plugins/funind/recdef.ml @@ -58,8 +58,10 @@ let declare_fun name kind ?univs value = (Declare.declare_constant ~name ~kind (Declare.DefinitionEntry ce)) let defined lemma = - let (_ : _ list) = - Declare.Proof.save ~proof:lemma ~opaque:Vernacexpr.Transparent ~idopt:None + let pm = Declare.OblState.empty in + let _pm, _ = + Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent + ~idopt:None in () @@ -1502,8 +1504,9 @@ let open_new_goal ~lemma build_proof sigma using_lemmas ref_ goal_name [Hints.Hint_db.empty TransparentState.empty false] ])) in let lemma = build_proof env (Evd.from_env env) start_tac end_tac in - let (_ : _ list) = - Declare.Proof.save ~proof:lemma ~opaque:opacity ~idopt:None + let pm = Declare.OblState.empty in + let _pm, _ = + Declare.Proof.save ~pm ~proof:lemma ~opaque:opacity ~idopt:None in () in @@ -1662,7 +1665,12 @@ let com_eqn uctx nb_arg eq_name functional_ref f_ref terminate_ref in let _ = Flags.silently - (fun () -> Declare.Proof.save ~proof:lemma ~opaque:opacity ~idopt:None) + (fun () -> + let pm = Declare.OblState.empty in + let _pm = + Declare.Proof.save ~pm ~proof:lemma ~opaque:opacity ~idopt:None + in + ()) () in () -- cgit v1.2.3 From 3ef2bd35926a83fbcfd34d03e1fb1db894a39627 Mon Sep 17 00:00:00 2001 From: Gaƫtan Gilbert Date: Wed, 8 Jul 2020 14:06:19 +0200 Subject: declare: Add [save_regular] API for obligation-ignoring proofs --- plugins/funind/functional_principles_proofs.ml | 5 ++--- plugins/funind/gen_principle.ml | 14 ++++++-------- plugins/funind/recdef.ml | 15 ++++++--------- 3 files changed, 14 insertions(+), 20 deletions(-) (limited to 'plugins/funind') diff --git a/plugins/funind/functional_principles_proofs.ml b/plugins/funind/functional_principles_proofs.ml index b743329e7d..743afe4177 100644 --- a/plugins/funind/functional_principles_proofs.ml +++ b/plugins/funind/functional_principles_proofs.ml @@ -863,9 +863,8 @@ let generate_equation_lemma evd fnames f fun_num nb_params nb_args rec_args_num let lemma, _ = Declare.Proof.by (Proofview.V82.tactic prove_replacement) lemma in - let pm = Declare.OblState.empty in - let _pm, _ = - Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent + let (_ : _ list) = + Declare.Proof.save_regular ~proof:lemma ~opaque:Vernacexpr.Transparent ~idopt:None in evd diff --git a/plugins/funind/gen_principle.ml b/plugins/funind/gen_principle.ml index 730cf42fe8..45b1713441 100644 --- a/plugins/funind/gen_principle.ml +++ b/plugins/funind/gen_principle.ml @@ -1526,10 +1526,9 @@ let derive_correctness (funs : Constr.pconstant list) (graphs : inductive list) let lemma = fst @@ Declare.Proof.by (Proofview.V82.tactic (proving_tac i)) lemma in - let pm = Declare.OblState.empty in - let _pm, _ = - Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent - ~idopt:None + let (_ : _ list) = + Declare.Proof.save_regular ~proof:lemma + ~opaque:Vernacexpr.Transparent ~idopt:None in let finfo = match find_Function_infos (fst f_as_constant) with @@ -1599,10 +1598,9 @@ let derive_correctness (funs : Constr.pconstant list) (graphs : inductive list) (proving_tac i))) lemma) in - let pm = Declare.OblState.empty in - let _pm, _ = - Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent - ~idopt:None + let (_ : _ list) = + Declare.Proof.save_regular ~proof:lemma + ~opaque:Vernacexpr.Transparent ~idopt:None in let finfo = match find_Function_infos (fst f_as_constant) with diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml index 7b00191026..253c95fa67 100644 --- a/plugins/funind/recdef.ml +++ b/plugins/funind/recdef.ml @@ -58,9 +58,8 @@ let declare_fun name kind ?univs value = (Declare.declare_constant ~name ~kind (Declare.DefinitionEntry ce)) let defined lemma = - let pm = Declare.OblState.empty in - let _pm, _ = - Declare.Proof.save ~pm ~proof:lemma ~opaque:Vernacexpr.Transparent + let (_ : _ list) = + Declare.Proof.save_regular ~proof:lemma ~opaque:Vernacexpr.Transparent ~idopt:None in () @@ -1504,9 +1503,8 @@ let open_new_goal ~lemma build_proof sigma using_lemmas ref_ goal_name [Hints.Hint_db.empty TransparentState.empty false] ])) in let lemma = build_proof env (Evd.from_env env) start_tac end_tac in - let pm = Declare.OblState.empty in - let _pm, _ = - Declare.Proof.save ~pm ~proof:lemma ~opaque:opacity ~idopt:None + let (_ : _ list) = + Declare.Proof.save_regular ~proof:lemma ~opaque:opacity ~idopt:None in () in @@ -1666,9 +1664,8 @@ let com_eqn uctx nb_arg eq_name functional_ref f_ref terminate_ref let _ = Flags.silently (fun () -> - let pm = Declare.OblState.empty in - let _pm = - Declare.Proof.save ~pm ~proof:lemma ~opaque:opacity ~idopt:None + let (_ : _ list) = + Declare.Proof.save_regular ~proof:lemma ~opaque:opacity ~idopt:None in ()) () -- cgit v1.2.3