Parma Polyhedra Library requirements
C++ rational-grid comparisons and relations

C++ rational-grid comparisons and relations

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-001251
PPL-SPEC-001251
Exact grid equality and inequality

operator== shall return true exactly when both ambient dimensions and represented sets agree. Different dimensions shall compare unequal, including empty grids in different dimensions. Inequality expressions shall be the logical negation of equality. Equal-dimensional empty grids shall compare equal, including when inconsistency has not previously been detected. Self comparison shall have the ordinary reflexive result for every admitted value.

The result shall be independent of constructor choice, generator order, redundant descriptors and the current dual-description caches.

The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate calculations. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Set equality includes periodicity and the ambient coordinate space; matching affine hulls or matching syntactic rows alone do not establish equality.

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

APPROVED
GRIDS
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 independent rational cosets, continuous subspaces, singletons, empty/universe and incompatible dimensions. Use literal generator/congruence models and alternate construction, normalization and reload histories. Include unequal lattices with identical affine hulls and equal values with redundant generators.

src/Grid_public.cc; src/Grid_inlines.hh; src/Grid_nonpublic.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

bool operator==(const Grid& left, const Grid& right);
// Inequality uses C++20 rewriting of operator==.
SW_SPEC
2
PPL-SPEC-001252
PPL-SPEC-001252
Equality-compatible grid hashing

hash_code() shall return a value of type int32_t. Equal grid values under 🔗 1. Exact grid equality and inequality shall have equal hashes. Normalization, query history and equivalent descriptions shall not change the hash of an unchanged grid. Hash collisions shall be permitted, including between unequal values of the same dimension. The numerical hash shall not be a persistent identifier or promise a value stable across library versions or configurations.

The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate calculations. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Hash compatibility permits associative storage without implying that a coarse hash distinguishes different sets.

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Check exact equal-value descriptions before and after each cache transition, copy, assignment and self comparison. Verify the public return type and do not infer inequality from equal hashes.

src/Grid_inlines.hh; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

int32_t hash_code() const;
SW_SPEC
3
PPL-SPEC-001253
PPL-SPEC-001253
Exact grid containment

For equal-dimensional grids, left.contains(right) shall return true exactly when γ(right) ⊆ γ(left). Every grid shall contain the empty grid; empty shall contain no nonempty grid; universe shall contain every equal-dimensional grid. Self containment shall hold. Different ambient dimensions shall throw std::invalid_argument before empty, universe or identity shortcuts. Previously undetected inconsistency shall retain the same set meaning.

The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate calculations. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Containment must respect integer parameter steps and rational offsets, not only affine spans or the presence of individual points.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use exact rational one-dimensional coset divisibility and invertible coupled-coordinate products. Cross all pairs of empty, singleton, periodic and continuous factors; vary representations and query order. Check reflexivity, containment of empty and dimension rejection.

src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

bool contains(const Grid& other) const;
SW_SPEC
4
PPL-SPEC-001254
PPL-SPEC-001254
Exact strict grid containment

For equal-dimensional grids, left.strictly_contains(right) shall return true exactly when γ(right) ⊊ γ(left). It shall be false for self comparison and equal sets; a nonempty grid shall strictly contain empty. Different ambient dimensions shall throw std::invalid_argument even when either operand is empty.

The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate calculations. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Strict containment combines inclusion with semantic inequality; changes only to representation cannot make containment strict.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use the same independent coset/product inclusion oracle as containment. Check strict chains of periods, fractional shifts, equal alternate representations, self comparison, empty and incompatible dimensions.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

bool strictly_contains(const Grid& other) const;
SW_SPEC
5
PPL-SPEC-001255
PPL-SPEC-001255
Exact grid disjointness

For equal-dimensional grids, left.is_disjoint_from(right) shall return true exactly when γ(left)∩γ(right) = ⌀. The result shall be symmetric. Empty shall be disjoint from every grid, including itself; no nonempty grid shall be disjoint from itself. Different ambient dimensions shall throw std::invalid_argument before shortcuts. Success shall preserve both operands even when detecting inconsistent input or incompatible periodic residues.

