Parma Polyhedra Library requirements
C++ rational-grid values and foundational queries

C++ rational-grid values and foundational queries

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-001241
PPL-SPEC-001241
Rational-grid values, coefficient profile and valid use

Grid shall represent the solutions in Rn of a finite system of rational linear congruences. For integer coefficients after common denominator scaling, a row a⋅x ≡ mb shall mean a⋅x − b ∈ mZ when m > 0, and a⋅x = b when m = 0. Empty and universe shall be distinct in every supported ambient dimension. Coordinates absent from all restrictions shall remain free. The coordinate carrier shall remain real, including when all stored coefficients are integral.

A nonempty rational generator description shall denote p + ∑iziiq + ∑jtjℓj, with rational supporting point p, rational parameter directions qi, rational line directions ℓj, zi ∈ Z and tj ∈ R. Additional supporting points shall contribute their displacements from p as integer parameter directions. Generator insertion order shall not affect this mathematical meaning.

coefficient_type shall be the configured Coefficient. Objects and supplied descriptors shall be live and valid. Coordinate identities and reserved dimension indications shall follow 🔗 1. Coordinate type and reserved dimension index. Library and descriptor initialization in 🔗 1. Initialization owners and automatic C++ initialization and 🔗 3. Thread initialization, default state and finalization shall apply. Every coefficient operation, including intermediate calculations, shall meet the selected arithmetic profile's range and resource prerequisites. Exact guarantees shall apply when these preconditions hold; bounded coefficient storage shall not silently turn the grid into an integer-coordinate domain.

When eliminating an equality from a proper congruence, an unrepresentable inhomogeneous difference shall be replaced by an equivalent exact residue modulo the positive row modulus. Range requirements shall continue to apply to modulus scaling and homogeneous coefficients; real coordinates shall not permit reducing homogeneous coefficients modulo that modulus.

Diagonal LCMs used in either description-conversion direction shall be exact even when the working value exceeds the configured coefficient range. Each quotient stored in a destination row shall still fit that range. Cancelling a positive factor shared by proper congruence rows shall include their moduli and stored integrality row, while preserving zero-modulus equalities.

Elimination of a nonzero column between two proper congruences, or between points and parameters, shall store its known zero and positive GCD without requiring cancelling products in that column to fit the coefficient range. Assertion checks of the corresponding Bezout identity shall not add a bounded intermediate-product prerequisite. Non-pivot two-product linear combinations shall be evaluated exactly before applying stored-result range requirements, including when native carrier products overflow. An unrepresentable proper-congruence constant shall use an exact equivalent residue modulo its positive row modulus. Homogeneous coefficients and generator coordinates shall still fit their selected storage; homogeneous terms shall not be reduced modulo a congruence modulus.

Independent objects shall own independent values. Mutation, destruction and operations that may update caches shall be externally synchronized against other uses of the same object. Failed construction shall release the resources acquired by the incomplete object. Failure of an operation on an existing object shall preserve ownership sufficient for safe destruction; rollback or permission for further queries shall require a stronger operation-specific guarantee.

Congruences describe periodic restrictions over real coordinates. Integer parameters, real line directions and ordinary affine equalities have different meanings. The cited grid-domain paper supplies these definitions.

BagnaraDHMZ07 | Section 3, Definition 1 and The Generator Representation (PDF page indices 6–7, zero-based).

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use independent literal congruences and rational point/parameter/line models. Include fractional offsets, continuous directions, discrete periodic sets, multiple supporting points, redundant generators, order permutations, free coordinates and empty/universe in zero dimensions. Inspect configured coefficient admission, initialization and failure ownership. Exercise equality elimination with positive and negative constant differences outside the coefficient range, equal pivot coefficients, and constant products exceeding the native accumulator. Exercise conversion with nonprimitive proper rows, working diagonal LCMs outside the coefficient range, and representable stored quotients in both directions. Eliminate coprime columns with products outside the coefficient range, and verify Bezout identities with large opposing products, in both descriptions and representations. Compare against literal rational generators. Exercise cancellation in non-pivot homogeneous terms, wide modular constant combinations and genuinely unrepresentable stored results. Include large Bezout products exceeding the native carrier.

