Documentation

Complexitylib.Classes.P.Range.Internal

Loops over a range of indices — proof internals #

The helper facts behind Complexitylib.Classes.P.Range. Concatenation over a range is a loop whose state carries the output so far, the index in unary, and the input; iterate_mem_FP_of_polyBound runs it, and the bound on its state comes from the rule alone, since a polynomial-time rule has polynomially long outputs and the loop runs at most as often as its argument is long. The rest is the one-bit marks, and the arithmetic behind computing a maximum as a count.

Contents #

The loop #

One step: append the next entry's encoding and advance the counter. The state is pair (pair accumulated counter) input.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def Complexity.entryCat (E : List Bool → List Bool) (x : List Bool) (n : ℕ) :

    The bits the loop has accumulated after n steps.

    Equations
    Instances For
      @[simp]
      theorem Complexity.entryCat_zero (E : List Bool → List Bool) (x : List Bool) :
      entryCat E x 0 = []
      theorem Complexity.entryCat_succ (E : List Bool → List Bool) (x : List Bool) (n : ℕ) :
      entryCat E x (n + 1) = entryCat E x n ++ E (pair x (List.replicate n true))

      Concatenation over a range is the loop's accumulation after as many rounds as the count is long.

      theorem Complexity.listStep_iterate (E : List Bool → List Bool) (x : List Bool) (n : ℕ) :

      What the loop accumulates.

      theorem Complexity.length_entryCat_le (E : List Bool → List Bool) (x : List Bool) (b n : ℕ) :
      (∀ i < n, (E (pair x (List.replicate i true))).length ≤ b) → (entryCat E x n).length ≤ n * b
      theorem Complexity.length_entryCat (E : List Bool → List Bool) (x : List Bool) (n : ℕ) :
      (entryCat E x n).length = ∑ i ∈ Finset.range n, (E (pair x (List.replicate i true))).length

      Concatenation over a range is polynomial-time. The loop's state after k rounds holds k outputs of E, each polynomially long in |z|, and k is at most |z|, so the states are polynomially bounded.

      Encoding a list #

      The accumulation is the encoding. If each step writes the encoding of the corresponding entry, the loop writes the inner part of the list's own encoding.

      One-bit marks #

      theorem Complexity.isEmptyMark_mem_FP_internal {f : List Bool → List Bool} (hf : f ∈ FP) :
      (fun (z : List Bool) => isEmptyMark (f z)) ∈ FP
      theorem Complexity.nonemptyMark_mem_FP {f : List Bool → List Bool} (hf : f ∈ FP) :
      (fun (z : List Bool) => nonemptyMark (f z)) ∈ FP

      The maximum as a count #

      theorem Complexity.lt_maxOver_iff {f : List Bool → List Bool} {z : List Bool} {j : ℕ} (n : ℕ) :
      j < maxOver f z n ↔ ∃ i < n, j < (f (pair z (List.replicate i true))).length

      j is below the maximum exactly when some value is longer than j.

      The test behind maxFn: one mark when j is below the maximum.