Invariant Preservation Test Suite¶
Verification tool — instantiates Structure-Preserving Embedding Design
A reusable battery of tests that checks whether the relations and operations declared worth preserving actually survive the embedding — turning a preservation contract into pass/fail evidence.
An Invariant Preservation Test Suite is a standing battery of checks that verifies the source's invariants — its relations and operations — still hold after it is embedded in the host. It takes the properties someone declared must be preserved (order, composition, a homomorphism law like f(a ∘ b) = f(a) ⊕ f(b), a referential constraint) and turns each into a concrete, repeatable test that passes or fails on real cases. Its defining scope, separating it from the identity-focused collision probe and the neighbor-focused audit, is relational and operational fidelity: does the structure between elements — not merely the elements themselves — map faithfully?
Example¶
A compiler translates a high-level intermediate representation into machine code; the embedding here is the lowering, and the structure that must survive is the meaning of the program — its operations and how they compose. The suite encodes invariants as tests: over a battery of sample programs it checks that the compiled output produces results identical to the source semantics (behavioral equivalence), that operations which must not be reordered stay ordered, and that an algebraic identity in the source (add-then-negate equals subtract) still holds after lowering. Each program is a case; each invariant is a check; a red result points at the exact law the pass broke — say, an optimization that reassociated floating-point operations and quietly changed a result. The suite does not produce the compiler or measure its speed; it certifies that the operational structure crossed intact, one invariant at a time.
How it works¶
Start from the preservation contract — the explicit list of relations, operations, and laws that must survive — and make each one testable. Assemble a case set of chosen and adversarial examples on which to exercise every invariant. Run each invariant as a check on each case and report pass/fail per invariant, localizing which structure broke and where. It is spec-driven and one-directional: it asks "did this law survive the crossing?", not "can I get the original back?"
Tuning parameters¶
- Invariant coverage — how many of the contract's laws are actually tested; every gap is an unmonitored assumption.
- Case-set breadth — typical inputs only versus adversarial and boundary cases; harder cases catch more breakage but cost more to build.
- Property vs. example testing — fixed examples (cheap, may miss) versus property or metamorphic tests over generated inputs (broader coverage, harder to write).
- Tolerance — exact preservation versus within-bound (numeric error ≤ δ); too loose and real breakage passes, too tight and benign noise fails.
- Failure granularity — one aggregate pass/fail versus per-invariant, per-case localization that names which law broke on which input.
When it helps, and when it misleads¶
Its strength is making structure preservation checkable and regression-proof: every future change to the map re-runs the suite, and a break names the specific violated law instead of a vague "something's off." Its failure modes: it only tests the invariants someone thought to write down — an unpreserved relation nobody encoded is silently missed — and a wall of green can lull a team into treating the suite as proof when it is only evidence over the cases run. The classic misuse is writing the tests after the map, to ratify it, so they encode whatever the map already does rather than what the source demands. The discipline that guards against this is to derive the invariants from the source's structure and the preservation contract first, independently of the implementation — a structure-preserving map is, formally, a homomorphism, and the suite exists to check that law actually holds.[1]
How it implements the components¶
Invariant Preservation Test Suite fills the relation-and-operation verification components — the ones a test battery produces or operates:
relation_and_operation_preservation_tests— this is the mechanism: the concrete, executable checks that each relation and operation survives the embedding.validation_case_set— it curates and runs the set of cases, typical and adversarial, on which the invariants are exercised.preservation_contract— it consumes and operationalizes the contract, turning each declared law into an executable check (the contract itself is authored by a Structure-Preserving Map Specification).
It checks relations and operations, not identity or recoverability: distortion_and_loss_register (identity collisions) belongs to Embedding Collision Probe, and round_trip_check (reconstruction) belongs to a Round-Trip Validation Test.
Related¶
- Instantiates: Structure-Preserving Embedding Design — the suite is how the archetype's preservation claims are made checkable.
- Consumes: a Structure-Preserving Map Specification — supplies the preservation contract whose laws the suite turns into tests.
- Sibling mechanisms: Embedding Collision Probe · Nearest-Neighbor Audit · Round-Trip Validation Test · Structure-Preserving Map Specification · Graph Embedding
Notes¶
Passing every invariant test does not guarantee the map is invertible. A lossy embedding can preserve every listed relation and operation yet still be impossible to reverse — recoverability is a separate property, checked by a Round-Trip Validation Test. Keep the two claims distinct: "structure preserved forward" and "original reconstructable" are not the same guarantee.
References¶
[1] A homomorphism is a map that respects structure: the image of a combination equals the combination of the images, f(a ∘ b) = f(a) ⊕ f(b). Most preservation invariants are instances of this law; an isomorphism additionally requires it to be invertible, which is what a round-trip test — not this suite — checks. ↩