tests/recyclingconstructors1.cc; src/Grid_defs.hh; src/Grid_nonpublic.cc; src/Grid_simplify.cc; src/Grid_conversion.cc; src/Linear_Expression_Impl_defs.hh; tests/Grid/congruences1.cc; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

class Grid {
public:
  typedef Coefficient coefficient_type;
};
SW_SPEC
2
PPL-SPEC-001242
PPL-SPEC-001242
Dimensioned empty and universe grid construction

Grid(n,kind) shall construct the selected EMPTY or UNIVERSE value in ambient dimension n. Default construction shall produce the zero-dimensional universe. Zero-dimensional universe shall contain the unique empty tuple; zero-dimensional empty shall contain none.

max_space_dimension() shall report the structural limit for Grid in the selected configuration. Requests above that limit, including the reserved dimension indication, shall throw std::length_error before allocating storage for the requested dimension. The limit shall not promise that actual resources suffice for every smaller request. Failed construction shall release resources acquired by the incomplete object.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Distinguished grid values require an ambient dimension even when there are no points. Structural dimension validation precedes extent-dependent storage.

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Check defaults, both distinguished values in zero and positive dimensions, structural bounds and oversized/reserved requests for both kinds. Inject allocation failures into admitted construction and check incomplete-object cleanup.

src/Grid_inlines.hh; src/Grid_nonpublic.cc; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

explicit Grid(dimension_type n=0, Degenerate_Element kind=UNIVERSE);
static dimension_type max_space_dimension();
SW_SPEC
3
PPL-SPEC-001243
PPL-SPEC-001243
Owned grid copying, assignment and destruction

Copy construction shall produce an independent grid with the source's represented set and ambient dimension. The three declared complexity values shall not alter ordinary copying. Assignment shall replace the receiver's represented set and dimension with the source's, return a reference to the receiver, and support different dimensions and self-assignment. Mutation or destruction of either independent value shall not change the other value.

Destruction shall release owned resources exactly once. Failed copy construction shall release resources acquired by the incomplete object. Failed assignment shall preserve ownership needed for safe destruction; rollback to the receiver's entry value shall not be required.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Value semantics must be independent of whether congruences, generators or both cached descriptions are current.

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Cross empty, universe, fractional singleton, periodic and continuous grids with different dimensions, self-assignment and all complexity values. Copy before and after each representation is minimized, mutate each object independently, destroy sources, and inject allocation failures without assuming failed-assignment rollback.

src/Grid_public.cc; src/Grid_inlines.hh; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

Grid(const Grid& source, Complexity_Class complexity=ANY_COMPLEXITY);
Grid& operator=(const Grid& source);
~Grid();
SW_SPEC
4
PPL-SPEC-001244
PPL-SPEC-001244
Whole grid value exchange

x.m_swap(y) and swap(x,y) shall exchange the represented grids, ambient dimensions and owned representation state. They shall support self exchange and grids of different dimensions. Subsequent independent mutation shall affect only its selected object. Exchange shall not require grid normalization, coefficient arithmetic or new allocation.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Exchanging ownership can preserve whole values without rebuilding either dual description.

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Cross different dimensions, distinguished values and cold/minimized cache histories. Check both forms and self exchange, independent mutation and the absence of allocations while exchange runs.

src/Grid_inlines.hh; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

void m_swap(Grid& other);
void swap(Grid& left, Grid& right);
SW_SPEC
5
PPL-SPEC-001245
PPL-SPEC-001245
Exact grid construction from congruence systems

Construction from a valid Congruence_System shall inherit its ambient dimension and denote exactly the simultaneous solutions of its rows. Equalities, proper congruences, redundant rows, tautologies and inconsistent systems shall retain their congruence meanings. A system without restrictions shall describe universe in its ambient dimension. Zero-dimensional systems shall give universe or empty according to their constant conditions.

