The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Basic.Real.Basic

123 declarations. Mathlib docs · Source

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 ℚ.

The facts that the real numbers are an Archimedean floor ring, and a conditionally complete linear order, have been deferred to the file Mathlib/Algebra/Order/Archimedean/Real/Basic.lean, in order to keep the imports here simple.

The fact that the real numbers are a (trivial) *-ring has similarly been deferred to Mathlib/Basic/Real/Star.lean.

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.

theorem Real.ofCauchy.inj E1 #

∀ {cauchy cauchy_1 : CauSeq.Completion.Cauchy abs}, { cauchy := cauchy } = { cauchy := cauchy_1 } → cauchy = cauchy_1

theorem CauSeq.congr_simp E1 #

∀ {α : Type u_3} [inst : Field α] [inst_1 : LinearOrder α] [inst_2 : IsStrictOrderedRing α] (β : Type u_4)
  [inst_3 : Ring β] (abv abv_1 : β → α), abv = abv_1 → CauSeq β abv = CauSeq β abv_1

def Real.ctorIdx E1 #

ℝ → ℕ

theorem Real.ofCauchy.injEq E0 #

∀ (cauchy cauchy_1 : CauSeq.Completion.Cauchy abs),
  ({ cauchy := cauchy } = { cauchy := cauchy_1 }) = (cauchy = cauchy_1)

structure Real E3 #

Type

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

ctor Real.ofCauchy E0 #

CauSeq.Completion.Cauchy abs → ℝ

abbrev Real.cauchy E1 #

ℝ → CauSeq.Completion.Cauchy abs

The underlying Cauchy completion

def termℝ E1 #

Lean.ParserDescr

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

theorem CauSeq.Completion.ofRat_rat E0 #

∀ {abv : ℚ → ℚ} [inst : IsAbsoluteValue abv] (q : ℚ), CauSeq.Completion.ofRat q = ↑q

theorem Real.ext_cauchy_iff E0 #

∀ {x y : ℝ}, x = y ↔ x.cauchy = y.cauchy

theorem Real.ext_cauchy E1 #

∀ {x y : ℝ}, x.cauchy = y.cauchy → x = y

def Real.equivCauchy E1 #

ℝ ≃ CauSeq.Completion.Cauchy abs

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

instance Real.instZero E0 #

Zero ℝ

instance Real.instOne E0 #

One ℝ

instance Real.instAdd E0 #

Add ℝ

instance Real.instNeg E0 #

Neg ℝ

instance Real.instMul E0 #

Mul ℝ

instance Real.instSub E0 #

Sub ℝ

instance Real.instInv E0 #

Inv ℝ

theorem Real.ofCauchy_zero E1 #

{ cauchy := 0 } = 0

theorem Real.ofCauchy_one E1 #

{ cauchy := 1 } = 1

theorem Real.ofCauchy_add E1 #

∀ (a b : CauSeq.Completion.Cauchy abs), { cauchy := a + b } = { cauchy := a } + { cauchy := b }

theorem Real.ofCauchy_neg E1 #

∀ (a : CauSeq.Completion.Cauchy abs), { cauchy := -a } = -{ cauchy := a }

theorem Real.ofCauchy_sub E1 #

∀ (a b : CauSeq.Completion.Cauchy abs), { cauchy := a - b } = { cauchy := a } - { cauchy := b }

theorem Real.ofCauchy_mul E1 #

∀ (a b : CauSeq.Completion.Cauchy abs), { cauchy := a * b } = { cauchy := a } * { cauchy := b }

theorem Real.ofCauchy_inv E1 #

∀ {f : CauSeq.Completion.Cauchy abs}, { cauchy := f⁻¹ } = { cauchy := f }⁻¹

theorem Real.cauchy_zero E1 #

Real.cauchy 0 = 0

theorem Real.cauchy_one E1 #

Real.cauchy 1 = 1

theorem Real.cauchy_add E1 #

∀ (a b : ℝ), (a + b).cauchy = a.cauchy + b.cauchy

theorem Real.cauchy_neg E1 #

