Parma Polyhedra Library requirements
C++ box representations and mathematical queries

C++ box representations and mathematical queries

PPL-SPEC-001030
1. Exact extraction of individual box boundaries
UID: PPL-SPEC-001030
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

For a nonempty receiver and a variable var within its ambient dimension, has_lower_bound(var,n,d,closed) shall return true exactly when that factor has a finite lower boundary. On true, n ⁄ d shall be its exact infimum, with d > 0, coprime numerator and denominator, and denominator one when the numerator is zero. closed shall state whether that boundary belongs to the factor. has_upper_bound shall give the corresponding exact supremum and upper boundary inclusion. On false, all supplied output objects shall retain their values. Numerator and denominator outputs shall be distinct.

These calls shall require the stated nonempty and coordinate-validity preconditions; they shall not promise validation or a specified outcome outside them. The represented box and ambient dimension shall remain unchanged. The profile, numerical, lifetime and synchronization conditions of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Finite endpoint conversion and coefficient assignment shall retain the selected numerical policy's range and exception conditions; an exception shall not imply rollback of outputs already assigned. Valid use shall impose no additional initialization requirement beyond the selected numerical facilities.

RATIONALE:

Exact boundary values and inclusion distinguish an open extremum from an attained coordinate value.

INTERFACE:

Public header: <ppl.hh>; member excerpts for Box<ITV> in Parma_Polyhedra_Library:

bool has_lower_bound(Variable var, Coefficient& n, Coefficient& d,
                     bool& closed) const;
bool has_upper_bound(Variable var, Coefficient& n, Coefficient& d,
                     bool& closed) const;
VERIFICATION_CRITERIA:

Use exact rational factors and independently decoded finite native endpoints. Check positive/negative/zero fractions, canonical signs, both open boundaries, one-sided and fully unbounded factors, unchanged sentinel outputs on false, source preservation and valid use without additional initialization. Exercise selected checked coefficient range failures separately from ordinary false results.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; tests/boxqueriesspec1.cc; tests/boxqueryoracle.hh; tests/boxqueriespublic1.cc.

PPL-SPEC-001031
2. Constraint and congruence exports of box values
UID: PPL-SPEC-001031
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

constraints() shall return an owned, dimension-preserving constraint system whose conjunction denotes exactly the receiver. Finite coordinate boundaries shall retain their exact values and strictness; unconstrained coordinates shall not introduce restrictions. Empty, including an unclassified empty factor, shall export an inconsistent conjunction. Zero-dimensional universe shall export the tautological conjunction and zero-dimensional empty an inconsistent one.

minimized_constraints() shall return an equivalent system, using one equality for a singleton factor and the necessary finite endpoint constraints for a nonsingleton factor. The interface shall not require a particular row order or syntactic scaling.

congruences() and minimized_congruences() shall return owned, dimension-preserving congruence systems containing every receiver point. For a nonempty box, they shall express exactly the affine equalities fixing its singleton coordinates and shall impose no periodic restriction on varying factors. Empty shall export an inconsistent system. The two forms shall have the same mathematical meaning; no extra proper congruence precision shall be inferred from minimization.

The box's set and dimension shall remain unchanged and returned systems shall be independent values. The validity, numerical, lifetime and synchronization conditions of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Construction of output descriptors shall retain the initialized library and thread context required by 🔗 1. Initialization owners and automatic C++ initialization and 🔗 3. Thread initialization, default state and finalization. Coefficient representability, intermediate arithmetic and reported range failures shall follow the configured coefficient profile; resource or numerical exceptions shall not promise a returned partial system.

RATIONALE:

A constraint system can describe every coordinate interval exactly, while congruences express only the singleton-coordinate equalities of a nonempty Cartesian box.

INTERFACE:

Public header: <ppl.hh>; member excerpts for Box<ITV> in Parma_Polyhedra_Library:

Constraint_System constraints() const;
Constraint_System minimized_constraints() const;
Congruence_System congruences() const;
Congruence_System minimized_congruences() const;
VERIFICATION_CRITERIA:

Compare exported constraints with independent Cartesian membership and exact rational elimination. Check singleton equalities and redundant-row freedom without prescribing row order. Evaluate exported congruences on singleton and varying coordinates; include rational singletons, strict intervals, absent trailing coordinates, universe, classified and lazy empty, both zero-dimensional values, owned-result independence and descriptor resource failure.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; tests/boxqueriesspec1.cc; tests/boxqueryoracle.hh; tests/boxqueriespublic1.cc. tests/Box/constraints1.cc; tests/Box/minconstraints1.cc; tests/Box/congruences1.cc;

PPL-SPEC-001032
3. Affine boundedness, extrema and witnesses on boxes
UID: PPL-SPEC-001032
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

bounds_from_above(expr) and bounds_from_below(expr) shall decide exactly whether the affine expression's values over the receiver are bounded in the indicated direction. Empty shall be bounded in both directions. Zero coefficients shall not make an otherwise bounded objective unbounded because of unused coordinate factors.

