forIn loop-invariant gadgets #
forInPureWithInvariant and forInPureWithInvariant' annotate a forIn/forIn' loop with its
invariant so that vcgen reads the invariant from the program. Their @[spec] specifications
restate Spec.forIn_list/Spec.forIn'_list for every container with a PureForIn instance.
forInLoopWithInvariant, forInLoopWithVariant and forInLoopWithInvariantAndVariant do the same
for a repeat loop, one per set of annotations the loop states. Each restates Spec.forIn_loop,
leaving what the loop does not state to vcgen to infer.
Gadgets #
A forIn loop annotated with its loop invariant, which vcgen reads from the inv argument.
It is definitionally forIn xs init f, so the annotation is erased at runtime. The invariant
ranges over the elements consumed so far, the elements remaining, and the loop state.
Equations
- Std.WP.Gadget.forInPureWithInvariant xs init f inv = forIn xs init f
Instances For
A membership-aware forIn' loop annotated with its loop invariant, which vcgen reads from the
inv argument. It is definitionally forIn' xs init f, so the annotation is erased at runtime. The
invariant ranges over the elements consumed so far, the elements remaining, and the loop state.
Equations
- Std.WP.Gadget.forInPureWithInvariant' xs init f inv = forIn' xs init f
Instances For
Specifications #
A repeat loop annotated with the loop invariant that vcgen reads from the inv argument.
It is definitionally forIn l init f, so the annotation is erased at runtime. The invariant takes
the loop's exit flag, false while the loop iterates and true once it is done.
Equations
- Std.WP.Gadget.forInLoopWithInvariant l init f inv = forIn l init f
Instances For
A repeat loop annotated with the termination measure that vcgen reads from the var
argument. It is definitionally forIn l init f, so the annotation is erased at runtime. The measure
is the function a Variant is built from, so that the assertion language it evaluates in is
the one the specification is applied at.
Equations
- Std.WP.Gadget.forInLoopWithVariant l init f var = forIn l init f
Instances For
A repeat loop annotated with the loop invariant and the termination measure that vcgen reads
from the inv and var arguments. It is definitionally forIn l init f, so the annotations are
erased at runtime. The invariant takes the loop's exit flag, false while the loop iterates and
true once it is done. The measure is the function a Variant is built from, so that the
assertion language it evaluates in is the one the specification is applied at.
Equations
- Std.WP.Gadget.forInLoopWithInvariantAndVariant l init f inv var = forIn l init f