Proving a Postcondition for One Increment

A proof for a simple assignment can relate its post-update value to the input. Use the target property to identify adequate initial states.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Work an integer example
  2. Check the model's boundary

Work an integer example

To finish with count at least five after adding one, it suffices for count to begin at least four under exact integer arithmetic. At four the new count is five. See weakest preconditions.

Check the model's boundary

A fixed-width counter can overflow. Its specification must either exclude that state or use the actual update semantics. Wraparound arithmetic explains that case.[1]

References

  1. Benjamin C. Pierce et al., Software Foundations ↩