Replies: 2 comments 6 replies
-
This is a very interesting example. I will write by hand in WhyML this very same implementation, making use of the Why3 module system to emulate functors definition and applications. And yes, I can confirm that for the moment Cameleer does not support functors application. This would require typing information issued by the OCaml compiler, which I currently do not use. |
Beta Was this translation helpful? Give feedback.
-
I think we should move most of the Why3/Cameleer/DV specific questions to the relevant repository ( |
Beta Was this translation helpful? Give feedback.
-
Hello, sorry to be making so much noise today! I have thought some more about the current treatment of arrays and aliasing. Playing with Cameleer, I believe I am getting close to the point where I can prove something false.
The root of the problem is the logical reflection of the type
int array * int array
, and the fact that OCaml's mutable arrays are reflected at the logical level as sequences of elements. Such a logical reflection is sound only if one cannot create aliased arrays. But Gospel per se doesn't prevent aliasing. Why3 (which is used internally by Cameleer) prevents aliasing inside a single module, but cannot prevent it if the code is split into several modules, connected by Gospel specifications.The code is as follows:
My first
main
function is rejected by Why3, but the secondmain
function inside the functorMake
is accepted, even though its postcondition is intuitively false if the functiondanger
is allowed to return a pair of aliased arrays.If the final functor application was accepted, then we would have a real problem (I think). And, intuitively, it looks as though this functor application should be accepted: the specs of the formal and actual arguments are identical. But at the moment, functor applications are not handled by Cameleer, it seems (@mariojppereira).
This is up for discussion. As far as I understand, Why3 internally uses an alias analysis (based on a notion of region), but the results of such an analysis cannot currently be expressed in Gospel specs, so Gospel cannot rely on such an analysis in order to guarantee sound reasoning.
Beta Was this translation helpful? Give feedback.
All reactions