Parma Polyhedra Library requirements
C++ checked extended scalar arithmetic
PPL-SPEC-001710
1. Conversion of policy-admitted scalar special values UID: PPL-SPEC-001710 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

assign_r and value construction from a scalar source shall classify an admitted source NaN or signed infinity under that source's policy and request the corresponding destination special assignment. Infinity shall retain its sign and the requested direction; NaN shall use ROUND_IGNORE. Finite sources shall retain their ordinary conversion contracts, including finite source endpoint values that another policy would reserve as special.

For native floating-to-floating NaN assignment, this guarantee shall require the destination's check_fpu_nan_result capability. For a cross-policy checked constructor or assignment, conversion and handler dispatch shall follow 🔗 1. Operation-specific numerical policy capabilities and 🔗 2. Finite checked scalar converting construction and assignment; accepting a result in a handler shall not make an unsupported payload representable. Same-type copies shall retain 🔗 1. Same-type checked copying of admitted special values. Placement construction shall complete exactly one underlying object, retaining the ownership and failure rules of 🔗 7. Raw scalar placement construction and exact assignment.

Arguments shall use a supported raw scalar type or an admitted Checked_Number instantiation, with well-formed selected operations and live storage. A source's own policy shall interpret its reserved encodings; an encoding reserved only by another policy shall retain its source-policy meaning. Finite rational operands shall be canonical. Resources, synchronization, shared temporaries and caller-owned FPU state shall satisfy the corresponding finite scalar contract. Native floating exceptions shall be nontrapping. Signalling NaNs shall be outside this contract.

Special assignment shall retain the destination-policy outcomes of 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 4. Typed special-value assignment to native floating-point storage, including directed finite saturation or V_UNREPRESENTABLE when the requested class is unsupported. An unrepresentable or NaN-class result shall not license inspecting an unspecified payload; a supported NaN shall remain queryable through the PPL classification interface. The destination shall remain reusable. No strong rollback guarantee shall be implied.

The named result-returning interfaces shall invoke no result handler. Their admitted convenience wrappers shall use the defaults and handlers specified by 🔗 1. Operation-specific numerical policy capabilities. Supported output aliases shall use entry values; distinct sources shall remain unchanged. ROUND_NOT_NEEDED shall require an admitted exact result and shall not be used for NaN or an invalid operation. Disabling a diagnostic check shall not expand a native integer or GMP operation's admitted domain. Finite arithmetic and range outcomes shall retain their separate contracts.

RATIONALE:

Extended values and enabled diagnostic causes require an explicit contract separate from finite arithmetic and destination representability.

INTERFACE:

Public header: <ppl.hh>; admitted scalar combinations of assign_r, construct and the value-converting Checked_Number constructors and assignment operators. Internal dispatch: Checked::assign_ext and Checked::construct_ext and their selected scalar backends.

VERIFICATION_CRITERIA:

Cross GMP integer/rational, native integer and available native floating sources and destinations. Check both infinity signs and NaN, supported and unsupported destination representations, inward saturation, outward rejection, source preservation, cross-policy finite endpoints, handler counts/throws, fresh placement ownership and destination recovery. Compare every status with the existing special-marker contract rather than a guessed payload.

SOURCE:

src/checked_ext_inlines.hh; src/checked_float_inlines.hh; tests/floatingarithmetic1.cc; tests/coefficient1.cc; tests/longdouble1.cc.

PPL-SPEC-001711
2. Unary and binary-scale transformations of scalar special values UID: PPL-SPEC-001711 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For non-native scalar encodings, floor_assign_r, ceil_assign_r and trunc_assign_r shall propagate an admitted signed infinity unchanged. neg_assign_r shall reverse its sign and abs_assign_r shall select positive infinity. Each shall propagate an admitted source NaN through NaN assignment. The four power-of-two transformations add_2exp_assign_r, sub_2exp_assign_r, mul_2exp_assign_r and div_2exp_assign_r shall preserve either infinity sign and propagate NaN. These special branches shall not evaluate a finite power or finite arithmetic intermediate.

