Parma Polyhedra Library requirements
C++ box textual interfaces and memory accounting
PPL-SPEC-000969
1. Human-readable box presentation UID: PPL-SPEC-000969 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

Insertion shall write false for an empty box and true for a universe box. Otherwise, it shall visit every ambient coordinate in increasing index order and write the active variable name, the literal separator " in ", and that coordinate's interval presentation. Consecutive coordinates shall be separated by ", ". Unrestricted factors of a non-universe product shall also be shown. Zero-dimensional empty and universe shall retain their respective words. Successful insertion shall return the supplied stream reference without adding a newline or explicitly flushing it.

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. Interval presentation shall follow 🔗 2. Readable interval presentation and output delivery, including stream formatting and locale. The display shall not encode a separate ambient-dimension header. print() shall deliver the same display to the current std::cerr without appending a newline.

The represented box value shall remain unchanged; logically const emptiness/universe queries may refresh status. Stream failures shall retain the supplied stream's state and exception-mask behavior. Exceptions escaping the selected formatter, endpoint or stream operations shall propagate with partial output retained; their internal stream handling shall follow the applicable exception mask. Rendering callbacks shall not invalidate or mutate the box or coordinate storage being visited.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

RATIONALE:

A readable list of coordinate factors must preserve order and use the configured coordinate names.

INTERFACE:

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

namespace IO_Operators {
  template <typename ITV>
  std::ostream& operator<<(std::ostream& s, const Box<ITV>& box);
}
// Member of Box<ITV>:
void print() const;
VERIFICATION_CRITERIA:

Check exact words and coordinate order using independent literal intervals, default/custom variable formatters, unrestricted factors, zero-dimensional cases and lazy emptiness. Verify stream identity, no newline, print redirection, source values and partial failure/exception behavior.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/globals_defs.hh; tests/boxtextspec1.cc.

PPL-SPEC-000970
2. Reloadable box record export UID: PPL-SPEC-000970 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Under compatible machine-output formatting and endpoint serialization prerequisites, ascii_dump(s) shall emit the box status record, the label space_dim, the ambient dimension and a newline, followed by exactly one serialized interval record per coordinate in increasing index order. The status protocol shall follow 🔗 5. Status ASCII loading and partial rejection state; interval records shall follow 🔗 4. Reloadable interval metadata and endpoint export. The record shall retain enough information to reload the same ambient dimension and mathematical Cartesian value with 🔗 3. Compatible box record loading and failure state.

For a box whose status already certifies emptiness, endpoint storage may be inactive. Export shall emit a valid canonical universe interval for each such coordinate without interpreting inactive endpoint payloads. The certified empty status shall preserve the empty Cartesian meaning independently of those replacement records. For other valid status states, coordinate export shall retain the interval serialization's metadata and inactive-payload rules. Export shall preserve the source mathematical value and shall not require first querying its emptiness.

ascii_dump() shall deliver the same record to the current std::cerr. Output shall require sufficient stream resources, compatible numeric formatting/locale and the selected endpoint codec's prerequisites. Stream/endpoint/resource failures shall retain their own state and exception behavior, with no output rollback. The record shall not imply cross-version or different-policy format compatibility.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

RATIONALE:

Machine records must preserve dimension and empty-set meaning without reading inactive coordinate payloads.

INTERFACE:

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

// Members of Box<ITV>:
void ascii_dump(std::ostream& s) const;
void ascii_dump() const;
VERIFICATION_CRITERIA:

Round-trip independently modeled empty/universe, zero-dimensional and mixed-factor boxes in classified and unclassified states. Inspect label/count/order and canonical inactive-factor records. Check concatenated records, source preservation, stderr delivery and failing output streams, including native endpoint profiles with inactive storage.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/globals_defs.hh; tests/boxtextspec1.cc.

PPL-SPEC-000971
3. Compatible box record loading and failure state UID: PPL-SPEC-000971 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

For a complete valid record produced under 🔗 2. Reloadable box record export with compatible status, interval policy, endpoint arithmetic, dimension limits, numeric formatting and locale, ascii_load(s) shall return true and replace the destination by the recorded ambient dimension and mathematical Cartesian value. It shall consume one box record, permitting a following record or suffix to remain in the stream. A previously different destination dimension or value shall not affect a successful result.

Status-field parsing and its outcomes shall follow 🔗 5. Status ASCII loading and partial rejection state. A missing or incorrect space_dim label, an absent, negative-signed or unsupported dimension, or a rejected or truncated coordinate interval record shall return false when stream extraction returns normally. Coordinate loading shall follow 🔗 5. Compatible interval record loading and partial failure state. A completed record that fails the box invariant check shall return false in every build. Stream exception masks and selected endpoint/resource exceptions shall retain their own propagation rules. A complete admissible dimension shall fit the selected box profile and available resources. Use trusted compatible dumps.

