Apress / practical-tla-plus

Source Code for 'Practical TLA+' by Hillel Wayne
Other
287 stars 67 forks source link

Chapter 7: binary search and overflows #6

Closed ghost closed 3 years ago

ghost commented 4 years ago

The last part of the binary algorithm in chapter 7 suggests to create the NoOverflows invariant. In doing so, the invariant is violated due to high taking MaxInt + 1 value (tested with MaxInt == 7).

The algorithm requires a small fix in the elsif check:

  goto Result;
elsif seq[m] < target /\ m < high then 
   low := m + 1;
else 

This allow the model to pass and terminate without causing further overflows.

hwayne commented 3 years ago

Working on this now, thank you!