can_recycle_congruence_systems() shall return true.

The const-reference form shall preserve its source. The non-const rvalue form may consume source storage; after successful or exceptional return the source shall require no operation other than destruction. Both forms shall reject a source dimension above max_space_dimension() with std::length_error before dimension-dependent storage allocation.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Congruence input is an exact defining description, including periodicity that cannot be recovered from an affine hull alone.

BagnaraDHMZ07 | Section 3, Definition 1 (PDF page index 6, zero-based).

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Evaluate literal congruences independently on rational witnesses. Cross copied and recycled systems, inconsistent nontrivial pairs, zero-dimensional constants, fractional residue classes, redundant rows and ambient free coordinates. Check source preservation for copying and destruction-only cleanup for recycling, including injected failures.

src/Grid_inlines.hh; src/Grid_nonpublic.cc; tests/gridvaluesspec1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

static bool can_recycle_congruence_systems();
explicit Grid(const Congruence_System& source);
Grid(Congruence_System&& source);
SW_SPEC
6
PPL-SPEC-001246
PPL-SPEC-001246
Exact grid construction from generator systems

Construction from a valid Grid_Generator_System shall inherit its ambient dimension and denote its point, integer-parameter and real-line combinations in 🔗 1. Rational-grid values, coefficient profile and valid use. An empty system shall construct an empty grid. A nonempty system without a supporting point shall throw std::invalid_argument. A supporting point in zero dimensions shall construct zero-dimensional universe. Generator insertion order, redundant points and equivalent simultaneous rescaling of generator numerators and divisors shall not change the represented set.

The const-reference form shall preserve its source. The non-const rvalue form may consume source storage; after successful or exceptional return the source shall require no operation other than destruction. A source dimension above max_space_dimension() shall throw std::length_error before allocating dimension-dependent grid storage.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

A supporting point fixes the affine offset; parameters and lines supply different displacement sets. A collection of directions without a supporting point is not an admitted nonempty constructor input.

BagnaraDHMZ07 | Section 3, The Generator Representation and Definition 3 (PDF page index 7, zero-based).

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Check literal rational point/parameter/line models, repeated and different supporting points, unequal divisors, both constructor forms, free directions, empty and zero-dimensional inputs. Reject line-only and parameter-only systems. Permute generator order and check the value before normalization as well as after each minimized view.

src/Grid_inlines.hh; src/Grid_nonpublic.cc; tests/gridvaluesspec1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

explicit Grid(const Grid_Generator_System& source);
Grid(Grid_Generator_System&& source);
SW_SPEC
7
PPL-SPEC-001247
PPL-SPEC-001247
Grid construction from equality constraint systems

For positive ambient dimension, construction from a Constraint_System shall accept equality rows and denote exactly their common affine subspace. An empty system shall describe universe in its ambient dimension. An inequality row shall throw std::invalid_argument in positive dimension.

In zero dimensions, constant conditions shall instead be evaluated directly: a system whose rows are all satisfied shall construct universe, and any inconsistent row shall construct empty, including an inconsistent constant inequality. Both forms shall inherit the source's ambient dimension.

can_recycle_constraint_systems() shall return true.

The const-reference form shall preserve its source. The non-const rvalue form shall permit source consumption; after successful or exceptional return the source shall require no operation other than destruction. Oversized source dimensions shall throw std::length_error before dimension-dependent grid storage.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Affine equalities are grid congruences with zero modulus. Positive-dimensional inequality systems require a separate conversion policy, while zero-dimensional constraints are constant truth conditions.

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Check copied and recycled equality systems against independent affine solutions, inconsistent equalities and free coordinates. Check rejection of positive-dimensional strict/nonstrict inequalities. Enumerate constant zero-dimensional truth/falsity conditions, and inject constructor failures while respecting recycled-source destruction-only use. Check coefficient storage transfer for an equality in the destination representation, and conversion of NNC equality rows without retaining the hidden epsilon coordinate as a grid dimension.

