Skip to content

Commit

Permalink
doc(data/real/*): add a few docstrings, ereal.has_zero, and `ereal.…
Browse files Browse the repository at this point in the history
…inhabited` (#4378)
  • Loading branch information
urkud committed Oct 3, 2020
1 parent e593ffa commit a0ba5e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/data/real/basic.lean
Expand Up @@ -10,6 +10,8 @@ import order.conditionally_complete_lattice
import data.real.cau_seq_completion
import algebra.archimedean

/-- The type `ℝ` of real numbers constructed as equivalence classes of Cauchy sequences of rational
numbers. -/
def real := @cau_seq.completion.Cauchy ℚ _ _ _ abs _
notation `ℝ` := real

Expand Down
6 changes: 4 additions & 2 deletions src/data/real/ereal.lean
Expand Up @@ -31,7 +31,6 @@ In Isabelle they define + - * and / (making junk choices for things like -∞ +
and then prove whatever bits of the ordered ring/field axioms still hold. They
also do some limits stuff (liminf/limsup etc).
See https://isabelle.in.tum.de/dist/library/HOL/HOL-Library/Extended_Real.html
-/

/-- ereal : The type `[-∞, ∞]` -/
Expand All @@ -48,7 +47,10 @@ by { unfold_coes, norm_num }
@[simp, norm_cast] protected lemma coe_real_inj' {x y : ℝ} : (x : ereal) = (y : ereal) ↔ x = y :=
by { unfold_coes, simp [option.some_inj] }

/- neg -/
instance : has_zero ereal := ⟨(0 : ℝ)⟩
instance : inhabited ereal := ⟨0

/-! ### Negation -/

/-- negation on ereal -/
protected def neg : ereal → ereal
Expand Down
1 change: 1 addition & 0 deletions src/data/real/nnreal.lean
Expand Up @@ -38,6 +38,7 @@ iff.intro nnreal.eq (congr_arg coe)
lemma ne_iff {x y : ℝ≥0} : (x : ℝ) ≠ (y : ℝ) ↔ x ≠ y :=
not_iff_not_of_iff $ nnreal.eq_iff

/-- Reinterpret a real number `r` as a non-negative real number. Returns `0` if `r < 0`. -/
protected def of_real (r : ℝ) : ℝ≥0 := ⟨max r 0, le_max_right _ _⟩

lemma coe_of_real (r : ℝ) (hr : 0 ≤ r) : (nnreal.of_real r : ℝ) = r :=
Expand Down

0 comments on commit a0ba5e7

Please sign in to comment.