OCaml boundary contracts
|
Type
|
Level
|
MID
|
UID
|
REFS
|
Title
|
Statement
|
Rationale
|
Comment
|
BIBLIOGRAPHY
|
STATUS
|
COMPONENT
|
APPLICABILITY
|
VERIFICATION_METHODS
|
VERIFICATION_CRITERIA
|
SOURCE
|
LANGUAGE
|
VISIBILITY
|
INTERFACE
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
SW_SPEC
|
1 |
|
|
Parents:
|
|
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. |
An algebraic representation can change tree shape while preserving exactly the same affine function or geometric object. |
|
|
|
|
|
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. |
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. |
|
|
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. |
|
|
SW_SPEC
|
2 |
|
|
|
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. |
Native pointers are outside the OCaml heap, while owner references must remain visible to its collector. |
|
|
|
|
|
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. |
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. |
|
|
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. |
||
|
SW_SPEC
|
3 |
|
|
Incoming link from:
4. OCaml operation-option correspondence
1 |
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. |
OCaml callers need a host exception rather than native unwinding across the runtime boundary. |
|
|
|
|
|
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. |
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. |
|
|
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. |
||
|
SW_SPEC
|
4 |
|
|
|
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. |
OCaml variants are encoded by constructor order; each ordinal must continue to denote the intended native option when either side evolves. |
|
|
|
|
|
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. |
interfaces/OCaml/ppl_ocaml_globals.mli; interfaces/OCaml/ppl_ocaml_common.cc. |
|
|
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. |