Documentation

Complexitylib.RationalHitting.Internal.BinaryBinomial

Rational hitting lists: binary binomial #

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

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

Clean multiplication interface used by the finite rising-product loop.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.RationalHitting.StackLanguage.eval_multiplyClean (s : Store (Fin 8)) (hf : ∀ (k : Fin 8), 2 ≤ ↑k → s k = []) (B : ℕ) (ha : (s 0).length ≤ B) (hb : (s 1).length ≤ B) :
    ∃ t ≤ 200 * (B + 1) ^ 4, Eval multiplyClean s (Function.update (Function.update s 0 (wordValue (s 0) * wordValue (s 1)).bits) 1 []) t

    Embed the multiplication registers in the factorial register bank.

    Equations
    Instances For

      The clean scratch registers used by factorial iteration.

      Equations
      Instances For
        theorem Complexity.RationalHitting.StackLanguage.eval_factorMul (s : Store (Fin 10)) (hf : ∀ (k : Fin 10), 2 ≤ ↑k → ↑k < 8 → s k = []) (B : ℕ) (ha : (s 0).length ≤ B) (hb : (s 1).length ≤ B) :
        ∃ t ≤ 200 * (B + 1) ^ 4, Eval (Program.rename (⇑factorMul) multiplyClean) s (Function.update (Function.update s 0 (wordValue (s 0) * wordValue (s 1)).bits) 1 []) t

        One rising-product step: multiply accumulator by the copied current index, advance the binary index, and drop one symbol of the unary loop counter.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Complexity.RationalHitting.StackLanguage.eval_factorialBody (s : Store (Fin 10)) (hf : FactorialScratch s) (B : ℕ) (h0 : (s 0).length ≤ B) (h8 : (s 8).length ≤ B) :
          ∃ t ≤ 300 * (B + 1) ^ 4, Eval factorialBody s (Function.update (Function.update (Function.update s 0 (wordValue (s 0) * wordValue (s 8)).bits) 8 (incrementWord (s 8))) 9 (s 9).tail) t
          theorem Complexity.RationalHitting.StackLanguage.eval_factorialLoop (n L : ℕ) (s : Store (Fin 10)) (hf : FactorialScratch s) (hcan : (wordValue (s 0)).bits = s 0) (hn : (s 9).length = n) (hp : (s 0).length + n * ((s 8).length + n) ≤ L) (hi : (s 8).length + n ≤ L) :
          ∃ t ≤ n * (300 * (L + 1) ^ 4 + 1) + 1, ∃ (v : Store (Fin 10)), Eval factorialLoop s v t ∧ v 0 = (wordValue (s 0) * (wordValue (s 8)).ascFactorial n).bits ∧ wordValue (v 8) = wordValue (s 8) + n ∧ v 9 = [] ∧ FactorialScratch v ∧ (v 8).length ≤ (s 8).length + n

          Rising products, with a unary iteration budget obtained from the input. No scalar factorial operation occurs in this fixed finite program.

          theorem Complexity.RationalHitting.StackLanguage.eval_factorial (n : ℕ) (s : Store (Fin 10)) (hf : FactorialScratch s) (h0 : s 0 = [true]) (h8 : s 8 = [true]) (h9 : (s 9).length = n) :
          ∃ t ≤ n * (300 * (1 + n * (1 + n) + 1) ^ 4 + 1) + 1, ∃ (v : Store (Fin 10)), Eval factorialLoop s v t ∧ v 0 = n.factorial.bits ∧ wordValue (v 8) = n + 1 ∧ v 9 = [] ∧ FactorialScratch v

          Ordinary factorial on unary n, including zero, with polynomial bit cost. The two binary registers initially contain 1; no computed value is an input.

          Factorial with clean local registers: only the unary counter and output register are changed. This is the binary subroutine for the Taylor binomials.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Complexity.RationalHitting.StackLanguage.eval_factorialCore (s : Store (Fin 10)) (hs : ∀ (k : Fin 10), ↑k < 9 → s k = []) :
            ∃ t ≤ (s 9).length * (300 * (1 + (s 9).length * (1 + (s 9).length) + 1) ^ 4 + 1) + 2 * (s 9).length + 10, Eval factorialCore s (Function.update (Function.update s 0 (s 9).length.factorial.bits) 9 []) t

            Cancel one unary digit, recording when the minuend is exhausted.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Complexity.RationalHitting.StackLanguage.eval_unaryDiff {K : Type} [DecidableEq K] {a b flag : K} (hab : a ≠ b) (haf : a ≠ flag) (hbf : b ≠ flag) (s : Store K) :
              Eval (unaryDiff a b flag) s (Function.update (Function.update (Function.update s a (List.drop (s b).length (s a))) b []) flag (List.replicate ((s b).length - (s a).length) true ++ s flag)) (5 * (s b).length + 1)

              Variable-length subtraction of unary loop counters. The leftover flag is nonempty exactly when the second counter exceeded the first.

              Embed the arithmetic register bank in the binomial-coefficient program.

              Equations
              Instances For

                The lower arithmetic registers are all empty.

                Equations
                Instances For

                  Polynomial bound on the stack steps of factorial computation.

                  Equations
                  Instances For

                    Compute one factorial and copy its binary result to the chosen register.

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

                      Stack-step bound for a factorial block, including copies and cleanup.

                      Equations
                      Instances For
                        theorem Complexity.RationalHitting.StackLanguage.Binomial.eval_factorBlock (a b : Fin 18) (ha : 10 ≤ ↑a) (hb : 10 ≤ ↑b) (ha17 : a ≠ 17) (hb17 : b ≠ 17) (s : Store (Fin 18)) (hs : LowEmpty s) (h17 : s 17 = []) :
                        ∃ t ≤ factorCost (s a).length (s b).length, Eval (factorBlock a b) s (Function.update s b (s a).length.factorial.bits) t

                        Initial register store containing the two unary binomial arguments.

                        Equations
                        Instances For

                          The input store extended with both truncated differences of its arguments.

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

                            Compute the unary difference and underflow flag for binomial evaluation.

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