maximize shall return true exactly when the receiver is nonempty and the objective is bounded above. On true, its numerator and positive denominator shall give the exact supremum as a reduced fraction, and maximum shall be true exactly when some receiver point attains it. minimize shall analogously report the exact infimum and attainment. A constant objective on any nonempty box shall be attained, including in zero dimensions. Ordinary false shall preserve every supplied output. Numerator and denominator outputs shall be distinct.

The generator overloads shall additionally return a point in the receiver when the extremum is attained, and a closure point in its topological closure when it is not attained. Its coordinates, including coordinates absent from the expression, shall satisfy the respective membership condition, and its objective value shall equal the reported extremum. Omitted generator coordinates shall have their declared zero-extension meaning. A witness shall not be accepted merely because it gives the correct objective value.

An expression's ambient dimension greater than the box dimension shall throw std::invalid_argument before changing outputs, including for an empty receiver or a constant expression with excess declared dimension. The represented box, its dimension and the supplied expression shall retain their values. The profile, numerical, lifetime and synchronization conditions of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Expressions and generators shall retain their descriptor prerequisites; creating output generators and reporting dimension errors shall retain the context of 🔗 1. Initialization owners and automatic C++ initialization and 🔗 3. Thread initialization, default state and finalization. Numerical intermediate and output representability shall follow the selected coefficient profile. Reported allocation or numerical exceptions may leave outputs partly assigned; ordinary false-result preservation shall not imply exception rollback.

RATIONALE:

An exact extremum, its attainment and a valid extremizing witness are separate mathematical obligations.

INTERFACE:

Public header: <ppl.hh>; member excerpts for Box<ITV> in Parma_Polyhedra_Library:

bool bounds_from_above(const Linear_Expression& expr) const;
bool bounds_from_below(const Linear_Expression& expr) const;
bool maximize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& maximum) const;
bool maximize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& maximum, Generator& g) const;
bool minimize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& minimum) const;
bool minimize(const Linear_Expression& expr, Coefficient& n,
              Coefficient& d, bool& minimum, Generator& g) const;
VERIFICATION_CRITERIA:

Project an independently constrained objective coordinate using exact rational elimination. Cover all coefficient signs, strict and closed boundaries, fractional endpoints, unused bounded and unbounded coordinates, constant objectives, empty and zero-dimensional boxes and lazy emptiness. Check reduced fractions, attainment, every coordinate of point/closure-point witnesses and exact objective evaluation. Verify all false-result sentinels, dimension errors before output replacement and selected numerical/resource failure outcomes.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; tests/boxqueriesspec1.cc; tests/boxqueryoracle.hh; tests/boxqueriespublic1.cc. tests/Box/max_min1.cc; tests/Box/interval1.cc;

PPL-SPEC-001033
4. Detection of constant affine values and zero frequency
UID: PPL-SPEC-001033
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Public
RELATIONS (Parent):
STATEMENT:

frequency(expr,fn,fd,vn,vd) shall return true exactly when the receiver is nonempty and the expression has one value throughout it. On true, fn and fd shall be zero and one, respectively, while vn/vd shall be that exact value as a reduced fraction with positive denominator. A coordinate with zero expression coefficient shall not prevent constancy even when its factor varies or is unbounded. For boxes this success shall express a unique value, not a nonzero periodic frequency. Empty shall return false. Zero-dimensional universe shall return the expression's constant term with zero frequency.

Ordinary false shall preserve all four supplied output values. Those outputs shall be distinct. Greater expression ambient dimension shall throw std::invalid_argument before output replacement, including when the receiver is empty. The expression and the represented box and its ambient dimension shall retain their values.

The profile, numerical, lifetime and synchronization prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Expression descriptors and dimension error reporting shall retain their initialized-context prerequisites. Coefficient intermediate and output representability and reported range failures shall follow the configured coefficient profile. Allocation or numerical exceptions may leave output values partly assigned; ordinary false-result preservation shall not imply exception rollback.

RATIONALE:

A Cartesian product has a discrete affine image only when the expression is constant on its nonempty factors.

INTERFACE:

Public header: <ppl.hh>; member excerpts for Box<ITV> in Parma_Polyhedra_Library:

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

Use an independent exact objective projection to distinguish singleton ranges from varying and unbounded ranges. Include multiple rational singleton coordinates, negative coefficients, offsets, ignored free coordinates, open intervals, empty/lazy states, zero-dimensional values, source preservation, four unchanged false-result sentinels and excess expression dimension. Check the exact 0/1 frequency and canonical value, plus selected checked arithmetic failures.

SOURCE:

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; tests/boxqueriesspec1.cc; tests/boxqueryoracle.hh; tests/boxqueriespublic1.cc. tests/Box/frequency1.cc;