Parma Polyhedra Library requirements
C++ rational-grid scalar queries

C++ rational-grid scalar 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-001265
PPL-SPEC-001265
Exact directional boundedness of affine expressions on grids

bounds_from_above(expr) and bounds_from_below(expr) shall return true exactly when the expression is bounded in the indicated direction over the grid. Empty shall be bounded in both directions. On a nonempty grid, either both queries shall be true and the expression shall have one constant value, or both shall be false and the expression shall be unbounded in both directions.

For a generator description p + ∑iℤqi + ∑jℝlj and e(x) = a⋅x + b, boundedness shall be equivalent to a⋅qi = 0 and a⋅lj = 0 for every direction, including point differences when the description has more than one generating point. Zero coefficients shall not introduce dependence on unused directions.

An expression with declared ambient dimension greater than the grid shall throw std::invalid_argument before output replacement, including empty, zero-dimensional and syntactically constant cases. The source grid's set and ambient dimension and the expression's value and dimension shall be preserved. Logically const queries may normalize caches; borrowed descriptor views shall follow 🔗 10. Borrowed congruence and generator views of grid values.

The initialization, arithmetic-profile, lifetime and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate and output representability. Writable coefficient outputs shall be pairwise distinct and shall not overlap input expression or receiver storage. Allocation and selected numerical failures may propagate; they shall not imply output rollback or a queryable surviving receiver beyond destruction-safe ownership.

A grid direction is reversible with an integer or real multiplier; a varying affine objective therefore has neither a lower nor an upper bound.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Independently compute scalar images of literal rational generating points, their differences, parameters and lines. Include empty, latent inconsistency, zero-dimensional universe, constant objectives and objectives orthogonal to nontrivial directions. Vary storage and both description/cache histories.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridscalarqueryspec1.cc; tests/gridscalarquerypublic1.cc; tests/gridscalarqueryfailure1.cc; tests/Grid/bounds1.cc; tests/Grid/maxmin1.cc; tests/Grid/frequency1.cc.

CPP
Public

Public header: <ppl.hh>; members of Parma_Polyhedra_Library::Grid.

bool bounds_from_above(const Linear_Expression& expr) const;
bool bounds_from_below(const Linear_Expression& expr) const;
SW_SPEC
2
PPL-SPEC-001266
PPL-SPEC-001266
Exact rational-grid supremum and attainment

maximize(expr,n,d,attained) shall return true exactly when the grid is nonempty and the expression is bounded above. On true, n/d shall be its exact supremum as a reduced fraction with positive denominator, and attained shall be true. Every grid point shall have that value. Empty or an unbounded objective shall return false and preserve every supplied output. Zero-dimensional universe shall return the expression's constant term over one.

An expression with declared ambient dimension greater than the grid shall throw std::invalid_argument before output replacement, including empty, zero-dimensional and syntactically constant cases. The source grid's set and ambient dimension and the expression's value and dimension shall be preserved. Logically const queries may normalize caches; borrowed descriptor views shall follow 🔗 10. Borrowed congruence and generator views of grid values.

The initialization, arithmetic-profile, lifetime and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate and output representability. Writable coefficient outputs shall be pairwise distinct and shall not overlap input expression or receiver storage. Allocation and selected numerical failures may propagate; they shall not imply output rollback or a queryable surviving receiver beyond destruction-safe ownership.

The only finite affine supremum of a nonempty grid is its constant objective value; it is always attained.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Compare the returned fraction and attainment with exact rational scalar-image calculations. Use signed/fractional points, unused varying coordinates, empty and unbounded cases. Check reduced positive denominators, sentinel preservation on false and dimension errors.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridscalarqueryspec1.cc; tests/gridscalarquerypublic1.cc; tests/gridscalarqueryfailure1.cc; tests/Grid/bounds1.cc; tests/Grid/maxmin1.cc; tests/Grid/frequency1.cc.

CPP
Public

Public header: <ppl.hh>; members of Parma_Polyhedra_Library::Grid.

bool maximize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& attained) const;
SW_SPEC
3
PPL-SPEC-001267
PPL-SPEC-001267
Exact rational-grid infimum and attainment

