-
7. Access through supported language interfaces UID: PPL-HLR-000007 STATUS: APPROVED COMPONENT: LIBRARY_WIDE APPLICABILITY: ALL VERIFICATION_METHODS: Test, Analysis, Review RELATIONS (Child): - PPL-LLR-000213 Configured binding domain selection (Refined by)
- PPL-LLR-000214 Mathematical consistency of corresponding binding operations (Refined by)
- PPL-LLR-000215 Consistent binding type dependencies (Refined by)
- PPL-LLR-000439 Binding interruption support and state changes (Refined by)
- PPL-LLR-000201 Explicit C library lifecycle (Refined by)
- PPL-LLR-000202 C object ownership and borrowed access (Refined by)
- PPL-LLR-000203 C boundary error reporting (Refined by)
- PPL-LLR-000311 Public C++ access to supported facilities (Refined by)
- PPL-LLR-000312 Independent values after copying domain objects (Refined by)
- PPL-LLR-000204 Java coefficient value preservation (Refined by)
- PPL-LLR-000205 Java library lifecycle (Refined by)
- PPL-LLR-000206 Java boundary exception translation (Refined by)
- PPL-LLR-000436 Java native object ownership (Refined by)
- PPL-LLR-000207 OCaml numerical term conversion (Refined by)
- PPL-LLR-000208 OCaml native object reclamation (Refined by)
- PPL-LLR-000209 OCaml boundary error translation (Refined by)
- PPL-LLR-000210 Prolog mathematical term interpretation (Refined by)
- PPL-LLR-000211 Prolog predicate outcomes (Refined by)
- PPL-LLR-000212 Prolog object lifetime operations (Refined by)
- PPL-LLR-000437 Prolog library lifecycle (Refined by)
STATEMENT: PPL shall expose its numerical facilities through its C++ interface and expose selected facilities through the supported C, Java, OCaml and Prolog interfaces. Each interface shall preserve the declared semantics of the facilities it exposes.
RATIONALE: Language-specific representations and error mechanisms must not silently change the numerical meaning of an exposed facility.
VERIFICATION_CRITERIA: Review the supported facility set for each interface and compare equivalent computations across enabled interfaces, including value conversion, object lifetime and error reporting.
BIBLIOGRAPHY: BagnaraHZ08SCP | Whole work (background on the library's numerical abstractions and design).
SOURCE: doc/definitions.dox: PPL_CXX_interface; interfaces/Makefile.am; interfaces/C/C_interface.dox; interfaces/Java/README.java.md; interfaces/OCaml/OCaml_interface.dox; interfaces/Prolog/Prolog_interface.dox.
The OCaml interface shall translate its supported linear-expression, constraint and generator values into the corresponding native mathematical objects while preserving variable identities, relation meanings and representable integral coefficients. Returned representations shall denote the native results.
Language-level representation changes must preserve the mathematical meaning of exchanged objects.
Verification covers supported OCaml/native mathematical representations and their conversions. Independent mathematical reconstruction and conversion tests verify coordinate, coefficient and relation preservation. Coverage remains limited to representations exposed by the selected interface; 🔗 2. Mathematical consistency of corresponding binding operations governs the wider facility-preservation obligation.
Conversion tests cover signed coefficients, several variable positions, equality and strict and non-strict inequalities, and supported generator kinds; reconstructed native objects and returned OCaml representations have the same mathematical interpretation.
interfaces/OCaml/ppl_ocaml_globals.mli, numerical representation types; interfaces/OCaml/ppl_ocaml_common.cc, mathematical object conversion helpers; interfaces/OCaml/tests/test1.ml.
-
1. OCaml mathematical representation exchange UID: PPL-SPEC-001692 STATUS: APPROVED COMPONENT: OCAML_INTERFACE APPLICABILITY: IF_OCAML VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: OCaml VISIBILITY: Public RELATIONS (Parent): - PPL-LLR-000011 Coordinate identity and ambient dimension (Specifies)
- PPL-LLR-000012 Affine meaning of linear expressions (Specifies)
- PPL-LLR-000013 Meaning of linear constraints (Specifies)
- PPL-LLR-000014 Meaning of linear congruences (Specifies)
- PPL-LLR-000015 Distinct meanings of geometric generators (Specifies)
- PPL-LLR-000207 OCaml numerical term conversion (Specifies)
- PPL-LLR-000214 Mathematical consistency of corresponding binding operations (Specifies)
STATEMENT: For well-formed values of the exposed algebraic types, conversion to native objects shall preserve zero-based variable identities, signed integral Z.t coefficients within the configured native range, affine expression meaning, equality and strict/non-strict inequality meaning, and generator kind. Returned values shall denote the native result; syntactic tree shape and normalization need not be preserved.
Conversion of finite acyclic expressions to native objects shall preserve operator grouping and apply the configured coefficient rules at each node. Native stack usage shall be independent of expression depth. The expression values used during traversal shall remain valid under the OCaml runtime's lifetime and collection rules.
A point or closure point with expression coordinates ai and nonzero divisor d denotes coordinates ai ⁄ d. Lines and rays denote the native direction described by the expression. Grid generators and congruences shall preserve their native rational-divisor and integral-modulus meanings. Native validity and operation-specific topology and arithmetic preconditions apply. A Z.t may be immediate or heap allocated; the binding shall use its value rather than assume either memory layout.
RATIONALE: An algebraic representation can change tree shape while preserving exactly the same affine function or geometric object.
INTERFACE: Module Ppl_ocaml.
type linear_expression = Variable of int | Coefficient of Z.t | Unary_Plus of linear_expression | Unary_Minus of linear_expression | Plus of linear_expression * linear_expression | Minus of linear_expression * linear_expression | Times of Z.t * linear_expression type linear_constraint = Less_Than of linear_expression * linear_expression | Less_Or_Equal of linear_expression * linear_expression | Equal of linear_expression * linear_expression | Greater_Than of linear_expression * linear_expression | Greater_Or_Equal of linear_expression * linear_expression type linear_generator = Line of linear_expression | Ray of linear_expression | Point of linear_expression * Z.t | Closure_Point of linear_expression * Z.t
Configured domain and solver constructors consume these types; their expression, constraint and generator queries return the corresponding types. The companion linear_grid_generator and linear_congruence types in the module signature define grid exchange.
VERIFICATION_CRITERIA: Independently evaluate returned affine expressions and convert nested inputs with known grouped affine results. Round-trip positive, negative, zero and configured coefficient endpoints. Check multiple coordinates, all five relation kinds and all four polyhedral generator kinds. Include immediate and large Zarith values, divisor normalization and compacting collections.
SOURCE: interfaces/OCaml/ppl_ocaml_globals.mli; interfaces/OCaml/ppl_ocaml_common.cc; interfaces/OCaml/ppl_ocaml_globals.ml; interfaces/OCaml/tests/zarith1.ml; interfaces/OCaml/tests/polyhedron1.ml; interfaces/OCaml/tests/boundary_contracts1.ml.
-
4. OCaml operation-option correspondence UID: PPL-SPEC-001731 STATUS: APPROVED COMPONENT: OCAML_INTERFACE APPLICABILITY: IF_OCAML VERIFICATION_METHODS: Analysis, Inspection LANGUAGE: OCaml VISIBILITY: Public RELATIONS (Parent): STATEMENT: For well-typed public OCaml values, conversion of operation options shall select the native choice with the same documented meaning: empty/universe, bounded integer width (8, 16, 32, 64 or 128 bits), unsigned or two's-complement signed representation, wrapping/undefined/impossible overflow, minimization or maximization, and polynomial/simplex/unrestricted complexity. MIP pricing and PIP cutting/pivot names and values shall select their corresponding native control parameters. These options retain the native operation's mathematical preconditions and exactness or approximation guarantees. Values forged outside the public OCaml type definitions are outside this conversion contract; supported boundary failures follow 🔗 3. OCaml native exception translation.
RATIONALE: OCaml variants are encoded by constructor order; each ordinal must continue to denote the intended native option when either side evolves.
INTERFACE: Module Ppl_ocaml types degenerate_element, bounded_integer_type_width, bounded_integer_type_representation, bounded_integer_type_overflow, optimization_mode, complexity_class, control_parameter_name, control_parameter_value, pip_problem_control_parameter_name and pip_problem_control_parameter_value as declared in ppl_ocaml_globals.mli.
VERIFICATION_CRITERIA: Compare every public variant's runtime encoding with the corresponding native conversion branch, including all pricing, cutting and pivot strategies. Inspect option forwarding at generated call sites and native constructor preconditions. Check that no variant ordinal is silently mapped to another policy.
SOURCE: interfaces/OCaml/ppl_ocaml_globals.mli; interfaces/OCaml/ppl_ocaml_common.cc.
-
7. Access through supported language interfaces UID: PPL-HLR-000007 STATUS: APPROVED COMPONENT: LIBRARY_WIDE APPLICABILITY: ALL VERIFICATION_METHODS: Test, Analysis, Review RELATIONS (Child): - PPL-LLR-000213 Configured binding domain selection (Refined by)
- PPL-LLR-000214 Mathematical consistency of corresponding binding operations (Refined by)
- PPL-LLR-000215 Consistent binding type dependencies (Refined by)
- PPL-LLR-000439 Binding interruption support and state changes (Refined by)
- PPL-LLR-000201 Explicit C library lifecycle (Refined by)
- PPL-LLR-000202 C object ownership and borrowed access (Refined by)
- PPL-LLR-000203 C boundary error reporting (Refined by)
- PPL-LLR-000311 Public C++ access to supported facilities (Refined by)
- PPL-LLR-000312 Independent values after copying domain objects (Refined by)
- PPL-LLR-000204 Java coefficient value preservation (Refined by)
- PPL-LLR-000205 Java library lifecycle (Refined by)
- PPL-LLR-000206 Java boundary exception translation (Refined by)
- PPL-LLR-000436 Java native object ownership (Refined by)
- PPL-LLR-000207 OCaml numerical term conversion (Refined by)
- PPL-LLR-000208 OCaml native object reclamation (Refined by)
- PPL-LLR-000209 OCaml boundary error translation (Refined by)
- PPL-LLR-000210 Prolog mathematical term interpretation (Refined by)
- PPL-LLR-000211 Prolog predicate outcomes (Refined by)
- PPL-LLR-000212 Prolog object lifetime operations (Refined by)
- PPL-LLR-000437 Prolog library lifecycle (Refined by)
STATEMENT: PPL shall expose its numerical facilities through its C++ interface and expose selected facilities through the supported C, Java, OCaml and Prolog interfaces. Each interface shall preserve the declared semantics of the facilities it exposes.
RATIONALE: Language-specific representations and error mechanisms must not silently change the numerical meaning of an exposed facility.
VERIFICATION_CRITERIA: Review the supported facility set for each interface and compare equivalent computations across enabled interfaces, including value conversion, object lifetime and error reporting.
BIBLIOGRAPHY: BagnaraHZ08SCP | Whole work (background on the library's numerical abstractions and design).
SOURCE: doc/definitions.dox: PPL_CXX_interface; interfaces/Makefile.am; interfaces/C/C_interface.dox; interfaces/Java/README.java.md; interfaces/OCaml/OCaml_interface.dox; interfaces/Prolog/Prolog_interface.dox.
The OCaml interface shall associate each owned native numerical object exposed by the interface, including supported domain, MIP problem and PIP problem objects, with an OCaml-managed handle whose finalization releases that native object. Borrowed views shall retain their documented ownership and validity preconditions rather than acquiring an independent owned lifetime.
Owned native allocations must participate in the managed runtime's resource lifecycle.
Verification covers owned OCaml domain and solver handles, their finalizers and borrowed-view validity. Normal-lifetime checks, allocation-sensitive lifecycle checks and finalizer inspection verify cleanup and owner separation. Finalization timing is controlled by the OCaml runtime; prompt reclamation at a particular program point is not promised. Failure cleanup is governed by 🔗 3. Failure and resource safety.
Inspect finalizers for generated domain handles and MIP and PIP problem handles. Exercise their normal owned lifetimes, including repeated creation and collection of unreachable handles, and confirm that cleanup releases their native allocations without deleting a still-live independent object. For borrowed domain and solver views, including PIP solution-tree nodes, review owner-lifetime and mutation-invalidation preconditions and verify that view cleanup does not release the owner's native allocation. Coordinate these cases with the permitted library lifecycle transitions in 🔗 1. Initialization and finalization lifecycle.
interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4, custom operations; interfaces/OCaml/ppl_interface_generator_ocaml_hh_code.m4, owned domain finalizers; interfaces/OCaml/ppl_ocaml_common.cc, owned MIP and PIP problem finalizers and borrowed tree-node wrappers.
-
2. OCaml managed native ownership UID: PPL-SPEC-001693 STATUS: APPROVED COMPONENT: OCAML_INTERFACE APPLICABILITY: IF_OCAML VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: OCaml VISIBILITY: Public RELATIONS (Parent): STATEMENT: Owned domain, MIP and PIP problem handles shall register a custom finalizer which releases the owned native object exactly once when the OCaml runtime finalizes the handle. Independent copies shall own independent allocations. A marked borrowed native pointer shall not be deleted by its wrapper finalizer.
Factories shall allocate managed native owners before constructing native objects or owned conversion temporaries. Native slots shall contain null or their owned pointer before they can be observed by a finalizer or client. Native-only construction may defer the null-slot write to its failure path before exception translation or any further managed allocation. No subsequent OCaml allocation shall be needed to publish a newly owned native pointer. C++ failures during construction or multi-result computation shall leave no unowned native allocation; partially initialized managed owners shall be safe to finalize.
Borrowed powerset iterators and read-only disjuncts shall keep their owner in GC-scanned storage and check its generation before native access. PIP tree views shall keep their problem owner reachable and reject generation-invalid access. View collection shall not delete the owner's native allocation. Clients shall respect the library lifecycle and operation-specific view invalidation rules. No collection time or prompt finalization is promised.
RATIONALE: Native pointers are outside the OCaml heap, while owner references must remain visible to its collector.
INTERFACE: Module Ppl_ocaml: abstract configured domain types, mip_problem, pip_problem, pip_tree_node, configured powerset iterator types and constructors, copies and solution/disjunct view accessors. Owned-object reclamation is through OCaml custom-block finalization rather than an explicit user deletion operation.
VERIFICATION_CRITERIA: Create and copy domain and solver handles, collect unreachable wrappers, and check live independent objects remain usable. Compact while a borrowed PIP or powerset view is reachable; check retention and stale-use rejection. Inspect each generated finalizer and native allocation balance. Compare owned inputs with valid borrowed disjuncts in partition and ranking-result factories. Inject failures at each managed-owner allocation and native construction step, including powerset cursors, partition pairs and ranking-function results.
SOURCE: interfaces/OCaml/ppl_interface_generator_ocaml_hh_code.m4; interfaces/OCaml/ppl_ocaml_common_defs.hh; interfaces/OCaml/ppl_ocaml_common_inlines.hh; interfaces/OCaml/ppl_ocaml_common.cc; interfaces/OCaml/ppl_ocaml_globals.ml; interfaces/OCaml/tests/zarith1.ml; interfaces/OCaml/tests/pip_lifetime1.ml; interfaces/OCaml/tests/ppl_interface_generator_ocaml_test_ml.m4; interfaces/OCaml/tests/ppl_interface_generator_ocaml_test_ml_code.m4; generated powerset tests.
-
7. Access through supported language interfaces UID: PPL-HLR-000007 STATUS: APPROVED COMPONENT: LIBRARY_WIDE APPLICABILITY: ALL VERIFICATION_METHODS: Test, Analysis, Review RELATIONS (Child): - PPL-LLR-000213 Configured binding domain selection (Refined by)
- PPL-LLR-000214 Mathematical consistency of corresponding binding operations (Refined by)
- PPL-LLR-000215 Consistent binding type dependencies (Refined by)
- PPL-LLR-000439 Binding interruption support and state changes (Refined by)
- PPL-LLR-000201 Explicit C library lifecycle (Refined by)
- PPL-LLR-000202 C object ownership and borrowed access (Refined by)
- PPL-LLR-000203 C boundary error reporting (Refined by)
- PPL-LLR-000311 Public C++ access to supported facilities (Refined by)
- PPL-LLR-000312 Independent values after copying domain objects (Refined by)
- PPL-LLR-000204 Java coefficient value preservation (Refined by)
- PPL-LLR-000205 Java library lifecycle (Refined by)
- PPL-LLR-000206 Java boundary exception translation (Refined by)
- PPL-LLR-000436 Java native object ownership (Refined by)
- PPL-LLR-000207 OCaml numerical term conversion (Refined by)
- PPL-LLR-000208 OCaml native object reclamation (Refined by)
- PPL-LLR-000209 OCaml boundary error translation (Refined by)
- PPL-LLR-000210 Prolog mathematical term interpretation (Refined by)
- PPL-LLR-000211 Prolog predicate outcomes (Refined by)
- PPL-LLR-000212 Prolog object lifetime operations (Refined by)
- PPL-LLR-000437 Prolog library lifecycle (Refined by)
STATEMENT: PPL shall expose its numerical facilities through its C++ interface and expose selected facilities through the supported C, Java, OCaml and Prolog interfaces. Each interface shall preserve the declared semantics of the facilities it exposes.
RATIONALE: Language-specific representations and error mechanisms must not silently change the numerical meaning of an exposed facility.
VERIFICATION_CRITERIA: Review the supported facility set for each interface and compare equivalent computations across enabled interfaces, including value conversion, object lifetime and error reporting.
BIBLIOGRAPHY: BagnaraHZ08SCP | Whole work (background on the library's numerical abstractions and design).
SOURCE: doc/definitions.dox: PPL_CXX_interface; interfaces/Makefile.am; interfaces/C/C_interface.dox; interfaces/Java/README.java.md; interfaces/OCaml/OCaml_interface.dox; interfaces/Prolog/Prolog_interface.dox.
The OCaml interface shall report every native failure designated by its supported failure model through the OCaml exception mechanism, including invalid-argument, arithmetic-overflow, allocation-failure and supported timeout conditions. Native C++ exceptions raised by supported operations shall be contained at the OCaml runtime boundary rather than escaping to the caller.
OCaml callers must be able to handle library failures without depending on the native language's exception machinery.
Verification covers the OCaml failure model, host exception mapping and native exception containment. Failure-category tests and inspection of conversion and boundary cleanup provide evidence. Timeout cases apply only where the corresponding facility is supported; binding-owned timeout state is governed by 🔗 4. Binding interruption support and state changes. Resource cleanup is governed by 🔗 3. Failure and resource safety.
Exercise the supported failure categories and confirm their declared OCaml exceptions, including invalid arguments, domain and size errors, checked-coefficient overflow, allocation failure and supported interruptions. Inspect native exception containment and cleanup of resources acquired before a host-runtime error is raised.
interfaces/OCaml/ppl_ocaml_common_defs.hh, exception translation; interfaces/OCaml/ppl_ocaml_globals.ml, exception registration; interfaces/OCaml/ppl_ocaml_globals.mli, exposed exception declarations.
-
Incoming link from: 4. OCaml operation-option correspondence1
3. OCaml native exception translation UID: PPL-SPEC-001694 STATUS: APPROVED COMPONENT: OCAML_INTERFACE APPLICABILITY: IF_OCAML VERIFICATION_METHODS: Test, Analysis, Inspection LANGUAGE: OCaml VISIBILITY: Public RELATIONS (Parent): STATEMENT: Native exceptions raised by supported OCaml numerical entry points shall be contained. bad_alloc shall raise Out_of_memory and invalid_argument shall raise Invalid_argument. Native overflow, domain, length, logic and runtime errors shall raise the corresponding declared PPL_arithmetic_overflow, PPL_domain_error, PPL_length_error, PPL_logic_error and PPL_internal_error exceptions with diagnostics. Other standard exceptions shall raise PPL_unknown_standard_exception; unexpected native exceptions shall raise PPL_unexpected_error. Supported timeout exceptions shall reset the triggering binding-owned timer and raise PPL_timeout_exception.
Native handlers and scoped native resources shall finish cleanup before the host exception is raised. If native unwinding leaves local root records from exited frames, the bridge shall restore the prior root chain before any runtime allocation. Diagnostic creation shall preserve the exception type and message when allocation succeeds. Allocation failure during translation shall be reported through the OCaml runtime after native cleanup. Raising an exception does not promise rollback beyond an operation's contract. Well-typed host representations, lifecycle, range and synchronization preconditions apply.
RATIONALE: OCaml callers need a host exception rather than native unwinding across the runtime boundary.
INTERFACE: Module Ppl_ocaml: the exception constructors above, as declared in ppl_ocaml_globals.mli, and supported foreign entry points. String-bearing exceptions carry the native diagnostic. Out_of_memory and PPL_timeout_exception have no diagnostic payload.
VERIFICATION_CRITERIA: Check invalid arguments, invalid dimensions, checked coefficient overflow and supported deterministic or wall-clock interruption. Check diagnostics and recovery after exceptions from handwritten and generated entry points, including a subsequent collection and native call. Inspect all translation categories, local-root lifetimes and temporary-resource cleanup. Exercise allocation failure in the exception bridge in a controlled boundary test.
SOURCE: interfaces/OCaml/ppl_ocaml_common_defs.hh; interfaces/OCaml/ppl_ocaml_globals.ml; interfaces/OCaml/tests/zarith1.ml; interfaces/OCaml/tests/test1.ml; interfaces/OCaml/tests/boundary_contracts1.ml.