Parma Polyhedra Library requirements
C++ bounded-difference text, memory and invariant queries
PPL-SPEC-001137
1. Human-readable bounded-difference presentation PPL-SPEC-001137

Stream insertion shall write true for a universe shape and false for an empty shape, including their zero-dimensional forms. Otherwise it shall list unary and coordinate-difference constraints in the upper triangular pair order of coordinates 0, …, n, with index 0 denoting the constant origin. Two opposite finite bounds that are additive inverses shall be displayed as one equality; other finite sides shall be displayed as non-strict inequalities. Positive-infinite sides shall not be displayed. Consecutive constraints shall be separated by ", " and no ambient-dimension header shall be inserted.

A unary equality shall use variable = value; an upper unary bound shall use variable <= value. A lower unary bound shall use variable >= value for signed or unbounded coefficients. For unsigned integer coefficients it shall use -variable <= value, retaining the stored nonnegative constant without numerical negation. Difference constraints shall use the orientation giving the selected nonnegative constant where available, retaining the corresponding relation and value. Variable names shall follow the active formatter and its live-callback prerequisites in 🔗 7. Active Variable formatter and initialized thread state and 🔗 8. Variable names, formatter dispatch and output failures. Bound values shall follow the admitted mathematical numeric stream output of 🔗 5. Mathematical numeric output and stream delivery status and 🔗 6. Checked numeric stream policy integration.

Insertion shall return the supplied stream reference without adding a newline or explicitly flushing it. print() shall deliver the same presentation to the current std::cerr. Display shall preserve the represented set and dimension; its const classification may refresh representation caches. Stream and formatter failures shall retain their applicable state, exception-mask and partial-output behavior. Rendering callbacks shall not mutate or invalidate traversed source objects.

The selected representation, numerical runtime and synchronization prerequisites of 🔗 1. Bounded-difference values, numerical profiles and valid use shall hold. The borrowed stream and any output callback environment shall remain live throughout the call. Recoverable resource exceptions may propagate; discarded owned temporaries shall be released.

2. Reloadable bounded-difference record export PPL-SPEC-001138

For a valid admitted source, ascii_dump(stream) shall write its status fields, a newline, its square difference-bound matrix record, a newline, and its redundancy-bit matrix record of 🔗 12. ASCII representation and loading. Status fields shall identify the stored ZE, EM, SPC and SPR conditions in that order, using + or - prefixes. The bound-matrix dimension shall be one greater than the ambient dimension, including zero-dimensional shapes. The export shall write the stored redundancy matrix when reduction is certified, and a zero-row, zero-column redundancy matrix otherwise.

The matrix payload and mathematical numeric formatting shall follow 🔗 11. Reloadable ASCII records for admitted bound values, including exact finite native decimal values and admitted positive infinities. Compatible status, matrix, numeric policy, locale and version conventions shall retain enough information for 🔗 3. Compatible bounded-difference record loading and failure state to restore the same mathematical set and ambient dimension. Neither native object bytes nor a floating zero sign is part of this mathematical round-trip guarantee.

Export shall preserve the source value and ownership without requiring an initial emptiness, closure or reduction query. ascii_dump() shall send the same record to the current std::cerr. Output failure shall follow the stream's selected state and exception behavior, retaining partial output and without certifying successful delivery.

The selected representation, numerical runtime and synchronization prerequisites of 🔗 1. Bounded-difference values, numerical profiles and valid use shall hold. The borrowed stream and any output callback environment shall remain live throughout the call. Recoverable resource exceptions may propagate; discarded owned temporaries shall be released.

The internal status contract shall follow 🔗 4. BD_Shape internal status signed-keyword export.

3. Compatible bounded-difference record loading and failure state PPL-SPEC-001139

For a complete valid record of 🔗 2. Reloadable bounded-difference record export under compatible representation, numeric formatting, profile, locale and resource conditions, ascii_load(stream) shall return true and replace any valid receiver by the recorded ambient dimension and mathematical set. The previous receiver's dimension, emptiness and cache flags shall not affect the result. All serialized status conditions shall replace their previous conditions. One complete record shall be consumed while a following record or suffix remains available after permitted separating whitespace.

