Parma Polyhedra Library requirements
Internal interval metadata and flag storage

Internal interval metadata and flag storage

1. Boundary sides and interval metadata property keys
UID: PPL-SPEC-000661
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

Boundary_NS::LOWER and UPPER shall identify the lower and upper boundary respectively and have the corresponding ROUND_DOWN and ROUND_UP encodings. round_dir_check(side, check) shall return that bound direction, with ROUND_STRICT_RELATION exactly when check is true. It shall not inspect or change the hardware rounding mode.

Boundary_NS::SPECIAL and OPEN shall identify independent boundary properties. Interval_NS::CARDINALITY_0 and CARDINALITY_1 shall identify cached empty and singleton answers; CARDINALITY_IS shall identify whether the owner's applicable cached answer is established. Property values shall be Boolean, their default setter value true, and their unsupported query value false. Constructing a property key from a named enumeration value shall retain that value.

The metadata containers shall store claims about endpoints or cached answers; the owning interval shall establish their mathematical consistency. Changing an endpoint flag shall not implicitly establish or invalidate cardinality claims. Calls shall use live objects and named boundary sides; property keys shall meet the selected metadata type's interface. Access shall be synchronized against mutation. Metadata storage alone shall require no library or thread initialization, coefficient constants or FPU setup.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

Endpoint status and cached knowledge are separate state; their storage must not silently assert new mathematical facts.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

namespace Boundary_NS {
  struct Property;
  enum Boundary_Type { LOWER = ROUND_DOWN, UPPER = ROUND_UP };
  constexpr Rounding_Dir round_dir_check(Boundary_Type side, bool check = false);
}
namespace Interval_NS { struct Property; }
VERIFICATION_CRITERIA:

Check literal side encodings, both strict-direction choices, property types/defaults and supported/unsupported query meanings without initialization or FPU control. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

PPL-SPEC-000662
2. Bounded unsigned flag-word updates preserve unrelated bits
UID: PPL-SPEC-000662
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

For a non-Boolean unsigned integer word type T of width w, reset_bits shall set the complete word to zero. Single-bit updates and queries shall require 0 ≤ b < w: reset_bit shall clear exactly bit b, set_bit(..., true) shall set it and set_bit(..., false) shall clear it, and get_bit shall return its Boolean value. Other bits shall be preserved.

Field operations shall require 0 ≤ s < w, 0 ≤ l < w and s + l ≤ w. set_bits shall also require its value v to satisfy 0 ≤ v < 2l; it shall replace exactly the field [s, s + l) with the binary digits of v. get_bits shall return those digits as a right-aligned T value without modifying the word. A zero-length field shall have value zero and perform no update. The operations shall have defined shifts under these preconditions and shall require no numerical initialization.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

Independent flag updates require explicit shift and field-fit conditions, particularly for empty fields and the largest valid bit.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

namespace Interval_NS {
  template <typename T> constexpr void reset_bits(T& bits);
  template <typename T> constexpr void reset_bit(T& bits, unsigned int bit);
  template <typename T> constexpr void set_bit(T& bits, unsigned int bit, bool value);
  template <typename T> constexpr bool get_bit(const T& bits, unsigned int bit);
  template <typename T>
  constexpr void set_bits(T& bits, unsigned int start, unsigned int len, T value);
  template <typename T>
  constexpr T get_bits(T& bits, unsigned int start, unsigned int len);
}
VERIFICATION_CRITERIA:

Compare complete words against independent Boolean arrays for zero/all/mixed patterns, every valid single position and all fields in small words; include largest positions in wider words and zero-length fields. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

3. Stateless interval metadata reports unsupported properties
UID: PPL-SPEC-000663
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

Interval_Info_Null<Policy> shall propagate may_be_empty, may_contain_infinity and check_inexact from its policy, and shall report store_special, store_open, cache_empty and cache_singleton as false. Default construction, copying, assignment, clearing and swapping shall retain no per-object property state.

Boundary and interval-property setters shall have no effect. Each property query shall return its property type's unsupported_value, including custom property types satisfying the required Value and default/unsupported value interface. clear_boundary_properties shall have no effect. Null-owner borrowing and initialization rules shall follow 🔗 1. Boundary sides and interval metadata property keys; text operations shall follow 🔗 8. Metadata ASCII representation and stream failure states.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

Policies without property storage need a consistent unsupported answer rather than accidentally retaining endpoint or cache flags.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

template <typename Policy> class Interval_Info_Null;
constexpr Interval_Info_Null();
constexpr void clear();
constexpr void clear_boundary_properties(Boundary_Type side);
template <typename P>
constexpr void set_boundary_property(Boundary_Type side, const P& p,
                           typename P::Value v = P::default_value);
