DEVELOPMENT EDITION · 769442725406
Verification Manual
On this page

Numerical, pipeline, and matrix reasoning

Numerical proof needs a precise domain: bounded machine values, exact model integers/rationals, or a specific rounded algorithm. Moving between those domains requires explicit relationships. A solver proving one interpretation does not establish a different numerical requirement.

Bounded arithmetic and intermediate results

For signed arithmetic, prove that each relevant intermediate fits its base type and each stored/passed/result value fits its required subtype. Overflow and subtype range failure are different obligations. Natural'Last + 1 overflows Integer; 0 - 1 can fit Integer but fail when returned as Natural.

A wider destination does not retroactively widen an overflowing expression. Convert an operand before the operation when the intermediate must use the wider type. The same rule applies when moving into an exact mathematical model: converting the result of an already bounded addition is too late.

Derive input bounds from the required calculation. If summing at most count nonnegative values each at most limit, identify a safe bound on the accumulator and on the expression forming that bound. A proof annotation containing count * limit still needs that typed multiplication to be safe unless it is deliberately stated in a mathematical domain.

The overflow repair and integer reference show conversion and boundary details in all three syntaxes. Modular arithmetic is a separate intentional wrapping type family, not a switch disabling signed-overflow proof.

Safety checks beyond arithmetic

Most safety diagnostics are requests for a missing fact at a particular operation. Distinguish the property so the repair preserves the API's intended inputs and outputs:

Check Fact to establish before the operation
Range The converted, assigned, passed or returned value belongs to the required subtype
Index Each array/string index is within the corresponding present bounds
Length Related array/string lengths conform where the operation requires it; equal lower bounds are a separate question
Alias Writable actuals and relevant globals designate permitted nonoverlapping regions
Discriminant The record's active variant permits the selected component or constrained use
Predicate The value satisfies its effective subtype predicate at the checked boundary
Null The access value is non-null before dereference
Tag A class-wide value has a tag admitted by the specific conversion/use

An empty array's range has no present index even if its subtype has valid scalar bounds. A non-null value still needs a legal lifetime/ownership state. A tag check does not prove a concrete subtype's entire functional postcondition. A dynamic alias obligation can be solved with index/domain facts; a statically forbidden ownership overlap must be repaired at the flow stage. The type, expression, and composite reference define the precise generated-check contexts.

Division, signs, and rounding

Establish a nonzero divisor and a representable result. The most negative signed base value divided by −1 can overflow even though the divisor is nonzero. Distinguish truncating division, remainder and modulo with negative operands.

Vibe follows Python: / is true division and yields a float (7 / 2 is 3.5), while // and % are floor division and its modulo, rounding toward negative infinity (-7 // 2 is -4). Vada's and Varc's integer / truncates toward zero, with separate remainder and modulo operators (expressions). Each carries a nonzero-divisor and a representable-result obligation; test the intended sign and boundary cases.

Exact models versus executable big numbers

Use mathematical integers to state a relation that should not wrap or overflow in the specification. Then prove the bounded implementation equals that model within its input domain. The power example bounds a mathematical power and relates the returned Integer to it, while its loop carries the model relation.

Executable big integers are still resource-limited. The run-time allows magnitudes up to 2**4096 and raises Storage_Error beyond them; mathematical proof over unbounded integers does not establish absence of that exhaustion. Big_Reals is a ghost rational model, not native exact arbitrary real/transcendental computation. See models.

Floating point and fixed point

Floating operations have their declared type, finite range, rounding and exceptional-value conditions. Verada's proof model excludes/checks NaN and infinities at relevant boundaries; it does not silently reason as though every executable float were an exact real number. State the algorithm's required accuracy/result relation rather than only its lack of overflow.

Static real literal evaluation can remain exact until typed conversion. CPython commonly rounds each float operation earlier. Untyped constant expressions and runtime floating algorithms therefore need explicit compatibility review; matching source spelling is not an adequate oracle argument.

Ordinary fixed point has its declared delta/range and implemented arithmetic/conversion rules. Prove the range and intended scaled/rounded relation. A decimal fixed-point type such as delta 0.01 digits 12 holds exact decimal steps, which suits money; its division truncates toward zero. A financial program still needs an explicit policy for rounding and limits: the type alone does not specify the business rule. The numeric corpus contains supported examples.

Reduction properties are algorithm-specific

A fold accumulates in a particular order from a particular initial value. Prove safety of each accumulator update and the intended fold relation. An exact mathematical sum, a plain floating left fold, a compensated sum and a fixed lane-combining algorithm are different specifications. Floating addition is not associative in general.

Vibe's sum over floats is the compensated (Neumaier) sum, as CPython's is; plain_sum adds left to right and lane_sum is a reproducible eight-lane sum. Vada reductions and Varc consumers fold left to right from their initial value. None of them is proved equal to the exact real sum, and none establishes an application error bound: state those separately. The compensated sum's correction takes no assumption: where the values are bounded its arithmetic is proved, and otherwise a step whose rounding error would not be finite leaves the correction as it was, so prove --no-assume accepts a float sum. See Vibe iteration.

Optimization does not reassociate floating-point arithmetic: a native build computes the fold the source describes.

Pipelines and generated invariants

Supported map/filter/lockstep/takewhile/consumer forms lower to explicit shared computations. They are consumed expressions, not arbitrary escaping lazy iterators. Stage functions obey the supported purity/type rules. Bounds and ordering still determine which operations are evaluated and which checks must prove.

For a sum of bounded percentages, provide both element and length bounds. For a dot product, bound the product and the number of paired terms. zip stops according to its supported lockstep length rule; it does not prove equal lengths unless the API requires them. enumerate exposes a surface counter with its documented origin.

Filter/early-stop order is observable. A filter before takewhile can hide an element from the stop predicate; takewhile before filtering can stop on it. The Vibe reference explicitly rejects some orderings rather than silently exchanging them. Source reverse flags and consumer vocabulary also have frontend limits. Read the exact iteration reference when a proof assumes a particular selected prefix or counter origin.

Generated invariants can discharge ordinary accumulator bounds but do not infer every application relation. If a proof failure offers expansion to a loop, inspect that loop to find the state/relationship needing an explicit invariant. Reprove and compare execution after applying an expansion; a fix-it is a proposed edit with obligations, not an assurance stamp by itself.

Matrices, shape, and indexing

For a multidimensional array, separate the rank, each dimension's bounds/length, the element type, and the traversal order. Rectangularity is a type/model fact; it is not arbitrary ragged-list semantics. Shape-dependent operations need appropriate conformance: equal lengths for a relevant assignment, square shape for a trace, and dimension-specific bounds for every indexed access.

The matrix corpus states a square/length precondition for a trace and carries a bound on its running total. A row-total operation also bounds its chosen row index. Scaling requires a factor bound so each component remains in its declared subtype.

Use one invariant per nesting level. An outer invariant describes completed rows; an inner invariant describes progress within the current row and preserves the outer relation. Vibe shape[k] uses a literal zero-based dimension selector, while shared attribute dimension arguments have their own origin. len(matrix) is not automatically the total component count. Whole component iteration follows the supported row-major scalar traversal, not Python row objects. A shape property does not automatically prove every flattened offset formula; APL operations state their own obligations and facts.

Numerical review workflow

Name the required domain/result relation first. List all conversions and intermediates, derive bounds/shape facts, and express the inductive relation for loops/folds. Check signed, zero, empty and maximum-length cases. Then run strict proof, required backend tests and any applicable external comparison with recorded versions. Keep a numerical regression that would fail if the algorithm/order/rounding policy changed, while avoiding claims broader than the actual model and tested domain.