The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate calculations. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Intersecting affine hulls do not establish that periodic grids share a point. Rational residue compatibility determines lattice intersection.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use independent rational greatest-common-divisor conditions for cosets, then combine independent coordinates through invertible rational maps. Include fractional periods, incompatible shifts, singleton membership, continuous factors, zero dimensions, symmetry and argument rejection.

src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

bool is_disjoint_from(const Grid& other) const;
SW_SPEC
6
PPL-SPEC-001256
PPL-SPEC-001256
Exact grid relation with a congruence

relation_with(cg) shall classify the grid relative to the solution set of cg. For nonempty grids it shall report exactly one of is_included(), is_disjoint() and strictly_intersects(): respectively all points satisfy cg, no point does, or both satisfying and nonsatisfying points exist. Empty shall report is_included() && is_disjoint() && saturates(). An equality congruence shall additionally report saturates() exactly when the grid is included in its equality hyperplane. For a nonempty positive-dimensional grid and a proper congruence, the returned relation shall consist of the inclusion/disjointness/intersection assertion alone. Zero-dimensional universe shall report is_included() && saturates() for a true constant congruence and is_disjoint() for a false one.

For a nonempty generator description, let S = {a⋅x − b : x ∈ γ(G)}. If a real line has nonzero scalar image, S = R. Otherwise S = s + dZ, where s = a⋅p − b and d ≥ 0 generates the rational subgroup of parameter images and supporting-point differences. This scalar image shall determine equality and periodic intersection without depending on generator order or rational divisor representation.

A congruence dimension greater than the grid dimension shall throw std::invalid_argument before distinguished-value shortcuts. Smaller descriptors shall have zero coefficients in the remaining coordinates.

Scalar products, rational point differences and modulus/divisor products used solely for relation classification shall be exact even when their intermediates exceed the configured coefficient range. The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply; cached descriptor conversion and normalization remain subject to the configured arithmetic profile. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Exact relation queries require rational residue arithmetic, including point offsets, integer combinations of all parameter images and arbitrary real line images. Saturation and periodic inclusion have distinct API assertion conventions.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use the independent integer-scaled scalar-image gcd oracle and all point/parameter/line permutations in the existing relation tests. Include fractional divisors, extra supporting points, proper/equality constants, undetected emptiness, alternate caches, zero dimensions and rejection.

src/Grid_public.cc; tests/Grid/relations2.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

Poly_Con_Relation relation_with(const Congruence& cg) const;
SW_SPEC
7
PPL-SPEC-001257
PPL-SPEC-001257
Exact grid relation with a linear constraint

relation_with(c) shall classify all points, no points or a proper nonempty subset of grid points satisfying c using is_included(), is_disjoint() or strictly_intersects(). Empty shall report is_included() && is_disjoint() && saturates(). In every case, saturates() shall be present exactly when every grid point lies on the equality hyperplane obtained from c by replacing its relation with equality. Thus a grid on the boundary of a strict inequality shall report is_disjoint() && saturates().

For nonempty grids, a nonconstant scalar image along any line, parameter or supporting-point displacement shall take values on both sides of every finite halfspace threshold. Otherwise the scalar image shall be constant and its sign shall determine strict/nonstrict satisfaction and saturation. Equality constraints shall use the exact equality-congruence meaning in 🔗 6. Exact grid relation with a congruence.

A constraint dimension greater than the grid dimension shall throw std::invalid_argument before shortcuts; omitted coefficients shall be zero. Strict boundary behavior shall apply also to constant constraints and zero dimensions.

Strict constraints extracted from NNC polyhedra shall retain their mathematical relation when queried against a larger-dimensional grid.

Scalar products, rational point differences and modulus/divisor products used solely for relation classification shall be exact even when their intermediates exceed the configured coefficient range. The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply; cached descriptor conversion and normalization remain subject to the configured arithmetic profile. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Integer displacements still extend in both signs, so a nonconstant linear form on a grid cannot have a one-sided finite extremum. Saturation concerns the boundary hyperplane independently of inequality satisfaction.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Exercise literal affine annihilators, unbounded parameter/line images, rational supporting points and boundary equalities. Reuse independent strict-boundary and scalar-sign controls, with generator permutations, cache histories, constants, latent empty values and dimension errors.

