Definition
Inductive safety closure is the condition under which a computed set of states proves a safety property §1.11, a statement that no bad state is ever reached: the set contains every initial state, one step from any state in it leads back into it, and it contains no bad state. Widening termination is the guarantee that an analysis using widening, an operation that enlarges a still-growing summary of states, reaches a summary with the first two properties in finitely many rounds; the third must still be checked.
Where it fits
Main entry: Widening and narrowing (§3.23).
Write for the set of initial states, for the set of states one step away from some state in a set , and for the set of bad states. The exact set of reachable states §3.21 is the least fixed point §3.22 of : the smallest set with . A safety proof does not need it. Any set with contains every reachable state, by induction on the number of steps, and so proves that no run reaches . These are the three obligations of an inductive invariant §19.2.4. The first two together say . The Widening and narrowing entry calls such a a post-fixed point; other texts call it a pre-fixed point, so state the inclusion instead of relying on the name. Neither name in this entry’s title is a standard term: textbooks speak of an inductive invariant that implies the property, or of a post-fixed point that excludes the bad states, and of the termination of widening.
Widening supplies such a in finitely many rounds, as a summary with . Here is a sound counterpart of on summaries, and means “is at least as precise as”. The set of states that stands for then passes the first two obligations. The third is a separate check. If the set contains a bad state, the analysis has proved nothing either way, because the bad state may have been added by the approximation.
A counter starts at 0, and while a step adds 1. The values reachable at the loop test are 0, 1 and 2, and the safety property is .
is not exact, because it contains the unreachable value 3, but it proves the property. It contains the initial value 0. The values in that allow a step are 0 and 1, which lead to 1 and 2, both in . Every value in is at most 3.
is not closed: the value 1 steps to 2, outside it. It omits a reachable value and proves nothing.
Interval analysis §3.9 with a widening operator starts at the loop test with . One round gives ; the upper bound rose, so widening moves it to , giving . That summary is closed, since its values 0 and 1 step to 1 and 2, but it contains bad values such as 4, so the safety check fails. A narrowing operator, which shrinks a closed summary while keeping it closed, then gives , the exact set here, and the check succeeds.
Limits and common mistakes
Stopping is not closure. An implementation that stops after a fixed number of rounds, or when its data stops changing for any reason other than a passed test , may stop at a summary that misses reachable states, as does above. The closure test must use a sound that includes every step of the model: resets, error paths and interrupts §6.11 as well as the loop body.
Narrowing keeps soundness §3.7 only while each of its results stays closed. The standard conditions on a narrowing operator guarantee this when is monotone, meaning that a more precise input never gives a less precise output, and they also make the shrinking phase stop.
Questions answered
Does the least fixed point need to be computed exactly?
No: a safety proof needs only some set of states that contains every initial state, is closed under the program’s steps (one step from any state in the set stays in the set), and contains no bad state. The least fixed point is the exact set of reachable states, the smallest set that contains the initial states and is closed. Every closed set that contains the initial states contains the least fixed point, so if such a set avoids the bad states, every reachable state does too.
Example: a counter starts at 0 and adds 1 while it is below 2, so it reaches 0, 1 and 2. The interval contains 0, its values below 2 step to 1 and 2, and all its values satisfy . It therefore proves although it contains the unreachable value 3.
Computing the exact set is in general impossible, because whether a state is reachable is undecidable §19.2.1 for programs over unbounded integers. Widening, an operation that enlarges a still-growing summary, produces a closed overapproximation §19.2.5 in finitely many rounds instead. Two checks remain: the result must be closed under every step the model allows, which the implementation’s having stopped changing does not show, and it must contain no bad state, because a set that is too coarse proves nothing.
Related entries: Fixed point (§3.22), Loop invariant (§3.24), Inductive invariant and its three obligations (§19.2.4). Further reading: [69].