Documentation

Mathlib.NumberTheory.Padics.PadicVal.Basic

p-adic Valuation #

This file defines the p-adic valuation on ℕ, ℤ, and ℚ.

The p-adic valuation on ℚ is the difference of the multiplicities of p in the numerator and denominator of q. This function obeys the standard properties of a valuation, with the appropriate assumptions on p. The p-adic valuations on ℕ and ℤ agree with that on ℚ.

The valuation induces a norm on ℚ. This norm is defined in Mathlib/NumberTheory/Padics/PadicNorm.lean.

Notation #

This file uses the local notation /. for Rat.mk.

Implementation notes #

Much, but not all, of this file assumes that p is prime. This assumption is inferred automatically by taking [Fact p.Prime] as a type class argument.

Calculations with p-adic valuations #

References #

Tags #

p-adic, p adic, padic, norm, valuation

theorem padicValNat.self {p : ℕ} (hp : 1 < p) :

If p ≠ 0 and p ≠ 1, then padicValNat p p is 1.

def padicValInt (p : ℕ) (z : ℤ) :

For p ≠ 1, the p-adic valuation of an integer z ≠ 0 is the largest natural number k such that p^k divides z. If x = 0 or p = 1, then padicValInt p q defaults to 0.

Equations
Instances For
    theorem padicValInt.of_ne_one_ne_zero {p : ℕ} {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) :
    @[simp]
    theorem padicValInt.zero {p : ℕ} :

    padicValInt p 0 is 0 for any p.

    @[simp]
    theorem padicValInt.one {p : ℕ} :

    padicValInt p 1 is 0 for any p.

    @[simp]
    theorem padicValInt.of_nat {p n : ℕ} :

    The p-adic value of a natural is its p-adic value as an integer.

    theorem padicValInt.self {p : ℕ} (hp : 1 < p) :
    padicValInt p ↑p = 1

    If p ≠ 0 and p ≠ 1, then padicValInt p p is 1.

    @[simp]
    theorem padicValInt.eq_zero_iff {p : ℕ} {z : ℤ} :
    padicValInt p z = 0 ↔ p = 1 ∨ z = 0 ∨ ¬↑p ∣ z
    theorem padicValInt.eq_zero_of_not_dvd {p : ℕ} {z : ℤ} (h : ¬↑p ∣ z) :
    def padicValRat (p : ℕ) (q : ℚ) :

    padicValRat defines the valuation of a rational q to be the valuation of q.num minus the valuation of q.den. If q = 0 or p = 1, then padicValRat p q defaults to 0.

    Equations
    Instances For
      theorem padicValRat_def (p : ℕ) (q : ℚ) :
      padicValRat p q = ↑(padicValInt p q.num) - ↑(padicValNat p q.den)
      @[simp]
      theorem padicValRat.neg {p : ℕ} (q : ℚ) :

      padicValRat p q is symmetric in q.

      @[simp]
      theorem padicValRat.zero {p : ℕ} :

      padicValRat p 0 is 0 for any p.

      @[simp]
      theorem padicValRat.one {p : ℕ} :

      padicValRat p 1 is 0 for any p.

      @[simp]
      theorem padicValRat.of_int {p : ℕ} {z : ℤ} :
      padicValRat p ↑z = ↑(padicValInt p z)

      The p-adic value of an integer z ≠ 0 is its p-adic value as a rational.

      theorem padicValRat.of_int_multiplicity {p : ℕ} {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) :
      padicValRat p ↑z = ↑(multiplicity (↑p) z)

      The p-adic value of an integer z ≠ 0 is the multiplicity of p in z.

      theorem padicValRat.multiplicity_sub_multiplicity {p : ℕ} {q : ℚ} (hp : p ≠ 1) (hq : q ≠ 0) :
      padicValRat p q = ↑(multiplicity (↑p) q.num) - ↑(multiplicity p q.den)
      @[simp]
      theorem padicValRat.of_nat {p n : ℕ} :
      padicValRat p ↑n = ↑(padicValNat p n)

      The p-adic value of an integer z ≠ 0 is its p-adic value as a rational.

      theorem padicValRat.self {p : ℕ} (hp : 1 < p) :
      padicValRat p ↑p = 1

      If p ≠ 0 and p ≠ 1, then padicValRat p p is 1.

      theorem padicValRat_of_nat {p : ℕ} (n : ℕ) :
      ↑(padicValNat p n) = padicValRat p ↑n

      padicValRat coincides with padicValNat.

      @[simp]
      theorem padicValNat_self {p : ℕ} [Fact (Nat.Prime p)] :
      theorem one_le_padicValNat_of_dvd {p n : ℕ} [hp : Fact (Nat.Prime p)] (hn : n ≠ 0) (div : p ∣ n) :
      theorem dvd_iff_padicValNat_ne_zero {p n : ℕ} [Fact (Nat.Prime p)] (hn0 : n ≠ 0) :
      theorem padicValRat.finite_int_prime_iff {p : ℕ} [hp : Fact (Nat.Prime p)] {a : ℤ} :

      The multiplicity of p : ℕ in a : ℤ is finite exactly when a ≠ 0.

      theorem padicValRat.defn (p : ℕ) [hp : Fact (Nat.Prime p)] {q : ℚ} {n d : ℤ} (hqz : q ≠ 0) (qdf : q = Rat.divInt n d) :
      padicValRat p q = ↑(multiplicity (↑p) n) - ↑(multiplicity (↑p) d)

      A rewrite lemma for padicValRat p q when q is expressed in terms of Rat.mk.

      theorem padicValRat.mul {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ} (hq : q ≠ 0) (hr : r ≠ 0) :

      A rewrite lemma for padicValRat p (q * r) with conditions q ≠ 0, r ≠ 0.

      @[simp]
      theorem padicValRat.pow {p : ℕ} [hp : Fact (Nat.Prime p)] (q : ℚ) {k : ℕ} :
      padicValRat p (q ^ k) = ↑k * padicValRat p q

      A rewrite lemma for padicValRat p (q^k).

      @[simp]
      theorem padicValRat.inv {p : ℕ} [hp : Fact (Nat.Prime p)] (q : ℚ) :

      A rewrite lemma for padicValRat p (q⁻¹).

      @[simp]
      theorem padicValRat.zpow {p : ℕ} [hp : Fact (Nat.Prime p)] (q : ℚ) {k : ℤ} :
      padicValRat p (q ^ k) = k * padicValRat p q
      theorem padicValRat.div {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ} (hq : q ≠ 0) (hr : r ≠ 0) :

      A rewrite lemma for padicValRat p (q / r) with conditions q ≠ 0, r ≠ 0.

      theorem padicValRat.padicValRat_le_padicValRat_iff {p : ℕ} [hp : Fact (Nat.Prime p)] {n₁ n₂ d₁ d₂ : ℤ} (hn₁ : n₁ ≠ 0) (hn₂ : n₂ ≠ 0) (hd₁ : d₁ ≠ 0) (hd₂ : d₂ ≠ 0) :
      padicValRat p (Rat.divInt n₁ d₁) ≤ padicValRat p (Rat.divInt n₂ d₂) ↔ ∀ (n : ℕ), ↑p ^ n ∣ n₁ * d₂ → ↑p ^ n ∣ n₂ * d₁

      A condition for padicValRat p (n₁ / d₁) ≤ padicValRat p (n₂ / d₂), in terms of divisibility by p^n.

      theorem padicValRat.le_padicValRat_add_of_le {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ} (hqr : q + r ≠ 0) (h : padicValRat p q ≤ padicValRat p r) :

      Sufficient conditions to show that the p-adic valuation of q is less than or equal to the p-adic valuation of q + r.

      theorem padicValRat.min_le_padicValRat_add {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ} (hqr : q + r ≠ 0) :

      The minimum of the valuations of q and r is at most the valuation of q + r.

      theorem padicValRat.add_eq_min {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ} (hqr : q + r ≠ 0) (hq : q ≠ 0) (hr : r ≠ 0) (hval : padicValRat p q ≠ padicValRat p r) :

      Ultrametric property of a p-adic valuation.

      theorem padicValRat.add_eq_of_lt {p : ℕ} [hp : Fact (Nat.Prime p)] {q r : ℚ} (hqr : q + r ≠ 0) (hq : q ≠ 0) (hr : r ≠ 0) (hval : padicValRat p q < padicValRat p r) :
      theorem padicValRat.lt_add_of_lt {p : ℕ} [hp : Fact (Nat.Prime p)] {q r₁ r₂ : ℚ} (hqr : r₁ + r₂ ≠ 0) (hval₁ : padicValRat p q < padicValRat p r₁) (hval₂ : padicValRat p q < padicValRat p r₂) :
      padicValRat p q < padicValRat p (r₁ + r₂)
      theorem padicValRat.self_pow_inv {p : ℕ} [hp : Fact (Nat.Prime p)] (r : ℕ) :
      padicValRat p (↑p ^ r)⁻¹ = -↑r
      theorem padicValRat.sum_pos_of_pos {p : ℕ} [hp : Fact (Nat.Prime p)] {n : ℕ} {F : ℕ → ℚ} (hF : ∀ i < n, 0 < padicValRat p (F i)) (hn0 : ∑ i ∈ Finset.range n, F i ≠ 0) :
      0 < padicValRat p (∑ i ∈ Finset.range n, F i)

      A finite sum of rationals with positive p-adic valuation has positive p-adic valuation (if the sum is non-zero).

      theorem padicValRat.lt_sum_of_lt {p j : ℕ} [hp : Fact (Nat.Prime p)] {F : ℕ → ℚ} {S : Finset ℕ} (hS : S.Nonempty) (hF : ∀ i ∈ S, padicValRat p (F j) < padicValRat p (F i)) (hn1 : ∀ (i : ℕ), 0 < F i) :
      padicValRat p (F j) < padicValRat p (∑ i ∈ S, F i)

      If the p-adic valuation of a finite set of positive rationals is greater than a given rational number, then the p-adic valuation of their sum is also greater than the same rational number.

      theorem padicValNat.mul {p a b : ℕ} [hp : Fact (Nat.Prime p)] :
      a ≠ 0 → b ≠ 0 → padicValNat p (a * b) = padicValNat p a + padicValNat p b

      A rewrite lemma for padicValNat p (a * b) with conditions a ≠ 0, b ≠ 0.

      theorem padicValNat.div_of_dvd {p a b : ℕ} [hp : Fact (Nat.Prime p)] (h : b ∣ a) :
      theorem padicValNat.div {p b : ℕ} [hp : Fact (Nat.Prime p)] (dvd : p ∣ b) :
      padicValNat p (b / p) = padicValNat p b - 1

      Dividing out by a prime factor reduces the padicValNat by 1.

      @[simp]
      theorem padicValNat.pow {p : ℕ} [hp : Fact (Nat.Prime p)] (a n : ℕ) :
      padicValNat p (a ^ n) = n * padicValNat p a

      A version of padicValRat.pow for padicValNat.

      theorem padicValNat.prime_pow {p : ℕ} [hp : Fact (Nat.Prime p)] (n : ℕ) :
      padicValNat p (p ^ n) = n
      theorem padicValNat.div_pow {p a b : ℕ} [hp : Fact (Nat.Prime p)] (dvd : p ^ a ∣ b) :
      padicValNat p (b / p ^ a) = padicValNat p b - a
      theorem padicValNat.div' {p : ℕ} [hp : Fact (Nat.Prime p)] {m : ℕ} (cpm : p.Coprime m) {b : ℕ} (dvd : m ∣ b) :
      theorem dvd_of_one_le_padicValNat {p n : ℕ} (hp : 1 ≤ padicValNat p n) :
      p ∣ n
      theorem padicValNat_dvd_iff_le_of_ne_one {p : ℕ} (hp : p ≠ 1) {a n : ℕ} (ha : a ≠ 0) :
      p ^ n ∣ a ↔ n ≤ padicValNat p a
      theorem padicValNat_dvd_iff_le {p : ℕ} [hp : Fact (Nat.Prime p)] {a n : ℕ} (ha : a ≠ 0) :
      p ^ n ∣ a ↔ n ≤ padicValNat p a
      theorem padicValNat_dvd_iff_of_ne_one {p : ℕ} (hp : p ≠ 1) (n a : ℕ) :
      p ^ n ∣ a ↔ a = 0 ∨ n ≤ padicValNat p a
      theorem padicValNat_dvd_iff {p : ℕ} (n : ℕ) [hp : Fact (Nat.Prime p)] (a : ℕ) :
      p ^ n ∣ a ↔ a = 0 ∨ n ≤ padicValNat p a
      theorem pow_succ_padicValNat_not_dvd {p n : ℕ} [hp : Fact (Nat.Prime p)] (hn : n ≠ 0) :
      ¬p ^ (padicValNat p n + 1) ∣ n
      theorem padicValNat_primes {p q : ℕ} [hp : Fact (Nat.Prime p)] [hq : Fact (Nat.Prime q)] (ne : p ≠ q) :
      theorem padicValNat_prime_prime_pow {p q : ℕ} [hp : Fact (Nat.Prime p)] [hq : Fact (Nat.Prime q)] (n : ℕ) (ne : p ≠ q) :
      padicValNat p (q ^ n) = 0
      theorem padicValNat_mul_pow_left {p q : ℕ} [hp : Fact (Nat.Prime p)] [hq : Fact (Nat.Prime q)] (n m : ℕ) (ne : p ≠ q) :
      padicValNat p (p ^ n * q ^ m) = n
      theorem padicValNat_mul_pow_right {p q : ℕ} [hp : Fact (Nat.Prime p)] [hq : Fact (Nat.Prime q)] (n m : ℕ) (ne : q ≠ p) :
      padicValNat q (p ^ n * q ^ m) = m
      theorem padicValNat_le_nat_log {p : ℕ} (n : ℕ) :

      The p-adic valuation of n is less than or equal to its logarithm w.r.t. p.

      theorem padicValNat_add_le_self {p a : ℕ} [hp : Fact (Nat.Prime p)] (ha : p < a) :
      padicValNat p a + p ≤ a
      theorem nat_log_eq_padicValNat_iff {p n : ℕ} [hp : Fact (Nat.Prime p)] (hn : n ≠ 0) :
      Nat.log p n = padicValNat p n ↔ n < p ^ (padicValNat p n + 1)

      The p-adic valuation of n is equal to the logarithm w.r.t. p iff n is less than p raised to one plus the p-adic valuation of n.

      theorem Nat.log_ne_padicValNat_succ {n : ℕ} (hn : n ≠ 0) :
      log 2 n ≠ padicValNat 2 (n + 1)

      This is false for prime numbers other than 2: for p = 3, n = 1, one has log 3 1 = padicValNat 3 2 = 0.

      theorem Nat.max_log_padicValNat_succ_eq_log_succ {p : ℕ} (n : ℕ) [hp : Fact (Prime p)] :
      max (log p n) (padicValNat p (n + 1)) = log p (n + 1)
      theorem range_pow_padicValNat_subset_divisors {p n : ℕ} (hn : n ≠ 0) :
      Finset.image (fun (x : ℕ) => p ^ x) (Finset.range (padicValNat p n + 1)) ⊆ n.divisors
      theorem range_pow_padicValNat_subset_divisors' {p n : ℕ} [hp : Fact (Nat.Prime p)] :
      Finset.image (fun (t : ℕ) => p ^ (t + 1)) (Finset.range (padicValNat p n)) ⊆ n.divisors.erase 1

      The p-adic valuation of (p * n)! is n more than that of n!.

      theorem padicValNat_eq_zero_of_mem_Ioo {p m k : ℕ} (hm : m ∈ Set.Ioo (p * k) (p * (k + 1))) :

      The p-adic valuation of m equals zero if it is between p * k and p * (k + 1) for some k.

      theorem padicValNat_factorial_mul_add {p n : ℕ} (m : ℕ) [hp : Fact (Nat.Prime p)] (h : n < p) :
      @[simp]

      The p-adic valuation of n! is equal to the p-adic valuation of the factorial of the largest multiple of p below n, i.e. (p * ⌊n / p⌋)!.

      theorem padicValNat_factorial {p n b : ℕ} [hp : Fact (Nat.Prime p)] (hnb : Nat.log p n < b) :
      padicValNat p n.factorial = ∑ i ∈ Finset.Ico 1 b, n / p ^ i

      Legendre's Theorem

      The p-adic valuation of n! is the sum of the quotients n / p ^ i. This sum is expressed over the finset Ico 1 b where b is any bound greater than log p n.

      theorem sub_one_mul_padicValNat_factorial {p : ℕ} [hp : Fact (Nat.Prime p)] (n : ℕ) :
      (p - 1) * padicValNat p n.factorial = n - (p.digits n).sum

      Legendre's Theorem

      Taking (p - 1) times the p-adic valuation of n! equals n minus the sum of base p digits of n.

      theorem padicValNat_factorial_lt_of_ne_zero (p : ℕ) [hp : Fact (Nat.Prime p)] {n : ℕ} (hn : n ≠ 0) :
      theorem padicValNat_choose {p n k b : ℕ} [hp : Fact (Nat.Prime p)] (hkn : k ≤ n) (hnb : Nat.log p n < b) :
      padicValNat p (n.choose k) = {i ∈ Finset.Ico 1 b | p ^ i ≤ k % p ^ i + (n - k) % p ^ i}.card

      Kummer's Theorem

      The p-adic valuation of n.choose k is the number of carries when k and n - k are added in base p. This sum is expressed over the finset Ico 1 b where b is any bound greater than log p n.

      theorem padicValNat_choose' {p n k b : ℕ} [hp : Fact (Nat.Prime p)] (hnb : Nat.log p (n + k) < b) :
      padicValNat p ((n + k).choose k) = {i ∈ Finset.Ico 1 b | p ^ i ≤ k % p ^ i + n % p ^ i}.card

      Kummer's Theorem

      The p-adic valuation of (n + k).choose k is the number of carries when k and n are added in base p. This sum is expressed over the finset Ico 1 b where b is any bound greater than log p (n + k).

      theorem sub_one_mul_padicValNat_choose_eq_sub_sum_digits' {p k n : ℕ} [hp : Fact (Nat.Prime p)] :
      (p - 1) * padicValNat p ((n + k).choose k) = (p.digits k).sum + (p.digits n).sum - (p.digits (n + k)).sum

      Kummer's Theorem Taking (p - 1) times the p-adic valuation of the binomial n + k over k equals the sum of the digits of k plus the sum of the digits of n minus the sum of digits of n + k, all base p.

      theorem sub_one_mul_padicValNat_choose_eq_sub_sum_digits {p k n : ℕ} [hp : Fact (Nat.Prime p)] (h : k ≤ n) :
      (p - 1) * padicValNat p (n.choose k) = (p.digits k).sum + (p.digits (n - k)).sum - (p.digits n).sum

      Kummer's Theorem Taking (p - 1) times the p-adic valuation of the binomial n over k equals the sum of the digits of k plus the sum of the digits of n - k minus the sum of digits of n, all base p.

      theorem padicValInt_dvd_iff_of_ne_one {p : ℕ} (hp : p ≠ 1) (n : ℕ) (a : ℤ) :
      ↑p ^ n ∣ a ↔ a = 0 ∨ n ≤ padicValInt p a
      theorem padicValInt_dvd_iff {p : ℕ} [hp : Fact (Nat.Prime p)] (n : ℕ) (a : ℤ) :
      ↑p ^ n ∣ a ↔ a = 0 ∨ n ≤ padicValInt p a
      theorem padicValInt_dvd {p : ℕ} (a : ℤ) :
      ↑p ^ padicValInt p a ∣ a
      theorem padicValInt_self {p : ℕ} [hp : Fact (Nat.Prime p)] :
      padicValInt p ↑p = 1
      theorem padicValInt.mul {p : ℕ} [hp : Fact (Nat.Prime p)] {a b : ℤ} (ha : a ≠ 0) (hb : b ≠ 0) :
      theorem padicValInt_mul_eq_succ {p : ℕ} [hp : Fact (Nat.Prime p)] (a : ℤ) (ha : a ≠ 0) :
      padicValInt p (a * ↑p) = padicValInt p a + 1