For a supported native floating type, the same mathematical special values shall be retained by its unary and power-of-two operations. NaN diagnosis as V_NAN shall require check_fpu_nan_result; no NaN payload or sign shall be prescribed. Successful native infinity transformations may retain lazy result classification; classification of the stored value shall still identify the correct infinity. Native exponent admission and FPU state shall retain the corresponding finite operation's prerequisites.

Arguments shall use a supported raw scalar type or an admitted Checked_Number instantiation, with well-formed selected operations and live storage. A source's own policy shall interpret its reserved encodings; an encoding reserved only by another policy shall retain its source-policy meaning. Finite rational operands shall be canonical. Resources, synchronization, shared temporaries and caller-owned FPU state shall satisfy the corresponding finite scalar contract. Native floating exceptions shall be nontrapping. Signalling NaNs shall be outside this contract.

Special assignment shall retain the destination-policy outcomes of 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 4. Typed special-value assignment to native floating-point storage, including directed finite saturation or V_UNREPRESENTABLE when the requested class is unsupported. An unrepresentable or NaN-class result shall not license inspecting an unspecified payload; a supported NaN shall remain queryable through the PPL classification interface. The destination shall remain reusable. No strong rollback guarantee shall be implied.

The named result-returning interfaces shall invoke no result handler. Their admitted convenience wrappers shall use the defaults and handlers specified by 🔗 1. Operation-specific numerical policy capabilities. Supported output aliases shall use entry values; distinct sources shall remain unchanged. ROUND_NOT_NEEDED shall require an admitted exact result and shall not be used for NaN or an invalid operation. Disabling a diagnostic check shall not expand a native integer or GMP operation's admitted domain. Finite arithmetic and range outcomes shall retain their separate contracts.

RATIONALE:

Extended values and enabled diagnostic causes require an explicit contract separate from finite arithmetic and destination representability.

INTERFACE:

Public header: <ppl.hh>; the five named unary _assign_r interfaces and the four named _2exp_assign_r interfaces above. Internal dispatch: the corresponding Checked::*_ext and native floating kernels.

VERIFICATION_CRITERIA:

Cross NaN and both infinity signs with all five unary operations and all four power transforms. Check signed infinity results, source/output aliases, NaN classification, supported result flags, finite recovery and preservation of separate sources. Keep finite signed-zero tests allocated to their finite unary contracts.

SOURCE:

src/checked_ext_inlines.hh; src/checked_float_inlines.hh; tests/floatingarithmetic1.cc; tests/float1.cc.

PPL-SPEC-001712
3. Extended scalar binary arithmetic and enabled fault diagnosis UID: PPL-SPEC-001712 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For non-native special encodings, an admitted source NaN shall request NaN assignment before binary arithmetic. Addition or subtraction with an infinite operand shall select the extended-real sign, except that opposite infinities added with check_inf_add_inf enabled shall diagnose V_INF_ADD_INF and equal infinities subtracted with check_inf_sub_inf enabled shall diagnose V_INF_SUB_INF. An infinite product with a nonzero partner shall use the product of the operand signs. Infinity times zero shall require check_inf_mul_zero and diagnose V_INF_MUL_ZERO.

For div_assign_r and idiv_assign_r, finite input divided by either admitted infinity shall give exact zero. Infinity divided by a finite nonzero value shall give the signed infinity. With the corresponding check enabled, infinity divided by infinity shall diagnose V_INF_DIV_INF and a zero divisor shall diagnose V_DIV_ZERO. Finite nonzero division and truncated quotient conventions shall remain separate contracts.

Supported native floating arithmetic shall obey the same defined extended mathematical values and enabled operation-specific causes. When check_fpu_nan_result is enabled, a resulting NaN not already diagnosed by an enabled cause check shall return V_NAN. Native result codes may retain lazy infinity classification. With several simultaneous invalid conditions, no common diagnostic priority across scalar backends shall be required; the result shall be NaN-class. For nontrapping IEEE native floating storage with check_div_zero disabled, an integral quotient of a finite nonzero numerator by signed zero shall be the infinity whose sign is the exclusive-or of the source signs. No native integer division by zero shall be inferred from this floating convention. A transparent IEEE native integral quotient with NaN operands, infinity/infinity or zero/zero shall propagate a NaN payload without promising an ordered result relation.

An operation-specific diagnosed cause shall be passed through destination NaN assignment, preserving the cause and any V_UNREPRESENTABLE flag.

