Parma Polyhedra Library requirements
Internal extended-number row storage

Internal extended-number row storage

UID:
VERSION:
CLASSIFICATION:
PREFIX:
Type
Level
MID
UID
REFS
Title
Statement
Rationale
Comment
BIBLIOGRAPHY
STATUS
COMPONENT
APPLICABILITY
VERIFICATION_METHODS
VERIFICATION_CRITERIA
SOURCE
LANGUAGE
VISIBILITY
INTERFACE
SW_SPEC
1
PPL-SPEC-000651

DB_Row<T> shall own an indexed finite sequence of extended-number values. The selected T and checked-number operations shall support positive infinity initialization, the requested copying/conversion, validity and memory hooks, and nonthrowing destruction. Numerical operations shall satisfy their configured policy, representability and rounding prerequisites; initialization and synchronization shall follow 🔗 3. Thread initialization, default state and finalization where the selected element operations require them.

Default construction shall produce a preconstructed owner with no row storage. This state shall admit destruction, ordinary copying/assignment, complete-owner swapping and first allocation/construction. Size, element, iterator, memory and validity queries shall require a constructed row. A constructed zero-length row shall be distinct from a preconstructed owner and shall admit ordinary constructed-row queries. Calls shall use live valid owners, nonoverflowing supported sizes/capacities and sufficient resources; failures shall not be successful numerical results.

Efficient numerical matrices distinguish an owner awaiting storage from a fully constructed row that happens to have no entries.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check legal preconstructed copying/assignment/swap and later construction without querying unconstructed storage; compare independent finite sequences in constructed empty and nonempty rows.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

template <typename T> class DB_Row;
DB_Row();
SW_SPEC
2
PPL-SPEC-000652
PPL-SPEC-000652
Allocation and positive-infinity row construction

On a preconstructed owner, allocate(capacity) shall acquire storage for at least the requested capacity and produce a constructed row of logical size zero. construct(size,capacity) and the corresponding sizing constructor shall construct exactly size logical entries, each initialized to positive infinity, with at least capacity storage. The one-size forms shall use the requested size as their capacity request.

Calls shall require 0 ≤ size ≤ capacity ≤ max_size(). Zero logical size and zero capacity request shall be admitted; a configured one-element-tail representation may reserve one physical slot for that request without creating a logical entry. Postconstruction/allocation shall not be repeated on an already allocated owner. Element lifetimes and failure states shall obey 🔗 10. Row construction cleanup and recoverable failure states.

A new difference-bound row starts with unconstraining positive-infinity bounds and a separately controlled logical extent.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare tight, spare-capacity, staged allocation/construction and direct construction for zero/nonzero sizes in native, GMP integer and GMP rational profiles; check every initial entry is positive infinity.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

void allocate(dimension_type capacity);
void construct(dimension_type size);
void construct(dimension_type size, dimension_type capacity);
DB_Row(dimension_type size);
DB_Row(dimension_type size, dimension_type capacity);
SW_SPEC
3
PPL-SPEC-000653
PPL-SPEC-000653
Independent row copies and enlarged copies

Ordinary copy construction shall preserve a source's construction state. A constructed source shall yield an independently owned sequence of the same size and values; a preconstructed source shall yield a preconstructed target. The explicit-capacity copy shall require a constructed source and capacity at least its size. The size/capacity copy shall additionally require the new size to be at least the source size and at most capacity; it shall preserve source entries and initialize every additional entry to positive infinity.

Successful copying shall not alter the source. Later changes or destruction of either owner shall not change the other's values. A source supplied through an rvalue shall use ordinary copy construction; no distinct move operation shall be required. Each capacity shall satisfy 🔗 2. Allocation and positive-infinity row construction; failed construction shall follow 🔗 10. Row construction cleanup and recoverable failure states.

Copying mathematical bounds must preserve exact values and independent ownership, while enlargement adds unconstraining new entries.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare copied values/addresses, alternative capacities, enlarged infinity suffixes, preconstructed sources, source mutation/destruction and multi-limb integer/rational payloads.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

DB_Row(const DB_Row& y);
DB_Row(const DB_Row& y, dimension_type capacity);
DB_Row(const DB_Row& y, dimension_type size, dimension_type capacity);
SW_SPEC
4
PPL-SPEC-000654
Row assignment and ownership-preserving swaps

Assignment shall replace the target with an independent ordinary copy of the source's values and construction state and return the target wrapper. It shall admit distinct owners and self-assignment. A recoverable failure preparing the replacement shall preserve the prior complete target and source. Assignment from a preconstructed source shall release old target storage and leave the target preconstructed.

Member/free swap shall exchange complete owned implementations and their construction states without coefficient copying or allocation, admitting preconstructed, constructed, empty and self-swapped rows. Existing element references/iterators shall retain the same live objects, now owned by the other row. Row iter_swap shall perform that whole-owner exchange at two valid vector positions. Old target borrows after replacement assignment shall not be reused. 🔗 1. Extended-number row meaning and construction states shall apply.