∀ (a : ℝ), (-a).cauchy = -a.cauchy

theorem Real.cauchy_mul E1 #

∀ (a b : ℝ), (a * b).cauchy = a.cauchy * b.cauchy

theorem Real.cauchy_sub E1 #

∀ (a b : ℝ), (a - b).cauchy = a.cauchy - b.cauchy

theorem Real.cauchy_inv E1 #

∀ (f : ℝ), f⁻¹.cauchy = f.cauchy⁻¹

instance Real.instNatCast E0 #

NatCast ℝ

instance Real.instIntCast E0 #

IntCast ℝ

instance Real.instNNRatCast E0 #

NNRatCast ℝ

instance Real.instRatCast E0 #

RatCast ℝ

theorem Real.ofCauchy_natCast E1 #

∀ (n : ℕ), { cauchy := ↑n } = ↑n

theorem Real.ofCauchy_intCast E1 #

∀ (z : ℤ), { cauchy := ↑z } = ↑z

theorem Real.ofCauchy_nnratCast E1 #

∀ (q : ℚ≥0), { cauchy := ↑q } = ↑q

theorem Real.ofCauchy_ratCast E1 #

∀ (q : ℚ), { cauchy := ↑q } = ↑q

theorem Real.cauchy_natCast E1 #

∀ (n : ℕ), (↑n).cauchy = ↑n

theorem Real.cauchy_intCast E1 #

∀ (z : ℤ), (↑z).cauchy = ↑z

theorem Real.cauchy_nnratCast E1 #

∀ (q : ℚ≥0), (↑q).cauchy = ↑q

theorem Real.cauchy_ratCast E1 #

∀ (q : ℚ), (↑q).cauchy = ↑q

instance Real.commRing E0 #

CommRing ℝ

def Real.ringEquivCauchy E1 #

ℝ ≃+* CauSeq.Completion.Cauchy abs

Real.equivCauchy as a ring equivalence.

theorem Real.ringEquivCauchy_apply E0 #

∀ (self : ℝ), Real.ringEquivCauchy self = self.cauchy

theorem Real.ringEquivCauchy_symm_apply_cauchy E0 #

∀ (cauchy : CauSeq.Completion.Cauchy abs), (Real.ringEquivCauchy.symm cauchy).cauchy = cauchy

instance Real.instRing E0 #

Ring ℝ

instance Real.instCommSemiring E0 #

CommSemiring ℝ

instance Real.semiring E0 #

Semiring ℝ

instance Real.instCommMonoidWithZero E0 #

CommMonoidWithZero ℝ

instance Real.instMonoidWithZero E0 #

MonoidWithZero ℝ

instance Real.instAddCommGroup E0 #

AddCommGroup ℝ

instance Real.instAddGroup E0 #

AddGroup ℝ

instance Real.instAddCommMonoid E0 #

AddCommMonoid ℝ

instance Real.instAddMonoid E0 #

AddMonoid ℝ

instance Real.instAddLeftCancelSemigroup E0 #

AddLeftCancelSemigroup ℝ

instance Real.instAddRightCancelSemigroup E0 #

AddRightCancelSemigroup ℝ

instance Real.instAddCommSemigroup E0 #

AddCommSemigroup ℝ

instance Real.instAddSemigroup E0 #

AddSemigroup ℝ

instance Real.instCommMonoid E0 #

CommMonoid ℝ

instance Real.instMonoid E0 #

Monoid ℝ

instance Real.instCommSemigroup E0 #

CommSemigroup ℝ

instance Real.instSemigroup E0 #

Semigroup ℝ

instance Real.instInhabited E0 #

Inhabited ℝ

def Real.mk E1 #

CauSeq ℚ abs → ℝ

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

theorem Real.mk_eq E0 #

∀ {f g : CauSeq ℚ abs}, Real.mk f = Real.mk g ↔ f ≈ g

instance Real.instLT E0 #

LT ℝ

theorem Real.lt_cauchy E1 #

∀ {f g : CauSeq ℚ abs}, { cauchy := ⟦f⟧ } < { cauchy := ⟦g⟧ } ↔ f < g

