Documentation

Examples.Language.Imports

Named source calls across independently declared programs #

The client imports the existing recursive factorial and effectful traversal libraries. Its source calls refer to their qualified names; the generated function table contains the relocated library implementations and their internal call graphs, not host callbacks or specifications standing in for code.

The generated one-step equations expose the original library observations. Existing mathematical proofs therefore establish the client's factorial result and two-buffer frame without reopening recursion or either traversal loop. A second client imports the first, retaining this transitive source call graph. These are source correctness claims, not inherited compiled instruction bounds.

Ordinary arguments and the actual result observed in their real source heaps. This interface does not assert the existence of a total mathematical model.

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

    Ordinary mathematical function generated from the same represented source block.

    Equations
    Instances For
      theorem Complexity.Language.Examples.Imports.Implementation.factorial_action_rel_native (n : ℕ) (initialHeap✝ : Heap) :
      ∃ (returned : Value Ty.nat) (finish : Heap), factorial n initialHeap✝ = Part.some (Except.ok returned, finish) ∧ (Representation.ofEmbedding (Function.Embedding.refl ℕ)).Rel (factorial_model n) returned finish ∧ (fun (finish : Heap) => initialHeap✝.ShapeExtends finish) finish

      Successful execution observes the native result in its actual final heap and retains every previously represented immutable list.

      @[reducible, inline]

      Budget-free total correctness with ordinary source parameters and relational initial/final heap postconditions. This is the existing source function contract.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[reducible, inline]

        Signatures of the functions added by this source declaration.

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

          Fold an actual source invocation back to its named ordinary-argument observation.

          @[reducible, inline]

          Apply a predicate, postcondition or bound with ordinary source parameters to the actual argument environment. No new contract or execution is introduced.

          Equations
          Instances For

            Ordinary arguments and the actual result observed in their real source heaps. This interface does not assert the existence of a total mathematical model.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              @[reducible, inline]

              The actual declared argument environment, constructed from ordinary source parameters. This is proof-side parameter transport, not an additional runtime operation.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                @[reducible, inline]

                Signature-preserving positions of this imported source program.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem Complexity.Language.Examples.Imports.Implementation.factorial_total :
                  factorial_contract (fun (n_source : Value Ty.nat) (initialHeap : Heap) => True) fun (n_source : Value Ty.nat) (initialHeap : Heap) (returned : Value Ty.nat) (finalHeap : Heap) => returned = factorial_model ((fun (value : ℕ) => value) n_source) ∧ finalHeap = initialHeap

                  Exact total source contract derived from the checked encoded-result equation and the existing raw-input reconstruction, with the same final heap.

                  Actual imported function bodies with their internal calls relocated.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[reducible, inline]

                    Budget-free total correctness with ordinary source parameters and relational initial/final heap postconditions. This is the existing source function contract.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem Complexity.Language.Examples.Imports.Implementation.factorial_total_iff (pre✝ : ℕ → Heap → Prop) (post✝ : ℕ → Heap → ℕ → Heap → Prop) :
                      factorial_contract pre✝ post✝ ↔ ∀ (n : ℕ) (initialHeap : Heap), pre✝ n initialHeap → ∃ (value : ℕ) (finalHeap : Heap), factorial n initialHeap = Part.some (Except.ok value, finalHeap) ∧ post✝ n initialHeap value finalHeap

                      The source contract is equivalent to ordinary curried preconditions and successful result/heap postconditions, including termination and absence of faults.

                      The same source execution returns the encoded mathematical result without changing its supplied heap, under the actual input representations.

                      theorem Complexity.Language.Examples.Imports.Implementation.boundedMapPair_spec {pre✝ : Env [Ty.buffer CellTy.nat, Ty.buffer CellTy.nat, Ty.nat] → Heap → Prop} {post✝ : Env [Ty.buffer CellTy.nat, Ty.buffer CellTy.nat, Ty.nat] → Heap → Unit → Heap → Prop} :
                      FunctionTotal program boundedMapPairId pre✝ post✝ → ∀ (xs ys : Buffer CellTy.nat) (limit : ℕ) (continuation : Std.Do.PostCond Unit (Std.Do.PostShape.except Fault (Std.Do.PostShape.arg Heap Std.Do.PostShape.pure))), ⦃fun (initialHeap : Heap) => { down := pre✝ (Env.cons xs (Env.cons ys (Env.cons limit Env.empty))) initialHeap ∧ ∀ (value : Unit) (finalHeap : Heap), post✝ (Env.cons xs (Env.cons ys (Env.cons limit Env.empty))) initialHeap value finalHeap → (continuation.1 value finalHeap).down }⦄ boundedMapPair xs ys limit ⦃continuation⦄

                      Apply a supplied source contract with ordinary named arguments and its actual returned value and final heap. No callee body or new contract is inferred.

                      Added function bodies already typed against the complete linked table.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[reducible, inline]

                        The actual declared argument environment, constructed from ordinary source parameters. This is proof-side parameter transport, not an additional runtime operation.

                        Equations
                        Instances For

                          The named function's actual independently interpreted source body.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            @[reducible, inline]

                            Apply a predicate, postcondition or bound with ordinary source parameters to the actual argument environment. No new contract or execution is introduced.

                            Equations
                            Instances For

                              Fold an actual source invocation back to its named ordinary-argument observation.

                              One source-body equation in ordinary monadic notation; named callees remain opaque.

                              theorem Complexity.Language.Examples.Imports.Implementation.factorial_action_rel_native_preserving (n : ℕ) (initialHeap✝ : Heap) :
                              ∃ (returned : Value Ty.nat) (finish : Heap), factorial n initialHeap✝ = Part.some (Except.ok returned, finish) ∧ (Representation.ofEmbedding (Function.Embedding.refl ℕ)).Rel (factorial_model n) returned finish ∧ (fun (finish : Heap) => initialHeap✝.ShapeExtends finish ∧ Buffer.PreservesContents initialHeap✝ finish) finish

                              Successful execution observes the native result in its actual final heap and retains every previously represented immutable list.

                              @[reducible, inline]

                              The source program's declared first-order signatures.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                theorem Complexity.Language.Examples.Imports.Implementation.boundedMapPair_contract_iff_triple (pre✝ : Buffer CellTy.nat → Buffer CellTy.nat → ℕ → Heap → Prop) (post✝ : Buffer CellTy.nat → Buffer CellTy.nat → ℕ → Heap → Unit → Heap → Prop) :
                                boundedMapPair_contract pre✝ post✝ ↔ ∀ (xs ys : Buffer CellTy.nat) (limit : ℕ) (initialHeap : Heap), ⦃fun (currentHeap : Heap) => { down := currentHeap = initialHeap ∧ pre✝ xs ys limit initialHeap }⦄ boundedMapPair xs ys limit ⦃(fun (value : Unit) (finalHeap : Heap) => { down := post✝ xs ys limit initialHeap value finalHeap }, fun (x : Fault) (x_1 : Heap) => { down := False }, PUnit.unit)⦄

                                Prove the ordinary-parameter source contract with a total-correctness triple for the same action. The ghost initial heap equals the actual entry heap; successful results use the actual final heap, and faults are excluded.

                                One source-body equation in ordinary monadic notation; named callees remain opaque.

                                theorem Complexity.Language.Examples.Imports.Implementation.factorial_spec {pre✝ : Env [Ty.nat] → Heap → Prop} {post✝ : Env [Ty.nat] → Heap → ℕ → Heap → Prop} :
                                FunctionTotal program factorialId pre✝ post✝ → ∀ (n : ℕ) (continuation : Std.Do.PostCond ℕ (Std.Do.PostShape.except Fault (Std.Do.PostShape.arg Heap Std.Do.PostShape.pure))), ⦃fun (initialHeap : Heap) => { down := pre✝ (Env.cons n Env.empty) initialHeap ∧ ∀ (value : ℕ) (finalHeap : Heap), post✝ (Env.cons n Env.empty) initialHeap value finalHeap → (continuation.1 value finalHeap).down }⦄ factorial n ⦃continuation⦄

                                Apply a supplied source contract with ordinary named arguments and its actual returned value and final heap. No callee body or new contract is inferred.

                                The named function's actual independently interpreted source body.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  @[reducible, inline]

                                  The complete signature tables retained from imported source programs.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    @[reducible, inline]

                                    Signature-preserving positions of this imported source program.

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

                                      The named function's actual partial source action, with ordinary typed arguments and an explicitly supplied shared heap.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        theorem Complexity.Language.Examples.Imports.Implementation.factorial_contract_iff_triple (pre✝ : ℕ → Heap → Prop) (post✝ : ℕ → Heap → ℕ → Heap → Prop) :
                                        factorial_contract pre✝ post✝ ↔ ∀ (n : ℕ) (initialHeap : Heap), ⦃fun (currentHeap : Heap) => { down := currentHeap = initialHeap ∧ pre✝ n initialHeap }⦄ factorial n ⦃(fun (value : ℕ) (finalHeap : Heap) => { down := post✝ n initialHeap value finalHeap }, fun (x : Fault) (x_1 : Heap) => { down := False }, PUnit.unit)⦄

                                        Prove the ordinary-parameter source contract with a total-correctness triple for the same action. The ghost initial heap equals the actual entry heap; successful results use the actual final heap, and faults are excluded.

                                        The named function's actual partial source action, with ordinary typed arguments and an explicitly supplied shared heap.

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

                                          Automatic correspondence for the same generated source function, without a machine budget.

                                          theorem Complexity.Language.Examples.Imports.Implementation.boundedMapPair_total_iff (pre✝ : Buffer CellTy.nat → Buffer CellTy.nat → ℕ → Heap → Prop) (post✝ : Buffer CellTy.nat → Buffer CellTy.nat → ℕ → Heap → Unit → Heap → Prop) :
                                          boundedMapPair_contract pre✝ post✝ ↔ ∀ (xs ys : Buffer CellTy.nat) (limit : ℕ) (initialHeap : Heap), pre✝ xs ys limit initialHeap → ∃ (value : Unit) (finalHeap : Heap), boundedMapPair xs ys limit initialHeap = Part.some (Except.ok value, finalHeap) ∧ post✝ xs ys limit initialHeap value finalHeap

                                          The source contract is equivalent to ordinary curried preconditions and successful result/heap postconditions, including termination and absence of faults.

                                          The finite table of actual named source bodies.

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

                                            The client makes a real library call and returns its actual result.

                                            The existing recursive proof supplies the client's mathematical result.

                                            The imported recursive call terminates and preserves every initial shared heap.

                                            The client's two imported calls have the same source action as the existing two-buffer composition; neither callee's implementation is unfolded.

                                            theorem Complexity.Language.Examples.Imports.boundedMapPair_eval (xs ys : Buffer CellTy.nat) (limit : ℕ) {leftContents rightContents : Array ℕ} {heap : Heap} (observedLeft : xs.Contents heap leftContents) (observedRight : ys.Contents heap rightContents) (separated : xs.Disjoint ys) :
                                            ∃ (finish : Heap), Implementation.boundedMapPair xs ys limit heap = Part.some (Except.ok (), finish) ∧ xs.Contents finish (Array.map (fun (x : CellValue CellTy.nat) => min (x + 1) limit) leftContents) ∧ ys.Contents finish (Array.map (fun (x : CellValue CellTy.nat) => min (x + 1) limit) rightContents) ∧ ∀ {kind : CellTy} (other : Buffer kind) (contents : Array (CellValue kind)), xs.Disjoint other → ys.Disjoint other → other.Contents heap contents → other.Contents finish contents

                                            The existing composition proof gives both mapped arrays and preservation outside both views at the same actual final heap, without a new frame argument.

                                            Ordinary arguments and the actual result observed in their real source heaps. This interface does not assert the existence of a total mathematical model.

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

                                              The finite table of actual named source bodies.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                theorem Complexity.Language.Examples.Imports.Second.factorial_action_rel_native (n : ℕ) (initialHeap✝ : Heap) :
                                                ∃ (returned : Value Ty.nat) (finish : Heap), factorial n initialHeap✝ = Part.some (Except.ok returned, finish) ∧ (Representation.ofEmbedding (Function.Embedding.refl ℕ)).Rel (factorial_model n) returned finish ∧ (fun (finish : Heap) => initialHeap✝.ShapeExtends finish) finish

                                                Successful execution observes the native result in its actual final heap and retains every previously represented immutable list.

                                                @[reducible, inline]

                                                Budget-free total correctness with ordinary source parameters and relational initial/final heap postconditions. This is the existing source function contract.

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

                                                  The named function's actual partial source action, with ordinary typed arguments and an explicitly supplied shared heap.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    theorem Complexity.Language.Examples.Imports.Second.factorial_spec {pre✝ : Env [Ty.nat] → Heap → Prop} {post✝ : Env [Ty.nat] → Heap → ℕ → Heap → Prop} :
                                                    FunctionTotal program factorialId pre✝ post✝ → ∀ (n : ℕ) (continuation : Std.Do.PostCond ℕ (Std.Do.PostShape.except Fault (Std.Do.PostShape.arg Heap Std.Do.PostShape.pure))), ⦃fun (initialHeap : Heap) => { down := pre✝ (Env.cons n Env.empty) initialHeap ∧ ∀ (value : ℕ) (finalHeap : Heap), post✝ (Env.cons n Env.empty) initialHeap value finalHeap → (continuation.1 value finalHeap).down }⦄ factorial n ⦃continuation⦄

                                                    Apply a supplied source contract with ordinary named arguments and its actual returned value and final heap. No callee body or new contract is inferred.

                                                    Fold an actual source invocation back to its named ordinary-argument observation.

                                                    theorem Complexity.Language.Examples.Imports.Second.factorial_total_iff (pre✝ : ℕ → Heap → Prop) (post✝ : ℕ → Heap → ℕ → Heap → Prop) :
                                                    factorial_contract pre✝ post✝ ↔ ∀ (n : ℕ) (initialHeap : Heap), pre✝ n initialHeap → ∃ (value : ℕ) (finalHeap : Heap), factorial n initialHeap = Part.some (Except.ok value, finalHeap) ∧ post✝ n initialHeap value finalHeap

                                                    The source contract is equivalent to ordinary curried preconditions and successful result/heap postconditions, including termination and absence of faults.

                                                    theorem Complexity.Language.Examples.Imports.Second.factorial_action_rel_native_preserving (n : ℕ) (initialHeap✝ : Heap) :
                                                    ∃ (returned : Value Ty.nat) (finish : Heap), factorial n initialHeap✝ = Part.some (Except.ok returned, finish) ∧ (Representation.ofEmbedding (Function.Embedding.refl ℕ)).Rel (factorial_model n) returned finish ∧ (fun (finish : Heap) => initialHeap✝.ShapeExtends finish ∧ Buffer.PreservesContents initialHeap✝ finish) finish

                                                    Successful execution observes the native result in its actual final heap and retains every previously represented immutable list.

                                                    One source-body equation in ordinary monadic notation; named callees remain opaque.

                                                    @[reducible, inline]

                                                    The actual declared argument environment, constructed from ordinary source parameters. This is proof-side parameter transport, not an additional runtime operation.

                                                    Equations
                                                    Instances For
                                                      @[reducible, inline]

                                                      Signature-preserving positions of this imported source program.

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

                                                        The same source execution returns the encoded mathematical result without changing its supplied heap, under the actual input representations.

                                                        The named function's actual independently interpreted source body.

                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          @[reducible, inline]
                                                          abbrev Complexity.Language.Examples.Imports.Second.factorial_onArgs {α✝ : Sort u_1} :
                                                          (ℕ → α✝) → Env [Ty.nat] → α✝

                                                          Apply a predicate, postcondition or bound with ordinary source parameters to the actual argument environment. No new contract or execution is introduced.

                                                          Equations
                                                          Instances For
                                                            theorem Complexity.Language.Examples.Imports.Second.factorial_total :
                                                            factorial_contract (fun (n_source : Value Ty.nat) (initialHeap : Heap) => True) fun (n_source : Value Ty.nat) (initialHeap : Heap) (returned : Value Ty.nat) (finalHeap : Heap) => returned = factorial_model ((fun (value : ℕ) => value) n_source) ∧ finalHeap = initialHeap

                                                            Exact total source contract derived from the checked encoded-result equation and the existing raw-input reconstruction, with the same final heap.

                                                            @[reducible, inline]

                                                            Signatures of the functions added by this source declaration.

                                                            Equations
                                                            Instances For
                                                              theorem Complexity.Language.Examples.Imports.Second.factorial_contract_iff_triple (pre✝ : ℕ → Heap → Prop) (post✝ : ℕ → Heap → ℕ → Heap → Prop) :
                                                              factorial_contract pre✝ post✝ ↔ ∀ (n : ℕ) (initialHeap : Heap), ⦃fun (currentHeap : Heap) => { down := currentHeap = initialHeap ∧ pre✝ n initialHeap }⦄ factorial n ⦃(fun (value : ℕ) (finalHeap : Heap) => { down := post✝ n initialHeap value finalHeap }, fun (x : Fault) (x_1 : Heap) => { down := False }, PUnit.unit)⦄

                                                              Prove the ordinary-parameter source contract with a total-correctness triple for the same action. The ghost initial heap equals the actual entry heap; successful results use the actual final heap, and faults are excluded.

                                                              Automatic correspondence for the same generated source function, without a machine budget.

                                                              Ordinary mathematical function generated from the same represented source block.

                                                              Equations
                                                              Instances For

                                                                Importing a client retains its call into the original recursive library.

                                                                The second import layer likewise preserves any initial heap.