consensus-specs icon indicating copy to clipboard operation
consensus-specs copied to clipboard

Describe the function preconditions in comments/docstrings

Open hwwhww opened this issue 5 years ago • 2 comments

Issue

Pointed out by @franck44 and @protolambda, it would be more readable if we can more it clear of what are the preconditions of each function.

How to solve it

Add more detailed comments about the pre-conditions.

/cc @protolambda feel free to update this issue content. :)

hwwhww avatar Jun 30 '20 15:06 hwwhww

It might be helpful to use Nagini to specify pre- and post-conditions (as well as other useful annotations). It enriches statically-typed Python3 subset (PEP-484, mypy) with constructs to specify pre-conditions (Requires) and post-conditions (Ensures), exceptional post-conditions (Exsures), as well as invariants, function purity (@Pure), assertions, predicates, etc.

It uses Boogie and Z3 as Dafny, though it's underlying logic is different. However, the idea is to use its extensions to annotate the py-spec with pre-/post-conditions and other useful annotations (like @Pure).

One option can be to design a contract library based on the ideas of the Nagini contract library (e.g. one can express Dafny annotations instead of Viper ones).

ericsson49 avatar Jul 02 '20 20:07 ericsson49

Took a look Viper and Nagini today. Some quick notes:

hwwhww avatar Sep 03 '20 16:09 hwwhww