Documentation

Complexitylib.RationalHitting.Internal.Tabulation

Rational hitting lists: tabulation #

Adapted from OpenAI's formalization at revision adc7f1241b42e322a6451854ab7e4b4c146bf78a. Source: https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Computability/RationalHitting/Tabulation.lean

Imports, namespaces, module visibility, documentation, and formatting are adapted for complexitylib. The source theorem statements and mathematical arguments are retained.

Reusable dense records. Individual word lengths need not be fixed.

Equations
Instances For
    @[simp]
    theorem Complexity.RationalHitting.StackLanguage.listCode_cons {A : Type} (ca : A → List Bool) (a : A) (l : List A) :
    listCode ca (a :: l) = codeWord (ca a) ++ listCode ca l
    @[simp]
    theorem Complexity.RationalHitting.StackLanguage.listCode_length_le {A : Type} (ca : A → List Bool) (l : List A) (B : ℕ) (h : ∀ a ∈ l, (ca a).length ≤ B) :
    (listCode ca l).length ≤ l.length * (2 * B + 1)
    theorem Complexity.RationalHitting.StackLanguage.listCode_element {A : Type} (ca : A → List Bool) (l : List A) (a : A) (h : a ∈ l) :
    (ca a).length ≤ (listCode ca l).length
    theorem Complexity.RationalHitting.StackLanguage.Feasible.listCons {A : Type} (ca : A → List Bool) :
    Feasible (pairCode ca (listCode ca)) (listCode ca) fun (a : A × List A) => a.1 :: a.2

    A complete uniform table-building step: evaluation of a compiled callback, indexed counter update, and append of an escaped dense record.

    Equations
    Instances For

      Encode a tabulation state consisting of input, counter, and accumulated outputs.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[simp]
        theorem Complexity.RationalHitting.StackLanguage.tableStateCode_length {A B : Type} (ca : A → List Bool) (cb : B → List Bool) (a : A × ℕ × List B) :
        (tableStateCode ca cb a).length = 2 * (ca a.1).length + 2 * a.2.1 + (listCode cb a.2.2).length + 2
        theorem Complexity.RationalHitting.StackLanguage.tableStep_iterate_fields {A B : Type} (f : A × ℕ → B) (a : A × ℕ × List B) (j : ℕ) :
        ((tableStep f)^[j] a).1 = a.1 ∧ ((tableStep f)^[j] a).2.1 = a.2.1 + j
        theorem Complexity.RationalHitting.StackLanguage.tableStep_iterate_size {A B : Type} {ca : A → List Bool} {cb : B → List Bool} {f : A × ℕ → B} (p : Procedure (pairCode ca unaryCode) cb f) (n : ℕ) (a : A × ℕ × List B) (j : ℕ) (hj : j ≤ n) :
        theorem Complexity.RationalHitting.StackLanguage.tableStep_iterate_start {A B : Type} (f : A × ℕ → B) (a : A) (n : ℕ) :
        (tableStep f)^[n] (a, 0, []) = (a, n, List.map (fun (i : ℕ) => f (a, i)) (List.range n))
        theorem Complexity.RationalHitting.StackLanguage.Feasible.tabulate {A B : Type} {ca : A → List Bool} {cb : B → List Bool} {f : A × ℕ → B} (hf : Feasible (pairCode ca unaryCode) cb f) :
        Feasible (pairCode unaryCode ca) (listCode cb) fun (a : ℕ × A) => List.map (fun (i : ℕ) => f (a.2, i)) (List.range a.1)

        Polynomial-time tabulation of an arbitrary polynomial-time callback. The construction uses only one finite stack program, including all indexing, record layout, and loop control; the counter is unary.

        Canonical storage format for the compositional finite-program proofs.

        • code : A → List Bool

          The canonical Boolean encoding.

        Instances
          @[instance_reducible]
          Equations
          • One or more equations did not get rendered due to their size.

          A natural number whose computation interface uses unary encoding.

          • val : ℕ

            The natural number represented in unary.

          Instances For
            Equations
            Instances For

              A Boolean word whose computation interface uses its raw bits.

              Instances For

                Polynomial time means a concrete finite clean stack program and actual step bound, through Procedure. It is not machine advice or an oracle.

                Equations
                Instances For
                  theorem Complexity.RationalHitting.StackLanguage.Poly.const {A B : Type} [Coding A] [Coding B] (b : B) :
                  Poly fun (x : A) => b
                  theorem Complexity.RationalHitting.StackLanguage.Poly.comp {A B C : Type} [Coding A] [Coding B] [Coding C] {f : A → B} {g : B → C} (hg : Poly g) (hf : Poly f) :
                  Poly fun (a : A) => g (f a)
                  theorem Complexity.RationalHitting.StackLanguage.Poly.pair {A B C : Type} [Coding A] [Coding B] [Coding C] {f : A → B} {g : A → C} (hf : Poly f) (hg : Poly g) :
                  Poly fun (a : A) => (f a, g a)
                  theorem Complexity.RationalHitting.StackLanguage.Poly.subtypeMk {A B : Type} [Coding A] [Coding B] {f : A → B} {P : B → Prop} (hf : Poly f) (h : ∀ (a : A), P (f a)) :
                  Poly fun (a : A) => ⟨f a, ⋯⟩
                  theorem Complexity.RationalHitting.StackLanguage.Poly.of_eq {A B : Type} [Coding A] [Coding B] {f g : A → B} (hf : Poly f) (h : ∀ (a : A), f a = g a) :
                  theorem Complexity.RationalHitting.StackLanguage.Poly.cond {A B : Type} [Coding A] [Coding B] {c : A → Bool} {f g : A → B} (hc : Poly c) (hf : Poly f) (hg : Poly g) :
                  Poly fun (a : A) => if c a = true then f a else g a
                  theorem Complexity.RationalHitting.StackLanguage.Poly.tabulate {A B : Type} [Coding A] [Coding B] {f : A × Unary → B} (hf : Poly f) :
                  Poly fun (a : Unary × A) => List.map (fun (i : ℕ) => f (a.2, { val := i })) (List.range a.1.val)