Documentation

Examples.Language.LinkedListViewsCompiled

Scalar and compound native branch results on RAM #

The ordinary headOr and inspectOrPrepend declarations retain their generated source correctness. Their resource proofs use the actual Uncons and constructor executions, including selected-branch allocation and initialized result slots. Structural bounds are inferred from these bodies and supplied callee contracts.

The shared publication rule connects the independent mathematical result and resource proofs to one halted invocation. Input loading is outside the count; finite word, code, stack and arena conditions remain those of the actual launch.

Native emptiness uses the actual root-tag call, with a bound inferred from its supplied certificate and the generated caller's return instructions.

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

    Complete native invocation accounting, including initialization, call and halt.

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

      The native wrapper reuses the tag test's actual execution at any heap and cursor. No node is read, so readiness needs neither head ranges nor a heap representation; complete RAM invocation retains its usual launch conditions.

      theorem Complexity.Language.Examples.LinkedList.isEmpty_execute_le {w heapLimit cursor : ℕ} {placement : ℕ → Ram.Word w} (values : List ℕ) (root : Option (NodeRef CellTy.nat)) {heap : Heap} (observed : (Representation.list CellTy.nat).Rel values root heap) {entry : Ram.Source.State w} (launch : Ram.LanguageCompiler.FunctionArenaLaunch NativeViews.Source.program NativeViews.Source.isEmptyId 1 heapLimit placement (NativeViews.Source.isEmpty_args root) heap cursor entry) :

      Ordinary native List emptiness and its constant instruction bound hold for the same halted RAM call. The heap and cursor stay unchanged, and input loading is outside the count. Source correctness has no resource premise.

      Scalar head selection has a uniform bound inferred from the real node read and generated branch, assignment and return instructions.

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

        Complete preloaded invocation bound, including initialization, call and halt.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Complexity.Language.Examples.LinkedList.headOr_execute_le {w heapLimit cursor : ℕ} {placement : ℕ → Ram.Word w} (fallback : ℕ) (values : List ℕ) (root : Option (NodeRef CellTy.nat)) {heap : Heap} (observed : (Representation.list CellTy.nat).Rel values root heap) {entry : Ram.Source.State w} (launch : Ram.LanguageCompiler.FunctionArenaLaunch NativeViews.Source.program NativeViews.Source.headOrId 1 heapLimit placement (NativeViews.Source.headOr_args fallback root) heap cursor entry) :
          ∃ (outcome : Ram.LanguageCompiler.FunctionArenaExecution NativeViews.Source.program NativeViews.Source.headOrId 1 heapLimit placement (NativeViews.Source.headOr_args fallback root) heap entry), outcome.value = values.head?.getD fallback ∧ outcome.heap = heap ∧ outcome.cursor = cursor ∧ outcome.bodySteps ≤ ↑headOrCost + 2 ∧ outcome.result.steps ≤ headOrSteps

          An ordinary scalar List match returns the mathematical head or fallback on RAM, without changing the heap or allocation cursor. Its complete instruction bound is independent of List length.

          The two-call helper's bound is inferred without reopening either callee.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Complexity.Language.Examples.LinkedList.inspectAndPrepend_measured {w heapLimit cursor : ℕ} (head : ℕ) (values : List ℕ) (root : Option (NodeRef CellTy.nat)) (heap : Heap) {placement : ℕ → Ram.Word w} {entry : Ram.Source.State w} (positive : 0 < w) (headFits : head < 2 ^ w) (memory : Ram.LanguageCompiler.HeapRep placement heapLimit heap entry) (observed : (Representation.list CellTy.nat).Rel values root heap) (space : cursor + 3 ≤ heapLimit) :

            Compose the actual node read and constructor at the returned heap and cursor. The mathematical compound result remains an independent source contract, and no proposed instruction bound is required for this execution.

            theorem Complexity.Language.Examples.LinkedList.inspectAndPrepend_ready_cost {w heapLimit cursor : ℕ} (head : ℕ) (values : List ℕ) (root : Option (NodeRef CellTy.nat)) (heap : Heap) {placement : ℕ → Ram.Word w} {entry : Ram.Source.State w} (positive : 0 < w) (headFits : head < 2 ^ w) (memory : Ram.LanguageCompiler.HeapRep placement heapLimit heap entry) (observed : (Representation.list CellTy.nat).Rel values root heap) (space : cursor + 3 ≤ heapLimit) :

            Reading and prepending share the actual intermediate heap. Three fresh words are sufficient, and the witness retains the actual compound returned value.

            The compound join's bound includes real initialization of all result fields, and uses the selected branch maximum instead of charging both branch executions.

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

              Full preloaded invocation bound of the compound conditional.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem Complexity.Language.Examples.LinkedList.inspectOrPrepend_execute_le {w heapLimit cursor : ℕ} {placement : ℕ → Ram.Word w} (flag : Bool) (head : ℕ) (values : List ℕ) (root : Option (NodeRef CellTy.nat)) {heap : Heap} (observed : (Representation.list CellTy.nat).Rel values root heap) {entry : Ram.Source.State w} (launch : Ram.LanguageCompiler.FunctionArenaLaunch NativeViews.Source.program NativeViews.Source.inspectOrPrependId 3 heapLimit placement (NativeViews.Source.inspectOrPrepend_args flag head root) heap cursor entry) (space : (cursor + if flag = true then 3 else 0) ≤ heapLimit) :

                A conditional returns an optional head/tail together with a List, through the actual RAM runner. Only its true path allocates; both retain every old List observation. Correctness, cursor growth and instruction bounds concern the same invocation, including compound-slot initialization and field copies.