Documentation

BiasedBisect.Integer

Integer $s, t$ #

We explore $s$ and $t$ are positive integers.

Most statements here can be generalized to when $s/t$ are rationals, but the generalization will be deferred to homogeneity.

Main statements #

When $s$ and $t$ are positive integers, Δ collaps to a subset of $l \cdot \gcd(s, t)$

theorem Δ_int (s t : ℕ+) :
Δ s t {δ : | ∃ (l : ), δ = l * (s.gcd t)}

And obviously, all $δ$ are integers (natural numbers to be precise, but keeping it in ℤ simplifies some reasoning later).

We will also start creating the integer version of various objects we have created, starting with δnext_int.

theorem δlift (s t : ℕ+) (δ : ) (mem : δ Δ s t) :
∃ (d : ), d = δ
theorem δnext_int (s t : ℕ+) (δ : ) :
∃ (d' : ), d' = δnext s t δ

Since δ are all integers, their gaps is at least 1.

theorem δnext_int_larger (s t : ℕ+) (δ : ) :
δnext s t δ δ + 1

We can now define integer versions of δₖ.

noncomputable def δₖ_int (s t : ℕ+) :
Equations
Instances For
    theorem δₖ_int_agree (s t : ℕ+) (k : ) :
    (δₖ_int s t k) = δₖ (↑s) (↑t) k
    noncomputable def Jline_int (s t : ℕ+) (δ : ) :
    Equations
    Instances For
      theorem Jline_int_rec (s t : ℕ+) (δ : ) (d0 : δ 0) :
      Jline_int s t δ = Jline_int s t (δ - s) + Jline_int s t (δ - t)
      noncomputable def Jceiled_int (s t : ℕ+) (δ : ) :
      Equations
      Instances For
        theorem Jceiled_int_accum (s t : ℕ+) (δ : ) :
        Jceiled_int s t δ + Jline_int s t (δ + 1) = Jceiled_int s t (δ + 1)

        And the integer version of dE.

        noncomputable def dE_int (s t : ℕ+) :
        Equations
        Instances For
          theorem dE_int_agree (s t : ℕ+) (n : ) :
          (dE_int s t n) = dE (↑s) (↑t) n
          theorem dE_int_homo (s t l : ℕ+) (n : ) :
          l * dE_int s t n = dE_int (l * s) (l * t) n

          Let's introduce a new sequence Φ(δ) that's simply Jceiled_int shifted by 1.

          noncomputable def Φ (s t : ℕ+) (δ : ) :
          Equations
          Instances For
            theorem Φ_agree (s t : ℕ+) (δ : ) :
            Φ s t δ = φ s t δ
            theorem Φ_mono (s t : ℕ+) :
            Monotone (Φ s t)
            theorem Φ_pos (s t : ℕ+) (δ : ) :
            0 < Φ s t δ
            theorem Φ_symm (s t : ℕ+) (δ : ) :
            Φ s t δ = Φ t s δ

            Φ(δ) is the unique sequence that satisfies the following conditions:

            theorem Φ_neg (s t : ℕ+) (δ : ) (dpos : δ < 0) :
            Φ s t δ = 1
            theorem Φ_rec (s t : ℕ+) (δ : ) (dpos : δ 0) :
            Φ s t δ = Φ s t (δ - s) + Φ s t (δ - t)

            Φ is the discrete analog of the continuous function φ.

            def ΔceiledByΦ (s t : ℕ+) (n : ) :
            Equations
            Instances For
              theorem ΔceiledByΦ_agree (s t : ℕ+) (n : ) :
              theorem dE_int_range_agree (s t : ℕ+) (n : ) :
              Int.cast '' Set.Iic (dE_int s t n - 1) = Set.Iio (dE (↑s) (↑t) n) Int.cast '' Set.univ

              And finally, we show that Φ is the inverse function of dE_int in some sense.

              theorem Φ_inv (s t : ℕ+) (n : ) (n1 : n 1) :
              ΔceiledByΦ s t n = Set.Iic (dE_int s t n - 1)
              theorem Φδₖ (s t : ℕ+) (k : ) :
              Φ s t (δₖ_int s t k) = nₖ (↑s) (↑t) (k + 1)
              theorem Φδₖt (s t : ℕ+) (k : ) :
              Φ s t (δₖ_int s t k - t) = wₖ (↑s) (↑t) (k + 1)

              Analog to φδₖ, Φ sends δₖ back to nₖ. But since Φ is discrete, we can develop another theorem: when Φ changes, it precisely correspond to when nₖ move to the next value.

              theorem Φjump (s t : ℕ+) (δ : ) (k : ) (h : Φ s t δ = nₖ (↑s) (↑t) k) (hlt : Φ s t δ < Φ s t (δ + 1)) :
              Φ s t (δ + 1) = nₖ (↑s) (↑t) (k + 1)

              We will investigate the generator function $Z\{Φ\}(x) = \sum_{i\inℕ} Φ(i) x^i$ and and show that it converges to a nice function.

              theorem ΛexchangeMem (s t : ℕ+) (pq : × ) (i : ) :
              pq (Λceiled s t ↑(i + pq.1 * s + pq.2 * t)).toFinset
              def Λexchange (s t : ℕ+) :
              ( × ) × (i : ) × { x : × // x (Λceiled s t i).toFinset }
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                We will relate Φ with this polynomial.

                noncomputable def ξPolynomial (s t : ℕ+) :
                Equations
                Instances For

                  Φ will be expanded in terms of ξSet, the roots of ξPolynomial. We also show ξPolynomial doesn't have multiple root and has simple factorization over ξSet.

                  noncomputable def ξSet (s t : ℕ+) :
                  Equations
                  Instances For
                    theorem ξNonMult (s t : ℕ+) (r : ) (rmem : r ξSet s t) :
                    s * r ^ (s - 1) + t * r ^ (t - 1) 0

                    The generating function Z{Φ}(x) converges to a rational function. The bound here is not sharp, but it should be sufficient for future reasoning over complex plane.

                    theorem ZΦ_sum (s t : ℕ+) (x : ) (bound : x < 2⁻¹) :
                    HasSum (fun (i : ) => x ^ i * (Φ s t i)) (((Polynomial.eval 1 (ξPolynomial s t))⁻¹ - (Polynomial.eval x (ξPolynomial s t))⁻¹) * (1 - x)⁻¹)
                    theorem PartialFractionDecompostion {F : Type u_1} [Field F] [DecidableEq F] (x : F) (roots : Finset F) (hasroots : roots.Nonempty) (notroot : xroots) :
                    theorem PartialFractionDecompostion2 {F : Type u_1} [Field F] [DecidableEq F] (x : F) (roots : Finset F) (coef : F) (hasroots : roots.Nonempty) (notroot : xroots) (not1 : x 1) (onenotroot : 1roots) :
                    theorem ΦX_sum_eq (s t : ℕ+) (x : ) (bound : x < 2⁻¹) :
                    ((Polynomial.eval 1 (ξPolynomial s t))⁻¹ - (Polynomial.eval x (ξPolynomial s t))⁻¹) * (1 - x)⁻¹ = ξξSet s t, (x - ξ)⁻¹ * (ξ - 1)⁻¹ * (s * ξ ^ (s - 1) + t * ξ ^ (t - 1))⁻¹
                    theorem ZΦ_sum2 (s t : ℕ+) (x : ) (bound : x < 2⁻¹) :
                    HasSum (fun (i : ) => x ^ i * ξξSet s t, ξ⁻¹ ^ i * (1 - ξ)⁻¹ * (s * ξ ^ s + t * ξ ^ t)⁻¹) (((Polynomial.eval 1 (ξPolynomial s t))⁻¹ - (Polynomial.eval x (ξPolynomial s t))⁻¹) * (1 - x)⁻¹)

                    By inverting the transformation, we obtain a formula for Φ.

                    theorem ΦFormula (s t : ℕ+) (i : ) :
                    (Φ s t i) = ξξSet s t, ξ⁻¹ ^ i * (1 - ξ)⁻¹ * (s * ξ ^ s + t * ξ ^ t)⁻¹

                    With formula for Φ developed, we further show one of the term in its summation is the "main" term that controls the growth rate, and use it to show the asymptotic behavior.

                    noncomputable def ξPolynomialℝ (s t : ℕ+) :
                    Equations
                    Instances For
                      theorem PowMono (a : ℕ+) :
                      StrictMonoOn (fun (x : ) => x ^ a) (Set.Ici 0)

                      ξ₀ Is the "main term" in ξSet. It is a real number between 0 and 1, and has the smallest norm among ξSet when $s$ an $t$ are coprime.

                      noncomputable def ξ₀ (s t : ℕ+) :
                      Equations
                      Instances For
                        theorem ξ₀min (s t : ℕ+) :
                        ξ₀ s t > 0
                        theorem ξ₀max (s t : ℕ+) :
                        ξ₀ s t < 1
                        theorem ξ₀homo (s t l : ℕ+) :
                        ξ₀ s t = ξ₀ (l * s) (l * t) ^ l
                        theorem ξ₀Smallest (s t : ℕ+) (coprime : s.Coprime t) (ξ : ) :
                        ξ ξSet s tξ (ξ₀ s t)ξ₀ s t < ξ

                        Res₀ is the coefficient associated to ξ₀.

                        noncomputable def Res₀ (s t : ℕ+) :
                        Equations
                        Instances For
                          theorem Res₀pos (s t : ℕ+) :
                          Res₀ s t > 0

                          Φ grows exponentially, and we can give explicit coefficients.

                          theorem ΦAsymptotic (s t : ℕ+) (coprime : s.Coprime t) :
                          Filter.Tendsto (fun (i : ) => (Φ s t i) * ((ξ₀ s t) ^ i * (Res₀ s t))) Filter.atTop (nhds 1)
                          theorem ΦAsymptoticℝ (s t : ℕ+) (coprime : s.Coprime t) :
                          Filter.Tendsto (fun (i : ) => (Φ s t i) * (ξ₀ s t ^ i * Res₀ s t)) Filter.atTop (nhds 1)
                          theorem ΦAsymptoticℝ' (s t : ℕ+) (coprime : s.Coprime t) :
                          Filter.Tendsto (fun (i : ) => (Φ s t i) * (ξ₀ s t ^ i * Res₀ s t)) Filter.atTop (nhds 1)

                          As the "inverse function" of Φ, dE grows like log. We first prove it for coprime $s$ and $t$, then generalize it to all integers.

                          theorem dE_int_Asymptotic_coprime (s t : ℕ+) (coprime : s.Coprime t) :
                          Filter.Tendsto (fun (n : ) => (dE_int s t n) * Real.log (ξ₀ s t) / Real.log n) Filter.atTop (nhds (-1))
                          theorem reduce_coprime (s t : ℕ+) :
                          ∃ (l : ℕ+) (S : ℕ+) (T : ℕ+), s = l * S t = l * T S.Coprime T
                          theorem dE_int_Asymptotic (s t : ℕ+) :
                          Filter.Tendsto (fun (n : ) => (dE_int s t n) * Real.log (ξ₀ s t) / Real.log n) Filter.atTop (nhds (-1))

                          wₖ grows linearly w.r.t. nₖ for integer $s$ and $t$. We can then conclude that wₗᵢ, as the linear interpolation, grows at the same rate.

                          theorem wₖ_Asymtotic (s t : ℕ+) :
                          Filter.Tendsto (fun (k : ) => (wₖ (↑s) (↑t) k) / (nₖ (↑s) (↑t) k)) Filter.atTop (nhds (ξ₀ s t ^ t))
                          theorem lerp_dist (a u v g : ) (arange : a Set.Icc 0 1) :
                          dist ((1 - a) * u + a * v) g max (dist u g) (dist v g)
                          theorem w_Asymtotic_of_wₖ (s t limit : ) [PosReal s] [PosReal t] (wₖas : Filter.Tendsto (fun (k : ) => (wₖ s t k) / (nₖ s t k)) Filter.atTop (nhds limit)) :
                          Filter.Tendsto (fun (n : ) => wₗᵢ s t n / n) Filter.atTop (nhds limit)
                          theorem w_Asymtotic_int (s t : ℕ+) :
                          Filter.Tendsto (fun (n : ) => wₗᵢ (↑s) (↑t) n / n) Filter.atTop (nhds (ξ₀ s t ^ t))