Mathematical value replacement and storage-owner exchange have different borrowing and failure guarantees.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check independent assignment and source destruction, preconstructed-state transfer, self-assignment, allocated/preconstructed swapping, retained coefficient addresses, vector row iter_swap, and allocation/element-copy failure preservation.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

DB_Row& operator=(const DB_Row& y);
void m_swap(DB_Row& y);
template <typename T> void swap(DB_Row<T>& x, DB_Row<T>& y);
template <typename T>
void iter_swap(typename std::vector<DB_Row<T>>::iterator x,
               typename std::vector<DB_Row<T>>::iterator y);
SW_SPEC
5
PPL-SPEC-000655
Row sizes, supported limits, coefficient ranges and equality

size() shall return the logical entry count of a constructed row. max_size() shall report an element-count bound compatible with the representable allocation extent including implementation metadata; available memory may impose a lower limit. At 0 ≤ i < size(), subscript access shall return the exact mutable or const stored entry reference.

Mutable and const begin/end shall span those same logical entries in order, with equal endpoints for a constructed empty row. Their random-access pointer adapters shall retain 🔗 1. Pointer-adapter types and borrowed storage through 🔗 6. Pointer-adapter compatible comparisons and mixed distance. Equality of two constructed rows shall mean equal sizes and pairwise equal element values under the selected T equality; inequality shall negate it. Equality shall not depend on spare capacity or ownership addresses. Queries shall not change entries or ownership.

Member overloads that return references, iterators or nonowning views into the owner shall require an lvalue owner. Matching rvalue calls that would produce such borrows shall be rejected during overload resolution. Temporary iterator and row-view values shall remain usable while their backing owner remains alive.

Coordinate access and comparison must describe the logical sequence rather than allocated slack or accidental storage identity.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check Boolean inequality expressions in both operand orders through C++20 equality rewriting, retaining the stated equality and mismatch behavior. Compare all valid indexed/iterator positions and pairwise row values, unequal sizes and contents, empty ranges, mixed const views, standard traversal algorithms and the metadata-inclusive maximum allocation formula. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc. tests/rowstoragespec1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

static dimension_type max_size();
dimension_type size() const;
T& operator[](dimension_type i) &;
const T& operator[](dimension_type i) const &;
typedef Implementation::Ptr_Iterator<T*> iterator;
typedef Implementation::Ptr_Iterator<const T*> const_iterator;
iterator begin() &;
iterator end() &;
const_iterator begin() const &;
const_iterator end() const &;
template <typename T> bool operator==(const DB_Row<T>& x, const DB_Row<T>& y);
// Inequality uses C++20 rewriting of operator==.
SW_SPEC
6
PPL-SPEC-000656
PPL-SPEC-000656
Within-capacity expansion and suffix destruction

Expansion shall require a constructed row and a new size between its current size and actual capacity. It shall retain all existing entries and construct each added logical position as positive infinity. Shrinking shall require a new size no greater than the current size, retain the prefix and destroy the removed suffix in reverse construction order. Re-expanding previously removed positions shall create fresh infinity entries, without restoring their former values.

Both operations shall retain backing capacity and all surviving prefix objects/addresses. Borrows of destroyed suffix entries shall become invalid. Zero/no-op sizes shall be admitted. If a recoverable element construction failure interrupts expansion, the row shall retain its old prefix plus exactly the successfully constructed new prefix and record that logical size; it shall remain destructible and reusable under 🔗 10. Row construction cleanup and recoverable failure states.

Bound-row resizing must preserve surviving coordinates and make every newly introduced bound unconstraining.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare every small shrink/regrowth boundary and retained address with independent prefix models; count element lifetimes and inject each expansion construction failure, then retry.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

void expand_within_capacity(dimension_type new_size);
void shrink(dimension_type new_size);
SW_SPEC
7
PPL-SPEC-000657
Pointwise upward conversion of extended-number rows

Upward-approximation construction shall require a preconstructed target, a constructed source, and an admitted capacity at least the source size. It shall produce the same logical size, independently owning a converted value at each source coordinate. Each successfully converted finite value shall be an upper bound on its exact source value under the selected conversion's supported ROUND_UP semantics; exactly representable conversions shall preserve that value. Admitted signed infinities shall retain their extended-number meaning.

Conversion shall preserve the source. Selected source/target policies shall support all requested values and rounding directions, with every arithmetic/resource precondition active. Empty constructed sources shall produce constructed empty targets. Recoverable failures shall follow 🔗 10. Row construction cleanup and recoverable failure states and shall not be reported as successful bounds.

Changing the numeric representation of difference bounds must round outward coordinate by coordinate.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Compare signed rational inputs against independent GMP ceilings for integral targets and exact rational copies for rational targets, include both infinities and empty rows, and check source preservation.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

