Parma Polyhedra Library requirements
C++ typed special markers for integer and rational storage

C++ typed special markers for integer and rational storage

1. Typed special-marker assignment to native integer storage
UID: PPL-SPEC-000844
STATUS: APPROVED
COMPONENT: NUMERICS
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

Minus_Infinity, Plus_Infinity and Not_A_Number shall be typed markers for VC_MINUS_INFINITY, VC_PLUS_INFINITY and VC_NAN. Their static vclass members shall give those classes, and Is_Special shall identify those three unqualified marker types. MINUS_INFINITY, PLUS_INFINITY and NOT_A_NUMBER shall provide corresponding marker objects. Special_Marker<T> shall have the truth value of Is_Special<T>::value; it shall not strip qualifiers or require numeric operations from the marker. Existing trait specializations shall determine its admission.

For the raw or checked native integer destinations in 🔗 1. Exact same-storage native integer arithmetic, assign_r shall replace the destination according to the marker and the destination policy. If infinities are admitted, negative and positive infinity shall be stored in their reserved representations and return V_EQ_MINUS_INFINITY and V_EQ_PLUS_INFINITY without V_UNREPRESENTABLE. If NaN is admitted, its reserved representation shall be stored and V_NAN returned without V_UNREPRESENTABLE. A NaN shall require no ordered relation.

If infinities are not admitted, negative infinity with ROUND_UP shall store the lower finite endpoint and return V_LT_INF; positive infinity with ROUND_DOWN shall store the upper finite endpoint and return V_GT_SUP. For the other admitted directions, the result shall be V_EQ_MINUS_INFINITY | V_UNREPRESENTABLE or V_EQ_PLUS_INFINITY | V_UNREPRESENTABLE, respectively, with no payload promise. Unsupported NaN shall return V_NAN | V_UNREPRESENTABLE with no payload promise. The finite interval shall follow 🔗 1. Bounded checked integer limits and reserved endpoints. In signed storage, positive infinity shall use the native maximum, negative infinity the native minimum, and NaN the native minimum plus one when infinities are admitted, or the native minimum otherwise. In unsigned storage, positive infinity shall use the native maximum, negative infinity the native maximum minus one, and NaN the native maximum minus twice the policy's infinity-admission Boolean.

Infinity markers shall admit ROUND_DOWN, ROUND_UP and ROUND_IGNORE, with or without ROUND_STRICT_RELATION. They shall also admit ROUND_NOT_NEEDED and its strict form when infinities are representable. NaN markers shall admit the first three base directions and their strict forms. A strict flag shall not alter these class, relation or flag outcomes. The supplied marker shall remain unchanged.

The entry payload shall impose no numerical precondition on replacement. After an unrepresentable result, the destination shall remain live and reusable without inspecting an unspecified payload. Calls shall require no rounding default or result handler and shall not invoke a handler. Live-object, synchronization, initialization and hardware-direction prerequisites shall follow 🔗 1. Exact same-storage native integer arithmetic.

RATIONALE:

Typed markers distinguish mathematical special values from finite integer endpoints, including when a policy cannot represent the requested value.

INTERFACE:

Public header: <ppl.hh>; the three marker types Special and admitted raw/checked integer type To shall give these effective instantiations in Parma_Polyhedra_Library:

template <typename T>
concept Special_Marker = bool(Is_Special<T>::value);

Result assign_r(To& to, const Special& marker, Rounding_Dir dir);
VERIFICATION_CRITERIA:

Check marker traits/classes and all eleven native storage types with and without reserved infinities and NaN. Independently check reserved payloads, finite endpoints, exact result codes and representability flags for each admitted request. Replace finite and admitted special entry values, preserve markers and hardware direction, require no handler or initialization, and reset/reuse destinations after unsupported results.

SOURCE:

src/Checked_Number_defs.hh; tests/commonhelpersspec1.cc; src/checked_defs.hh; src/checked_int_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/scalarspecialmarkersspec1.cc.

2. Typed special-marker assignment to GMP integer and rational storage
UID: PPL-SPEC-000845
STATUS: APPROVED
COMPONENT: NUMERICS
APPLICABILITY: IF_CPP, SCALAR_MPZ, SCALAR_MPQ
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

For raw mpz_class or mpq_class destinations, and admitted Checked_Number<T, Policy> destinations with either underlying type, assign_r from the typed markers in 🔗 1. Typed special-marker assignment to native integer storage shall replace the destination according to its policy. If infinities are admitted, negative and positive infinity shall be stored as their PPL special representations and return V_EQ_MINUS_INFINITY and V_EQ_PLUS_INFINITY without V_UNREPRESENTABLE. If NaN is admitted, its PPL representation shall be stored and V_NAN returned without V_UNREPRESENTABLE. These result flags shall truthfully characterize the supported stored representations as specified by 🔗 1. Numerical result classes and relation meanings.

If infinities are not admitted, either infinity marker shall return its exact infinity class/relation with V_UNREPRESENTABLE and no payload promise. An unbounded finite range shall not provide a finite inward endpoint for infinity. Unsupported NaN shall return a NaN-class diagnostic with no payload promise; absence of V_UNREPRESENTABLE alone shall not claim successful NaN representation. No ordinary finite numerical answer shall be inferred from an unsupported result.

Infinity markers shall admit ROUND_DOWN, ROUND_UP and ROUND_IGNORE, with or without a strict flag, and additionally ROUND_NOT_NEEDED and its strict form when infinities are representable. NaN markers shall admit the first three base directions and their strict forms, with an empty ordered relation. The marker shall remain unchanged; the entry payload shall impose no numerical precondition on replacement.

A PPL special representation shall not be passed to ordinary GMP numerical operations. Subsequent finite arithmetic shall satisfy its applicable finite/canonical prerequisites; in particular, a PPL rational special representation shall not be treated as a finite canonical rational. After an unsupported result, the destination shall remain live and reusable without inspecting an unspecified payload. Available resources shall suffice for the objects and their replacement. Object access overlapping mutation shall be synchronized. Calls shall require no library initialization, coefficient-constant stage, FPU setup, rounding default or policy handler, shall invoke no handler and shall preserve hardware direction. Raw destinations shall use their native checked destination policy; native floating-point forms shall retain 🔗 4. Typed special-value assignment to native floating-point storage.

RATIONALE:

An unbounded finite range and a supported special representation are separate properties. A representability flag must not contradict the value that a policy can actually store.

INTERFACE:

Public header: <ppl.hh>; effective instantiations for the admitted To and marker type Special in Parma_Polyhedra_Library:

Result assign_r(To& to, const Special& marker, Rounding_Dir dir);
VERIFICATION_CRITERIA:

Exercise both GMP underlying types and policies admitting neither, either or both special classes. Check every admitted direction/strict flag, exact infinity classes, supported NaN classification and truthful representability flags. Check replacement of finite and admitted special values, preserved markers, no handler dispatch, reset/reuse after unsupported results and hardware independence without initialization.

SOURCE:

src/checked_mpz_inlines.hh; src/checked_mpq_inlines.hh; src/Checked_Number_defs.hh; src/Checked_Number_inlines.hh; tests/scalarspecialmarkersspec1.cc.