On this page
Checks, contracts and proof outcomes
Classify the obligation before choosing a repair. An arithmetic bound, a callee precondition, a loop invariant and a termination argument ask different questions. All can be reported at a useful source location, but they are not interchangeable reasons to strengthen a random assertion or increase the solver budget.
Executable checks
| Codes | Condition | Facts to inspect |
|---|---|---|
| B4101-B4102 | Base-type overflow or constrained range | Operand bounds, intermediate type and destination subtype. |
| B4103 | Array index | Actual lower/upper bounds of each dimension. |
| B4104 | Division | Nonzero divisor and signed division boundary. |
| B4105 | Alias check | Overlapping mutable actuals and called profiles. |
| B4106 | Length | Array/string shapes and assignment lengths. |
| B4107 | Discriminant | Active variant and required discriminant constraint. |
| B4108 | Predicate | Type/subtype predicate at the relevant boundary. |
| B4109 | Null check | Ownership/null state before dereference. |
| B4110 | Tag check | Dynamic tag required by the supported conversion or dispatch. |
Use B4101's complete diagnosis to distinguish a confirmed failing boundary input from a missing proof fact. A guard can establish a fact for the following branch. A precondition instead changes what callers must establish; it is appropriate only when the operation's intended domain really excludes the rejected input. If the operation must accept the input, implement the required exceptional, optional or saturating behavior.
Modular contracts
B5101 is a failed precondition at a call. Compare the actual arguments with the callee's promise and trace where the caller should have learned the necessary fact. B5102 is a failed postcondition on a return path. Verify all outputs, changed components and exceptional paths, including what a called operation promises.
Proof ordinarily uses a callee's contract at a boundary. A correct implementation can be insufficiently specified for its client. Eligible expression functions and selected helpers can unfold, but this is not a reason to depend on undocumented body visibility. The contracts chapter shows how to expose useful result and frame properties without revealing an implementation unnecessarily.
An unsatisfiable precondition can make body proof vacuous and produces B8003. Confirm that the intended application has valid callers. Strengthening Pre to False removes a useful interface rather than repairing it.
Loops and termination
B5103 concerns establishing the invariant when the annotated point is first reached. B5104 concerns preservation across an iteration. At that point the prover retains the invariant and appropriate frame facts, rather than every detail of earlier iterations. Record the index bounds, accumulated result and unchanged components needed to justify the next step and eventual result. The invariant must remain true for empty inputs and boundary iterations where those are allowed.
A variant is a well-founded progress argument. It is not the same as an invariant and does not follow merely because testing finished quickly. Functions, procedures marked Always_Terminates, and required cleanup operations have termination requirements; ordinary procedures are not all covered by a universal termination promise. Structural termination failures remain errors even when advisory code generation is selected. See termination.
Programs that end and exceptional cases
B5113 is an Exceptional_Cases consequence that might not hold when the exception propagates; B5121 is an Exit_Cases guard that might not describe how the subprogram ends; B5120 is a call that might end the program (such as GNAT.OS_Lib.OS_Exit) where the caller may not, or where its Program_Exit condition might not hold. Proof-enclave frame checks (B5116 to B5119) are described with flow and memory.
Unknown results and environment failures
B5115 means proof effort was exhausted without a proof or confirmed failure. Reduce unnecessary quantification, supply missing intermediate facts, use a suitable model and check the available solver/backend configuration. Raising a documented budget is useful when a sound obligation needs more effort; it is not the first repair for a missing invariant or false contract. B7007 instead reports solver startup.
If an answer changes with the cache or certificates, prove again with --no-cache and compare. A check that the solver proves only with another random seed is reported as B8011 under a larger budget; --stability N measures how a proof stands up to such changes. Certificates (--certificates) are proofs the solver re-checks from their cores rather than searching again. See proof operations and trust.
For delivery, prove again in full and run the program after repairing the source. A run-time check covers only what can be executed: modes lists the contracts that only a proof checks.