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 #
ofDigits: takes a sequence of digits(d₀, d₁, ...)(as anℕ → Fin b), and returns the real number0.d₀d₁d₂....digits: takes a real number in $[0,1)$ and returns the sequence of its digits.
Main Statements #
ofDigits_digitsstates thatofDigits (digits x b) = x.
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ⁱ.
Instances For
ofDigits d is the real number 0.d₀d₁d₂... in base b.
We allow repeating representations like 0.999... here.
Instances For
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)
Converts a real number x from the interval [0, 1) into sequence of
its digits in base b.
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.hasSum_ofDigitsTerm_digits
(x : ℝ)
{b : ℕ}
[NeZero b]
(hb : 1 < b)
(hx : x ∈ Set.Ico 0 1)
:
HasSum (ofDigitsTerm (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.