Parma Polyhedra Library requirements
C++ generator distances and stored ordering
PPL-SPEC-001579
1. Rectilinear distance between generator points UID: PPL-SPEC-001579 STATUS: APPROVED COMPONENT: GEOMETRIC_DESCRIPTORS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For admitted generators with rational coordinates as specified by 🔗 4. Generator-distance admission, workspaces and dispatch, rectilinear_distance_assign shall assign the requested directed bound on

D1(x, y) = n − 1∑i = 0|xi − yi|.

With exact rational temporary arithmetic and an exactly representable output, the sum shall be returned exactly.

The admission, direction, workspace, alias, lifetime and failure conditions of 🔗 4. Generator-distance admission, workspaces and dispatch shall apply. Successful completion shall return true; rejection shall return false with the stated preservation. An upward result shall be at least the exact norm and a downward result shall be nonnegative and at most the exact norm, under the numerical prerequisites. Both source generators shall retain their values, kinds, representations and dimensions.

RATIONALE:

A rational point descriptor supplies geometric coordinates independently of its normalized integer coefficients and divisor; the chosen norm determines the meaning of their distance.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

template <typename To>
bool rectilinear_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir);
template <typename Temp, typename To>
bool rectilinear_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir);
template <typename Work, typename To>
bool rectilinear_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir,
    Work& tmp0, Work& tmp1, Work& tmp2);
VERIFICATION_CRITERIA:

Compute independent exact rational coordinate differences and their absolute sum; check both source orders, identical coordinates with different point kinds, negative coordinates, zero dimensions and all overload/workspace choices.

SOURCE:

src/Generator_defs.hh; src/Generator_inlines.hh; src/Generator.cc; src/distances_defs.hh; src/distances_inlines.hh; tests/generatorspec1.cc; tests/generatorpublic1.cc; tests/generatormetricsspec1.cc.

PPL-SPEC-001580
2. Euclidean distance between generator points UID: PPL-SPEC-001580 STATUS: APPROVED COMPONENT: GEOMETRIC_DESCRIPTORS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For admitted generators with rational coordinates as specified by 🔗 4. Generator-distance admission, workspaces and dispatch, euclidean_distance_assign shall assign the requested directed bound on

D2(x, y) = √(n − 1∑i = 0(xi − yi)2).

Every squared contribution shall preserve the directed bound even when a coordinate difference is inexact in the workspace type. Rational square roots shall retain the precision and enclosure conditions of 🔗 2. Finite rational square root at the selected irrational precision and 🔗 3. Selection and ownership of irrational rational precision; no universal exactness or fixed error width shall be inferred beyond those contracts.

The admission, direction, workspace, alias, lifetime and failure conditions of 🔗 4. Generator-distance admission, workspaces and dispatch shall apply. Successful completion shall return true; rejection shall return false with the stated preservation. An upward result shall be at least the exact norm and a downward result shall be nonnegative and at most the exact norm, under the numerical prerequisites. Both source generators shall retain their values, kinds, representations and dimensions.

RATIONALE:

A rational point descriptor supplies geometric coordinates independently of its normalized integer coefficients and divisor; the chosen norm determines the meaning of their distance.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

template <typename To>
bool euclidean_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir);
template <typename Temp, typename To>
bool euclidean_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir);
template <typename Work, typename To>
bool euclidean_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir,
    Work& tmp0, Work& tmp1, Work& tmp2);
VERIFICATION_CRITERIA:

Compare nonnegative results by exact squared inequalities, without using a floating square root as the oracle. Include a 3-4-5 displacement, irrational norms, close rational coordinates rounded into native workspaces and both directions through every overload.

SOURCE:

src/Generator_defs.hh; src/Generator_inlines.hh; src/Generator.cc; src/distances_defs.hh; src/distances_inlines.hh; tests/generatorspec1.cc; tests/generatorpublic1.cc; tests/generatormetricsspec1.cc.

PPL-SPEC-001581
3. Maximum-coordinate distance between generator points UID: PPL-SPEC-001581 STATUS: APPROVED COMPONENT: GEOMETRIC_DESCRIPTORS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Public RELATIONS (Parent): STATEMENT:

For admitted generators with rational coordinates as specified by 🔗 4. Generator-distance admission, workspaces and dispatch, l_infinity_distance_assign shall assign the requested directed bound on

D∞(x, y) =  max0 ≤ i < n|xi − yi|.

The maximum over the empty coordinate tuple shall be zero. With exact rational temporary arithmetic and an exactly representable output, the maximum shall be returned exactly.

The admission, direction, workspace, alias, lifetime and failure conditions of 🔗 4. Generator-distance admission, workspaces and dispatch shall apply. Successful completion shall return true; rejection shall return false with the stated preservation. An upward result shall be at least the exact norm and a downward result shall be nonnegative and at most the exact norm, under the numerical prerequisites. Both source generators shall retain their values, kinds, representations and dimensions.

RATIONALE:

A rational point descriptor supplies geometric coordinates independently of its normalized integer coefficients and divisor; the chosen norm determines the meaning of their distance.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

template <typename To>
bool l_infinity_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir);
template <typename Temp, typename To>
bool l_infinity_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir);
template <typename Work, typename To>
bool l_infinity_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir,
    Work& tmp0, Work& tmp1, Work& tmp2);
VERIFICATION_CRITERIA:

Compute the exact maximum of absolute rational coordinate differences. Check ties, each coordinate as the unique maximum, zero contributions, both source orders, empty tuples and rounded native workspaces through every overload.

SOURCE:

src/Generator_defs.hh; src/Generator_inlines.hh; src/Generator.cc; src/distances_defs.hh; src/distances_inlines.hh; tests/generatorspec1.cc; tests/generatorpublic1.cc; tests/generatormetricsspec1.cc.

4. Generator-distance admission, workspaces and dispatch UID: PPL-SPEC-001582 STATUS: APPROVED COMPONENT: GEOMETRIC_DESCRIPTORS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

Distances shall be admitted exactly when both generators are points or closure points and have the same ambient dimension. A line, a ray or a dimension mismatch shall return false before assigning the output or any supplied scratch object. Equal-dimensional point/closure-point pairs shall return true on successful numerical completion. A zero-dimensional pair shall assign exact zero. A closure point shall contribute its rational coordinates without asserting inclusion in any polyhedron. For each source, xi = ai ⁄ d shall use its own positive divisor. Neither coefficient vectors alone nor homogeneous-coordinate distances shall replace these coordinates. Boolean success shall not imply exactness of a rounded result.

The default overload shall use three Checked_Number<To,Extended_Number_Policy> workspaces. An explicit scalar temporary type Temp shall use three Checked_Number<Temp,Extended_Number_Policy> workspaces. Supplied references shall use their actual admitted raw or checked numerical type Work. Their accumulation shall use 🔗 17. Rectilinear distance between bound-entry arrays, 🔗 18. Euclidean distance between bound-entry arrays or 🔗 19. Maximum-coordinate distance between bound-entry arrays, respectively. The generic helper instantiated with the corresponding specialization shall use the same admission, coordinate and numerical rules.

Source validity and coefficient conditions of 🔗 1. Generator kinds and numerical prerequisites shall apply. Each scalar conversion, subtraction, accumulation, square, square root and final assignment shall satisfy its backend's representability, failure, resource, shared-temporary, nontrapping and FPU prerequisites. Native floating types shall retain their configured availability and hardware conditions. Rational square-root precision shall remain stable throughout a dependent call. Calls evaluating coordinate differences shall use ROUND_UP or ROUND_DOWN, optionally with ROUND_STRICT_RELATION. Inexact coordinate conversion shall not by itself invalidate a directed bound. The zero-dimensional exact assignment shall admit any otherwise valid direction for that scalar assignment.

Supplied scratch objects shall be pairwise distinct and disjoint from both source generators. Their entry values need not be initialized where they are overwritten before reading. The output shall have live assignable storage disjoint from the sources; it may coincide with any one scratch object or its compatible raw storage. The same generator may be passed as both sources. Callers shall preserve object and borrowed-storage lifetimes and provide synchronization required by the selected numerical profile. Numerical or allocation failures may propagate through their declared channels, shall not establish a successful directed bound, and may leave partial output/scratch values according to the selected scalar policies; no aggregate rollback guarantee shall be inferred.

RATIONALE:

Explicit admission and workspace rules distinguish a geometric distance from a coefficient-vector calculation and make directed bounds meaningful under rounding and permitted output aliases.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

template <typename Specialization, typename Work, typename To>
bool l_m_distance_assign(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir,
    Work& tmp0, Work& tmp1, Work& tmp2);
VERIFICATION_CRITERIA:

Check all rejected kind pairs and both dimension-mismatch orders with output and scratch sentinels. Exercise both point kinds, zero dimensions, default and explicit raw/checked workspaces, each output/scratch alias and identical sources. Use independent rational norms and squared comparisons under inexact conversions; verify source preservation and caller-owned rounding state.

SOURCE:

src/Generator_defs.hh; src/Generator_inlines.hh; src/Generator.cc; src/distances_defs.hh; src/distances_inlines.hh; tests/generatorspec1.cc; tests/generatorpublic1.cc; tests/generatormetricsspec1.cc.

PPL-SPEC-001583
5. Stored ordering of polyhedral generators UID: PPL-SPEC-001583 STATUS: APPROVED COMPONENT: GEOMETRIC_DESCRIPTORS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

compare(x,y) shall order valid generator rows of the same topology without changing either source. Callers shall provide this common-topology precondition, as in rows of one generator system. Its result shall be negative, zero or positive according to the stored ordering, with magnitude at most two. Lines shall precede all other kinds, returning magnitude two when this rule decides the order.

For two necessarily-closed rows, comparison shall use their stored expressions: homogeneous coefficients in increasing variable order followed by the divisor field, with absent trailing coefficients treated as zero. A homogeneous coefficient difference shall return magnitude two and a divisor-field difference magnitude one, using the sign of the first difference.

