Parma Polyhedra Library requirements
Internal coefficient-tree insertion, removal and coordinate changes
PPL-SPEC-000616
1. Default-value insertion retains an existing coefficient UID: PPL-SPEC-000616 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Under 🔗 1. Ordered coefficient-map values and valid tree use, insertion of a valid key without an explicit value shall preserve an existing entry's coefficient and return its exact position. If the key is absent, it shall add one explicitly stored zero coefficient and return the new entry. Every other association shall be preserved. A new entry shall require the resulting count to be within max_size(). The library coefficient-zero constant shall be available where this form uses it. Ordinary entry iterators shall be reacquired after the call, except for its returned position; cached end references shall retain 🔗 9. Begin positions and owner-stable cached end references.

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.

RATIONALE:

Ensuring that a sparse position exists differs from overwriting a coefficient with a supplied value.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

iterator insert(dimension_type key) &;
VERIFICATION_CRITERIA:

Check absent and present keys across independent finite maps, including nonzero/zero existing values, sparse extremes, empty maps and capacity growth. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc. tests/rowstoragespec1.cc.

PPL-SPEC-000617
2. Explicit insertion and replacement capture the argument value UID: PPL-SPEC-000617 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Insertion with an explicit coefficient shall set the requested key to the argument's value on entry, creating the entry if absent or replacing its prior coefficient if present. The returned iterator shall denote that exact key and stored value. Every other association shall be preserved; zero shall remain an explicitly stored entry. A new entry shall require its resulting count to fit max_size().

The argument may be an independent coefficient or a live coefficient borrowed from this tree, including the replaced entry. Its entry value shall be retained across rebalancing and backing-array relocation. No argument reference shall be retained by the stored coefficient. Clients shall reacquire ordinary iterators after insertion and shall not reuse old coefficient borrows after a new entry can invalidate them. Cached end references shall retain 🔗 9. Begin positions and owner-stable cached end references.

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.

RATIONALE:

Sparse numerical updates need value copying even when a donor belongs to the target owner and insertion changes its layout.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

iterator insert(dimension_type key, data_type_const_reference data) &;
VERIFICATION_CRITERIA:

Compare insertion/overwrite maps for independent arguments, every donor/receiver combination in small maps, and borrowed arguments across real capacity/rebalancing boundaries; check source destruction and multi-limb values where supported. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc. tests/rowstoragespec1.cc.

PPL-SPEC-000618
3. Hinted insertion preserves the unhinted map result UID: PPL-SPEC-000618 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Both hinted insertion forms shall admit any current valid iterator of the same tree, including end, as their hint. The hint shall not affect whether an entry is created or replaced, the returned key, or any resulting key/coefficient association. The default form shall satisfy 🔗 1. Default-value insertion retains an existing coefficient and the explicit-value form 🔗 2. Explicit insertion and replacement capture the argument value, including borrowed coefficient arguments. The hint shall be used only while valid within the call; clients shall reacquire ordinary iterators after return.

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.

RATIONALE:

Locality hints can improve the search strategy but cannot alter coefficient-map semantics.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

iterator insert(iterator itr, dimension_type key) &;
iterator insert(iterator itr, dimension_type key, data_type_const_reference data) &;
VERIFICATION_CRITERIA:

For every occupied/end hint in small maps, compare default and explicit-value results with an independent dictionary, including near/far keys, overwrite, aliasing and empty-map end hints. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc. tests/rowstoragespec1.cc.

PPL-SPEC-000619
4. Erasure by key returns the strict successor UID: PPL-SPEC-000619 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Erasure by a valid key shall remove exactly that entry when present and otherwise preserve the map. It shall return the least remaining stored key strictly greater than the argument, or end if none exists. An empty tree shall return end. The reserved key value shall remain outside this mutation's key precondition even though it is an admitted absent lookup query. All surviving key/coefficient associations shall be preserved, including explicitly stored zeros. Ordinary iterators shall be reacquired after the call; cached end references shall remain valid.

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.

RATIONALE:

A sparse erasure’s continuation is a strict successor even when the requested key was absent.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

iterator erase(dimension_type key) &;
VERIFICATION_CRITERIA:

Compare present/absent erasures against independent dictionaries and upper-bound successors, including both extremes, singleton/empty results, holes, compaction and backing shrinkage. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc. tests/rowstoragespec1.cc.

PPL-SPEC-000620
5. Erasure by occupied iterator removes exactly its entry UID: PPL-SPEC-000620 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Iterator erasure shall require a live occupied iterator from its target tree, rather than end. It shall remove exactly that iterator's entry and return the least remaining stored key greater than the removed key, or end if none exists. Every surviving association shall be preserved. Other ordinary iterators and coefficient references shall be reacquired after this structural mutation; the returned position and cached end references shall remain usable.

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.

RATIONALE:

Removing a known occupied position must retain its successor meaning despite rebalancing or shrinking storage.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

iterator erase(iterator itr) &;
VERIFICATION_CRITERIA:

Erase every occupied position in small maps, compare all survivors and the returned successor, and include first/last/singleton removal and later reuse. Check lvalue admission and temporary-owner rejection with compile-time client expressions. Preserve temporary iterator/view use and lvalue storage identity in runtime checks.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc. tests/rowstoragespec1.cc.

