- The contract for set_val routine: require states the precondition of this routine that the argument v shall not be negative; ensure enforces the postcondition of this routine that the val shall be equal to v.
- Class invariant enforces that for all objects/instances of this class their val shall not be negative.
In B method, it can check the correctness between the implementation and the specification by a theorem prover or a model checker. In Eiffel, it might use the hybrid method (static analysis plus test run) to check it.
If we can write the specification in B method (or similar formal languages such as Z notation, VDM), then refine them to an implementation by the refinement check. Afterwards, we may translate this refinement to Eiffel language and also keep the specification. It might be a good way from a formal specification, formal verification and finally to the code.
No comments :
Post a Comment