File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,34 @@ for(i=0; i<100; i++)
59
59
assert(a[i]==0);
60
60
```
61
61
62
+ CPROVER also supports writing function pre and postconditions, using
63
+ the built-in functions ` __CPROVER_precondition ` and
64
+ ` __CPROVER_postcondition ` . They can be used to express intent, and at
65
+ the moment they are just transformed to assertions in the goto
66
+ program. As such, they can be used as simple assertions in
67
+ code. However, it is advised to use ` __CPROVER_precondition ` at the
68
+ beginning of a function's body, and ` __CPROVER_postcondition ` before
69
+ the exit points in a function (either the return statements, or the
70
+ end of the body if the function returns void). The following is an
71
+ example usage:
72
+
73
+ ``` C
74
+ int foo (int a, int b) {
75
+ __ CPROVER_precondition(a >= 0);
76
+ __ CPROVER_precondition(b > 0);
77
+
78
+ int rval = a / b;
79
+
80
+ __ CPROVER_postcondition(rval >= 0);
81
+ return rval;
82
+ }
83
+ ```
84
+
85
+ A future release of CPROVER will support using these pre and
86
+ postconditions to create a function contract, which can be used for
87
+ modular verification.
88
+
89
+
62
90
Future CPROVER releases will support explicit quantifiers with a syntax
63
91
that resembles Spec\#:
64
92
You can’t perform that action at this time.
0 commit comments