Documentation

Mathlib.Data.Nat.MaxPowDiv

The maximal power of one natural number dividing another #

Here we introduce p.maxPowDvd n which returns the maximal k : ℕ for which p ^ k ∣ n with the convention that maxPowDvd 1 n = 0 for all n.

We prove enough about maxPowDvd in this file to show equality with Nat.padicValNat in padicValNat.padicValNat_eq_maxPowDvd.

The implementation of maxPowDvd improves on the speed of padicValNat.

Find largest k : ℕ such that p ^ k ∣ n for any p : ℕ, as well as the ratio n / p ^ k.

The implementation recurses from (p, n) to (p * p, n), so the recursion depth is $$O(\log(\nu_p(n)))$$, thus it is $$O(\log(\log(n)))$$.

Equations
Instances For
    @[irreducible]
    def Nat.maxPowDvdDiv.go (n p : ) (hp : 1 < p n 0) :

    Auxiliary definition for Nat.maxPowDvdDiv.

    Equations
    Instances For
      def Nat.divMaxPow (n p : ) :

      Divide n by the maximal power of p that divides n.

      Equations
      Instances For
        theorem Nat.maxPowDvdDiv.go_spec {n p : } (hnp : 1 < p n 0) :
        (go n p hnp).snd * p ^ (go n p hnp).fst = n ¬p (go n p hnp).snd
        theorem Nat.maxPowDvdDiv_of_base_le_one {p : } (hp : p 1) (n : ) :
        @[simp]
        @[simp]
        @[simp]
        @[simp]
        theorem Nat.divMaxPow_one_right (n : ) :
        n.divMaxPow 1 = n
        @[simp]
        theorem Nat.divMaxPow_zero_left (p : ) :
        divMaxPow 0 p = 0
        theorem Nat.not_dvd_divMaxPow {p n : } (hp : 1 < p) (hn : n 0) :