Analysis I, Appendix B.2: The decimal representation of real numbers #
An implementation of the decimal representation of Mathlib's real numbers ℝ.
This is separate from the way decimal numerals are already represented in Mathlib. We also represent the integer part of the natural numbers just by ℕ, avoiding using the decimal representation from the
previous section, although we still retain the Digit class.
Equations
Exercise B.2.1
- pos : NNRealDecimal → RealDecimal
- neg : NNRealDecimal → RealDecimal
Instances For
Equations
- AppendixB.RealDecimal.instCoeReal = { coe := fun (d : AppendixB.RealDecimal) => match d with | AppendixB.RealDecimal.pos d => ↑↑d | AppendixB.RealDecimal.neg d => -↑↑d }
theorem
AppendixB.RealDecimal.surj
(x : ℝ)
:
∃ (d : RealDecimal),
x = match d with
| pos d => ↑↑d
| neg d => -↑↑d
theorem
AppendixB.RealDecimal.not_inj_terminating
{x : ℝ}
(hx : TerminatingDecimal x)
:
∃ (d₁ : RealDecimal) (d₂ : RealDecimal),
d₁ ≠ d₂ ∧ ∀ (d : RealDecimal),
(match d with
| pos d => ↑↑d
| neg d => -↑↑d) = x ↔ d = d₁ ∨ d = d₂