theorem Real.mk_lt E0 #

∀ {f g : CauSeq ℚ abs}, Real.mk f < Real.mk g ↔ f < g

theorem Real.mk_zero E1 #

Real.mk 0 = 0

theorem Real.mk_one E1 #

Real.mk 1 = 1

theorem Real.mk_add E1 #

∀ {f g : CauSeq ℚ abs}, Real.mk (f + g) = Real.mk f + Real.mk g

theorem Real.mk_mul E1 #

∀ {f g : CauSeq ℚ abs}, Real.mk (f * g) = Real.mk f * Real.mk g

theorem Real.mk_neg E1 #

∀ {f : CauSeq ℚ abs}, Real.mk (-f) = -Real.mk f

theorem Real.mk_pos E0 #

∀ {f : CauSeq ℚ abs}, 0 < Real.mk f ↔ f.Pos

theorem Real.mk_const E1 #

∀ {x : ℚ}, Real.mk (CauSeq.const abs x) = ↑x

instance Real.instLE E0 #

LE ℝ

theorem Real.mk_le E0 #

∀ {f g : CauSeq ℚ abs}, Real.mk f ≤ Real.mk g ↔ f ≤ g

theorem Real.ind_mk E0 #

∀ {C : ℝ → Prop} (x : ℝ), (∀ (y : CauSeq ℚ abs), C (Real.mk y)) → C x

instance Real.partialOrder E0 #

PartialOrder ℝ

instance Real.instPreorder E0 #

Preorder ℝ

theorem Real.ratCast_lt E1 #

∀ {x y : ℚ}, ↑x < ↑y ↔ x < y

theorem Real.zero_lt_one E1 #

0 < 1

instance Real.instNontrivial E0 #

Nontrivial ℝ

instance Real.instZeroLEOneClass E0 #

ZeroLEOneClass ℝ

instance Real.instIsOrderedAddMonoid E0 #

IsOrderedAddMonoid ℝ

instance Real.instIsStrictOrderedRing E0 #

IsStrictOrderedRing ℝ

instance Real.instIsOrderedRing E0 #

IsOrderedRing ℝ

instance Real.instIsOrderedCancelAddMonoid E0 #

IsOrderedCancelAddMonoid ℝ

instance Real.instMax E0 #

Max ℝ

theorem Real.ofCauchy_sup E1 #

∀ (a b : CauSeq ℚ abs), { cauchy := ⟦a ⊔ b⟧ } = max { cauchy := ⟦a⟧ } { cauchy := ⟦b⟧ }

theorem Real.mk_sup E0 #

∀ (a b : CauSeq ℚ abs), Real.mk (a ⊔ b) = max (Real.mk a) (Real.mk b)

instance Real.instMin E0 #

Min ℝ

theorem Real.ofCauchy_inf E1 #

∀ (a b : CauSeq ℚ abs), { cauchy := ⟦a ⊓ b⟧ } = min { cauchy := ⟦a⟧ } { cauchy := ⟦b⟧ }

theorem Real.mk_inf E0 #

∀ (a b : CauSeq ℚ abs), Real.mk (a ⊓ b) = min (Real.mk a) (Real.mk b)

instance Real.instDistribLattice E0 #

DistribLattice ℝ

instance Real.lattice E0 #

Lattice ℝ

instance Real.instSemilatticeInf E0 #

SemilatticeInf ℝ

instance Real.instSemilatticeSup E0 #

SemilatticeSup ℝ

instance Real.leTotal_R E0 #

Std.Total fun x1 x2 ↦ x1 ≤ x2

instance Real.linearOrder E3 #

LinearOrder ℝ

instance Real.instIsDomain E0 #

IsDomain ℝ

instance Real.instDivInvMonoid E0 #

DivInvMonoid ℝ

theorem Real.ofCauchy_div E1 #

∀ (f g : CauSeq.Completion.Cauchy abs), { cauchy := f / g } = { cauchy := f } / { cauchy := g }

instance Real.instField E3 #

Field ℝ