PPL-SPEC-000621
6. Coordinate removal and order-preserving reindexing UID: PPL-SPEC-000621 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Coordinate removal shall admit a valid key k, remove its entry if present, and map every stored key q > k to q − 1 without changing its coefficient. Every key below k shall retain its key and value. This shall also apply when k is absent and to an empty map. The result shall contain exactly the transformed ordered map, including all surviving explicitly stored zeros. Ordinary iterators and coefficient references shall be reacquired; cached ends shall retain 🔗 9. Begin positions and owner-stable cached end references.

erase_and_reindex(index_map) shall require a map covering every stored key. A value of not_a_dimension() shall select erasure; all other images of stored keys shall be valid and strictly increasing. The operation shall produce exactly those surviving entries with the mapped keys and unchanged coefficients, including explicitly stored zeroes. All erasures shall precede key renumbering. If an erasure allocation fails, the tree shall remain valid, possibly with some selected entries erased, and surviving keys shall retain their original numbering. Completed reindexing shall preserve cached-end behavior; ordinary iterators and coefficient references shall be reacquired.

RATIONALE:

Forgetting one coefficient-vector coordinate must shift later coordinates even if the removed coordinate had no stored entry.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

void erase_element_and_shift_left(dimension_type key);
void erase_and_reindex(const std::vector<dimension_type>& index_map);
VERIFICATION_CRITERIA:

Compute an independent remove-and-decrement key transform for present/absent coordinates, zero and extreme valid keys, empty maps, stored zeros and repeated histories.

Compare bulk erasure/reindexing with an independent ordered-map model for empty, identity, complete and partial removals, gaps in the images, absent entries and stored zeroes. Check cached ends, subsequent insertion and recoverable allocation failures after earlier erasures have completed.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc.

PPL-SPEC-000622
7. Positive coordinate insertion shifts the complete selected suffix UID: PPL-SPEC-000622 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

For threshold k and nonnegative amount n, the operation shall map each stored key q ≥ k to q + n and preserve its coefficient; all keys below k shall remain unchanged. Every actually transformed key shall remain a valid representable key, excluding the reserved value. If no key is affected, any representable threshold and amount shall be admitted without evaluating an overflowing key sum. Amount zero shall preserve the map.

The operation shall retain the entry count, coefficient ownership, physical positions and current entry iterators. Existing iterators shall observe the transformed keys and unchanged coefficients. Cached ends shall remain valid.

RATIONALE:

Inserting coordinate positions must retain all suffix coefficient associations and avoid imposing artificial limits on unaffected sparse ranges.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

void increase_keys_from(dimension_type key, dimension_type n);
VERIFICATION_CRITERIA:

Compare independent threshold/addition maps, all valid small amounts, zero, empty/unaffected suffixes and near-reserved key boundaries; check live iterators and coefficient addresses without using overflowing transforms.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc.

PPL-SPEC-000623
8. Fast leftward key replacement preserves occupied positions UID: PPL-SPEC-000623 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Fast shifting shall require an occupied iterator at key q, a valid key i ≤ q, and no other stored key in [i, q). It shall replace exactly q by i, retaining its coefficient and every unrelated association. Choosing i = q shall be admitted. All current entry iterators and coefficient references shall remain valid; the selected iterator shall observe its new key at the same physical position. The map shall retain its entry count and owned storage, with no coefficient copying or allocation needed for the key replacement.

RATIONALE:

An order-preserving key correction can retain live iterator positions when the required gap is already empty.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

void fast_shift(dimension_type i, iterator itr);
VERIFICATION_CRITERIA:

Enumerate valid gap endpoints for every selected entry, compare independent single-key transforms, and retain all iterators/coefficient addresses across no-op and leftward replacements near zero and the reserved maximum.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc.

PPL-SPEC-000624
9. Backing-array allocation failure preserves the prior map UID: PPL-SPEC-000624 STATUS: APPROVED COMPONENT: CORE_DATA_STRUCTURES APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

When insertion or erasure requires replacement backing arrays, a recoverable failure allocating either replacement array shall preserve the prior complete map and its coefficient ownership, release incomplete replacement storage and retain valid cached ends. No insertion, removal or coordinate transformation shall be reported as a successful result when its required backing allocation fails. A retry with sufficient resources shall remain possible.

This guarantee shall cover ordinary and hinted insertion, occupied/key erasure and erase-and-shift operations when they trigger a backing replacement. It shall not promise ordinary recovery after a fatal GMP allocation failure or after violation of a member's valid-input preconditions.

RATIONALE:

Relocation must not consume old coefficient owners until both replacement arrays are available.

INTERFACE:

Internal source header: CO_Tree_defs.hh. Names belong to Parma_Polyhedra_Library. Member signatures apply to CO_Tree; iterator and data_type_const_reference are its nested types.

iterator insert(dimension_type key);
iterator insert(dimension_type key, data_type_const_reference data);
iterator insert(iterator itr, dimension_type key);
iterator insert(iterator itr, dimension_type key, data_type_const_reference data);
iterator erase(dimension_type key);
iterator erase(iterator itr);
void erase_element_and_shift_left(dimension_type key);
VERIFICATION_CRITERIA:

Force growth and shrinkage and fail each replacement-array allocation for every applicable interface, preserving dictionary values and multi-limb owner identities; then retry and check the independent successful mutation.

SOURCE:

src/CO_Tree_defs.hh; src/CO_Tree_inlines.hh; src/CO_Tree.cc; tests/CO_Tree/cotreemutationspec1.cc; tests/CO_Tree/cotree1.cc; tests/CO_Tree/memory1.cc.