Documentation

Mathlib.Analysis.Real.OfDigits

Representation of reals in positional system #

This file defines Real.ofDigits and Real.digits functions which allows to work with the representations of reals as sequences of digits in positional system.

Main Definitions #

Main Statements #

noncomputable def Real.ofDigitsTerm {b : ℕ} (digits : ℕ → Fin b) :
ℕ → ℝ

ofDigits takes a sequence of digits (d₀, d₁, ...) in base b and returns the real number 0.d₀d₁d₂... = ∑ᵢ(dᵢ/bⁱ). This auxiliary definition ofDigitsTerm sends the sequence to the function sending i to dᵢ/bⁱ.

Equations
Instances For
    theorem Real.ofDigitsTerm_nonneg {b : ℕ} {digits : ℕ → Fin b} {n : ℕ} :
    0 ≤ ofDigitsTerm digits n
    theorem Real.ofDigitsTerm_le {b : ℕ} {digits : ℕ → Fin b} {n : ℕ} :
    ofDigitsTerm digits n ≤ (↑b - 1) * (↑b ^ (n + 1))⁻¹
    theorem Real.summable_ofDigitsTerm {b : ℕ} {digits : ℕ → Fin b} :
    noncomputable def Real.ofDigits {b : ℕ} (digits : ℕ → Fin b) :

    ofDigits d is the real number 0.d₀d₁d₂... in base b. We allow repeating representations like 0.999... here.

    Equations
    Instances For
      theorem Real.ofDigits_nonneg {b : ℕ} (digits : ℕ → Fin b) :
      0 ≤ ofDigits digits
      theorem Real.ofDigits_le_one {b : ℕ} (digits : ℕ → Fin b) :
      ofDigits digits ≤ 1
      theorem Real.ofDigits_eq_sum_add_ofDigits {b : ℕ} (a : ℕ → Fin b) (n : ℕ) :
      ofDigits a = ∑ i ∈ Finset.range n, ofDigitsTerm a i + (↑b ^ n)⁻¹ * ofDigits fun (i : ℕ) => a (i + n)
      theorem Real.abs_ofDigits_sub_ofDigits_le {b : ℕ} {x y : ℕ → Fin b} {n : ℕ} (hxy : ∀ i < n, x i = y i) :
      noncomputable def Real.digits (x : ℝ) (b : ℕ) [NeZero b] :
      ℕ → Fin b

      Converts a real number x from the interval [0, 1) into sequence of its digits in base b.

      Equations
      Instances For
        theorem Real.ofDigits_digits_sum_eq {x : ℝ} {b : ℕ} [NeZero b] (hx : x ∈ Set.Ico 0 1) (n : ℕ) :
        ↑b ^ n * ∑ i ∈ Finset.range n, ofDigitsTerm (x.digits b) i = ↑⌊↑b ^ n * x⌋₊
        theorem Real.le_sum_ofDigitsTerm_digits {x : ℝ} {b : ℕ} [NeZero b] (hx : x ∈ Set.Ico 0 1) (n : ℕ) :
        x - (↑b)⁻¹ ^ n ≤ ∑ i ∈ Finset.range n, ofDigitsTerm (x.digits b) i
        theorem Real.sum_ofDigitsTerm_digits_le {x : ℝ} {b : ℕ} [NeZero b] (hx : x ∈ Set.Ico 0 1) (n : ℕ) :
        ∑ i ∈ Finset.range n, ofDigitsTerm (x.digits b) i ≤ x
        theorem Real.hasSum_ofDigitsTerm_digits (x : ℝ) {b : ℕ} [NeZero b] (hb : 1 < b) (hx : x ∈ Set.Ico 0 1) :
        theorem Real.ofDigits_digits {b : ℕ} [NeZero b] {x : ℝ} (hb : 1 < b) (hx : x ∈ Set.Ico 0 1) :
        ofDigits (x.digits b) = x
        theorem Real.ofDigits_const_last_eq_one (b : ℕ) [NeZero b] :
        (ofDigits fun (x : ℕ) => Fin.last b) = 1

        A generalization of the identity 0.(9) = 1 to arbitrary positional numeral systems.

        theorem Real.ofDigits_const_last_eq_one' {b : ℕ} (hb : 1 < b) :
        (ofDigits fun (x : ℕ) => ⟨b - 1, ⋯⟩) = 1

        A generalization of the identity 0.(9) = 1 to arbitrary positional numeral systems.