@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
4
4
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir
5
5
6
6
! This file was ported from Lean 3 source module data.complex.exponential
7
- ! leanprover-community/mathlib commit caa58cbf5bfb7f81ccbaca4e8b8ac4bc2b39cc1c
7
+ ! leanprover-community/mathlib commit a8b2226cfb0a79f5986492053fc49b1a0c6aeffb
8
8
! Please do not edit these lines, except to modify the commit id
9
9
! if you have ported upstream changes.
10
10
-/
@@ -1472,27 +1472,36 @@ nonrec theorem sinh_three_mul : sinh (3 * x) = 4 * sinh x ^ 3 + 3 * sinh x := by
1472
1472
rw [← ofReal_inj]; simp [sinh_three_mul]
1473
1473
#align real.sinh_three_mul Real.sinh_three_mul
1474
1474
1475
- open IsAbsoluteValue
1475
+ open IsAbsoluteValue Nat
1476
1476
1477
- /-- This is an intermediate result that is later replaced by `Real.add_one_le_exp`; use that lemma
1478
- instead. -/
1479
- theorem add_one_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : x + 1 ≤ exp x :=
1477
+ theorem sum_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) (n : ℕ) : (∑ i in range n, x ^ i / i !) ≤ exp x :=
1480
1478
calc
1481
- x + 1 ≤ CauSeq.lim (⟨fun n : ℕ => ((exp' x) n).re, isCauSeq_re (exp' x)⟩ : CauSeq ℝ Abs.abs) :=
1482
- le_lim
1483
- (CauSeq.le_of_exists
1484
- ⟨2 , fun j hj =>
1485
- show x + (1 : ℝ) ≤ (∑ m in range j, ((x : ℂ) ^ m / m.factorial)).re by
1486
- have h₁ : (((fun m : ℕ => ((x : ℂ) ^ m / m.factorial)) ∘ Nat.succ) 0 ).re = x :=
1487
- by simp [show Nat.succ 0 = 1 from rfl, Complex.ofReal_re]
1488
- have h₂ : ((x : ℂ) ^ 0 / (Nat.factorial 0 )).re = 1 := by simp
1489
- erw [← tsub_add_cancel_of_le hj, sum_range_succ', sum_range_succ', add_re, add_re, h₁,
1490
- h₂, add_assoc, ← coe_reAddGroupHom, reAddGroupHom.map_sum,
1491
- coe_reAddGroupHom]
1492
- refine' le_add_of_nonneg_of_le (sum_nonneg fun m _ => _) le_rfl
1493
- rw [← ofReal_pow, ← ofReal_nat_cast, ← ofReal_div, ofReal_re]
1494
- exact div_nonneg (pow_nonneg hx _) (Nat.cast_nonneg _)⟩)
1479
+ (∑ i in range n, x ^ i / i !) ≤ lim (⟨_, isCauSeq_re (exp' x)⟩ : CauSeq ℝ Abs.abs) := by
1480
+ refine' le_lim (CauSeq.le_of_exists ⟨n, fun j hj => _⟩)
1481
+ simp only [exp', const_apply, re_sum]
1482
+ norm_cast
1483
+ rw [← Nat.add_sub_of_le hj, Finset.sum_range_add]
1484
+ refine' le_add_of_nonneg_right (sum_nonneg fun i _ => _)
1485
+ positivity
1495
1486
_ = exp x := by rw [exp, Complex.exp, ← cauSeqRe, lim_re]
1487
+ #align real.sum_le_exp_of_nonneg Real.sum_le_exp_of_nonneg
1488
+
1489
+ theorem quadratic_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : 1 + x + x ^ 2 / 2 ≤ exp x :=
1490
+ calc
1491
+ 1 + x + x ^ 2 / 2 = ∑ i in range 3 , x ^ i / i ! := by simp [Finset.sum_range_succ]; ring_nf
1492
+ _ ≤ exp x := sum_le_exp_of_nonneg hx 3
1493
+ #align real.quadratic_le_exp_of_nonneg Real.quadratic_le_exp_of_nonneg
1494
+
1495
+ theorem add_one_lt_exp_of_pos {x : ℝ} (hx : 0 < x) : x + 1 < exp x :=
1496
+ (by nlinarith : x + 1 < 1 + x + x ^ 2 / 2 ).trans_le (quadratic_le_exp_of_nonneg hx.le)
1497
+ #align real.add_one_lt_exp_of_pos Real.add_one_lt_exp_of_pos
1498
+
1499
+ /-- This is an intermediate result that is later replaced by `Real.add_one_le_exp`; use that lemma
1500
+ instead. -/
1501
+ theorem add_one_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : x + 1 ≤ exp x := by
1502
+ rcases eq_or_lt_of_le hx with (rfl | h)
1503
+ · simp
1504
+ exact (add_one_lt_exp_of_pos h).le
1496
1505
#align real.add_one_le_exp_of_nonneg Real.add_one_le_exp_of_nonneg
1497
1506
1498
1507
theorem one_le_exp {x : ℝ} (hx : 0 ≤ x) : 1 ≤ exp x := by linarith [add_one_le_exp_of_nonneg hx]
@@ -1957,67 +1966,67 @@ theorem cos_two_neg : cos 2 < 0 :=
1957
1966
_ < 0 := by norm_num
1958
1967
#align real.cos_two_neg Real.cos_two_neg
1959
1968
1960
- --Porting note: removed `(h1 : 0 ≤ x)` because it is no longer used
1961
- theorem exp_bound_div_one_sub_of_interval_approx {x : ℝ} (h2 : x ≤ 1 ) :
1962
- (∑ j : ℕ in Finset.range 3 , x ^ j / j.factorial) +
1963
- x ^ 3 * ((3 : ℕ) + 1 ) / ((3 : ℕ).factorial * (3 : ℕ)) ≤
1964
- ∑ j in Finset.range 3 , x ^ j :=
1969
+ theorem exp_bound_div_one_sub_of_interval' {x : ℝ} (h1 : 0 < x) (h2 : x < 1 ) :
1970
+ Real.exp x < 1 / (1 - x) := by
1971
+ have H : 0 < 1 - (1 + x + x ^ 2 ) * (1 - x)
1972
+ · calc
1973
+ 0 < x ^ 3 := by positivity
1974
+ _ = 1 - (1 + x + x ^ 2 ) * (1 - x) := by ring
1965
1975
calc
1966
- (∑ j : ℕ in Finset.range 3 , x ^ j / j.factorial) +
1967
- x ^ 3 * ((3 : ℕ) + 1 ) / ((3 : ℕ).factorial * (3 : ℕ))
1968
- = (2 / 9 ) * x ^ 3 + x ^ 2 / 2 + x + 1 := by simp [Finset.sum]; ring
1969
- _ ≤ x ^ 2 + x + 1 := sub_nonneg.1 <|
1970
- calc 0 ≤ x^2 * (2 / 9 ) * (9 / 4 - x) :=
1971
- mul_nonneg (mul_nonneg (pow_two_nonneg _) (by norm_num : (0 : ℝ) ≤ 2 / 9 ))
1972
- (sub_nonneg.2 (le_trans h2 (by norm_num)))
1973
- _ = _ := by ring
1974
- _ = _ := by simp [Finset.sum]; ring
1975
- #align real.exp_bound_div_one_sub_of_interval_approx Real.exp_bound_div_one_sub_of_interval_approxₓ
1976
+ exp x ≤ _ := exp_bound' h1.le h2.le zero_lt_three
1977
+ _ ≤ 1 + x + x ^ 2 := by
1978
+ -- Porting note: was `norm_num [Finset.sum] <;> nlinarith`
1979
+ -- This proof should be restored after the norm_num plugin for big operators is ported.
1980
+ -- (It may also need the positivity extensions in #3907.)
1981
+ rw [Finset.sum, range_val]
1982
+ nth_rw 1 [← two_add_one_eq_three]
1983
+ rw [← Nat.succ_eq_add_one, Multiset.range_succ, Multiset.map_cons, Multiset.sum_cons]
1984
+ nth_rw 3 [← one_add_one_eq_two]
1985
+ rw [← Nat.succ_eq_add_one, Multiset.range_succ, Multiset.map_cons, Multiset.sum_cons]
1986
+ nth_rw 3 [← zero_add 1 ]
1987
+ rw [← Nat.succ_eq_add_one, Multiset.range_succ, Multiset.map_cons, Multiset.sum_cons]
1988
+ rw [Multiset.range_zero, Multiset.map_zero, Multiset.sum_zero]
1989
+ norm_num
1990
+ nlinarith
1991
+ _ < 1 / (1 - x) := by rw [lt_div_iff] <;> nlinarith
1992
+ #align real.exp_bound_div_one_sub_of_interval' Real.exp_bound_div_one_sub_of_interval'
1976
1993
1977
1994
theorem exp_bound_div_one_sub_of_interval {x : ℝ} (h1 : 0 ≤ x) (h2 : x < 1 ) :
1978
- Real.exp x ≤ 1 / (1 - x) :=
1979
- haveI h : (∑ j in Finset.range 3 , x ^ j) ≤ 1 / (1 - x) := by
1980
- norm_num [Finset.sum]
1981
- have h1x : 0 < 1 - x := by simpa
1982
- rw [inv_eq_one_div, le_div_iff h1x]
1983
- norm_num [← add_assoc, mul_sub_left_distrib, mul_one, add_mul, sub_add_eq_sub_sub,
1984
- pow_succ' x 2 ]
1985
- have hx3 : 0 ≤ x ^ 3 := by
1986
- norm_num
1987
- simp [h1]
1988
- simp [Finset.sum]
1989
- linarith
1990
- (exp_bound' h1 h2.le <| by linarith).trans
1991
- ((exp_bound_div_one_sub_of_interval_approx h2.le).trans h)
1995
+ Real.exp x ≤ 1 / (1 - x) := by
1996
+ rcases eq_or_lt_of_le h1 with (rfl | h1)
1997
+ · simp
1998
+ · exact (exp_bound_div_one_sub_of_interval' h1 h2).le
1992
1999
#align real.exp_bound_div_one_sub_of_interval Real.exp_bound_div_one_sub_of_interval
1993
2000
1994
- theorem one_sub_le_exp_minus_of_pos {y : ℝ} (h : 0 ≤ y) : 1 - y ≤ Real.exp (-y) := by
1995
- rw [Real.exp_neg]
1996
- have r1 : (1 - y) * Real.exp y ≤ 1 := by
1997
- cases le_or_lt (1 - y) 0
1998
- · have h'' : (1 - y) * y.exp ≤ 0 := by
1999
- rw [mul_nonpos_iff]
2000
- right
2001
- exact ⟨by assumption, y.exp_pos.le⟩
2002
- linarith
2003
- have hy1 : y < 1 := by linarith
2004
- rw [← le_div_iff' ‹0 < 1 - y›]
2005
- exact exp_bound_div_one_sub_of_interval h hy1
2006
- rw [inv_eq_one_div]
2007
- rw [le_div_iff' y.exp_pos]
2008
- rwa [mul_comm] at r1
2009
- #align real.one_sub_le_exp_minus_of_pos Real.one_sub_le_exp_minus_of_pos
2010
-
2011
- theorem add_one_le_exp_of_nonpos {x : ℝ} (h : x ≤ 0 ) : x + 1 ≤ Real.exp x := by
2012
- rw [add_comm]
2013
- have h1 : 0 ≤ -x := by linarith
2014
- simpa using one_sub_le_exp_minus_of_pos h1
2015
- #align real.add_one_le_exp_of_nonpos Real.add_one_le_exp_of_nonpos
2001
+ theorem one_sub_lt_exp_minus_of_pos {y : ℝ} (h : 0 < y) : 1 - y < Real.exp (-y) := by
2002
+ cases' le_or_lt 1 y with h' h'
2003
+ · linarith [(-y).exp_pos]
2004
+ rw [exp_neg, lt_inv _ y.exp_pos, inv_eq_one_div]
2005
+ · exact exp_bound_div_one_sub_of_interval' h h'
2006
+ · linarith
2007
+ #align real.one_sub_le_exp_minus_of_pos Real.one_sub_lt_exp_minus_of_pos
2008
+
2009
+ theorem one_sub_le_exp_minus_of_nonneg {y : ℝ} (h : 0 ≤ y) : 1 - y ≤ Real.exp (-y) := by
2010
+ rcases eq_or_lt_of_le h with (rfl | h)
2011
+ · simp
2012
+ · exact (one_sub_lt_exp_minus_of_pos h).le
2013
+ #align real.one_sub_le_exp_minus_of_nonneg Real.one_sub_le_exp_minus_of_nonneg
2014
+
2015
+ theorem add_one_lt_exp_of_neg {x : ℝ} (h : x < 0 ) : x + 1 < Real.exp x := by
2016
+ have h1 : 0 < -x := by linarith
2017
+ simpa [add_comm] using one_sub_lt_exp_minus_of_pos h1
2018
+ #align real.add_one_lt_exp_of_neg Real.add_one_lt_exp_of_neg
2019
+
2020
+ theorem add_one_lt_exp_of_nonzero {x : ℝ} (hx : x ≠ 0 ) : x + 1 < Real.exp x := by
2021
+ cases' lt_or_gt_of_ne hx with h h
2022
+ · exact add_one_lt_exp_of_neg h
2023
+ exact add_one_lt_exp_of_pos h
2024
+ #align real.add_one_lt_exp_of_nonzero Real.add_one_lt_exp_of_nonzero
2016
2025
2017
2026
theorem add_one_le_exp (x : ℝ) : x + 1 ≤ Real.exp x := by
2018
2027
cases' le_or_lt 0 x with h h
2019
2028
· exact Real.add_one_le_exp_of_nonneg h
2020
- exact add_one_le_exp_of_nonpos h .le
2029
+ exact (add_one_lt_exp_of_neg h) .le
2021
2030
#align real.add_one_le_exp Real.add_one_le_exp
2022
2031
2023
2032
theorem one_sub_div_pow_le_exp_neg {n : ℕ} {t : ℝ} (ht' : t ≤ n) : (1 - t / n) ^ n ≤ exp (-t) := by
0 commit comments