Documentation

Complexitylib.RationalHitting.Internal.DenseRecords

Rational hitting lists: dense records #

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

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

Escape each data bit by prefixing it with a false marker.

Equations
Instances For

    Move and escape the bits of one record.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      theorem Complexity.RationalHitting.StackLanguage.eval_packLoop (a b : Fin 3) (hab : a ≠ b) (s : Store (Fin 3)) :
      Eval (packLoop a b) s (Function.update (Function.update s a []) b (pairWord (s a).reverse ++ s b)) (4 * (s a).length + 1)

      Read one escaped data bit or consume the record terminator.

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

        Remove one self-delimiting record; produce its reversed binary word.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Complexity.RationalHitting.StackLanguage.eval_unpackRecord (w tail : List Bool) (s : Store (Fin 3)) (h0 : s 0 = codeWord w ++ tail) (h2 : s 2 = []) :

          Register embedding for the packing stage of a record move.

          Equations
          Instances For

            Move one delimited record between stacks.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Complexity.RationalHitting.StackLanguage.eval_recordMove (w tail : List Bool) (s : Store (Fin 4)) (h0 : s 0 = codeWord w ++ tail) (h2 : s 2 = []) (h3 : s 3 = []) :
              Eval recordMove s (Function.update (Function.update s 0 tail) 1 (codeWord w ++ s 1)) (9 * w.length + 12)
              theorem Complexity.RationalHitting.StackLanguage.eval_recordMove_rename {K : Type} [DecidableEq K] (f : Fin 4 ↪ K) (w tail : List Bool) (s : Store K) (h0 : s (f 0) = codeWord w ++ tail) (h2 : s (f 2) = []) (h3 : s (f 3) = []) :
              Eval (Program.rename (⇑f) recordMove) s (Function.update (Function.update s (f 0) tail) (f 1) (codeWord w ++ s (f 1))) (9 * w.length + 12)

              Move one record and decrement the unary scan counter.

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

                Number of real finite-stack macrosteps for scanning a given prefix.

                Equations
                Instances For
                  theorem Complexity.RationalHitting.StackLanguage.eval_scan (pre : List (List Bool)) (tail : List Bool) (s : Store (Fin 8)) (h0 : s 0 = codeArray pre ++ tail) (h4 : s 4 = List.replicate pre.length true) (h2 : s 2 = []) (h3 : s 3 = []) :

                  Restore all scanned records to the original stack.

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

                    Stack-step count for restoring the given list of records.

                    Equations
                    Instances For

                      Register embedding for unpacking a record without consuming it permanently.

                      Equations
                      Instances For

                        Copy the next record while restoring its original representation.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem Complexity.RationalHitting.StackLanguage.eval_peekRecord (w tail : List Bool) (s : Store (Fin 8)) (h0 : s 0 = codeWord w ++ tail) (h2 : s 2 = []) (h3 : s 3 = []) (h5 : s 5 = []) (h6 : s 6 = []) (h7 : s 7 = []) :
                          Eval peekRecord s (Function.update s 5 w) (18 * w.length + 22)

                          Indexed read. Register 4 is a unary index; register 0 is a serialized array and is restored byte-for-byte. Register 5 receives the exact binary word.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            theorem Complexity.RationalHitting.StackLanguage.eval_arrayRead (pre post : List (List Bool)) (w : List Bool) (s : Store (Fin 8)) (h0 : s 0 = codeArray (pre ++ w :: post)) (h1 : s 1 = []) (h2 : s 2 = []) (h3 : s 3 = []) (h4 : s 4 = List.replicate pre.length true) (h5 : s 5 = []) (h6 : s 6 = []) (h7 : s 7 = []) :
                            ∃ t ≤ 50 * (s 0).length + 30, Eval arrayRead s (Function.update (Function.update s 4 []) 5 w) t