template <typename P>
constexpr typename P::Value get_boundary_property(Boundary_Type side, const P& p) const;
template <typename P>
constexpr void set_interval_property(const P& p, typename P::Value v = P::default_value);
template <typename P>
constexpr typename P::Value get_interval_property(const P& p) const;
constexpr void m_swap(Interval_Info_Null& y);
template <typename P>
constexpr void swap(Interval_Info_Null<P>& x, Interval_Info_Null<P>& y);
VERIFICATION_CRITERIA:

Cross policy Boolean values, all standard property keys and a custom non-Boolean property type; verify unchanged unsupported answers after setters, clear, copies and member/free/self swaps. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

PPL-SPEC-000664
4. Shared openness view retains a separate Boolean value
UID: PPL-SPEC-000664
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

Interval_Info_Null_Open<Policy>(open) shall store the supplied Boolean openness value and report store_open as true. Its boundary query shall return that same stored value for OPEN on either side, and false for SPECIAL. Copying and assignment shall retain independent Boolean values. The type shall retain the null base's other policy traits and unsupported interval-property answers.

Inherited null-base setters, clearing and base swapping shall remain stateless and shall not change the derived openness value. This view shall not provide independently mutable lower/upper openness flags. Its own ASCII loading shall replace the shared Boolean as specified in 🔗 8. Metadata ASCII representation and stream failure states. Other prerequisites shall follow 🔗 1. Boundary sides and interval metadata property keys.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

A shared openness view supplies one openness choice for an input boundary without allocating the complete independent interval metadata state.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

template <typename Policy> class Interval_Info_Null_Open;
constexpr Interval_Info_Null_Open(bool open);
constexpr bool get_boundary_property(Boundary_Type side,
                           const Boundary_NS::Property& p) const;
VERIFICATION_CRITERIA:

Check both constructor values on both sides, unsupported special/cache properties, independent copies and assignments, and inherited base operations preserving the derived flag. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

5. Policy-selected metadata layout and cleared construction
UID: PPL-SPEC-000665
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

Interval_Info_Bitset<T, Policy> shall store metadata in one unsigned integer word. The policy shall provide Boolean may_be_empty, may_contain_infinity, check_inexact, store_special, store_open, cache_empty and cache_singleton traits and a nonnegative next_bit position. Each trait shall be exposed unchanged.

Starting at Policy::next_bit, the layout shall allocate lower-special, lower-open, upper-special and upper-open positions in that order, consuming one bit exactly when the corresponding property is stored. It shall then allocate a cardinality-known bit exactly when either cache is enabled, an empty-answer bit exactly when cache_empty is enabled, and a singleton- answer bit exactly when cache_singleton is enabled. Each named position and next_bit shall expose the corresponding layout offset. The selected layout shall fit within the word width.

Default construction and clear() shall establish an all-zero word, including policy-reserved prefix bits. The interval owner shall manage the meaning of any reserved prefix fields and ensure coherence of cached claims. Other validity and initialization conditions shall follow 🔗 1. Boundary sides and interval metadata property keys.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

Construction must initialize the complete word before any partial read-modify-write flag update, and optional properties must not overlap.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

template <typename T, typename Policy> class Interval_Info_Bitset;
constexpr Interval_Info_Bitset();
constexpr void clear();
VERIFICATION_CRITERIA:

Exercise every store/cache Boolean combination with multiple prefix lengths, check layout offsets independently, poison placement storage before construction, and verify all supported flags and reserved bits initially clear. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

PPL-SPEC-000666
6. Independent endpoint and cardinality flag updates
UID: PPL-SPEC-000666
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

For a valid layout in 🔗 5. Policy-selected metadata layout and cleared construction, setting SPECIAL or OPEN shall replace exactly that configured property on the selected side. Setting CARDINALITY_0, CARDINALITY_1 or CARDINALITY_IS shall replace exactly its configured bit. Omission of the value shall mean true. Every property query shall return its current configured Boolean value. Unsupported setters shall have no effect, and unsupported queries shall return false. An unnamed but representable Interval_NS::Property::Type enumeration value shall be unsupported.

clear_boundary_properties(side) shall clear exactly the selected side's stored special/open flags. Every other side, cache flag and reserved prefix bit shall be preserved. No setter shall infer relations among empty, singleton, known-status or endpoint flags; their consistent interpretation shall remain the interval owner's obligation. Other prerequisites shall follow 🔗 1. Boundary sides and interval metadata property keys and 🔗 5. Policy-selected metadata layout and cleared construction.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

Endpoint mutation and cache ownership must remain explicit so no partial update corrupts another stored property or extension field.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

