Skip to content

Commit 025eb7b

Browse files
committed
chore(Data/Nat/{Factorial, Choose}/Cast): move lemmas about Polynomial (#30745)
The remaining lemmas in the files are unrelated to `ascPochhammer` and `descPochhammer`. This significantly reduces the imports.
1 parent 190067e commit 025eb7b

File tree

4 files changed

+57
-44
lines changed

4 files changed

+57
-44
lines changed

Mathlib/Analysis/SpecialFunctions/Pochhammer.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Authors: Mitchell Horner
66
import Mathlib.Algebra.BigOperators.Field
77
import Mathlib.Analysis.Convex.Deriv
88
import Mathlib.Analysis.Convex.Piecewise
9-
import Mathlib.Data.Nat.Choose.Cast
109
import Mathlib.Analysis.Convex.Jensen
1110

1211
/-!

Mathlib/Data/Nat/Choose/Cast.lean

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Copyright (c) 2021 Yaël Dillies. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yaël Dillies
55
-/
6+
import Mathlib.Algebra.Field.Defs
7+
import Mathlib.Algebra.GroupWithZero.Units.Basic
68
import Mathlib.Data.Nat.Choose.Basic
79
import Mathlib.Data.Nat.Factorial.Cast
810

@@ -23,31 +25,21 @@ section DivisionSemiring
2325
variable [DivisionSemiring K] [CharZero K]
2426

2527
theorem cast_choose {a b : ℕ} (h : a ≤ b) : (b.choose a : K) = b ! / (a ! * (b - a)!) := by
26-
have : ∀ {n : ℕ}, (n ! : K) ≠ 0 := Nat.cast_ne_zero.2 (by positivity)
28+
have : ∀ {n : ℕ}, (n ! : K) ≠ 0 := Nat.cast_ne_zero.2 (factorial_pos _).ne'
2729
rw [eq_div_iff_mul_eq (mul_ne_zero this this)]
2830
rw_mod_cast [← mul_assoc, choose_mul_factorial_mul_factorial h]
2931

3032
theorem cast_add_choose {a b : ℕ} : ((a + b).choose a : K) = (a + b)! / (a ! * b !) := by
31-
rw [cast_choose K (_root_.le_add_right le_rfl), add_tsub_cancel_left]
32-
33-
theorem cast_choose_eq_ascPochhammer_div (a b : ℕ) :
34-
(a.choose b : K) = (ascPochhammer K b).eval ↑(a - (b - 1)) / b ! := by
35-
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul,
36-
mul_comm, ← descFactorial_eq_factorial_mul_choose, ← cast_descFactorial]
33+
rw [cast_choose K (le_add_right _ _), Nat.add_sub_cancel_left]
3734

3835
end DivisionSemiring
3936

4037
section DivisionRing
41-
variable [DivisionRing K] [CharZero K]
42-
43-
theorem cast_choose_eq_descPochhammer_div (a b : ℕ) :
44-
(a.choose b : K) = (descPochhammer K b).eval ↑a / b ! := by
45-
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul,
46-
mul_comm, ← descFactorial_eq_factorial_mul_choose, descPochhammer_eval_eq_descFactorial]
38+
variable [DivisionRing K] [NeZero (2 : K)]
4739

4840
theorem cast_choose_two (a : ℕ) : (a.choose 2 : K) = a * (a - 1) / 2 := by
4941
rw [← cast_descFactorial_two, descFactorial_eq_factorial_mul_choose, factorial_two, mul_comm,
50-
cast_mul, cast_two, eq_div_iff_mul_eq (two_ne_zero : (2 : K) ≠ 0)]
42+
cast_mul, cast_two, eq_div_iff_mul_eq two_ne_zero]
5143

5244
end DivisionRing
5345
end Nat

Mathlib/Data/Nat/Factorial/Cast.lean

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Copyright (c) 2021 Yaël Dillies. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Yaël Dillies
55
-/
6-
import Mathlib.RingTheory.Polynomial.Pochhammer
6+
import Mathlib.Data.Nat.Cast.Basic
7+
import Mathlib.Data.Nat.Factorial.Basic
78

89
/-!
910
# Cast of factorials
@@ -24,43 +25,17 @@ variable (S : Type*)
2425

2526
namespace Nat
2627