minimize(expr,n,d,attained) shall return true exactly when the grid is nonempty and the expression is bounded below. On true, n/d shall be its exact infimum as a reduced fraction with positive denominator, and attained shall be true. Every grid point shall have that value. Empty or an unbounded objective shall return false and preserve every supplied output. Zero-dimensional universe shall return the expression's constant term over one.

An expression with declared ambient dimension greater than the grid shall throw std::invalid_argument before output replacement, including empty, zero-dimensional and syntactically constant cases. The source grid's set and ambient dimension and the expression's value and dimension shall be preserved. Logically const queries may normalize caches; borrowed descriptor views shall follow 🔗 10. Borrowed congruence and generator views of grid values.

The initialization, arithmetic-profile, lifetime and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate and output representability. Writable coefficient outputs shall be pairwise distinct and shall not overlap input expression or receiver storage. Allocation and selected numerical failures may propagate; they shall not imply output rollback or a queryable surviving receiver beyond destruction-safe ownership.

Reversibility of every grid direction makes a finite infimum the constant objective value, equal to the supremum.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Check exact rational infima and attainment using independent scalar images. Include negative constants, fractional points, non-singleton grids with constant objectives and false/error output sentinels.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridscalarqueryspec1.cc; tests/gridscalarquerypublic1.cc; tests/gridscalarqueryfailure1.cc; tests/Grid/bounds1.cc; tests/Grid/maxmin1.cc; tests/Grid/frequency1.cc.

CPP
Public

Public header: <ppl.hh>; members of Parma_Polyhedra_Library::Grid.

bool minimize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& attained) const;
SW_SPEC
4
PPL-SPEC-001268
PPL-SPEC-001268
Point witnesses for rational-grid maximization

The maximize overload with a Generator output shall obey 🔗 2. Exact rational-grid supremum and attainment. On true, it shall additionally replace the witness with an ordinary point belonging to the receiver and attaining the returned supremum. Its type shall be POINT, not a closure point or a direction. All coordinates, including those absent from the objective, shall satisfy the grid's equalities and periodic restrictions. Omitted coordinates shall have their ordinary zero-extension meaning. False shall preserve the witness as well as all scalar and attainment outputs.

An expression with declared ambient dimension greater than the grid shall throw std::invalid_argument before output replacement, including empty, zero-dimensional and syntactically constant cases. The source grid's set and ambient dimension and the expression's value and dimension shall be preserved. Logically const queries may normalize caches; borrowed descriptor views shall follow 🔗 10. Borrowed congruence and generator views of grid values.

The initialization, arithmetic-profile, lifetime and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate and output representability. Writable coefficient outputs shall be pairwise distinct and shall not overlap input expression or receiver storage. Allocation and selected numerical failures may propagate; they shall not imply output rollback or a queryable surviving receiver beyond destruction-safe ownership.

A correct objective value alone does not establish membership; the witness must preserve the supporting point and its rational divisor.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Independently check the witness coordinates against literal congruences and recompute its objective. Include rational offsets, nontrivial unused coordinates, zero dimensions, negative constants and preservation of an unrelated ray sentinel on false/error.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridscalarqueryspec1.cc; tests/gridscalarquerypublic1.cc; tests/gridscalarqueryfailure1.cc; tests/Grid/bounds1.cc; tests/Grid/maxmin1.cc; tests/Grid/frequency1.cc.

CPP
Public

Public header: <ppl.hh>; members of Parma_Polyhedra_Library::Grid.

bool maximize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& attained, Generator& witness) const;
SW_SPEC
5
PPL-SPEC-001269
PPL-SPEC-001269
Point witnesses for rational-grid minimization

The minimize overload with a Generator output shall obey 🔗 3. Exact rational-grid infimum and attainment. On true, it shall additionally replace the witness with an ordinary point belonging to the receiver and attaining the returned infimum. Its type shall be POINT, not a closure point or a direction. Every coordinate shall satisfy the grid's equalities and periodic restrictions, including coordinates unused by the objective. Omitted coordinates shall have their ordinary zero-extension meaning. False shall preserve the witness and all scalar and attainment outputs.

An expression with declared ambient dimension greater than the grid shall throw std::invalid_argument before output replacement, including empty, zero-dimensional and syntactically constant cases. The source grid's set and ambient dimension and the expression's value and dimension shall be preserved. Logically const queries may normalize caches; borrowed descriptor views shall follow 🔗 10. Borrowed congruence and generator views of grid values.