src/Grid_public.cc; src/Grid_inlines.hh; tests/gridvaluesspec1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

static bool can_recycle_constraint_systems();
explicit Grid(const Constraint_System& source);
Grid(Constraint_System&& source);
SW_SPEC
8
PPL-SPEC-001248
PPL-SPEC-001248
Ambient and affine grid dimensions

space_dimension() shall report the ambient dimension without changing the represented grid. affine_dimension() shall return zero for empty and zero-dimensional grids; otherwise it shall return the dimension of the least affine subspace containing the grid. For a nonempty generator description this shall equal the rational rank of its line directions, parameter directions and supporting-point differences.

The answer shall be independent of the current dual representation, redundant input rows, generator order and prior normalization.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

A periodic full-rank grid is affinely full-dimensional even though it is discrete. Ambient dimension remains meaningful for empty sets.

BagnaraDHMZ07 | Section 3, generator representation and minimal forms (PDF page indices 7–8, zero-based).

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use independent exact rational elimination on literal direction vectors and point differences. Include singleton, lower-dimensional periodic and continuous values, full-rank discrete grids, empty/universe, redundant systems, both input descriptions and alternate normalization histories.

src/Grid_inlines.hh; src/Grid_public.cc; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

dimension_type space_dimension() const;
dimension_type affine_dimension() const;
SW_SPEC
9
PPL-SPEC-001249
PPL-SPEC-001249
Exact foundational grid classification

The following queries shall make exact decisions on admitted grid values:

  • is_empty() shall return true exactly for the empty represented set.
  • is_universe() shall return true exactly for all of the ambient real coordinate space.
  • is_bounded() shall return true exactly for empty or singleton grids.
  • is_discrete() shall return true exactly when every represented point is isolated; empty shall be discrete. In a nonempty rational generator description this is equivalent to the absence of nonzero line directions.
  • is_topologically_closed() shall return true for every rational grid.
  • contains_integer_point() shall return true exactly when the grid intersects Zn; zero-dimensional universe shall contain the integer empty tuple and zero-dimensional empty shall contain none.
  • constrains(v) shall return true exactly when independently varying coordinate v can leave the grid. Empty shall constrain every in-range coordinate. An out-of-range coordinate shall throw std::invalid_argument before an empty/universe shortcut.

Answers shall not depend on generator insertion order or whether the current congruence/generator descriptions have been normalized. A periodic restriction shall not be mistaken for an interval bound or a continuous free coordinate.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Nonzero parameter directions give unbounded integer displacements; nonzero line directions give arbitrarily small real displacements. A finite intersection of linear congruence solution sets is closed. These are different properties from whether an integer-coordinate point exists.

BagnaraDHMZ07 | Section 3, grid and generator definitions (PDF page indices 6–7, zero-based).

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use independently described rational singletons, periodic lattices, continuous lines and affine subspaces, fractional offsets excluding all integer points, inconsistent systems and all zero-dimensional cases. Cross constructor forms, redundant descriptions, all generator permutations and normalization orders. Check coordinate independence using literal line spans and validate out-of-range arguments even for empty and universe.

src/Grid_public.cc; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

bool is_empty() const;
bool is_universe() const;
bool is_bounded() const;
bool is_discrete() const;
bool is_topologically_closed() const;
bool contains_integer_point() const;
bool constrains(Variable coordinate) const;
SW_SPEC
10
PPL-SPEC-001250
PPL-SPEC-001250
Borrowed congruence and generator views of grid values

Borrowed congruence and grid-generator accessors shall require an lvalue receiver, with corresponding const && overloads deleted. Returned references shall not extend the receiver's lifetime. Constraint extraction returns an independent value and shall remain available on temporary grids.

congruences() and grid_generators() shall return valid descriptions of the receiver's exact represented grid in the same ambient dimension. If the required description is stale, it shall be computed without changing the grid's mathematical meaning.

