Parma Polyhedra Library requirements
C++ bounded-integer wrapping interpretations and abstractions
1. Mathematical interpretation of bounded-integer wrapping attributes UID: PPL-SPEC-001041 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

The modeled attributes identified by 🔗 1. Modeled bounded-integer type identity shall have the following mathematical meanings. A width w shall describe M = 2w. The unsigned value range shall be the integers in [0, M − 1]; the signed two's-complement range shall be the integers in [ − M ⁄ 2, M ⁄ 2 − 1].

For an unwrapped integer z, unsigned wrapping shall choose the unique integer r in the unsigned range congruent to z modulo M. Signed wrapping shall choose r when r < M ⁄ 2 and r − M otherwise. Negative unwrapped values shall use the same nonnegative unsigned residue, independently of a host language's signed remainder convention.

OVERFLOW_WRAPS shall use this modular interpretation. OVERFLOW_UNDEFINED shall permit arbitrary modeled result values after overflow, rather than choosing a particular residue; this arithmetic-result abstraction shall not model every other possible effect of language undefined behavior. OVERFLOW_IMPOSSIBLE shall retain only the transitions whose unwrapped result is within the selected value range.

A modeled width, including 128 bits, shall not assert the existence of a native scalar type or a configured coefficient type of that width. The numerical operations computing an abstraction shall retain their separate computational range and availability prerequisites. Attribute identity and factory/getter behavior shall remain as specified by 🔗 1. Modeled bounded-integer type identity.

RATIONALE:

Modeled overflow and host arithmetic have separate mathematical roles: unbounded intermediate arithmetic determines which bounded result interpretation applies.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

enum Bounded_Integer_Type_Width {
  BITS_8=8, BITS_16=16, BITS_32=32, BITS_64=64, BITS_128=128
};
enum Bounded_Integer_Type_Representation { UNSIGNED, SIGNED_2_COMPLEMENT };
enum Bounded_Integer_Type_Overflow {
  OVERFLOW_WRAPS, OVERFLOW_UNDEFINED, OVERFLOW_IMPOSSIBLE
};
VERIFICATION_CRITERIA:

Compare actual interval/Box operations with literal integer division and nonnegative remainder oracles. Check both encodings, all five modeled widths, negative values, period boundaries, signed half-period boundaries and the distinct three overflow interpretations. Exercise 128-bit modeled limits through GMP endpoint storage without assuming a native int128 type; reuse the metadata identity checks of 🔗 1. Modeled bounded-integer type identity.

BIBLIOGRAPHY:

SimonK07 | Section 2.2, binary signed/unsigned semantics; PDF page index 2 (zero-based).

SOURCE:

src/globals_types.hh; doc/definitions.dox: Approximating Bounded Integers.

tests/wrappingspec1.cc; tests/wrappingoracle.hh; tests/wrappingpublic1.cc.

2. Interval abstraction of wrapped integer images with refinement UID: PPL-SPEC-001042 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For the receiver's entry interval X, an admitted width and representation from 🔗 1. Mathematical interpretation of bounded-integer wrapping attributes, and the entry interval J denoted by refinement, wrap_assign shall produce an interval containing every

{wrapw, r(z) ∣ z ∈ X∩ℤ}∩J.

The completed interval shall be contained in the receiving profile's outward interval conversion of J; exact conversion shall imply containment in J itself. refinement may denote an arbitrary valid interval or singleton; it need not lie inside the modeled value range. A refinement inside that range shall therefore bound the completed result to that range. An empty receiver shall remain empty. A receiver unbounded in either direction may conservatively become the refinement itself, and noninteger input points need not all be eliminated. No universal least-hull or complete integer filtering guarantee shall be inferred. With exact arithmetic, closed integral endpoints and a closed integral refinement inside the modeled range, the result shall be the least interval hull of the retained wrapped integer images.

The receiver may be the refinement interval, and a singleton refinement may borrow either of its boundary objects. Those calls shall use both entry values. A refinement with distinct storage shall retain its value. Returned I_Result shape and definite status claims shall have the meanings of 🔗 1. Interval result possibilities and status-flag set operations for the whole operation, including its entry-to-result change claims.

The validity, policy, active-payload, lifetime and synchronization conditions of 🔗 1. Interval types, initial storage and independent value copies shall apply. The selected backend shall support any actually evaluated power-of-two subtraction and signed/unsigned residue at the supplied exponent, as specified by its scalar contracts. Exact precision claims shall require exact endpoint conversion, modular arithmetic and any intermediate unit adjustment. Computational range failures, resources, shared temporaries and caller-owned FPU state shall retain those scalar contracts. An admitted modeled width alone shall not establish these backend capabilities. Valid calls shall require no additional PPL initialization. Underlying failures may leave partly updated storage; there shall be no aggregate rollback guarantee.

RATIONALE:

A refinement can clip a modular image without making the modular image itself convex; entry-value aliases and truthful aggregate result claims remain independent obligations.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

// Member of Interval<Boundary,Info>:
template <Interval_Source From>
I_Result
wrap_assign(Bounded_Integer_Type_Width w,
            Bounded_Integer_Type_Representation r,
            const From& refinement);
VERIFICATION_CRITERIA:

Check returned logical shape and entry-to-result change claims on full-period assignment, split/join and intersection paths, including unchanged copied refinements, receiving aliases, borrowed scalars, empty inputs and signed residues. Enumerate concrete wrapped integers in bounded translated intervals using an independent quotient/remainder oracle. Include all endpoint topologies, fractions, one/full/multiple periods, sign discontinuities, empty/ray/universe inputs and arbitrary refinements inside, partly outside and disjoint from the modeled range. Check witness containment, refinement containment and the stated closed-integral least-hull guarantee. Exercise distinct-source preservation, same-interval and borrowed-boundary aliases, meaningful shape/change flags and native/GMP admitted backend prerequisites.

BIBLIOGRAPHY:

SimonK07 | Sections 5.1–5.4, explicit wrapping; PDF page indices 7–10 (zero-based).

SOURCE:

src/Interval_defs.hh; src/Boundary_defs.hh;

tests/wrappingspec1.cc; tests/wrappingoracle.hh; tests/wrappingpublic1.cc; tests/intervalresultsspec1.cc.

PPL-SPEC-001043
3. Box bounded-integer wrapping, overflow choices and guard refinement UID: PPL-SPEC-001043 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

wrap_assign shall interpret the selected coordinates as bounded integers using 🔗 1. Mathematical interpretation of bounded-integer wrapping attributes. It shall conservatively contain every selected concrete result obtained from the receiver's entry integer-valued selected coordinates under the requested overflow interpretation. The represented result shall remain a box, so modular disjunctions and relations may be approximated. Fractional points on selected coordinates may be discarded, and retained interior points need not all be integers.

Without a supplied guard, OVERFLOW_WRAPS shall use modular images; OVERFLOW_IMPOSSIBLE shall intersect each selected factor with the modeled value range. Under OVERFLOW_UNDEFINED, a factor already contained in the rational half-open interval from the modeled minimum through one past its maximum may be retained; a potentially overflowing factor may be forgotten and replaced by the modeled closed integer range. No-overflow factors shall not be discarded merely because another factor can overflow.

A nonnull cs_p shall denote a guard on the resulting coordinates. The completed box shall conservatively contain the guard-filtered selected integer results; it need not satisfy every guard row. In particular, relational rows and rows mentioning unselected coordinates may be ignored by this specialization. Interval rows for selected coordinates may refine their target ranges. A false constant row shall make the result empty. The guarded undefined-overflow path may forget a selected coordinate to universe when overflow is possible; no universal post-guard containment or least-result guarantee shall be inferred.

With an empty selection, no bounded-type limits or residues shall be required. A null guard shall preserve the receiver; a supplied guard shall perform conservative refinement under 🔗 3. Conservative box refinement by linear constraints, which may affect otherwise unselected coordinates. Empty, including a hidden empty factor, shall remain empty. Ambient dimension shall remain unchanged. For a nonempty selection, unselected factor meanings shall remain unchanged unless the entire product becomes empty. A distinct supplied guard and the selection set shall retain their mathematical values. complexity_threshold and wrap_individually shall not change this Box specialization's result.

An excess selected coordinate or guard ambient dimension shall throw std::invalid_argument before receiver modification, including for empty receivers. Guard dimension shall be checked even with an empty selection. Only the named width, representation and overflow attributes shall be admitted; no outcome shall be specified for invalid enum values.

The validity, numerical, lifetime and synchronization prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Selected modular evaluation shall retain 🔗 2. Interval abstraction of wrapped integer images with refinement's backend prerequisites. Modeled limit construction shall use unbounded integer arithmetic independent of configured Coefficient range; conversion into an endpoint profile shall retain that profile's representability and outward-rounding conditions. A guard shall retain its descriptor context, coefficient-intermediate range and refinement prerequisites; dimension reporting shall retain the initialized context of 🔗 1. Initialization owners and automatic C++ initialization and 🔗 3. Thread initialization, default state and finalization. Otherwise valid calls shall require no additional library initialization. Underlying resource/numerical failures may leave a partially updated box.

RATIONALE:

A Cartesian abstraction can preserve concrete bounded-integer outcomes while losing modular disjunctions and relational guard precision; the overflow interpretation and empty-selection path determine different operations.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

// Member of Box<ITV>:
void wrap_assign(const Variables_Set& vars,
                 Bounded_Integer_Type_Width w,
                 Bounded_Integer_Type_Representation r,
                 Bounded_Integer_Type_Overflow o,
                 const Constraint_System* cs_p = nullptr,
                 unsigned complexity_threshold = 16,
                 bool wrap_individually = true);
VERIFICATION_CRITERIA:

Compare bounded concrete integer enumeration against exact modular, possible-overflow and impossible-overflow models. Check all widths with GMP limits, native admitted widths, selected/unselected axes, closed/open and fractional factors, full periods, unbounded and lazy-empty values. Exercise all overflow modes, null/empty/false/selected/relational/unselected guards, empty selections, both precision flags and several thresholds, dimension prechecks and preserved source descriptors. Check analytic wide limits and capability independence from configured Coefficient storage.

BIBLIOGRAPHY:

SimonK07 | Sections 5.1–5.4, explicit wrapping and guard precision; PDF page indices 7–10 (zero-based).

SOURCE:

src/Box_defs.hh; src/Box_templates.hh; tests/Box/wrap1.cc; tests/Box/wraplimits1.cc; tests/Box/wrapguard1.cc; tests/Box/wrapcontracts2.cc;

tests/wrappingspec1.cc; tests/wrappingoracle.hh; tests/wrappingpublic1.cc.