Arguments shall use a supported raw scalar type or an admitted Checked_Number instantiation, with well-formed selected operations and live storage. A source's own policy shall interpret its reserved encodings; an encoding reserved only by another policy shall retain its source-policy meaning. Finite rational operands shall be canonical. Resources, synchronization, shared temporaries and caller-owned FPU state shall satisfy the corresponding finite scalar contract. Native floating exceptions shall be nontrapping. Signalling NaNs shall be outside this contract.

Special assignment shall retain the destination-policy outcomes of 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 4. Typed special-value assignment to native floating-point storage, including directed finite saturation or V_UNREPRESENTABLE when the requested class is unsupported. An unrepresentable or NaN-class result shall not license inspecting an unspecified payload; a supported NaN shall remain queryable through the PPL classification interface. The destination shall remain reusable. No strong rollback guarantee shall be implied.

The named result-returning interfaces shall invoke no result handler. Their admitted convenience wrappers shall use the defaults and handlers specified by 🔗 1. Operation-specific numerical policy capabilities. Supported output aliases shall use entry values; distinct sources shall remain unchanged. ROUND_NOT_NEEDED shall require an admitted exact result and shall not be used for NaN or an invalid operation. Disabling a diagnostic check shall not expand a native integer or GMP operation's admitted domain. Finite arithmetic and range outcomes shall retain their separate contracts.

RATIONALE:

Extended values and enabled diagnostic causes require an explicit contract separate from finite arithmetic and destination representability.

INTERFACE:

Public header: <ppl.hh>; admitted combinations of add_assign_r, sub_assign_r, mul_assign_r, div_assign_r and idiv_assign_r. Internal dispatch: the corresponding Checked::*_ext and scalar kernels.

VERIFICATION_CRITERIA:

Compare literal extended-real tables for negative/positive finite values, zero, both infinities and NaN across supported scalar/policy combinations. Check each enabled cause independently, rather than prescribing a priority for simultaneous faults. Exercise aliases, unchanged distinct sources, finite recovery and native transparent NaN quotient paths. Check handlers separately against their received cause and exception contract.

SOURCE:

src/checked_ext_inlines.hh; src/checked_int_inlines.hh; src/checked_mpz_inlines.hh; src/checked_mpq_inlines.hh; src/checked_float_inlines.hh; tests/checkedcontractedges1.cc; tests/floatingarithmetic1.cc; tests/float1.cc; tests/checkedstatementpaths1.cc.

PPL-SPEC-001713
4. Nonfinite remainder operands and enabled modulus faults UID: PPL-SPEC-001713 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For non-native encodings, rem_assign_r shall propagate a source-policy NaN from either operand before modulus checks. With check_inf_mod enabled, an infinite dividend shall diagnose V_INF_MOD. With check_div_zero enabled, finite remainder by zero shall diagnose V_MOD_ZERO. A finite dividend and admitted infinite divisor shall retain 🔗 6. Remainder with a policy-admitted infinite divisor.

smod_2exp_assign_r and umod_2exp_assign_r shall propagate a source-policy NaN; an infinite source with check_inf_mod enabled shall diagnose V_INF_MOD. Finite signed/unsigned residue conventions and exponent admission shall retain their scalar contracts.

The native floating implementations shall diagnose the same enabled infinity and zero-divisor causes. With check_fpu_nan_result enabled, an otherwise undiagnosed NaN result shall be V_NAN. A NaN combined with another fault need not have the same diagnostic priority as a non-native encoding. Cause results shall use destination NaN assignment and retain any V_UNREPRESENTABLE flag.

Arguments shall use a supported raw scalar type or an admitted Checked_Number instantiation, with well-formed selected operations and live storage. A source's own policy shall interpret its reserved encodings; an encoding reserved only by another policy shall retain its source-policy meaning. Finite rational operands shall be canonical. Resources, synchronization, shared temporaries and caller-owned FPU state shall satisfy the corresponding finite scalar contract. Native floating exceptions shall be nontrapping. Signalling NaNs shall be outside this contract.

