diff options
author | gareuselesinge <gareuselesinge@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-06-18 14:52:27 +0000 |
---|---|---|
committer | gareuselesinge <gareuselesinge@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-06-18 14:52:27 +0000 |
commit | 1e67a490cd5ebbf5669e4cbf34a2a3066c0b5fc1 (patch) | |
tree | 028eb2e6f65e79bb9b8ad3d10b300f1ec70103a4 | |
parent | 216dea268e06c813d3a98893db90676e1ada120c (diff) |
Proof using: nested sections bugfix
It used to be the case that the list of declared section variables
for a constant was taken into account only when discharging the first
enclosing sections, but not any outer section. Example of the bug:
Section A. Variable x : bool.
Section B. Variable y : nat.
Lemma foo : True. Proof using x y. Admitted.
End B. End A.
Check foo. (* nat -> True instead of bool -> nat -> True *)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15445 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r-- | kernel/cooking.ml | 6 | ||||
-rw-r--r-- | kernel/cooking.mli | 3 | ||||
-rw-r--r-- | kernel/term_typing.ml | 3 | ||||
-rw-r--r-- | test-suite/success/proof_using.v | 6 |
4 files changed, 15 insertions, 3 deletions
diff --git a/kernel/cooking.ml b/kernel/cooking.ml index 1a405e98b..e79bc90bb 100644 --- a/kernel/cooking.ml +++ b/kernel/cooking.ml @@ -136,6 +136,10 @@ let cook_constant env r = (fun c -> abstract_constant_body (expmod_constr r.d_modlist c) hyps) cb.const_body in + let const_hyps = + Sign.fold_named_context (fun (h,_,_) hyps -> + List.filter (fun (id,_,_) -> id <> h) hyps) + hyps ~init:cb.const_hyps in let typ = match cb.const_type with | NonPolymorphicType t -> let typ = abstract_constant_type (expmod_constr r.d_modlist t) hyps in @@ -146,4 +150,4 @@ let cook_constant env r = let j = make_judge (constr_of_def body) typ in Typeops.make_polymorphic_if_constant_for_ind env j in - (body, typ, cb.const_constraints) + (body, typ, cb.const_constraints, const_hyps) diff --git a/kernel/cooking.mli b/kernel/cooking.mli index 5f31ff8ce..66927becc 100644 --- a/kernel/cooking.mli +++ b/kernel/cooking.mli @@ -22,7 +22,8 @@ type recipe = { d_modlist : work_list } val cook_constant : - env -> recipe -> constant_def * constant_type * constraints + env -> recipe -> + constant_def * constant_type * constraints * Sign.section_context (** {6 Utility functions used in module [Discharge]. } *) diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml index 887a90010..2f57440e7 100644 --- a/kernel/term_typing.ml +++ b/kernel/term_typing.ml @@ -151,7 +151,8 @@ let translate_constant env kn ce = let translate_recipe env kn r = build_constant_declaration env kn - (let def,typ,cst = Cooking.cook_constant env r in def,typ,cst,None) + (let def,typ,cst,hyps = Cooking.cook_constant env r in + def,typ,cst,Some hyps) (* Insertion of inductive types. *) diff --git a/test-suite/success/proof_using.v b/test-suite/success/proof_using.v index 93a9ef116..bf302df44 100644 --- a/test-suite/success/proof_using.v +++ b/test-suite/success/proof_using.v @@ -51,11 +51,17 @@ Proof using v1 v2. admit. Qed. +Lemma deep2 : v1 = v2. +Proof using v1 v2. +Admitted. + End S2. Check (deep 3 : v1 = 3). +Check (deep2 3 : v1 = 3). End S1. Check (deep 3 4 : 3 = 4). +Check (deep2 3 4 : 3 = 4). |