Documentation

Complexitylib.RationalHitting.Internal.Compiler

Rational hitting lists: compiler #

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

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

@[instance_reducible]

Composition starts in the first machine's default state.

Equations
Instances For
    def Complexity.RationalHitting.TMTime.Link.left {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] (a : Turing.TM0.Cfg Γ Λ) :
    Turing.TM0.Cfg Γ (Λ ⊕ Δ)

    Tag a configuration as belonging to the first machine in a composition.

    Equations
    Instances For
      def Complexity.RationalHitting.TMTime.Link.right {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] (a : Turing.TM0.Cfg Γ Δ) :
      Turing.TM0.Cfg Γ (Λ ⊕ Δ)

      Tag a configuration as belonging to the second machine in a composition.

      Equations
      Instances For
        def Complexity.RationalHitting.TMTime.Link.machine {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Λ] [Inhabited Δ] (F : Turing.TM0.Machine Γ Λ) (G : Turing.TM0.Machine Γ Δ) :

        The transition map of the compiled machine in this compiler stage.

        Equations
        Instances For
          theorem Complexity.RationalHitting.TMTime.Link.step_left {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] [Inhabited Λ] [Inhabited Δ] (F : Turing.TM0.Machine Γ Λ) (G : Turing.TM0.Machine Γ Δ) {a b : Turing.TM0.Cfg Γ Λ} (h : Turing.TM0.step F a = some b) :
          theorem Complexity.RationalHitting.TMTime.Link.switch {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] [Inhabited Λ] [Inhabited Δ] (F : Turing.TM0.Machine Γ Λ) (G : Turing.TM0.Machine Γ Δ) {a : Turing.TM0.Cfg Γ Λ} (h : Turing.TM0.step F a = none) :
          Turing.TM0.step (machine F G) (left a) = some (right { q := default, Tape := a.Tape })
          theorem Complexity.RationalHitting.TMTime.Link.run_left {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] [Inhabited Λ] [Inhabited Δ] (F : Turing.TM0.Machine Γ Λ) (G : Turing.TM0.Machine Γ Δ) (t : ℕ) {a b : Turing.TM0.Cfg Γ Λ} (h : exec (Turing.TM0.step F) t a = some b) :
          theorem Complexity.RationalHitting.TMTime.Link.run_right {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] [Inhabited Λ] [Inhabited Δ] (F : Turing.TM0.Machine Γ Λ) (G : Turing.TM0.Machine Γ Δ) (t : ℕ) (a : Turing.TM0.Cfg Γ Δ) :
          theorem Complexity.RationalHitting.TMTime.Link.finite_sequence {Γ : Type u_1} {Λ : Type u_2} {Δ : Type u_3} [Inhabited Γ] [Inhabited Λ] [Inhabited Δ] [Fintype Λ] [Fintype Δ] (F : Turing.TM0.Machine Γ Λ) (G : Turing.TM0.Machine Γ Δ) :
          ∃ (m : ℕ) (H : Turing.TM0.Machine Γ (Fin (m + 1))), ∀ (w v : List Γ) (t u : ℕ) (a : Turing.TM0.Cfg Γ Λ) (b : Turing.TM0.Cfg Γ Δ), exec (Turing.TM0.step F) t (Turing.TM0.init w) = some a → Turing.TM0.step F a = none → a.Tape = Turing.Tape.mk₁ v → exec (Turing.TM0.step G) u (Turing.TM0.init v) = some b → Turing.TM0.step G b = none → ∃ (c : Turing.TM0.Cfg Γ (Fin (m + 1))), exec (Turing.TM0.step H) (t + 1 + u) (Turing.TM0.init w) = some c ∧ Turing.TM0.step H c = none ∧ c.Tape = b.Tape

          Splice two halting finite transducers with exactly one glue step. The intermediate output is the literal tape required by the second input.

          @[reducible, inline]

          The fixed four-symbol alphabet of the final finite-state machine.

          Equations
          Instances For

            Represent a Boolean tape symbol in the fixed alphabet.

            Equations
            Instances For

              The transition map of the compiled machine in this compiler stage.

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

                Translate a Boolean-tape configuration to the fixed alphabet.

                Equations
                Instances For
                  theorem Complexity.RationalHitting.StackLanguage.Compiler.raw_compilation {K : Type} [DecidableEq K] [Fintype K] (p : Program K) (ki ko : K) :
                  ∃ (m : ℕ) (G : Turing.TM0.Machine (Fin 4) (Fin (m + 1))) (C : ℕ), 0 < C ∧ ∀ (w xs : List Bool) (t : ℕ), w ≠ [] → Eval p (Function.update (fun (x : K) => []) ki w) (Function.update (fun (x : K) => []) ko xs.reverse) t → ∃ u ≤ C * (w.length + t + xs.length + 3) ^ 2, ∃ (a : Turing.TM0.Cfg (Fin 4) (Fin (m + 1))), TMTime.exec (Turing.TM0.step G) u (Turing.TM0.init (List.map TMTime.InputAdapter.raw w)) = some a ∧ Turing.TM0.step G a = none ∧ a.Tape = Turing.Tape.mk₁ (List.map TMTime.OutputAdapter.raw xs)

                  End-to-end, finite-state, Fin4 one-tape compilation. Input and output are literal 1/2 digit strings, NOT different encodings hidden by an interface. The stack program is a single fixed finite syntax tree. Final scratch must be empty; the designated output stack has reversed output order, as explicitly stated.

                  A fixed finite stack program with literal unary input and exact canonical output, bounded by a fixed polynomial in the input length.

                  Equations
                  Instances For

                    A single finite stack program generating exact hitting-list encodings in polynomial time.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem Complexity.RationalHitting.ExecutableGenerator.compilation_sum_bound (x t y R C A : ℕ) (hx : x ≤ R) (ht : t ≤ C * R) (hy : y ≤ A * R) (hR : 1 ≤ R) :
                      x + t + y + 3 ≤ (C + A + 4) * R
                      theorem Complexity.RationalHitting.ExecutableGenerator.compilation_square_bound (D C A x E : ℕ) :
                      D * ((C + A + 4) * x ^ E) ^ 2 = D * (C + A + 4) ^ 2 * x ^ (2 * E)

                      The raw compiler preserves literal input/output and gives a fixed finite alphabet and state space with a polynomial transition bound.