Documentation

Complexitylib.RationalHitting.Internal.GridComputation

Rational hitting lists: grid computation #

Adapted from OpenAI's formalization at revision adc7f1241b42e322a6451854ab7e4b4c146bf78a. Source: https://github.com/openai/math/blob/adc7f1241b42e322a6451854ab7e4b4c146bf78a/lean/OAI/Computability/RationalHitting/GridComputation.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.Poly.tabulateUp {A B : Type} [Coding A] [Coding B] {n : A → ℕ} {f : A × Unary → B} (hn : Poly fun (a : A) => { val := n a }) (hf : Poly f) :
Poly fun (a : A) => List.map (fun (i : ℕ) => f (a, { val := i })) (List.range (n a))
theorem Complexity.RationalHitting.StackLanguage.Poly.flatMapUp {A B : Type} [Coding A] [Coding B] {n : A → ℕ} {f : A × Unary → List B} (hn : Poly fun (a : A) => { val := n a }) (hf : Poly f) :
Poly fun (a : A) => List.flatMap (fun (i : ℕ) => f (a, { val := i })) (List.range (n a))
theorem Complexity.RationalHitting.StackLanguage.Poly.wordRange {A : Type} [Coding A] {n : A → ℕ} {f : A × Unary → BitWord} (hn : Poly fun (a : A) => { val := n a }) (hf : Poly f) :
Poly fun (a : A) => { val := List.flatMap (fun (i : ℕ) => (f (a, { val := i })).val) (List.range (n a)) }

Encode all entries of a normalized rational matrix in row order.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.RationalHitting.StackLanguage.Runtime.matrixWord_of {d : ℕ} (A B : Matrix (Fin d) (Fin d) ℤ) (den : ℤ) :
    (matrixWord (DenseSquare.of A) (DenseSquare.of B) den).val = List.flatMap (fun (i : Fin d) => List.flatMap (fun (j : Fin d) => encodeRat (Rat.divInt (A.updateCol i fun (r : Fin d) => B r j).det den)) (List.finRange d)) (List.finRange d)
    @[reducible, inline]

    Generator parameters, grid point, normalization matrix, and denominator.

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

      Encode every variable matrix of one normalized tuple.

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

        Emit the tuple encoding at a grid point only when normalization is defined.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem Complexity.RationalHitting.StackLanguage.map_filterMap_toList {A B C : Type} (l : List A) (f : A → Option B) (g : B → C) :
          List.map g (List.filterMap f l) = List.flatMap (fun (a : A) => List.map g (f a).toList) l

          Concatenate the tuple encodings emitted throughout the three-dimensional grid.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Complexity.RationalHitting.StackLanguage.Runtime.gridFn_fin {H : ℕ} (t p r : Fin H) :
            gridFn ({ val := ↑t + 1 }, { val := ↑p + 1 }, { val := ↑r + 1 }) = fun (i : Fin (Nat.succ 0).succ.succ) => ↑(![t, p, r] i) + 1