Skip to content

Commit

Permalink
chore: rm @simp from factorial (#7078)
Browse files Browse the repository at this point in the history
Co-authored-by: Moritz Firsching <firsching@google.com>
  • Loading branch information
mo271 and mo271 committed Sep 19, 2023
1 parent 6af751e commit fe39449
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Mathlib/Algebra/BigOperators/Intervals.lean
Expand Up @@ -191,7 +191,7 @@ theorem prod_Ico_id_eq_factorial : ∀ n : ℕ, (∏ x in Ico 1 (n + 1), x) = n
@[simp]
theorem prod_range_add_one_eq_factorial : ∀ n : ℕ, (∏ x in range n, (x + 1)) = n !
| 0 => rfl
| n + 1 => by simp [Finset.range_succ, prod_range_add_one_eq_factorial n]
| n + 1 => by simp [factorial, Finset.range_succ, prod_range_add_one_eq_factorial n]
#align finset.prod_range_add_one_eq_factorial Finset.prod_range_add_one_eq_factorial

section GaussSum
Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Analysis/Calculus/Taylor.lean
Expand Up @@ -118,7 +118,7 @@ theorem taylor_within_apply (f : ℝ → E) (n : ℕ) (s : Set ℝ) (x₀ x :
induction' n with k hk
· simp
rw [taylorWithinEval_succ, Finset.sum_range_succ, hk]
simp
simp [Nat.factorial]
#align taylor_within_apply taylor_within_apply

/-- If `f` is `n` times continuous differentiable on a set `s`, then the Taylor polynomial
Expand Down Expand Up @@ -285,7 +285,7 @@ theorem taylor_mean_remainder_lagrange {f : ℝ → ℝ} {x x₀ : ℝ} {n : ℕ
use y, hy
simp only [sub_self, zero_pow', Ne.def, Nat.succ_ne_zero, not_false_iff, zero_sub, mul_neg] at h
rw [h, neg_div, ← div_neg, neg_mul, neg_neg]
field_simp [xy_ne y hy]; ring
field_simp [xy_ne y hy, Nat.factorial]; ring
#align taylor_mean_remainder_lagrange taylor_mean_remainder_lagrange

/-- **Taylor's theorem** with the Cauchy form of the remainder.
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Analysis/SpecialFunctions/Exponential.lean
Expand Up @@ -69,7 +69,7 @@ theorem hasStrictFDerivAt_exp_zero_of_radius_pos (h : 0 < (expSeries 𝕂 𝔸).
convert (hasFPowerSeriesAt_exp_zero_of_radius_pos h).hasStrictFDerivAt
ext x
change x = expSeries 𝕂 𝔸 1 fun _ => x
simp [expSeries_apply_eq]
simp [expSeries_apply_eq, Nat.factorial]
#align has_strict_fderiv_at_exp_zero_of_radius_pos hasStrictFDerivAt_exp_zero_of_radius_pos

/-- The exponential in a Banach algebra `𝔸` over a normed field `𝕂` has Fréchet derivative
Expand Down
3 changes: 2 additions & 1 deletion Mathlib/Analysis/SpecialFunctions/Gamma/BohrMollerup.lean
Expand Up @@ -397,7 +397,8 @@ end BohrMollerup
-- (section)
section StrictMono

theorem Gamma_two : Gamma 2 = 1 := by simpa [one_add_one_eq_two] using Gamma_nat_eq_factorial 1
theorem Gamma_two : Gamma 2 = 1 := by
simpa [one_add_one_eq_two, Nat.factorial] using Gamma_nat_eq_factorial 1
#align real.Gamma_two Real.Gamma_two

theorem Gamma_three_div_two_lt_one : Gamma (3 / 2) < 1 := by
Expand Down
24 changes: 13 additions & 11 deletions Mathlib/Data/Complex/Exponential.lean
Expand Up @@ -1468,7 +1468,9 @@ theorem sum_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) (n : ℕ) : ∑ i in range

theorem quadratic_le_exp_of_nonneg {x : ℝ} (hx : 0 ≤ x) : 1 + x + x ^ 2 / 2 ≤ exp x :=
calc
1 + x + x ^ 2 / 2 = ∑ i in range 3, x ^ i / i ! := by simp [Finset.sum_range_succ]; ring_nf
1 + x + x ^ 2 / 2 = ∑ i in range 3, x ^ i / i ! := by
simp [factorial, Finset.sum_range_succ]
ring_nf
_ ≤ exp x := sum_le_exp_of_nonneg hx 3
#align real.quadratic_le_exp_of_nonneg Real.quadratic_le_exp_of_nonneg

Expand Down Expand Up @@ -1682,16 +1684,16 @@ theorem abs_exp_sub_one_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1) ≤ 2
abs (exp x - 1) = abs (exp x - ∑ m in range 1, x ^ m / m.factorial) := by simp [sum_range_succ]
_ ≤ abs x ^ 1 * ((Nat.succ 1 : ℝ) * ((Nat.factorial 1) * (1 : ℕ) : ℝ)⁻¹) :=
(exp_bound hx (by decide))
_ = 2 * abs x := by simp [two_mul, mul_two, mul_add, mul_comm, add_mul]
_ = 2 * abs x := by simp [two_mul, mul_two, mul_add, mul_comm, add_mul, Nat.factorial]
#align complex.abs_exp_sub_one_le Complex.abs_exp_sub_one_le

theorem abs_exp_sub_one_sub_id_le {x : ℂ} (hx : abs x ≤ 1) : abs (exp x - 1 - x) ≤ abs x ^ 2 :=
calc
abs (exp x - 1 - x) = abs (exp x - ∑ m in range 2, x ^ m / m.factorial) := by
simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc]
simp [sub_eq_add_neg, sum_range_succ_comm, add_assoc, Nat.factorial]
_ ≤ abs x ^ 2 * ((Nat.succ 2 : ℝ) * (Nat.factorial 2 * (2 : ℕ) : ℝ)⁻¹) :=
(exp_bound hx (by decide))
_ ≤ abs x ^ 2 * 1 := by gcongr; norm_num
_ ≤ abs x ^ 2 * 1 := by gcongr; norm_num [Nat.factorial]
_ = abs x ^ 2 := by rw [mul_one]
#align complex.abs_exp_sub_one_sub_id_le Complex.abs_exp_sub_one_sub_id_le

Expand Down Expand Up @@ -1756,7 +1758,7 @@ theorem expNear_zero (x r) : expNear 0 x r = r := by simp [expNear]
@[simp]
theorem expNear_succ (n x r) : expNear (n + 1) x r = expNear n x (1 + x / (n + 1) * r) := by
simp [expNear, range_succ, mul_add, add_left_comm, add_assoc, pow_succ, div_eq_mul_inv,
mul_inv]
mul_inv, Nat.factorial]
ac_rfl
#align real.exp_near_succ Real.expNear_succ

Expand All @@ -1781,7 +1783,7 @@ theorem exp_approx_succ {n} {x a₁ b₁ : ℝ} (m : ℕ) (e₁ : n + 1 = m) (a
subst e₁; rw [expNear_succ, expNear_sub, abs_mul]
convert mul_le_mul_of_nonneg_left (a := abs' x ^ n / ↑(Nat.factorial n))
(le_sub_iff_add_le'.1 e) ?_ using 1
· simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, ← pow_abs, mul_inv]
· simp [mul_add, pow_succ', div_eq_mul_inv, abs_mul, abs_inv, ← pow_abs, mul_inv, Nat.factorial]
ac_rfl
· simp [div_nonneg, abs_nonneg]
#align real.exp_approx_succ Real.exp_approx_succ
Expand Down Expand Up @@ -1818,7 +1820,7 @@ theorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x|
(congr_arg (fun x : ℂ => x / 2)
(by
simp only [sum_range_succ]
simp [pow_succ]
simp [pow_succ, Nat.factorial]
apply Complex.ext <;> simp [div_eq_mul_inv, normSq] <;> ring_nf
)))
_ ≤ abs ((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) / 2) +
Expand All @@ -1832,7 +1834,7 @@ theorem cos_bound {x : ℝ} (hx : |x| ≤ 1) : |cos x - (1 - x ^ 2 / 2)| ≤ |x|
gcongr
· exact Complex.exp_bound (by simpa) (by decide)
· exact Complex.exp_bound (by simpa) (by decide)
_ ≤ |x| ^ 4 * (5 / 96) := by norm_num
_ ≤ |x| ^ 4 * (5 / 96) := by norm_num [Nat.factorial]
#align real.cos_bound Real.cos_bound

theorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x| ^ 4 * (5 / 96) :=
Expand All @@ -1849,7 +1851,7 @@ theorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x|
(congr_arg (fun x : ℂ => x / 2)
(by
simp only [sum_range_succ]
simp [pow_succ]
simp [pow_succ, Nat.factorial]
apply Complex.ext <;> simp [div_eq_mul_inv, normSq]; ring)))
_ ≤ abs ((Complex.exp (-x * I) - ∑ m in range 4, (-x * I) ^ m / m.factorial) * I / 2) +
abs (-((Complex.exp (x * I) - ∑ m in range 4, (x * I) ^ m / m.factorial) * I) / 2) :=
Expand All @@ -1862,7 +1864,7 @@ theorem sin_bound {x : ℝ} (hx : |x| ≤ 1) : |sin x - (x - x ^ 3 / 6)| ≤ |x|
gcongr
· exact Complex.exp_bound (by simpa) (by decide)
· exact Complex.exp_bound (by simpa) (by decide)
_ ≤ |x| ^ 4 * (5 / 96) := by norm_num
_ ≤ |x| ^ 4 * (5 / 96) := by norm_num [Nat.factorial]
#align real.sin_bound Real.sin_bound

theorem cos_pos_of_le_one {x : ℝ} (hx : |x| ≤ 1) : 0 < cos x :=
Expand Down Expand Up @@ -1941,7 +1943,7 @@ theorem exp_bound_div_one_sub_of_interval' {x : ℝ} (h1 : 0 < x) (h2 : x < 1) :
-- This proof should be restored after the norm_num plugin for big operators is ported.
-- (It may also need the positivity extensions in #3907.)
repeat erw [Finset.sum_range_succ]
norm_num
norm_num [Nat.factorial]
nlinarith
_ < 1 / (1 - x) := by rw [lt_div_iff] <;> nlinarith
#align real.exp_bound_div_one_sub_of_interval' Real.exp_bound_div_one_sub_of_interval'
Expand Down
1 change: 0 additions & 1 deletion Mathlib/Data/Nat/Factorial/Basic.lean
Expand Up @@ -27,7 +27,6 @@ This file defines the factorial, along with the ascending and descending variant
namespace Nat

/-- `Nat.factorial n` is the factorial of `n`. -/
@[simp]
def factorial : ℕ → ℕ
| 0 => 1
| succ n => succ n * factorial n
Expand Down
2 changes: 1 addition & 1 deletion Mathlib/Data/Nat/Multiplicity.lean
Expand Up @@ -297,7 +297,7 @@ theorem multiplicity_two_factorial_lt : ∀ {n : ℕ} (_ : n ≠ 0), multiplicit
· simpa [bit0_eq_two_mul n]
· suffices multiplicity 2 (2 * n + 1) + multiplicity 2 (2 * n)! < ↑(2 * n) + 1 by
simpa [succ_eq_add_one, multiplicity.mul, h2, prime_two, Nat.bit1_eq_succ_bit0,
bit0_eq_two_mul n]
bit0_eq_two_mul n, factorial]
rw [multiplicity_eq_zero.2 (two_not_dvd_two_mul_add_one n), zero_add]
refine' this.trans _
exact_mod_cast lt_succ_self _
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/NumberTheory/Bernoulli.lean
Expand Up @@ -163,7 +163,7 @@ theorem bernoulli'PowerSeries_mul_exp_sub_one :
rw [bernoulli'PowerSeries, coeff_mul, mul_comm X, sum_antidiagonal_succ']
suffices (∑ p in antidiagonal n,
bernoulli' p.1 / p.1! * ((p.2 + 1) * p.2! : ℚ)⁻¹) = (n ! : ℚ)⁻¹ by
simpa [map_sum] using congr_arg (algebraMap ℚ A) this
simpa [map_sum, Nat.factorial] using congr_arg (algebraMap ℚ A) this
apply eq_inv_of_mul_eq_one_left
rw [sum_mul]
convert bernoulli'_spec' n using 1
Expand All @@ -185,7 +185,7 @@ theorem bernoulli'_odd_eq_zero {n : ℕ} (h_odd : Odd n) (hlt : 1 < n) : bernoul
· apply eq_zero_of_neg_eq
specialize h n
split_ifs at h <;> simp_all [h_odd.neg_one_pow, factorial_ne_zero]
· simpa using h 1
· simpa [Nat.factorial] using h 1
have h : B * (exp ℚ - 1) = X * exp ℚ := by
simpa [bernoulli'PowerSeries] using bernoulli'PowerSeries_mul_exp_sub_one ℚ
rw [sub_mul, h, mul_sub X, sub_right_inj, ← neg_sub, mul_neg, neg_eq_iff_eq_neg]
Expand Down Expand Up @@ -368,7 +368,7 @@ theorem sum_range_pow (n p : ℕ) :
-- massage `hps` into our goal
rw [hps, sum_mul]
refine' sum_congr rfl fun x _ => _
field_simp [mul_right_comm _ ↑p !, ← mul_assoc _ _ ↑p !]
field_simp [mul_right_comm _ ↑p !, ← mul_assoc _ _ ↑p !, factorial]
ring
#align sum_range_pow sum_range_pow

Expand Down
6 changes: 3 additions & 3 deletions Mathlib/NumberTheory/ZetaValues.lean
Expand Up @@ -362,13 +362,13 @@ section Examples
theorem hasSum_zeta_two : HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 2) (π ^ 2 / 6) := by
convert hasSum_zeta_nat one_ne_zero using 1; rw [mul_one]
rw [bernoulli_eq_bernoulli'_of_ne_one (by decide : 21), bernoulli'_two]
norm_num; field_simp; ring
norm_num [Nat.factorial]; field_simp; ring
#align has_sum_zeta_two hasSum_zeta_two

theorem hasSum_zeta_four : HasSum (fun n : ℕ => (1 : ℝ) / (n : ℝ) ^ 4) (π ^ 4 / 90) := by
convert hasSum_zeta_nat two_ne_zero using 1; norm_num
rw [bernoulli_eq_bernoulli'_of_ne_one, bernoulli'_four]
norm_num; field_simp; ring; decide
norm_num [Nat.factorial]; field_simp; ring; decide
#align has_sum_zeta_four hasSum_zeta_four

theorem Polynomial.bernoulli_three_eval_one_quarter :
Expand Down Expand Up @@ -398,7 +398,7 @@ theorem hasSum_L_function_mod_four_eval_three :
· have : (1 / 4 : ℝ) = (algebraMap ℚ ℝ) (1 / 4 : ℚ) := by norm_num
rw [this, mul_pow, Polynomial.eval_map, Polynomial.eval₂_at_apply, (by decide : 2 * 1 + 1 = 3),
Polynomial.bernoulli_three_eval_one_quarter]
norm_num; field_simp; ring
norm_num [Nat.factorial]; field_simp; ring
· rw [mem_Icc]; constructor; linarith; linarith
set_option linter.uppercaseLean3 false in
#align has_sum_L_function_mod_four_eval_three hasSum_L_function_mod_four_eval_three
Expand Down

0 comments on commit fe39449

Please sign in to comment.