constexpr void clear_boundary_properties(Boundary_Type side);
constexpr void set_boundary_property(Boundary_Type side,
                           const Boundary_NS::Property& p, bool v = true);
constexpr bool get_boundary_property(Boundary_Type side,
                           const Boundary_NS::Property& p) const;
constexpr void set_interval_property(const Interval_NS::Property& p, bool v = true);
constexpr bool get_interval_property(Interval_NS::Property p) const;
VERIFICATION_CRITERIA:

Compare complete property vectors with an independent Boolean model through every setter/query and side-clear transition, including unsupported policy combinations and preserved prefix bits. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

PPL-SPEC-000667
7. Bitset metadata copies and exchanges preserve the complete word
UID: PPL-SPEC-000667
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

Copy construction and assignment of Interval_Info_Bitset<T, Policy> shall preserve the source's complete word in a distinct owner, including reserved prefix bits. Assignment shall admit self-assignment and return its target. Later mutation or destruction of either owner shall not change the other's stored word. m_swap and free swap shall exchange both complete words, admit self-swapping and preserve every bit. Other valid-use conditions shall follow 🔗 5. Policy-selected metadata layout and cleared construction.

For constant-evaluable inputs and property/policy definitions, these operations shall support constant evaluation under the same stated preconditions.

RATIONALE:

Copy and exchange of interval metadata must retain extension fields as well as the currently configured standard flags.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

constexpr Interval_Info_Bitset(const Interval_Info_Bitset& y);
Interval_Info_Bitset& operator=(const Interval_Info_Bitset& y);
constexpr void m_swap(Interval_Info_Bitset& y);
template <typename T, typename P>
constexpr void swap(Interval_Info_Bitset<T, P>& x, Interval_Info_Bitset<T, P>& y);
VERIFICATION_CRITERIA:

Check independent copies, assignments, source destruction and every swap form on words containing both standard and reserved fields, including self operations. Check the constant-expression operations with translation-time assertions in addition to the runtime contract tests.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.

8. Metadata ASCII representation and stream failure states
UID: PPL-SPEC-000668
STATUS: APPROVED
COMPONENT: INTERVALS_BOXES
APPLICABILITY: IF_CPP
VERIFICATION_METHODS: Test, Analysis, Inspection
LANGUAGE: CPP
VISIBILITY: Internal
RELATIONS (Parent):
STATEMENT:

For Interval_Info_Null, ASCII output shall emit no bytes and loading shall consume no bytes, preserve the object and return true. For Interval_Info_Null_Open, output shall insert open or closed using ordinary string formatting, including the stream's width, fill and alignment. Loading shall extract a token under ordinary string-extraction rules, including the stream's width and whitespace settings; it shall assign the Boolean meaning and return true exactly for open and closed. Invalid or missing tokens shall return false and preserve the preceding Boolean value. With default compatible formatting, output followed by loading shall retain the shared Boolean.

For Interval_Info_Bitset with a noncharacter unsigned integer word type, ASCII output shall insert the complete word in hexadecimal base and loading shall extract a complete word in hexadecimal base using ordinary stream numeric syntax. Other stream formatting shall follow ordinary integer insertion/extraction rules. On normal return, including a failed load that returns false, both operations shall restore the preceding formatting flags. A successful load shall replace the complete word and return true; a failed numeric extraction shall return false and may change the word according to the stream's unsigned-integer extraction rules. Reserved/unused bits shall be retained and shall not cause rejection. With compatible stream formatting, output followed by loading shall retain the complete word.

Stream exceptions shall propagate under the stream's exception-mask rules; partial output/input and temporary hexadecimal base may remain after an exception. Calls shall preserve live valid metadata owners and require live streams, synchronized output/input access and the type's own valid-use rules. No numerical initialization shall be required.

RATIONALE:

Null, shared-open and bitset metadata have distinct serialized representations; normal-return formatting restoration differs from the permitted state after a stream exception.

INTERFACE:

Internal headers: Boundary_defs.hh and Interval_Info_defs.hh. Names belong to Parma_Polyhedra_Library and the indicated nested namespaces. Unqualified member signatures apply to the metadata type described above.

void ascii_dump(std::ostream& s) const;
bool ascii_load(std::istream& s);
VERIFICATION_CRITERIA:

Check exact tokens/hex words, reserved-bit round trips, trailing tokens, malformed and overflowing input, flags on success/false return, returning/throwing stream failures, and unchanged open flags on invalid reloads.

SOURCE:

src/Boundary_defs.hh; src/Interval_Info_defs.hh; src/Interval_Info_inlines.hh; tests/intervalinfospec1.cc.