Documentation

Complexitylib.RationalHitting.Internal.StackWords

Rational hitting lists: stack words #

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

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

theorem Complexity.RationalHitting.StackLanguage.transfer_cons {K : Type} [DecidableEq K] {a b : K} (hab : a ≠ b) (s : Store K) (x : Bool) (l : List Bool) (hs : s a = x :: l) :
transfer a b s = Function.update (Function.update s a l) b (x :: s b)
theorem Complexity.RationalHitting.StackLanguage.eval_reverse {K : Type} [DecidableEq K] {a b : K} (hab : a ≠ b) (s : Store K) :
Eval (reverse a b) s (Function.update (Function.update s a []) b ((s a).reverse ++ s b)) (2 * (s a).length + 1)

Copy a nonempty head to another register without consuming it.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.RationalHitting.StackLanguage.eval_copyHead {K : Type} [DecidableEq K] {a b : K} (s : Store K) (x : Bool) (l : List Bool) (hs : s a = x :: l) :
    Eval (copyHead a b) s (Function.update s b (x :: s b)) 2

    Two simultaneous reversed copies of a word, consuming the operand.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Complexity.RationalHitting.StackLanguage.eval_duplicateReverse {K : Type} [DecidableEq K] {a b c : K} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (s : Store K) :
      Eval (duplicateReverse a b c) s (Function.update (Function.update (Function.update s a []) b ((s a).reverse ++ s b)) c ((s a).reverse ++ s c)) (5 * (s a).length + 1)

      Copy an arbitrary binary word, restoring the operand and clearing temporary storage; all registers have fixed indices.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.RationalHitting.StackLanguage.eval_copy {K : Type} [DecidableEq K] {a b tmp : K} (hab : a ≠ b) (hat : a ≠ tmp) (hbt : b ≠ tmp) (s : Store K) :
        Eval (copy a b tmp) s (Function.update (Function.update s b (s a)) tmp []) (7 * (s a).length + 2 * (s b).length + 2 * (s tmp).length + 7)

        One carry-propagation step of binary increment.

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

          Propagate the increment carry until the flag is cleared.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Complexity.RationalHitting.StackLanguage.eval_incrementLoop {K : Type} [DecidableEq K] {a tmp flag : K} (hat : a ≠ tmp) (haf : a ≠ flag) (htf : tmp ≠ flag) (s : Store K) (hf : s flag = [true]) :
            ∃ t ≤ 5 * (s a).length + 10, Eval (incrementLoop a tmp flag) s (Function.update (Function.update (Function.update s a (carrySplit (s a)).2) tmp (List.replicate (carrySplit (s a)).1 false ++ s tmp)) flag []) t

            Increment a binary stack word and restore its orientation.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Complexity.RationalHitting.StackLanguage.eval_increment {K : Type} [DecidableEq K] {a tmp flag : K} (hat : a ≠ tmp) (haf : a ≠ flag) (htf : tmp ≠ flag) (s : Store K) :
              ∃ t ≤ 7 * (s a).length + 2 * (s tmp).length + 2 * (s flag).length + 18, Eval (increment a tmp flag) s (Function.update (Function.update (Function.update s a (incrementWord (s a))) tmp []) flag []) t