The initialization, arithmetic-profile, lifetime and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate and output representability. Writable coefficient outputs shall be pairwise distinct and shall not overlap input expression or receiver storage. Allocation and selected numerical failures may propagate; they shall not imply output rollback or a queryable surviving receiver beyond destruction-safe ownership.

An infimum witness must be a member of the grid, even when the objective ignores coordinates constrained to fractional or periodic values.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Check complete witness membership and objective values independently for both bounded non-singleton grids and singletons. Include zero-dimensional universe and unchanged ray/scalar sentinels after false/error.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridscalarqueryspec1.cc; tests/gridscalarquerypublic1.cc; tests/gridscalarqueryfailure1.cc; tests/Grid/bounds1.cc; tests/Grid/maxmin1.cc; tests/Grid/frequency1.cc.

CPP
Public

Public header: <ppl.hh>; members of Parma_Polyhedra_Library::Grid.

bool minimize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& attained, Generator& witness) const;
SW_SPEC
6
PPL-SPEC-001270
PPL-SPEC-001270
Exact affine-image frequency and closest value on rational grids

For the affine image S = {e(x) ∣ x ∈ G}, frequency(expr,fn,fd,vn,vd) shall return false when S is empty or equals ℝ, preserving all four supplied outputs. Otherwise it shall return true and positive denominators, with both fractions reduced. If S = {c}, fn/fd shall be zero over one and vn/vd shall be c. Otherwise S shall be the coset v + dℤ where d = fn ⁄ fd > 0 is its unique positive period generating all differences and v = vn ⁄ vd ∈ S has minimum absolute value. Either sign shall be permitted when two values tie.

A line with nonzero homogeneous objective image shall make the frequency undefined. Otherwise the positive period shall be the rational greatest common divisor of the parameter images and generating-point differences; a zero period shall mean the objective is constant. The objective's constant term shall translate the coset without changing its period. Zero-dimensional universe shall report zero frequency and the constant expression value.

For a bounded coefficient profile, generator scalar products, translated point values, parameter gcds and closest-residue selection shall use exact working integers until both output fractions are reduced. Only the final reduced numerators and denominators shall require coefficient admission. A machine-carrier overflow shall promote the working arithmetic without truncation. Stored grid descriptions remain subject to their profile limits.

An expression with declared ambient dimension greater than the grid shall throw std::invalid_argument before output replacement, including empty, zero-dimensional and syntactically constant cases. The source grid's set and ambient dimension and the expression's value and dimension shall be preserved. Logically const queries may normalize caches; borrowed descriptor views shall follow 🔗 10. Borrowed congruence and generator views of grid values.

The initialization, arithmetic-profile, lifetime and synchronization conditions in 🔗 1. Rational-grid values, coefficient profile and valid use shall apply, including intermediate and output representability. Writable coefficient outputs shall be pairwise distinct and shall not overlap input expression or receiver storage. Allocation and selected numerical failures may propagate; they shall not imply output rollback or a queryable surviving receiver beyond destruction-safe ownership.

The exact affine image of a rational grid is empty, continuous, a singleton or a rational coset. A closest representative is signed, while the generating period is nonnegative.

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

APPROVED
GRIDS
IF_CPP
Test, Analysis, Inspection

Compute images from literal generating points, point differences, rational parameters and lines using independent rational gcd arithmetic. Check exact period, coset membership, minimal absolute representative, both tie signs, constant/zero-dimensional cases, undefined continuous images, translations, false/error sentinels and cache/storage independence.

src/Grid_inlines.hh; src/Grid_public.cc; src/Grid_nonpublic.cc; tests/gridscalarqueryspec1.cc; tests/gridscalarquerypublic1.cc; tests/gridscalarqueryfailure1.cc; tests/Grid/bounds1.cc; tests/Grid/maxmin1.cc; tests/Grid/frequency1.cc; tests/exactboundedworking1.cc; src/Linear_Expression.cc; src/Linear_Expression_defs.hh.

CPP
Public

Public header: <ppl.hh>; members of Parma_Polyhedra_Library::Grid.

bool frequency(const Linear_Expression& expr, Coefficient& fn, Coefficient& fd,
               Coefficient& vn, Coefficient& vd) const;