minimized_congruences() and minimized_grid_generators() shall additionally supply the corresponding minimized triangular representations. Required administrative integrality rows may remain in congruence storage. These interfaces shall not promise a unique physical row order or byte-identical records across equivalent descriptions.

Returned references shall borrow receiver-owned storage. Their use shall require the receiver to remain live and no intervening operation capable of replacing or normalizing the borrowed representation. Iterators and row references shall obey the same condition. An independently copied returned system shall remain independent of later receiver mutation or destruction. Empty and zero-dimensional values shall retain their exact distinguished meanings in both descriptions.

The lifetime, initialization, arithmetic and synchronization prerequisites in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply. A logically const operation may update cached representations while preserving the represented grid and ambient dimension. Supported arithmetic and allocation failures may propagate through their declared channels; surviving ownership shall permit safe destruction, without a general rollback guarantee.

Before aligning proper-congruence moduli in a bounded profile, simplification shall remove each row's redundant sign, constant-residue and common-factor scaling. A tautological constant row shall retain a nonzero integrality representative. Alignment shall preserve the same rational satisfying set.

For a bounded discrete generator system, elimination may temporarily cancel the common positive factor of every coupled point/parameter coordinate and divisor, restoring that physical scale after reduction. The resulting strong form shall retain its previous storage scale. Lines shall not be rescaled by this operation, and integer-parameter periods shall not change. Centered coordinate reduction shall also accept a positive pivot at the profile's largest admissible coefficient without overflowing the half-pivot calculation. For a least signed pivot input, Bezout computation shall own its working magnitudes and admit only the completed positive gcd and signed coefficients; an unrepresentable input magnitude alone shall not cause arithmetic failure.

During triangular conversion, the selected coordinate's scaling and exact division shall be fused; an unrepresentable product immediately cancelled by that division shall not be stored. Other coupled point/parameter or proper- congruence rows shall receive the required common scale. Independent line or equality scales shall remain independent. Complete column differences shall be evaluated exactly. If an inverse-column working value exceeds the coefficient range, conversion shall replay the complete triangular inverse using independently owned unbounded integers. Later exact divisions shall precede admission of destination coefficients. Final unrepresentable entries shall still raise the configured range exception, including in native coefficient profiles. Replay shall preserve the source rows, their dimension kinds and the distinct coupled or independent row scales.

Clients need exact dual views while ownership and normalization invalidate physical observations independently of mathematical value.

BagnaraDHMZ07 | Section 3, Definitions 2–3, Propositions 1–3 and Double Description (PDF page indices 7–8, zero-based).

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Exercise both conversion directions with the literal lattice x = 1 ⁄ 60 + z ⁄ 3, y = 1 ⁄ 2 + 2w ⁄ 5, c =  − 1 ⁄ 3 for independent integers z, w. Check its equivalent congruences, positive and negative periods, rejected supporting points, both representations and row orders, and unchanged independent input systems.

Compare exported congruences with literal rational membership conditions and generated points/directions. Alternate the four accessors after each input form and verify dimensions, value preservation and admissible minimal forms. Reject borrowing from temporary grids while admitting independent constraint extraction from them. Copy borrowed systems, mutate or destroy the owner, and check the copied systems independently. Exercise empty, redundant and inconsistent inputs.

src/Grid_public.cc; src/Grid_conversion.cc; src/Grid_simplify.cc; tests/Grid/gridboundedconversion1.cc; tests/exactboundedworking1.cc; tests/gridvaluesspec1.cc; tests/gridvaluespublic1.cc; tests/gridvaluesfailure1.cc.

CPP
Public

Public header: <ppl.hh>; excerpts for Grid and related free functions in Parma_Polyhedra_Library:

const Congruence_System& congruences() const &;
const Congruence_System& minimized_congruences() const &;
const Grid_Generator_System& grid_generators() const &;
const Grid_Generator_System& minimized_grid_generators() const &;