Parma Polyhedra Library requirements
C++ box values and foundational queries

C++ box 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-000951
PPL-SPEC-000951
Cartesian box values, coordinate identity and valid use

Box<ITV> shall represent a Cartesian product of its coordinate intervals over the ordinary real carrier. A point shall belong exactly when each coordinate belongs to its corresponding factor; distinct coordinates shall impose no additional relationships. An empty factor shall make the product empty. The ambient dimension shall remain part of the value even for an empty box. In dimension zero, universe shall contain the unique empty tuple and shall differ from empty. interval_type shall name ITV; Rational_Box shall select Rational_Interval factors.

Selected interval operations shall be well-formed and their information policy shall admit the required empty, universe and endpoint values. Active numerical payloads shall be initialized and rational payloads canonical. Clients shall retain the selected endpoint operation's finite-range, resource, shared-temporary and caller-owned FPU prerequisites. Basic construction, copying, exchange and valid-coordinate factor access shall require no additional PPL initialization. Reporting dimension-incompatible coordinate arguments shall retain an initialized library/thread context under 🔗 1. Initialization owners and automatic C++ initialization and 🔗 3. Thread initialization, default state and finalization, including the live coefficient constants used by that reporting path. Other APIs using separately initialized descriptors or facilities shall retain their own prerequisites.

Boxes and borrowed arguments shall remain live throughout a call. Access shall be synchronized against mutation; logically const queries may update cached information and shall be synchronized where those updates could overlap. Cached status shall not change the represented product. Empty boxes may retain inactive coordinate storage; clients shall use the public empty-aware coordinate access contract rather than infer meaningful factors from internal empty storage.

A box is a dimensioned Cartesian set, so zero-dimensional universe, empty products and inactive empty storage need explicit meanings.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Compare independent Cartesian membership descriptions, empty factors and zero-dimensional empty/universe; instantiate rational and integral core value operations without automatic or explicit PPL initialization; separately check coordinate-validation outcomes under initialized library/thread context. Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc. tests/interfacedboxpolicies1.cc: Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

template <typename ITV> class Box;
// Member of Box<ITV>:
typedef ITV interval_type;
typedef Box<Rational_Interval> Rational_Box;
SW_SPEC
2
PPL-SPEC-000952
PPL-SPEC-000952
Dimensioned empty and universe box construction

Box(d,kind) shall construct a box of ambient dimension d: empty for EMPTY and the complete declared Cartesian carrier for UNIVERSE. Default construction shall give zero-dimensional universe. Each active universe factor shall have the selected interval's universe meaning; custom interval/information constructors shall retain their per-element state rather than be required to share copied identity.

max_space_dimension() shall return the dimension limit of this box profile. Construction above that limit shall throw std::length_error before attempting coordinate storage of that size. Dimensions within the limit shall remain subject to actual allocation/resource availability; the reported limit shall not promise successful allocation. Construction shall not require interpreting inactive interval payloads of an empty box.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Construction must distinguish mathematical dimension validity from physical resource availability.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Check default and explicit empty/universe construction in dimensions 0, 1, 2 and larger small cases, exact zero-dimensional meaning and above-limit rejection without allocating at the limit. Reuse custom per-element constructor regressions.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

explicit Box(dimension_type d=0,Degenerate_Element kind=UNIVERSE);
static dimension_type max_space_dimension();
SW_SPEC
3
PPL-SPEC-000953

Same-profile copying shall preserve ambient dimension and represented set while independently owning all mutable coordinate/metadata storage. The copy constructor's complexity argument shall not change that result. Assignment shall replace the receiving value even when dimensions differ and shall return the receiving object; self-assignment shall preserve its value. Destruction shall release owned resources without modifying other live values.

On successful return, subsequent mutation or destruction of either owner shall not change the other owner's represented value. Empty and lazy cached states shall retain correct mathematical meaning after copying/assignment.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Copying a dimensioned product must preserve meaning while retaining independent endpoint ownership.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Check copy construction under each complexity argument, assignment between different dimensions, empty/nonempty/lazy states, returned identity and self-assignment. Mutate/destroy donor and receiver independently and check retained endpoint values. Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc. tests/interfacedboxpolicies1.cc: Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

Box(const Box& y,Complexity_Class complexity=ANY_COMPLEXITY);
Box& operator=(const Box& y);
// The implicit destructor releases the owned coordinate representation.
SW_SPEC
4
PPL-SPEC-000954

Construction from Box<Other_ITV> shall preserve ambient dimension and enclose every source point under the receiving interval policies. An established empty source shall give empty. For other sources the conversion shall use receiving coordinate enclosures rather than trust cached facts whose validity can change through endpoint conversion. With exactly representable endpoints and supported membership, it shall preserve the represented set exactly. Otherwise endpoint conversion or relaxed openness may enlarge the product. The complexity argument shall not change this profile-conversion result. The separate source shall remain unchanged and the receiving value shall own independent coordinate storage.