27-
section Semiring
28-
29-
variable [Semiring S] (a b : ℕ)
30-
31-
theorem cast_ascFactorial : a.ascFactorial b = (ascPochhammer S b).eval (a : S) := by
32-
rw [← ascPochhammer_nat_eq_ascFactorial, ascPochhammer_eval_cast]
33-
34-
theorem cast_descFactorial :
35-
a.descFactorial b = (ascPochhammer S b).eval (a - (b - 1) : S) := by
36-
rw [← ascPochhammer_eval_cast, ascPochhammer_nat_eq_descFactorial]
37-
induction b with
38-
| zero => simp
39-
| succ b =>
40-
simp_rw [add_succ, Nat.add_one_sub_one]
41-
obtain h | h := le_total a b
42-
· rw [descFactorial_of_lt (lt_succ_of_le h), descFactorial_of_lt (lt_succ_of_le _)]
43-
rw [tsub_eq_zero_iff_le.mpr h, zero_add]
44-
· rw [tsub_add_cancel_of_le h]
45-
46-
theorem cast_factorial : (a ! : S) = (ascPochhammer S a).eval 1 := by
47-
rw [← one_ascFactorial, cast_ascFactorial, cast_one]
48-
49-
end Semiring
50-
5128
section Ring
5229

5330
variable [Ring S] (a b : ℕ)
5431

5532
/-- Convenience lemma. The `a - 1` is not using truncated subtraction, as opposed to the definition
5633
of `Nat.descFactorial` as a natural. -/
5734
theorem cast_descFactorial_two : (a.descFactorial 2 : S) = a * (a - 1) := by
58-
rw [cast_descFactorial]
35+
rw [descFactorial]
5936
cases a
6037
· simp
61-
· rw [succ_sub_succ, tsub_zero, cast_succ, add_sub_cancel_right, ascPochhammer_succ_right,
62-
ascPochhammer_one, Polynomial.X_mul, Polynomial.eval_mul_X, Polynomial.eval_add,
63-
Polynomial.eval_X, cast_one, Polynomial.eval_one]
38+
· simp [mul_add, add_mul]
6439

6540
end Ring
6641

Mathlib/RingTheory/Polynomial/Pochhammer.lean

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,29 @@ theorem ascPochhammer_eval_succ (r n : ℕ) :
228228
(n + r) * (ascPochhammer S r).eval (n : S) :=
229229
mod_cast congr_arg Nat.cast (ascPochhammer_nat_eval_succ r n)
230230

231+
namespace Nat
232+
variable (a b : ℕ)
233+
234+
theorem cast_ascFactorial : a.ascFactorial b = (ascPochhammer S b).eval (a : S) := by
235+
rw [← ascPochhammer_nat_eq_ascFactorial, ascPochhammer_eval_cast]
236+
237+
theorem cast_descFactorial :
238+
a.descFactorial b = (ascPochhammer S b).eval (a - (b - 1) : S) := by
239+
rw [← ascPochhammer_eval_cast, ascPochhammer_nat_eq_descFactorial]
240+
induction b with
241+
| zero => simp
242+
| succ b =>
243+
simp_rw [add_succ, Nat.add_one_sub_one]
244+
obtain h | h := le_total a b
245+
· rw [descFactorial_of_lt (lt_succ_of_le h), descFactorial_of_lt (lt_succ_of_le _)]
246+
rw [tsub_eq_zero_iff_le.mpr h, zero_add]
247+
· rw [tsub_add_cancel_of_le h]
248+
249+
theorem cast_factorial : (a ! : S) = (ascPochhammer S a).eval 1 := by
250+
rw [← one_ascFactorial, cast_ascFactorial, cast_one]
251+
252+
end Nat
253+
231254
end Factorial
232255

233256
section Ring
@@ -484,3 +507,27 @@ theorem monotoneOn_descPochhammer_eval (n : ℕ) :
484507
(sub_nonneg_of_le ha) (descPochhammer_nonneg hb_sub1)
485508

486509
end StrictOrderedRing
510+
511+
variable (K : Type*)
512+
513+
namespace Nat
514+
section DivisionSemiring
515+
variable [DivisionSemiring K] [CharZero K]
516+
517+
theorem cast_choose_eq_ascPochhammer_div (a b : ℕ) :
518+
(a.choose b : K) = (ascPochhammer K b).eval ↑(a - (b - 1)) / b ! := by
519+
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul,
520+
mul_comm, ← descFactorial_eq_factorial_mul_choose, ← cast_descFactorial]
521+
522+
end DivisionSemiring
523+
524+
section DivisionRing
525+
variable [DivisionRing K] [CharZero K]
526+
527+
theorem cast_choose_eq_descPochhammer_div (a b : ℕ) :
528+
(a.choose b : K) = (descPochhammer K b).eval ↑a / b ! := by
529+
rw [eq_div_iff_mul_eq (cast_ne_zero.2 b.factorial_ne_zero : (b ! : K) ≠ 0), ← cast_mul,
530+
mul_comm, ← descFactorial_eq_factorial_mul_choose, descPochhammer_eval_eq_descFactorial]
531+
532+
end DivisionRing
533+
end Nat

0 commit comments

Comments
 (0)