For NNC rows, comparison shall first use the public homogeneous coefficients in the same order with zero padding. A difference shall return magnitude two. With equal homogeneous coefficients, two lines shall compare equal; otherwise a ray shall precede a point or closure point with magnitude one, and two rays shall compare equal. Remaining point or closure-point rows shall compare divisors and then stored epsilon coefficients, returning their signed comparison with magnitude one when unequal.

The ordering shall be of stored row descriptions, not lexicographic order of rational point coordinates and not generator equivalence. Source validity, coefficient representability and synchronization prerequisites of 🔗 1. Generator kinds and numerical prerequisites shall apply.

RATIONALE:

Generator-system algorithms need a deterministic row ordering whose tie breakers retain divisor and topology information independently of geometric equivalence.

INTERFACE:

Public header: <ppl.hh>; names belong to Parma_Polyhedra_Library.

int compare(const Generator& x, const Generator& y);
VERIFICATION_CRITERIA:

Use literal normalized rows to exercise line priority, homogeneous differences, zero padding, ray/point priority, divisor differences and epsilon tie breaking. Check both orders, equality, transitivity on a fixed catalogue, both storage representations and each common topology; preserve each source.

SOURCE:

src/Generator_defs.hh; src/Generator_inlines.hh; src/Generator.cc; src/distances_defs.hh; src/distances_inlines.hh; tests/generatorspec1.cc; tests/generatorpublic1.cc; tests/generatormetricsspec1.cc.

PPL-SPEC-001653
6. Admitted generator-distance evaluation kernel UID: PPL-SPEC-001653 STATUS: APPROVED COMPONENT: GEOMETRIC_DESCRIPTORS APPLICABILITY: IF_CPP VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: CPP VISIBILITY: Internal RELATIONS (Parent): STATEMENT:

l_m_distance_assign_impl shall evaluate a valid point or closure-point pair of equal strictly positive dimension. Callers shall meet the source, workspace, output-alias, rounding, initialization, synchronization and backend conditions of 🔗 4. Generator-distance admission, workspaces and dispatch before entering this kernel; it shall not perform the public admission checks.

With Skip_Common_Zero_Runs equal to false, the kernel shall process every coordinate in decreasing index order, using each source's own positive divisor. It shall initialize tmp0 to zero, form the directed nonnegative coordinate differences, call Specialization::combine once for each coordinate, call Specialization::finalize once after accumulation, and assign the result from tmp0. The applicable numerical obligations of 🔗 1. Rectilinear distance between generator points, 🔗 2. Euclidean distance between generator points or 🔗 3. Maximum-coordinate distance between generator points shall apply for their corresponding standard specialization.

With Skip_Common_Zero_Runs equal to true, both sources shall have sparse representation and Specialization shall be the standard rectilinear, Euclidean or infinity-distance specialization for Work. The kernel may replace a maximal run of coordinates zero in both sources by one ordinary zero-coordinate step. Successful completion shall preserve the full traversal's result, final scratch values, directed rounding and floating-point zero signs and status effects. Contributions at nonzero coordinates shall retain their decreasing-index order. The skipping path shall not allocate coefficient vectors or polymorphic expression iterators.

Successful numerical completion shall return true. Numerical or allocation failures shall retain the failure channels and partial-state conditions of 🔗 4. Generator-distance admission, workspaces and dispatch. The public dispatcher shall retain ordinary traversal for other specialization types; callbacks of those types shall not lose coordinate invocations.

RATIONALE:

Zero contributions do not change the three standard norms. Retaining one zero step per run preserves idempotent signed-zero and scratch effects, while ordering all nonzero contributions preserves directed accumulation. The same assumption is unavailable for arbitrary specialization callbacks.

INTERFACE:

Internal function template in namespace Parma_Polyhedra_Library; src/Generator_inlines.hh and public header <ppl.hh>.

template <bool Skip_Common_Zero_Runs, typename Specialization,
          typename Work, typename To>
bool l_m_distance_assign_impl(
    Checked_Number<To, Extended_Number_Policy>& result,
    const Generator& x, const Generator& y, Rounding_Dir dir,
    Work& tmp0, Work& tmp1, Work& tmp2);
VERIFICATION_CRITERIA:

Compare sparse evaluations with dense full traversal and independent exact rational norms or squared Euclidean bounds. Check zero runs before, between and after nonzero coordinates, one-dimensional zeros, equal inexact rational coordinates, overlapping/disjoint supports, density and dimension boundaries, asymmetric supports, both directed and strict directions, raw/checked workspaces and each output alias. Compare final scratch values, floating-point bits and status, rounding state and unchanged sources. Count invocations for a custom specialization and inspect the skipping path's allocation behavior.

SOURCE:

src/Generator_inlines.hh; tests/generatorspec1.cc; tests/generatormetricsspec1.cc; tests/generatorsparsedistances1.cc.