Selected source/destination interval assignments shall be well-formed and satisfy their own admitted conversion prerequisites.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Interval conversion can change emptiness knowledge and boundary precision, so the target must reconstruct valid cached meaning.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Check exact same-family profile conversions, fractional outward integral endpoints, relaxed openness, marked and lazily empty sources, empty/universe zero-dimensional values and independent ownership. Compare literal source-point containment and receiving endpoints.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

template <typename Other_ITV>
explicit Box(const Box<Other_ITV>& y,
             Complexity_Class complexity=ANY_COMPLEXITY);
SW_SPEC
5
PPL-SPEC-000955
PPL-SPEC-000955
Whole box exchange across different dimensions

m_swap(y) and free swap(x,y) shall exchange complete box values, including dimensions, coordinate ownership and cached status. Different dimensions and empty/nonempty states shall be permitted. Self-exchange shall preserve the value. References into exchanged coordinate storage shall follow that storage's owner; callers shall not assume a reference continues to identify the original logical coordinate value. Exchange of the standard owned coordinate sequence/status shall not perform per-endpoint numerical conversions or require coefficient range operations.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Whole-owner exchange must retain dimensions and status alongside the factors.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Exchange different dimensions, empty/nonempty values, universe and lazy states through both forms; check both resulting mathematical values, self-exchange and active endpoint reference ownership.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

void m_swap(Box& y);
template <typename ITV> void swap(Box<ITV>& x,Box<ITV>& y);
SW_SPEC
6
PPL-SPEC-000956
PPL-SPEC-000956
Ambient and affine box dimension queries

space_dimension() shall return the ambient coordinate count, including for empty boxes. affine_dimension() shall return zero for empty boxes; otherwise it shall equal the number of nonsingleton coordinate factors over the ordinary real carrier. Both empty and universe in ambient dimension zero shall therefore have affine dimension zero. These queries shall not change the represented set or ambient dimension.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Ambient coordinate count differs from the dimension of a nonempty Cartesian set affine hull.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Check independent factor counts over empty, singleton, mixed finite and unbounded products in dimensions 0, 1 and 2; retain ambient dimension on empty boxes and after copying/conversion.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

dimension_type space_dimension() const;
dimension_type affine_dimension() const;
SW_SPEC
7
PPL-SPEC-000957
Empty-aware borrowed coordinate interval access

get_interval(v) shall return a const interval reference for an existing coordinate. For a nonempty box it shall denote that coordinate's factor. For an empty box it shall denote an empty interval, independently of any inactive internal coordinate payload. Different empty queries may share an internal interval; clients shall not infer distinct ownership or identity from those references.

An out-of-dimension variable shall throw std::invalid_argument before returning a reference, including on an empty box. A reference into an active factor shall require its owning coordinate storage to remain live and free of invalidating owner operations. A shared empty reference shall require its owning library/thread context to remain live. Clients shall not mutate through these const views.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

The public factor view must hide meaningless factor storage in an empty Cartesian product.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Compare every active factor with literal endpoints, check shared empty denotation in all small positive dimensions, out-of-range rejection on empty/nonempty values and live borrowed-reference histories without invalidating mutations. Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc. tests/interfacedboxpolicies1.cc: Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

const ITV& get_interval(Variable v) const;
SW_SPEC
8
PPL-SPEC-000958
PPL-SPEC-000958
Explicit coordinate factor replacement

For a nonempty box, set_interval(v,i) shall replace only the selected factor with the supplied interval's entry value, retaining ambient dimension and the other factors. A resulting empty factor shall make the box empty. The source interval shall remain unchanged; borrowing the same or another active factor as the source shall be permitted without changing its entry value during replacement.

For a one-dimensional empty box, replacing its sole factor shall establish that supplied one-dimensional interval, which may make the box nonempty. For an already empty box of dimension at least two, replacing one factor shall retain the empty box. An out-of-dimension variable shall throw std::invalid_argument without replacing factors. The operation shall update emptiness knowledge as needed so later queries reflect the resulting product.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Factor replacement is a low-level coordinate operation whose one-dimensional empty recovery and higher-dimensional empty behavior must be explicit.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Replace each active factor, including same/other-factor source references, preserved other coordinates and empty results. Check one-dimensional empty recovery, higher-dimensional empty retention, invalid variables and subsequent repeated classification queries. Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc. tests/interfacedboxpolicies1.cc: Check each configured binding alias with finite rational range crossings, outward enclosure, independent equal-box intersection and empty-box join.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

void set_interval(Variable v,const ITV& i);
SW_SPEC
9
PPL-SPEC-000959
PPL-SPEC-000959
Exact ordinary box classification

The following Boolean queries shall report exact properties of the represented ordinary real Cartesian set. is_empty() shall decide emptiness and is_universe() equality with the ambient universe. is_topologically_closed() shall decide topological closure; is_bounded() shall decide boundedness; is_discrete() shall be true exactly for empty boxes or products of singleton factors. contains_integer_point() shall be true exactly when the product contains an integer-coordinate point. In dimension zero the universe shall be nonempty, closed, bounded, discrete and contain the empty integer tuple; empty shall be closed, bounded, discrete and contain no integer point.