Status-word rejection, a truncated or rejected bound matrix, or a truncated or rejected redundancy matrix shall return false when the component extractions return normally. An unsupported decoded bound-matrix row count shall return false before resizing or requesting storage for that extent, as specified by 🔗 12. Exact ASCII input, forbidden payloads and failure state. A zero-row bound matrix shall be rejected. When reduction certification is present, its matrix shall have the same row and column counts as the bound matrix. When reduction is uncertified, the loader shall consume the redundancy matrix without retaining its storage. That includes inactive matrices written by earlier compatible PPL versions. Inconsistent serialized status conditions shall be rejected. Numerical payload rejection shall retain 🔗 12. Exact ASCII input, forbidden payloads and failure state. Stream masks, numerical policy and recoverable resource exceptions shall retain their own propagation channels.

The successful restoration guarantee assumes a trusted, complete and dump-compatible record. The loaded matrix, status, and retained closure and reduction information shall satisfy 🔗 5. Bounded-difference representation invariant query. If these checks detect an inconsistency, the loader shall return false in every build. Semantic queries or further shape operations require a complete valid representation.

Rounded or bounded coefficient profiles may discard serialized reduction certification and recheck a serialized closed feasibility cache, preserving the stored matrix's exact represented set. This cache repair shall not alter the semantic meaning or ambient dimension of a compatible record.

A false return or exception may leave replaced status or partially loaded matrices. It shall not promise rollback or a complete mathematical value. The receiver shall retain safely destructible ownership and may be replaced by a complete valid assignment before semantic queries or operations requiring a valid shape. Consumed input shall not be restored, and the library shall not take ownership of the stream.

The selected representation, numerical runtime and synchronization prerequisites of 🔗 1. Bounded-difference values, numerical profiles and valid use shall hold. The borrowed stream and any output callback environment shall remain live throughout the call. Recoverable resource exceptions may propagate; discarded owned temporaries shall be released.

The internal status contract shall follow 🔗 5. BD_Shape internal status signed-keyword loading and rejection.

PPL-SPEC-001140
4. Owned bounded-difference memory accounting PPL-SPEC-001140

external_memory_in_bytes() shall report the owned external storage of the difference-bound matrix plus that of the redundancy-bit matrix, counting live selected coefficient payloads and retained capacities according to 🔗 14. Matrix container and coefficient memory accounting and 🔗 13. Invariant, ordering and allocated-memory queries. Logically empty or currently inactive cache content shall not make owned allocated storage disappear from the count. Independently owned runtime temporaries, other objects and allocator bookkeeping shall be excluded.

total_memory_in_bytes() shall equal sizeof(BD_Shape<T>) plus the external count. Sizes shall be those of the selected build/profile and the sum shall fit memory_size_type. The selected live coefficient and bit-row memory hooks shall be well-formed. Both queries shall preserve the source set, dimension, caches, ownership and lifetimes.

The selected representation, numerical runtime and synchronization prerequisites of 🔗 1. Bounded-difference values, numerical profiles and valid use shall hold. Live owned storage shall remain unchanged during either query.

5. Bounded-difference representation invariant query PPL-SPEC-001141

For a live, well-owned and safely indexable representation whose selected scalar operations are admitted, OK() shall check the matrix's storage and coefficient validity and the status-condition compatibility. Certified empty representations shall retain their inactive-geometric-data admission. A nonempty representation shall reject a stored negative-infinite bound or a diagonal entry other than positive infinity.

For exact unbounded coefficient profiles, certified closure shall be checked against recomputation and certified reduction against the corresponding canonical reduction mask, including rejection of an essential positive- infinite edge. Rounded or bounded profiles shall use the selected exact graph semantic invariant for a certified reduction, without requiring floating closure to be idempotent. A violation of a checked invariant shall return false; passing those checks shall return true. The query shall preserve the receiver's represented set, dimension and ownership.

The query may copy matrices, recompute derived data in temporary objects, and report resource or numerical exceptions through their selected channels. Debug builds may emit invariant-failure diagnostics to std::cerr; no fixed diagnostic wording is part of the result. A true result is not an emptiness, semantic equality or minimal-storage answer. The query shall not be a corruption scanner for arbitrary pointers, broken object lifetimes or non-indexable fabricated storage.

The selected representation, numerical runtime and synchronization prerequisites of 🔗 1. Bounded-difference values, numerical profiles and valid use shall hold. Discarded owned query temporaries shall be released on reported failure.

The internal status contract shall follow 🔗 3. BD_Shape internal status consistency predicate.