Special assignment shall retain the destination-policy outcomes of 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 4. Typed special-value assignment to native floating-point storage, including directed finite saturation or V_UNREPRESENTABLE when the requested class is unsupported. An unrepresentable or NaN-class result shall not license inspecting an unspecified payload; a supported NaN shall remain queryable through the PPL classification interface. The destination shall remain reusable. No strong rollback guarantee shall be implied.

The named result-returning interfaces shall invoke no result handler. Their admitted convenience wrappers shall use the defaults and handlers specified by 🔗 1. Operation-specific numerical policy capabilities. Supported output aliases shall use entry values; distinct sources shall remain unchanged. ROUND_NOT_NEEDED shall require an admitted exact result and shall not be used for NaN or an invalid operation. Disabling a diagnostic check shall not expand a native integer or GMP operation's admitted domain. Finite arithmetic and range outcomes shall retain their separate contracts.

RATIONALE:

Extended values and enabled diagnostic causes require an explicit contract separate from finite arithmetic and destination representability.

INTERFACE:

Public header: <ppl.hh>; rem_assign_r, smod_2exp_assign_r and umod_2exp_assign_r for their admitted scalar combinations.

VERIFICATION_CRITERIA:

Check NaN in each operand, signed infinite dividends, zero divisors and both dyadic modulus forms. Check exact causes where only one fault applies, NaN class for combined faults, unsupported NaN destinations, source/output aliases, source preservation and a subsequent finite operation.

SOURCE:

src/checked_ext_inlines.hh; src/checked_int_inlines.hh; src/checked_mpz_inlines.hh; src/checked_mpq_inlines.hh; src/checked_float_inlines.hh; tests/floatingarithmetic1.cc; tests/checkedcontractedges1.cc; tests/checkedstatementpaths1.cc.

PPL-SPEC-001714
5. Extended accumulated products and enabled fault diagnosis UID: PPL-SPEC-001714 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

add_mul_assign_r and sub_mul_assign_r shall use the accumulator's entry value and both factor entry values. With non-native special encodings, a NaN admitted by any of their own policies shall request NaN assignment. Otherwise determine the product sign from the factors, reverse that contribution for subtraction and combine it with the entry accumulator. A determined infinity shall be assigned through the destination policy. Entirely finite operands shall retain their scalar accumulation contract.

Infinity times zero shall require check_inf_mul_zero and diagnose V_INF_MUL_ZERO. Adding opposing accumulator/product infinities with check_inf_add_inf shall diagnose V_INF_ADD_INF; subtracting equal accumulator/product infinities with check_inf_sub_inf shall diagnose V_INF_SUB_INF. A native floating implementation shall retain these enabled causes and, with check_fpu_nan_result, diagnose an otherwise undetected NaN result as V_NAN. Multiple simultaneous faults shall not require one diagnostic priority across backends. Cause results shall use destination NaN assignment and retain any V_UNREPRESENTABLE flag.

These special cases shall not change the fused/nonfused finite precision choice specified by 🔗 3. Configured native accumulation precision and truthful result relations. The accumulator shall be interpreted under its own policy, not a factor's policy.

Arguments shall use a supported raw scalar type or an admitted Checked_Number instantiation, with well-formed selected operations and live storage. A source's own policy shall interpret its reserved encodings; an encoding reserved only by another policy shall retain its source-policy meaning. Finite rational operands shall be canonical. Resources, synchronization, shared temporaries and caller-owned FPU state shall satisfy the corresponding finite scalar contract. Native floating exceptions shall be nontrapping. Signalling NaNs shall be outside this contract.

Special assignment shall retain the destination-policy outcomes of 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 4. Typed special-value assignment to native floating-point storage, including directed finite saturation or V_UNREPRESENTABLE when the requested class is unsupported. An unrepresentable or NaN-class result shall not license inspecting an unspecified payload; a supported NaN shall remain queryable through the PPL classification interface. The destination shall remain reusable. No strong rollback guarantee shall be implied.

The named result-returning interfaces shall invoke no result handler. Their admitted convenience wrappers shall use the defaults and handlers specified by 🔗 1. Operation-specific numerical policy capabilities. Supported output aliases shall use entry values; distinct sources shall remain unchanged. ROUND_NOT_NEEDED shall require an admitted exact result and shall not be used for NaN or an invalid operation. Disabling a diagnostic check shall not expand a native integer or GMP operation's admitted domain. Finite arithmetic and range outcomes shall retain their separate contracts.

