While loops with semantic guards and absorbed work #
boundedWhile accepts any decidable guard, so a source states its guard in its own terms:
0 < r, a ≠ 0, i < n. Realizes.whileBounded certifies the loop whose guard is a native
comparison of the encoded words. The congruence lemmas below move a loop, its domain and its
charge between pointwise equivalent guards and between environments at which the loop's
guard and body agree, so a certificate for the native guard transfers to the source's guard.
The realize tactic does this transfer itself.
whileWork_le bounds the local work of a loop whose body costs at most K by
cutoff * (K + 1); with a logarithmic cutoff this gives a sift its logarithmic local work through
Realizes.consequence. When every body begins with a memory query, that query pays the
iteration's control unit (whileWork_zero_le), and Realizes.while₀ is the while rule with local
work 0, the shape realize composes.
Main results #
boundedWhile_congr,whileSafe_imp,whileSafe_congr,whileWork_congr: congruence in the guard, the body and the environment.whileWork_le: the local work is at mostcutoff * (K + 1).whileWork_zero_le: a loop whose body begins with a query pays its control from memory.Realizes.while₀: the native while rule with absorbed local work.
Congruence #
Loops whose guards and bodies agree at their environments are equal, whatever the guards' decidability instances.
The reached-state domain transfers along agreeing guards and bodies and a weaker body domain. The body domains are compared only where the guard holds, as only there is a body run.
The reached-state domain is invariant under agreeing guards, bodies and body domains.
The local work is invariant under agreeing guards, bodies and body charges.
Work envelopes #
With body work at most K, a loop with cutoff n has local work at most n * (K + 1).
When every body issues a query, the loop's control work is at most its memory charge.
The absorbed rule #
A while loop whose body begins with a query has local work 0: each executed iteration's
control unit is paid by that query's memory charge. The guard is the native comparison cond
of the encoded environment and state; the cutoff is a ghost bound, never computed.