Skip to content

Commit 130d1c0

Browse files
committed
fix(Combinatorics.Stirling): add missing colons in comments; inline have
1 parent 6562098 commit 130d1c0

1 file changed

Lines changed: 14 additions & 24 deletions

File tree

Mathlib/Combinatorics/Enumerative/Stirling.lean

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,23 @@ recurrence relations, and establishes some of their key properties and identitie
1818
# The Stirling numbers of the first kind
1919
2020
The unsigned Stirling numbers of the first kind, represent the number of ways
21-
to partition n distinct elements into k non-empty cycles.
21+
to partition `n` distinct elements into `k` non-empty cycles.
2222
2323
# The Stirling numbers of the second kind
2424
2525
The Stirling numbers of the second kind, represent the number of ways to partition
26-
n distinct elements into k non-empty subsets.
26+
`n` distinct elements into `k` non-empty subsets.
2727
2828
# Main definitions
2929
30-
* `Nat.stirlingFirst`: the number of ways to partition n distinct elements into k non-empty
30+
* `Nat.stirlingFirst`: the number of ways to partition `n` distinct elements into `k` non-empty
3131
cycles, defined by the recursive relationship it satisfies.
32-
* `Nat.stirlingSecond`: the number of ways to partition n distinct elements into k non-empty
32+
* `Nat.stirlingSecond`: the number of ways to partition `n` distinct elements into `k` non-empty
3333
subsets, defined by the recursive relationship it satisfies.
3434
35-
# References:
36-
37-
* [Stirling Numbers of the First Kind – ProofWiki](https://proofwiki.org/wiki/Definition:Stirling_Numbers_of_the_First_Kind/Unsigned)
38-
* [Stirling Numbers of the Second Kind – ProofWiki](https://proofwiki.org/wiki/Definition:Stirling_Numbers_of_the_Second_Kind)
35+
## References
3936
37+
* [Knuth, *The Art of Computer Programming*, Volume 1, §1.2.6][knuth1997]
4038
-/
4139

4240
open Nat
@@ -67,15 +65,13 @@ theorem stirlingFirst_succ_zero (n : ℕ) : stirlingFirst (succ n) 0 = 0 :=
6765

6866
theorem stirlingFirst_succ_left (n k : ℕ) (hk : k ≠ 0) :
6967
stirlingFirst (n + 1) k = n * stirlingFirst n k + stirlingFirst n (k - 1) := by
70-
have hk : 0 < k := Nat.pos_of_ne_zero hk
71-
obtain ⟨l, rfl⟩ : ∃ l, k = l + 1 := Nat.exists_eq_add_of_le' hk
68+
obtain ⟨l, rfl⟩ := Nat.exists_eq_add_of_le' (Nat.pos_of_ne_zero hk)
7269
rfl
7370

7471
theorem stirlingFirst_succ_right (n k : ℕ) (hn : n ≠ 0) :
7572
stirlingFirst n (k + 1) =
7673
(n - 1) * stirlingFirst (n - 1) (k + 1) + stirlingFirst (n - 1) k := by
77-
have hn : 0 < n := Nat.pos_of_ne_zero hn
78-
obtain ⟨l, rfl⟩ : ∃ l, n = l + 1 := Nat.exists_eq_add_of_le' hn
74+
obtain ⟨l, rfl⟩ := Nat.exists_eq_add_of_le' (Nat.pos_of_ne_zero hn)
7975
rfl
8076

8177
theorem stirlingFirst_succ_succ (n k : ℕ) :
@@ -86,10 +82,8 @@ theorem stirlingFirst_eq_zero_of_lt : ∀ {n k : ℕ}, n < k → stirlingFirst n
8682
| _, 0, hk => absurd hk (Nat.not_lt_zero _)
8783
| 0, _ + 1, _ => by rw [stirlingFirst]
8884
| n + 1, k + 1, hk => by
89-
have hnk : n < k := Nat.lt_of_succ_lt_succ hk
90-
have hnk1 : n < k + 1 := Nat.lt_of_succ_lt hk
91-
rw [stirlingFirst_succ_succ, stirlingFirst_eq_zero_of_lt hnk,
92-
stirlingFirst_eq_zero_of_lt hnk1, mul_zero]
85+
rw [stirlingFirst_succ_succ, stirlingFirst_eq_zero_of_lt (Nat.lt_of_succ_lt_succ hk),
86+
stirlingFirst_eq_zero_of_lt (Nat.lt_of_succ_lt hk), mul_zero]
9387

9488
theorem stirlingFirst_self (n : ℕ) : stirlingFirst n n = 1 := by
9589
induction n <;> simp only [*, stirlingFirst, stirlingFirst_eq_zero_of_lt (Nat.lt_succ_self _),
@@ -133,15 +127,13 @@ theorem stirlingSecond_succ_zero (n : ℕ) : stirlingSecond (succ n) 0 = 0 :=
133127

134128
theorem stirlingSecond_succ_left (n k : ℕ) (hk : k ≠ 0) :
135129
stirlingSecond (n + 1) k = k * stirlingSecond n k + stirlingSecond n (k - 1) := by
136-
have hk : 0 < k := Nat.pos_of_ne_zero hk
137-
obtain ⟨l, rfl⟩ : ∃ l, k = l + 1 := Nat.exists_eq_add_of_le' hk
130+
obtain ⟨l, rfl⟩ := Nat.exists_eq_add_of_le' (Nat.pos_of_ne_zero hk)
138131
rfl
139132

140133
theorem stirlingSecond_succ_right (n k : ℕ) (hn : n ≠ 0) :
141134
stirlingSecond n (k + 1) =
142135
(k + 1) * stirlingSecond (n - 1) (k + 1) + stirlingSecond (n - 1) k := by
143-
have hn : 0 < n := Nat.pos_of_ne_zero hn
144-
obtain ⟨l, rfl⟩ : ∃ l, n = l + 1 := Nat.exists_eq_add_of_le' hn
136+
obtain ⟨l, rfl⟩ := Nat.exists_eq_add_of_le' (Nat.pos_of_ne_zero hn)
145137
rfl
146138

147139
theorem stirlingSecond_succ_succ (n k : ℕ) :
@@ -152,10 +144,8 @@ theorem stirlingSecond_eq_zero_of_lt : ∀ {n k : ℕ}, n < k → stirlingSecond
152144
| _, 0, hk => absurd hk (Nat.not_lt_zero _)
153145
| 0, _ + 1, _ => by rw [stirlingSecond]
154146
| n + 1, k + 1, hk => by
155-
have hnk : n < k := Nat.lt_of_succ_lt_succ hk
156-
have hnk1 : n < k + 1 := Nat.lt_of_succ_lt hk
157-
simp only [stirlingSecond_succ_succ, stirlingSecond_eq_zero_of_lt hnk,
158-
stirlingSecond_eq_zero_of_lt hnk1, mul_zero]
147+
simp only [stirlingSecond_succ_succ, stirlingSecond_eq_zero_of_lt (Nat.lt_of_succ_lt_succ hk),
148+
stirlingSecond_eq_zero_of_lt (Nat.lt_of_succ_lt hk), mul_zero]
159149

160150
theorem stirlingSecond_self (n : ℕ) : stirlingSecond n n = 1 := by
161151
induction n <;> simp only [*, stirlingSecond, stirlingSecond_eq_zero_of_lt (lt_succ_self _),

0 commit comments

Comments
 (0)