RATIONALE:

Extended values and enabled diagnostic causes require an explicit contract separate from finite arithmetic and destination representability.

INTERFACE:

Public header: <ppl.hh>; admitted combinations of add_mul_assign_r(to, x, y, dir) and sub_mul_assign_r(to, x, y, dir).

VERIFICATION_CRITERIA:

Cross accumulator and factor signs, finite zero, both infinities and NaN with independent extended-real product/sum tables. Check zero times an infinite right as well as left factor, the enabled causes, accumulator and factor policies independently, permitted aliases and finite recovery. Retain the separate exact or directed finite accumulation controls.

SOURCE:

src/checked_ext_inlines.hh; src/checked_float_inlines.hh; tests/checkedcontractedges1.cc; tests/floatingarithmetic1.cc.

PPL-SPEC-001715
6. Square-root special values and enabled negative-input diagnosis UID: PPL-SPEC-001715 STATUS: APPROVED COMPONENT: NUMERICS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For a non-native admitted special encoding, sqrt_assign_r shall propagate a source NaN, assign positive infinity for positive infinity and diagnose negative infinity as V_SQRT_NEG through destination NaN assignment. A finite negative operand with check_sqrt_neg enabled shall diagnose V_SQRT_NEG. Disabling that finite-domain check shall retain the selected finite kernel's precondition.

A supported native floating implementation with check_fpu_nan_result shall propagate source NaN as V_NAN; with check_sqrt_neg it shall diagnose negative values, including negative infinity, as V_SQRT_NEG. Positive infinity shall remain positive infinity; its result relation may retain the native kernel's lazy information. NaN payload/sign shall not be prescribed. Finite nonnegative roots, signed zero, directed result relations and rational irrational-precision ownership shall retain their separate contracts.

Arguments shall use a supported raw scalar type or an admitted Checked_Number instantiation, with well-formed selected operations and live storage. A source's own policy shall interpret its reserved encodings; an encoding reserved only by another policy shall retain its source-policy meaning. Finite rational operands shall be canonical. Resources, synchronization, shared temporaries and caller-owned FPU state shall satisfy the corresponding finite scalar contract. Native floating exceptions shall be nontrapping. Signalling NaNs shall be outside this contract.

Special assignment shall retain the destination-policy outcomes of 🔗 1. Typed special-marker assignment to native integer storage, 🔗 2. Typed special-marker assignment to GMP integer and rational storage and 🔗 4. Typed special-value assignment to native floating-point storage, including directed finite saturation or V_UNREPRESENTABLE when the requested class is unsupported. An unrepresentable or NaN-class result shall not license inspecting an unspecified payload; a supported NaN shall remain queryable through the PPL classification interface. The destination shall remain reusable. No strong rollback guarantee shall be implied.

The named result-returning interfaces shall invoke no result handler. Their admitted convenience wrappers shall use the defaults and handlers specified by 🔗 1. Operation-specific numerical policy capabilities. Supported output aliases shall use entry values; distinct sources shall remain unchanged. ROUND_NOT_NEEDED shall require an admitted exact result and shall not be used for NaN or an invalid operation. Disabling a diagnostic check shall not expand a native integer or GMP operation's admitted domain. Finite arithmetic and range outcomes shall retain their separate contracts.

RATIONALE:

Extended values and enabled diagnostic causes require an explicit contract separate from finite arithmetic and destination representability.

INTERFACE:

Public header: <ppl.hh>; sqrt_assign_r(to, source, dir) for admitted native integer, GMP integer/rational and native floating scalar combinations.

VERIFICATION_CRITERIA:

Check NaN and both infinity signs, finite negative values with checks enabled, destination policies admitting or rejecting NaN, exact diagnostic causes, aliases, unchanged separate sources and finite-root recovery. Keep finite rational enclosure/precision checks allocated to their own contracts.

SOURCE:

src/checked_ext_inlines.hh; src/checked_int_inlines.hh; src/checked_mpz_inlines.hh; src/checked_mpq_inlines.hh; src/checked_float_inlines.hh; tests/floatingarithmetic1.cc; tests/float1.cc.