diff options
| author | letouzey | 2011-04-12 22:31:42 +0000 |
|---|---|---|
| committer | letouzey | 2011-04-12 22:31:42 +0000 |
| commit | 5113afbb6e8c1f9122b37c37b0561c529c406256 (patch) | |
| tree | 9087ea477f4de7f185d3468b0f13b1a23a3c39fc /kernel/mod_typing.ml | |
| parent | 62b92230d3ed0c01ce6cdb7bc59635ca7f659a9c (diff) | |
Subtyping: align coqtop behavior concerning opaque csts on coqchk's one
After discussion with Bruno and Hugo, coqtop now accepts that an opaque
constant in a module type could be implemented by anything of
the right type, even if bodies differ. Said otherwise, with respect
to subtyping, an opaque constant behaves just as a parameter.
This was already the case in coqchk, and a footnote in documentation
is advertising for quite some time that:
"Opaque definitions are processed as assumptions."
Truly, it might seem awkward that "Definition x:=3" can implement
"Lemma x:nat. Proof 2. Qed." but the opacity ensures that nothing
can go wrong afterwards, since Coq is forced to ignore that the x
in signature has body "2".
Similarly, "T with Definition x := c" is now legal when T contains
an opaque x, even when this x isn't convertible with c.
By avoiding accesses to opaque bodies, we also achieve some speedup
(less delayed load of .vo final sections containing opaque terms).
Nota: the extraction will have to be adapted, since for the moment it
might access the body of opaque constants: the warning emitted when
doing that should become an error.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@13987 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'kernel/mod_typing.ml')
| -rw-r--r-- | kernel/mod_typing.ml | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/mod_typing.ml b/kernel/mod_typing.ml index aad541d218..b8162340f7 100644 --- a/kernel/mod_typing.ml +++ b/kernel/mod_typing.ml @@ -87,8 +87,11 @@ and check_with_aux_def env sign with_decl mp equiv = | SFBconst cb -> cb | _ -> error_not_a_constant l in + (* In the spirit of subtyping.check_constant, we accept + any implementations of parameters and opaques terms, + as long as they have the right type *) let def,cst = match cb.const_body with - | Undef _ -> + | Undef _ | OpaqueDef _ -> let (j,cst1) = Typeops.infer env' c in let typ = Typeops.type_of_constant_type env' cb.const_type in let cst2 = Reduction.conv_leq env' j.uj_type typ in @@ -104,9 +107,6 @@ and check_with_aux_def env sign with_decl mp equiv = let cst = union_constraints cb.const_constraints cst1 in let def = Def (Declarations.from_val c) in def,cst - | OpaqueDef _ -> - (* We cannot make transparent an opaque field *) - raise Reduction.NotConvertible in let cb' = { cb with |