constrains(v) shall be true for empty boxes and, for a nonempty box, exactly when that coordinate's factor differs from universe. A variable outside the ambient dimension shall throw std::invalid_argument. Queries may establish cached facts without changing the mathematical set.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Set classification must retain exact empty and zero-dimensional conventions independently of cached evaluation order.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Compare independent factor/topology/integer-witness models over every small ordinary endpoint topology, empty and unbounded products, rational intervals with no integer witness, all coordinate positions and cached query orders. Check invalid constrains variables.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

bool is_empty() const;
bool is_universe() const;
bool is_topologically_closed() const;
bool is_bounded() const;
bool is_discrete() const;
bool contains_integer_point() const;
bool constrains(Variable v) const;
SW_SPEC
10
PPL-SPEC-000960
PPL-SPEC-000960
Box set relations, dimension-sensitive equality and compatible hashes

For equal ambient dimensions, contains(y) shall decide Y ⊆ X, strictly_contains(y) proper inclusion and is_disjoint_from(y) empty intersection. Empty sets and zero-dimensional sets shall follow their ordinary set meanings. These methods shall throw std::invalid_argument when ambient dimensions differ, including for empty operands.

Free equality shall be true exactly for boxes with equal dimensions and equal represented sets; different dimensions shall compare unequal without a dimension exception. Free inequality shall negate equality. Equal boxes shall have equal hash_code() values; collisions between unequal boxes shall be permitted. Relations and hashing shall leave mathematical values unchanged and shall not depend on distinct cached evaluation histories.

The validity, synchronization, numerical and runtime prerequisites of 🔗 1. Cartesian box values, coordinate identity and valid use shall apply. Underlying allocation or endpoint failure shall retain its own guarantees; no general rollback promise shall be inferred.

Dimension is part of box identity, while Boolean relation APIs and equality intentionally have different mismatch outcomes.

APPROVED
INTERVALS_BOXES
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 same-dimension Cartesian inclusion/disjointness independently over empty, point, bounded, open and unbounded factors; check operand order, properness, reflexivity and cached histories. Check all dimension-mismatch outcomes and equal-value hash agreement without requiring collision freedom.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; src/Rational_Box.hh; tests/boxvaluesspec1.cc; tests/boxpublic1.cc; tests/Box/intervalcontracts1.cc.

CPP
Public

Public header: <ppl.hh>; members and free functions in Parma_Polyhedra_Library, with member excerpts applying to Box<ITV>:

bool contains(const Box& y) const;
bool strictly_contains(const Box& y) const;
bool is_disjoint_from(const Box& y) const;
int32_t hash_code() const;
template <typename ITV> bool operator==(const Box<ITV>& x,const Box<ITV>& y);
// Inequality uses C++20 rewriting of operator==.
SW_SPEC
11
PPL-SPEC-001221
PPL-SPEC-001221
Explicit empty box assignment

set_empty() shall replace the receiver's entry set X ⊆ Rn by ⌀ ⊆ Rn. It shall preserve the ambient dimension and shall be idempotent, including in dimension zero. Subsequent empty-aware queries and coordinate access shall observe the empty value under 🔗 7. Empty-aware borrowed coordinate interval access and 🔗 9. Exact ordinary box classification.

The operation shall retain the owned coordinate storage and the stored interval objects. Those factors shall become inactive; it shall not need to assign an empty value to each factor or query their numerical payloads. Borrowed references to retained factors shall retain their storage lifetime, but shall not independently denote the current box's factors while the box is empty. Independent copies shall remain unchanged.

The receiver shall have safely owned coordinate storage and externally synchronized access. The operation shall require no numerical arithmetic, no additional PPL initialization, no allocation and no interval-profile callback, and shall not change hardware rounding state.

Emptiness annihilates a Cartesian product without requiring every retained factor to be rewritten. The ambient dimension and owned storage are independent of the represented set becoming empty.

APPROVED
INTERVALS_BOXES
IF_CPP
Test, Analysis, Inspection

Check zero and positive dimensions, empty/universe and finite factor histories, repeated calls and independent copies. Observe empty-aware factor access and retained factor addresses/capacities through the existing narrow fixture. A diagnostic interval profile whose callbacks reject use shall confirm that explicit empty assignment does not inspect or rewrite inactive factors. Check direct public-header use without initialization and unchanged hardware rounding state in an initialized runtime.

src/Box_defs.hh; src/Box_inlines.hh; src/Box_templates.hh; tests/boxpublicstatespec1.cc; tests/boxstatepublic1.cc.

CPP
Public

Public header: <ppl.hh>; member of Parma_Polyhedra_Library::Box<ITV>:

void set_empty();