Documentation

Complexitylib.RationalHitting.Internal.RationalArithmetic

Rational hitting lists: rational arithmetic #

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

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

Compute a binomial coefficient and clear its input registers.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.RationalHitting.StackLanguage.eval_chooseClean (n k : ℕ) :
    ∃ t ≤ 4000000 * (n + k + 1) ^ 10, Eval chooseClean (both 14 15 (unaryCode n) (unaryCode k)) (single 0 (n.choose k).bits) t

    Compute the binomial coefficient of two unary arguments.

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

      Separate the sign from an encoded integer magnitude.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.RationalHitting.StackLanguage.eval_unpackInt {K : Type} [DecidableEq K] {a sg : K} (has : a ≠ sg) (s : Store K) (z : ℤ) (hz : s a = intCode z) :
        Eval (unpackInt a sg) s (Function.update (Function.update s a z.natAbs.bits) sg (decide (z < 0) :: s sg)) 5

        Encode a rational quotient and clean its temporary sign registers.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[reducible, inline]

          A nonzero integer used as a rational denominator.

          Equations
          Instances For

            A polynomially bounded procedure producing the canonical rational encoding.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryEta {A : Type} [Coding A] {f : A → Unary} (hf : Poly f) :
              Poly fun (a : A) => { val := (f a).val }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryAddFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => { val := f a + g a }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unarySubFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => { val := f a - g a }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryMulFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => { val := f a * g a }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryDivFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => { val := f a / g a }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryModFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => { val := f a % g a }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryPowFun {A : Type} [Coding A] {f : A → ℕ} (k : ℕ) (hf : Poly fun (a : A) => { val := f a }) :
              Poly fun (a : A) => { val := f a ^ k }
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryCastIntFun {A : Type} [Coding A] {f : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) :
              Poly fun (a : A) => ↑(f a)
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryEqFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => decide (f a = g a)
              theorem Complexity.RationalHitting.StackLanguage.Poly.unaryLtFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => decide (f a < g a)
              theorem Complexity.RationalHitting.StackLanguage.Poly.chooseFun {A : Type} [Coding A] {f g : A → ℕ} (hf : Poly fun (a : A) => { val := f a }) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => (f a).choose (g a)
              theorem Complexity.RationalHitting.StackLanguage.Poly.intPowFun {A : Type} [Coding A] {f : A → ℤ} {g : A → ℕ} (hf : Poly f) (hg : Poly fun (a : A) => { val := g a }) :
              Poly fun (a : A) => f a ^ g a
              theorem Complexity.RationalHitting.StackLanguage.Poly.ite {A B : Type} [Coding A] [Coding B] {c : A → Prop} [DecidablePred c] {f g : A → B} (hc : Poly fun (a : A) => decide (c a)) (hf : Poly f) (hg : Poly g) :
              Poly fun (a : A) => if c a then f a else g a
              theorem Complexity.RationalHitting.StackLanguage.Poly.sumUp {A : Type} [Coding A] {n : A → ℕ} {f : A × Unary → ℤ} (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))).sum

              Interpret a unary natural number as an integer.

              Equations
              Instances For

                Compute the binomial coefficient of two unary arguments.

                Equations
                Instances For

                  Raise an integer to a unary exponent.

                  Equations
                  Instances For

                    Test equality of unary natural numbers.

                    Equations
                    Instances For

                      Test strict comparison of unary natural numbers.

                      Equations
                      Instances For