Documentation

Examples.Language.Linking

Reusing source proofs after linking independent programs #

The existing traversal table is linked before the existing factorial table. Factorial's actual recursive calls are therefore relocated past the traversal functions, while traversal retains its real helper calls and heap writes. Neither implementation is copied or replaced by a host function.

The shared embedding theorem equates the linked observations with their original source actions. The existing factorial and array-map proofs then apply directly, including preservation of arbitrary initial heaps and disjoint borrowed views. This is source-semantic linking; it makes no claim about compiled instruction costs or calls newly added between the two previously closed tables.

The traversal functions keep their original signatures in the combined table.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    The recursive factorial function follows the complete traversal table.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      Observe the relocated factorial with ordinary parameters and its actual shared heap.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Linking preserves the whole recursive action, not only an assumed result specification.

        The original ordinary induction proof applies to the relocated recursive program.

        The linked recursion terminates with factorial and preserves any initial heap.

        Observe the linked traversal; its mutable buffer remains in the current shared heap.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Linking preserves the effectful traversal action, including its helper calls.

          theorem Complexity.Language.Examples.Linking.boundedMap_eval_frame (xs : Buffer CellTy.nat) (limit : ℕ) {contents : Array ℕ} {heap : Heap} (observed : xs.Contents heap contents) :
          ∃ (finish : Heap), boundedMap xs limit heap = Part.some (Except.ok (), finish) ∧ xs.Contents finish (Array.map (fun (x : CellValue CellTy.nat) => min (x + 1) limit) contents) ∧ xs.PreservesOutside heap finish

          The existing array-map and outside-buffer frame proofs hold at the linked invocation's same actual final heap, including disjoint slices of one object.