Failure may have replaced status and some coordinate records or discarded the previous coordinate sequence. A false return or exception shall not promise rollback or a complete valid mathematical box value. The object shall retain safely destructible owned resources and may be replaced by assignment from a valid box; callers shall establish a valid replacement before mathematical queries or other operations requiring a valid box. Input already consumed shall not be restored. Successful loading shall not transfer ownership of the input stream.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

RATIONALE:

Reloadable records need a precise success contract and an explicit partial-update failure state.

INTERFACE:

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

// Member of Box<ITV>:
bool ascii_load(std::istream& s);
VERIFICATION_CRITERIA:

Load independently generated compatible records into different prior dimensions, check exact mathematical values and repeated/concatenated loading. Exercise incorrect/truncated status, header and endpoint fields, prefixes and exception-enabled streams. Reassign valid values after every failed load before querying; check resource cleanup and successful reuse.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/globals_defs.hh; tests/boxtextspec1.cc.

PPL-SPEC-000972
4. Owned box memory accounting UID: PPL-SPEC-000972 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

external_memory_in_bytes() shall report the sum of the owned coordinate sequence's allocated slot storage and the external memory reported by every live interval element. If K coordinate slots are allocated and n elements are live, slot storage shall contribute K * sizeof(ITV); each live element's external storage shall be counted once, including elements in a logically empty box. Inactive logical factors shall not cause owned allocated storage to disappear from the accounting.

total_memory_in_bytes() shall report sizeof(Box<ITV>) plus that external count. Object/slot sizes shall be those of the selected build and interval profile. The result shall exclude allocator bookkeeping and independently owned library temporaries or other objects. Successful calls shall require each selected interval's memory query to be well-formed and the sum to fit memory_size_type. The queries shall preserve the represented value, ambient dimension and owned storage.

The validity, numerical, synchronization and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. The selected interval profile shall provide the required codec, output or memory operations. Borrowed objects and streams shall remain live throughout the call.

RATIONALE:

Memory reports describe retained owned storage, which can exceed the storage needed for the current mathematical value.

INTERFACE:

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

// Members of Box<ITV>:
memory_size_type external_memory_in_bytes() const;
memory_size_type total_memory_in_bytes() const;
VERIFICATION_CRITERIA:

Check total/external identity, no endpoint-owned storage for native scalar factors, interval-owned GMP limb storage, retained capacity after dimension removal, copies, empty storage and swaps. Compare independent owned-allocation observations and per-element codec/accounting prerequisites without treating allocator metadata as object storage.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/globals_defs.hh; tests/boxtextspec1.cc.

PPL-SPEC-001220
5. Box representation invariant query UID: PPL-SPEC-001220 STATUS: APPROVED COMPONENT: INTERVALS_BOXES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For a live, well-owned and safely indexable box whose selected interval operations are admitted, OK() shall check the following representation conditions. If a current nonempty cache claim is present, the coordinate product shall have no empty factor. Unless the box is certified empty, every coordinate factor shall pass its selected interval OK() query. A violation of a checked condition shall return false; passing these checks shall return true. Zero-dimensional empty and universe shall both pass. Certified empty boxes may retain inactive coordinate storage; its interval validity shall not be a condition of this query.

The receiver's mathematical value, dimension, owned coordinate storage and cached claims shall remain unchanged. The query may copy the box and query interval emptiness on that temporary. Allocation or interval-operation exceptions may propagate; discarded query temporaries shall release their owned storage. Debug builds may emit a diagnostic for an inconsistent nonempty claim; exact diagnostic wording shall not be part of the result.

The interval admission and synchronization conditions of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply to the operations used by the query. Diagnostic use may inspect safely owned but inconsistent cache claims or safely queryable invalid factors. It shall not inspect arbitrary damaged pointers, broken lifetimes or non-indexable fabricated storage. A true result shall not certify arbitrary client preconditions, minimum storage, or that the box is nonempty.

RATIONALE:

The Cartesian product is empty exactly when a factor is empty. A cached nonempty claim must agree with that fact. Factors of an explicitly empty box are inactive and need not describe an independent product.

INTERFACE:

Public header: <ppl.hh>; member of Parma_Polyhedra_Library::Box<ITV>:

bool OK() const;
VERIFICATION_CRITERIA:

Check valid empty, universe, bounded and lazily classified products in zero and positive dimensions, retaining value, cache and storage snapshots. Use the existing narrow status-access fixture to present a safely owned empty factor with a contradictory nonempty cache; require a false result. Use a well-formed diagnostic interval profile to require false when an active factor rejects its own invariant check, and true when the same factor is inactive in a certified empty box. Include successful direct public-header calls without automatic or explicit PPL initialization.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; tests/boxpublicstatespec1.cc; tests/boxstatepublic1.cc.