src/Grid_public.cc; tests/Grid/relations3.cc; tests/Grid/relations1.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

Poly_Con_Relation relation_with(const Constraint& c) const;
SW_SPEC
8
PPL-SPEC-001258
PPL-SPEC-001258
Exact grid subsumption of grid generators

relation_with(g) for a Grid_Generator shall return Poly_Gen_Relation::subsumes() exactly under the following conditions:

  • a point denotes a member of the grid;
  • for a parameter q, the grid is nonempty and every integer translate x + zq, for x ∈ γ(G) and z ∈ Z, remains in the grid;
  • for a line ℓ, the grid is nonempty and every real translate x + tℓ, for t ∈ R, remains in the grid.

In all other cases it shall return Poly_Gen_Relation::nothing(). In particular, empty shall subsume no generator, including a zero parameter; this shall hold before any earlier query has detected the emptiness. Parameter steps shall use their rational divisors and shall not be confused with arbitrary real line displacements. Zero-dimensional universe shall subsume every admitted zero-dimensional grid generator. A descriptor dimension greater than the grid dimension shall throw std::invalid_argument before empty/universe shortcuts; omitted coordinates shall be zero.

The scalar-product and modulus-times-divisor calculations used solely for satisfaction tests shall be exact without a configured-coefficient range prerequisite. The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply; cached conversion and normalization intermediates remain subject to the configured arithmetic profile. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Satisfying homogeneous direction equations alone does not establish that the source grid contains a supporting point. Nonempty rational lattices can admit an integer step while rejecting its real line.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Use literal congruence membership for points and independent homogeneous conditions for integer parameters and real lines. Include cold inconsistent systems, nonzero directions in otherwise free coordinates, zero parameters, fractional lattice steps, affine obstructions, cache histories and dimensions.

src/Grid_public.cc; src/Congruence_System.cc; tests/Grid/congruences2.cc; tests/Grid/relations1.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

Poly_Gen_Relation relation_with(const Grid_Generator& g) const;
SW_SPEC
9
PPL-SPEC-001259
PPL-SPEC-001259
Exact grid subsumption of polyhedral generators

relation_with(g) for a polyhedral Generator shall return Poly_Gen_Relation::subsumes() exactly when the grid is nonempty and the following corresponding condition holds. Points and closure points shall be tested as rational point members, with the same result for identical coordinates. Lines shall be tested as arbitrary real displacements. A ray shall be subsumed exactly when its direction is an admitted real line direction of the grid; an integer parameter in that direction alone shall not suffice.

It shall return Poly_Gen_Relation::nothing() otherwise, including every empty grid before or after inconsistency detection. Zero-dimensional universe shall subsume every admitted zero-dimensional polyhedral generator. Descriptors of greater dimension than the grid shall throw std::invalid_argument before shortcuts; omitted coordinates shall be zero.

The scalar-product and modulus-times-divisor calculations used solely for satisfaction tests shall be exact without a configured-coefficient range prerequisite. The valid-use, initialization, arithmetic-profile and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply; cached conversion and normalization intermediates remain subject to the configured arithmetic profile. Logically const queries may normalize cached descriptions; success shall preserve all operands' mathematical values and ambient dimensions. Borrowed views shall follow 🔗 10. Borrowed congruence and generator views of grid values. Supported failures may propagate; surviving ownership shall permit destruction without a general rollback or subsequent-query guarantee.

Grids are closed, so closure points have ordinary point membership. A nonzero real scalar image along a ray varies continuously and cannot stay in a discrete congruence class; ray subsumption therefore requires a full continuous line direction.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Cross point/closure-point membership, both orientations of rays and lines, periodic directions lacking continuous freedom, coupled rational coordinates, cold inconsistent grids, free unused coordinates, zero dimensions and argument rejection. Check the same mathematical value after each query.

src/Grid_public.cc; src/Congruence_System.cc; tests/Grid/congruences2.cc; tests/Grid/relations1.cc; tests/gridrelationsspec1.cc; tests/gridrelationspublic1.cc; tests/gridrelationsfailure1.cc.

CPP
Public

Public header: <ppl.hh>; Grid member or related free-function excerpts in Parma_Polyhedra_Library:

Poly_Gen_Relation relation_with(const Generator& g) const;