mathlib documentation

data.real.basic

Real numbers from Cauchy sequences #

This file defines ℝ as the type of equivalence classes of Cauchy sequences of rational numbers. This choice is motivated by how easy it is to prove that ℝ is a commutative ring, by simply lifting everything to ℚ.

structure real  :
Type

The type ℝ of real numbers constructed as equivalence classes of Cauchy sequences of rational numbers.

theorem real.ext_cauchy_iff {x y : ℝ} :
x = y ↔ x.cauchy = y.cauchy
theorem real.ext_cauchy {x y : ℝ} :
x.cauchy = y.cauchy → x = y

The real numbers are isomorphic to the quotient of Cauchy sequences on the rationals.

Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
theorem real.of_cauchy_zero  :
⟨0⟩ = 0
theorem real.of_cauchy_one  :
⟨1⟩ = 1
theorem real.of_cauchy_add (a b : cau_seq.completion.Cauchy) :
⟨a + b⟩ = ⟨a⟩ + ⟨b⟩
theorem real.of_cauchy_neg (a : cau_seq.completion.Cauchy) :
⟨-a⟩ = -⟨a⟩
theorem real.of_cauchy_mul (a b : cau_seq.completion.Cauchy) :
⟨a * b⟩ = ⟨a⟩ * ⟨b⟩
theorem real.cauchy_zero  :
0.cauchy = 0
theorem real.cauchy_one  :
1.cauchy = 1
theorem real.cauchy_add (a b : ℝ) :
(a + b).cauchy = a.cauchy + b.cauchy
theorem real.cauchy_neg (a : ℝ) :
theorem real.cauchy_mul (a b : ℝ) :
(a * b).cauchy = (a.cauchy) * b.cauchy
@[protected, instance]
Equations

Extra instances to short-circuit type class resolution.

These short-circuits have an additional property of ensuring that a computable path is found; if field ℝ is found first, then decaying it to these typeclasses would result in a noncomputable version of them.

@[protected, instance]
def real.ring  :
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected, instance]

The real numbers are a *-ring, with the trivial *-structure.

Equations
@[protected, instance]

Coercion ℚ → ℝ as a ring_hom. Note that this is cau_seq.completion.of_rat, not rat.cast.

Equations
def real.mk (x : cau_seq ℚ abs) :

Make a real number from a Cauchy sequence of rationals (by taking the equivalence class).