template <typename U>
void construct_upward_approximation(const DB_Row<U>& y,
                                    dimension_type capacity);
SW_SPEC
8
PPL-SPEC-000658
Row storage and live-payload memory accounting

For a constructed row and its actual physical capacity, the explicit- capacity external-memory query shall account for the complete allocated implementation, coefficient-slot storage and owned external payload of every physically live coefficient object, including a configured fallback's live first object at logical size zero. Total memory shall additionally include the row wrapper itself. Capacity supplied to these exact queries shall describe the actual allocation, including a one-slot minimum imposed by the configured tail representation.

Queries without supplied capacity shall return lower bounds consistent with known logical size and available capacity metadata. Their total- minus-external difference shall equal the wrapper size. Memory arithmetic shall be representable in memory_size_type and element memory hooks shall accurately describe their owned payload. Queries shall not change row values, element lifetimes or ownership.

Logical element count and known physical capacity support different memory estimates; owned numerical payload must remain part of either accounting scope.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check metadata/slot formulas and GMP payload sums at known capacities, no-capacity lower bounds, wrapper-size differences and retained physical-object payload after shrink-to-zero in each configured tail layout.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

memory_size_type external_memory_in_bytes() const;
memory_size_type total_memory_in_bytes() const;
memory_size_type external_memory_in_bytes(dimension_type capacity) const;
memory_size_type total_memory_in_bytes(dimension_type capacity) const;
SW_SPEC
9
PPL-SPEC-000659
Constructed-row validity checks and diagnostic metadata

On a constructed row with valid storage and an admitted actual capacity, OK(expected_size,expected_capacity) shall return false for a mismatched logical size or for an entry that fails its own OK() hook or represents NaN. A row with matching size and valid non-NaN entries shall pass these checks. The configured extra-debug representation shall additionally compare its stored capacity with supplied capacity metadata and ensure logical size fits that stored capacity, treating the configured one-slot minimum for zero request consistently.

Ordinary configurations shall not be required to retain/check capacity metadata. This query shall not repair entries or validate unconstructed storage. An exception from an element hook shall propagate with the hook's own state guarantee; node ownership shall remain with the row.

Validity diagnostics distinguish wrong logical metadata or unusable bound values from a successfully represented row.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Check valid rows, deliberately mismatched expected size, an admitted NaN diagnostic value followed by repair, and configured extra-debug capacity checks without corrupting storage.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

bool OK(dimension_type expected_size, dimension_type expected_capacity) const;
SW_SPEC
10
PPL-SPEC-000660

A recoverable backing-allocation failure shall release incomplete storage; failed first allocation shall leave a postconstruction receiver preconstructed. Failure of a sizing/copy constructor shall destroy every completed coefficient and release all storage of the incomplete owner, preserving the source. Failed replacement assignment shall retain 🔗 4. Row assignment and ownership-preserving swaps.

If a postconstruction or within-capacity expansion call fails after acquiring storage, its receiver shall remain constructed with the successfully completed coefficient prefix recorded in its logical size. It shall retain owned storage and admit destruction, valid shrinkage, copying and a valid expansion retry. It shall not require a repeat of first allocation on the already allocated receiver. No completed element shall be leaked or destroyed twice. A configured fallback's already-live first physical element shall retain its correct lifetime even at logical size zero. These guarantees shall apply to supported recoverable C++ exceptions rather than fatal GMP allocation failure or violated inputs.

A split allocation/construction protocol needs precise partial-prefix states as well as ordinary failed-constructor cleanup.

APPROVED
CORE_DATA_STRUCTURES
IF_CPP
Test, Analysis, Inspection

Fail backing allocations and each observable coefficient construction/copy, check source/target preservation or admitted partial-prefix size, exact live/destruction counts and storage balance, then retry or destroy safely in both tail configurations.

src/DB_Row_defs.hh; src/DB_Row_inlines.hh; src/DB_Row_templates.hh; tests/dbrowspec1.cc; tests/dbrowlegacy1.cc; tests/dbrowallocation1.cc; tests/dbrowiteratorlaws1.cc; tests/dbrowownedhistories1.cc.

CPP
Internal

Internal source header: DB_Row_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to DB_Row<T>; iterator and memory aliases have their declared source types.

void allocate(dimension_type capacity);
void construct(dimension_type size);
void construct(dimension_type size, dimension_type capacity);
DB_Row(dimension_type size);
DB_Row(dimension_type size, dimension_type capacity);
DB_Row(const DB_Row& y);
DB_Row(const DB_Row& y, dimension_type capacity);
DB_Row(const DB_Row& y, dimension_type size, dimension_type capacity);
template <typename U>
void construct_upward_approximation(const DB_Row<U>& y,
                                    dimension_type capacity);
DB_Row& operator=(const DB_Row& y);
void expand_within_capacity(dimension_type new_size);