instance Real.instDivisionRing E0 #

DivisionRing ℝ

instance Real.decidableLT E0 #

(a b : ℝ) → Decidable (a < b)

instance Real.decidableLE E0 #

(a b : ℝ) → Decidable (a ≤ b)

instance Real.decidableEq E0 #

(a b : ℝ) → Decidable (a = b)

instance Real.instRepr E0 #

Repr ℝ

Show an underlying Cauchy sequence for real numbers.

The representative chosen is the one passed in the VM to Quot.mk, so two Cauchy sequences converging to the same number may be printed differently.

theorem Real.le_mk_of_forall_le E1 #

∀ {x : ℝ} {f : CauSeq ℚ abs}, (∃ i, ∀ j ≥ i, x ≤ ↑(f j)) → x ≤ Real.mk f

theorem Real.mk_le_of_forall_le E1 #

∀ {f : CauSeq ℚ abs} {x : ℝ}, (∃ i, ∀ j ≥ i, ↑(f j) ≤ x) → Real.mk f ≤ x

theorem Real.mk_near_of_forall_near E1 #

∀ {f : CauSeq ℚ abs} {x ε : ℝ}, (∃ i, ∀ j ≥ i, |↑(f j) - x| ≤ ε) → |Real.mk f - x| ≤ ε

theorem Real.mul_add_one_le_add_one_pow E1 #

∀ {a : ℝ}, 0 ≤ a → ∀ (b : ℕ), a * ↑b + 1 ≤ (a + 1) ^ b

def IsPowMul E1 #

{R : Type u_1} → {S : Type u_2} → [Pow R ℕ] → [Pow S ℕ] → (R → S) → Prop

A function f : R → ℝ is power-multiplicative if for all r ∈ R and all positive n ∈ ℕ, f (r ^ n) = (f r) ^ n.

theorem IsPowMul.map_one_eq_zero_or_one E0 #

∀ {R : Type u_1} {S : Type u_2} [inst : Monoid R] [inst_1 : MonoidWithZero S] [IsRightCancelMulZero S] {f : R → S},
  IsPowMul f → f 1 = 0 ∨ f 1 = 1

theorem IsPowMul.map_one_le_one E0 #

∀ {R : Type u_1} {S : Type u_2} [inst : Monoid R] [inst_1 : MonoidWithZero S] [inst_2 : Preorder S]
  [IsRightCancelMulZero S] [ZeroLEOneClass S] {f : R → S}, IsPowMul f → f 1 ≤ 1

theorem IsPowMul.map_one E0 #

∀ {R : Type u_1} {S : Type u_2} {F : Type u_3} [inst : Ring R] [Nontrivial R] [inst_2 : Semiring S]
  [IsRightCancelMulZero S] [inst_4 : PartialOrder S] [inst_5 : FunLike F R S] [AddGroupNormClass F R S] {f : F},
  IsPowMul ⇑f → f 1 = 1

A power-multiplicative additive group norm on a nontrivial ring satisfies f 1 = 1.

theorem IsPowMul.map_pow E0 #

∀ {R : Type u_1} {S : Type u_2} {F : Type u_3} [inst : Ring R] [Nontrivial R] [inst_2 : Semiring S]
  [IsRightCancelMulZero S] [inst_4 : PartialOrder S] [inst_5 : FunLike F R S] [AddGroupNormClass F R S] {f : F},
  IsPowMul ⇑f → ∀ (a : R) (n : ℕ), f (a ^ n) = f a ^ n

A power-multiplicative additive group norm on a nontrivial ring satisfies f (a ^ n) = (f a) ^ n for all natural numbers n.

def RingHom.IsBoundedWrt E1 #

{α : Type u_1} → [inst : Ring α] → {β : Type u_2} → [inst_1 : Ring β] → (α → ℝ) → (β → ℝ) → (α →+* β) → Prop

A ring homomorphism f : α →+* β is bounded with respect to the functions nα : α → ℝ and nβ : β → ℝ if there exists a positive constant C such that for all x in α, nβ (f x) ≤ C * nα x.