Equations
theorem real.mk_eq {f g : cau_seq ℚ abs} :
@[protected, instance]
Equations
theorem real.lt_cauchy {f g : cau_seq ℚ abs} :
⟨⟦f⟧⟩ < ⟨⟦g⟧⟩ ↔ f < g
@[simp]
theorem real.mk_lt {f g : cau_seq ℚ abs} :
theorem real.mk_zero  :
theorem real.mk_one  :
theorem real.mk_add {f g : cau_seq ℚ abs} :
theorem real.mk_mul {f g : cau_seq ℚ abs} :
real.mk (f * g) = (real.mk f) * real.mk g
theorem real.mk_neg {f : cau_seq ℚ abs} :
@[simp]
theorem real.mk_pos {f : cau_seq ℚ abs} :
@[protected, instance]
Equations
@[simp]
theorem real.mk_le {f g : cau_seq ℚ abs} :
@[protected]
theorem real.ind_mk {C : ℝ → Prop} (x : ℝ) (h : ∀ (y : cau_seq ℚ abs), C (real.mk y)) :
C x
theorem real.add_lt_add_iff_left {a b : ℝ} (c : ℝ) :
c + a < c + b ↔ a < b
@[protected, instance]
Equations
@[protected, instance]
Equations
@[protected]
theorem real.zero_lt_one  :
0 < 1
@[protected]
theorem real.mul_pos {a b : ℝ} :
0 < a → 0 < b → 0 < a * b
@[protected, instance]
@[protected, instance]
noncomputable def real.linear_order  :
Equations
@[protected, instance]
@[protected, instance]
noncomputable def real.has_inv  :
Equations
@[protected, instance]
Equations
@[protected, instance]
noncomputable def real.field  :
Equations
@[protected, instance]
noncomputable def real.division_ring  :
Equations
@[protected, instance]
noncomputable def real.lattice  :
Equations
@[protected, instance]
noncomputable def real.semilattice_inf  :
Equations
@[protected, instance]
noncomputable def real.semilattice_sup  :
Equations
@[protected, instance]
noncomputable def real.has_inf  :
Equations
@[protected, instance]
noncomputable def real.has_sup  :
Equations
@[protected, instance]
noncomputable def real.decidable_lt (a b : ℝ) :
decidable (a < b)
Equations
@[protected, instance]
noncomputable def real.decidable_le (a b : ℝ) :
Equations
@[protected, instance]
noncomputable def real.decidable_eq (a b : ℝ) :
decidable (a = b)
Equations
@[simp]
theorem real.le_mk_of_forall_le {x : ℝ} {f : cau_seq ℚ abs} :
(∃ (i : ℕ), ∀ (j : ℕ), j ≥ i → x ≤ ↑(⇑f j)) → x ≤ real.mk f
theorem real.mk_le_of_forall_le {f : cau_seq ℚ abs} {x : ℝ} (h : ∃ (i : ℕ), ∀ (j : ℕ), j ≥ i → ↑(⇑f j) ≤ x) :
theorem real.mk_near_of_forall_near {f : cau_seq ℚ abs} {x ε : ℝ} (H : ∃ (i : ℕ), ∀ (j : ℕ), j ≥ i → |↑(⇑f j) - x| ≤ ε) :
|real.mk f - x| ≤ ε
@[protected, instance]
@[protected, instance]
noncomputable def real.floor_ring  :
Equations
theorem real.is_cau_seq_iff_lift {f : ℕ → ℚ} :
is_cau_seq abs f ↔ is_cau_seq abs (λ (i : ℕ), ↑(f i))
theorem real.of_near (f : ℕ → ℚ) (x : ℝ) (h : ∀ (ε : ℝ), ε > 0 → (∃ (i : ℕ), ∀ (j : ℕ), j ≥ i → |↑(f j) - x| < ε)) :
∃ (h' : is_cau_seq abs f), real.mk ⟨f, h'⟩ = x
theorem real.exists_floor (x : ℝ) :
∃ (ub : ℤ), ↑ub ≤ x ∧ ∀ (z : ℤ), ↑z ≤ x → z ≤ ub
theorem real.exists_is_lub (S : set ℝ) (hne : S.nonempty) (hbdd : bdd_above S) :
∃ (x : ℝ), is_lub S x
@[protected, instance]
noncomputable def real.has_Sup  :
Equations
theorem real.Sup_def (S : set ℝ) :
Sup S = dite (S.nonempty ∧ bdd_above S) (λ (h : S.nonempty ∧ bdd_above S), classical.some _) (λ (h : ¬(S.nonempty ∧ bdd_above S)), 0)
@[protected]
theorem real.is_lub_Sup (S : set ℝ) (h₁ : S.nonempty) (h₂ : bdd_above S) :
is_lub S (Sup S)
@[protected, instance]
noncomputable def real.has_Inf  :
Equations
theorem real.Inf_def (S : set ℝ) :
Inf S = -Sup (-S)
@[protected]
theorem real.is_glb_Inf (S : set ℝ) (h₁ : S.nonempty) (h₂ : bdd_below S) :
is_glb S (Inf S)
@[protected, instance]
Equations
theorem real.lt_Inf_add_pos {s : set ℝ} (h : s.nonempty) {ε : ℝ} (hε : 0 < ε) :
∃ (a : ℝ) (H : a ∈ s), a < Inf s + ε
theorem real.add_neg_lt_Sup {s : set ℝ} (h : s.nonempty) {ε : ℝ} (hε : ε < 0) :
∃ (a : ℝ) (H : a ∈ s), Sup s + ε < a
theorem real.Inf_le_iff {s : set ℝ} (h : bdd_below s) (h' : s.nonempty) {a : ℝ} :
Inf s ≤ a ↔ ∀ (ε : ℝ), 0 < ε → (∃ (x : ℝ) (H : x ∈ s), x < a + ε)
theorem real.le_Sup_iff {s : set ℝ} (h : bdd_above s) (h' : s.nonempty) {a : ℝ} :
a ≤ Sup s ↔ ∀ (ε : ℝ), ε < 0 → (∃ (x : ℝ) (H : x ∈ s), a + ε < x)
@[simp]
theorem real.Sup_empty  :
theorem real.csupr_empty {α : Sort u_1} [is_empty α] (f : α → ℝ) :
(⨆ (i : α), f i) = 0
@[simp]
theorem real.csupr_const_zero {α : Sort u_1} :
(⨆ (i : α), 0) = 0
theorem real.Sup_of_not_bdd_above {s : set ℝ} (hs : ¬bdd_above s) :
Sup s = 0
@[simp]
theorem real.Inf_empty  :
theorem real.cinfi_empty {α : Sort u_1} [is_empty α] (f : α → ℝ) :
(⨅ (i : α), f i) = 0
@[simp]
theorem real.cinfi_const_zero {α : Sort u_1} :
(⨅ (i : α), 0) = 0
theorem real.Inf_of_not_bdd_below {s : set ℝ} (hs : ¬bdd_below s) :
Inf s = 0
theorem real.Sup_nonneg (S : set ℝ) (hS : ∀ (x : ℝ), x ∈ S → 0 ≤ x) :
0 ≤ Sup S

As 0 is the default value for real.Sup of the empty set or sets which are not bounded above, it suffices to show that S is bounded below by 0 to show that 0 ≤ Inf S.

theorem real.Sup_nonpos (S : set ℝ) (hS : ∀ (x : ℝ), x ∈ S → x ≤ 0) :
Sup S ≤ 0

As 0 is the default value for real.Sup of the empty set, it suffices to show that S is bounded above by 0 to show that Sup S ≤ 0.

theorem real.Inf_nonneg (S : set ℝ) (hS : ∀ (x : ℝ), x ∈ S → 0 ≤ x) :
0 ≤ Inf S

As 0 is the default value for real.Inf of the empty set, it suffices to show that S is bounded below by 0 to show that 0 ≤ Inf S.

theorem real.Inf_nonpos (S : set ℝ) (hS : ∀ (x : ℝ), x ∈ S → x ≤ 0) :
Inf S ≤ 0

As 0 is the default value for real.Inf of the empty set or sets which are not bounded below, it suffices to show that S is bounded above by 0 to show that Inf S ≤ 0.

theorem real.Inf_le_Sup (s : set ℝ) (h₁ : bdd_below s) (h₂ : bdd_above s) :
Inf s ≤ Sup s
theorem real.cau_seq_converges (f : cau_seq ℝ abs) :
∃ (x : ℝ), f ≈ cau_seq.const abs x