Parma Polyhedra Library requirements
Internal coefficient-tree insertion, removal and coordinate changes
PPL-SPEC-000616
1. Default-value insertion retains an existing coefficient PPL-SPEC-000616

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.

PPL-SPEC-000617
2. Explicit insertion and replacement capture the argument value PPL-SPEC-000617

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.

PPL-SPEC-000618
3. Hinted insertion preserves the unhinted map result PPL-SPEC-000618

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.

PPL-SPEC-000619
4. Erasure by key returns the strict successor PPL-SPEC-000619

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.

PPL-SPEC-000620
5. Erasure by occupied iterator removes exactly its entry PPL-SPEC-000620

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.

PPL-SPEC-000621
6. Coordinate removal and order-preserving reindexing PPL-SPEC-000621

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.

PPL-SPEC-000622
7. Positive coordinate insertion shifts the complete selected suffix PPL-SPEC-000622

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.

PPL-SPEC-000623
8. Fast leftward key replacement preserves occupied positions PPL-SPEC-000623

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.

PPL-SPEC-000624
9. Backing-array allocation failure preserves the prior map PPL-SPEC-000624

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.