Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 2d34e94

Browse files
committed
chore(*big_operators*): line length (#4504)
1 parent 6b50fb9 commit 2d34e94

File tree

2 files changed

+67
-30
lines changed

2 files changed

+67
-30
lines changed

src/algebra/big_operators/basic.lean

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ variables {α : Type u} {β : Type v} {γ : Type w}
3434

3535
namespace finset
3636

37-
/-- `∏ x in s, f x` is the product of `f x` as `x` ranges over the elements of the finite set `s`. -/
37+
/--
38+
`∏ x in s, f x` is the product of `f x`
39+
as `x` ranges over the elements of the finite set `s`.
40+
-/
3841
@[to_additive "`∑ x in s, f` is the sum of `f x` as `x` ranges over the elements
3942
of the finite set `s`."]
4043
protected def prod [comm_monoid β] (s : finset α) (f : α → β) : β := (s.1.map f).prod
@@ -66,11 +69,15 @@ In practice, this means that parentheses should be placed as follows:
6669
(Example taken from page 490 of Knuth's *Concrete Mathematics*.)
6770
-/
6871

69-
localized "notation `∑` binders `, ` r:(scoped:67 f, finset.sum finset.univ f) := r" in big_operators
70-
localized "notation `∏` binders `, ` r:(scoped:67 f, finset.prod finset.univ f) := r" in big_operators
72+
localized "notation `∑` binders `, ` r:(scoped:67 f, finset.sum finset.univ f) := r"
73+
in big_operators
74+
localized "notation `∏` binders `, ` r:(scoped:67 f, finset.prod finset.univ f) := r"
75+
in big_operators
7176

72-
localized "notation `∑` binders ` in ` s `, ` r:(scoped:67 f, finset.sum s f) := r" in big_operators
73-
localized "notation `∏` binders ` in ` s `, ` r:(scoped:67 f, finset.prod s f) := r" in big_operators
77+
localized "notation `∑` binders ` in ` s `, ` r:(scoped:67 f, finset.sum s f) := r"
78+
in big_operators
79+
localized "notation `∏` binders ` in ` s `, ` r:(scoped:67 f, finset.prod s f) := r"
80+
in big_operators
7481

7582
open_locale big_operators
7683

@@ -81,7 +88,9 @@ variables {s s₁ s₂ : finset α} {a : α} {f g : α → β}
8188
∏ x in s, f x = (s.1.map f).prod := rfl
8289

8390
@[to_additive]
84-
theorem prod_eq_fold [comm_monoid β] (s : finset α) (f : α → β) : (∏ x in s, f x) = s.fold (*) 1 f := rfl
91+
theorem prod_eq_fold [comm_monoid β] (s : finset α) (f : α → β) :
92+
(∏ x in s, f x) = s.fold (*) 1 f :=
93+
rfl
8594

8695
end finset
8796

@@ -113,8 +122,7 @@ lemma ring_hom.map_multiset_sum [semiring β] [semiring γ] (f : β →+* γ) (s
113122
f s.sum = (s.map f).sum :=
114123
f.to_add_monoid_hom.map_multiset_sum s
115124

116-
lemma ring_hom.map_prod [comm_semiring β] [comm_semiring γ]
117-
(g : β →+* γ) (f : α → β) (s : finset α) :
125+
lemma ring_hom.map_prod [comm_semiring β] [comm_semiring γ] (g : β →+* γ) (f : α → β) (s : finset α) :
118126
g (∏ x in s, f x) = ∏ x in s, g (f x) :=
119127
g.to_monoid_hom.map_prod f s
120128

@@ -137,10 +145,11 @@ lemma prod_insert [decidable_eq α] :
137145
a ∉ s → (∏ x in (insert a s), f x) = f a * ∏ x in s, f x := fold_insert
138146

139147
/--
140-
The product of `f` over `insert a s` is the same as the product over `s`, as long as `a` is in `s` or `f a = 1`.
148+
The product of `f` over `insert a s` is the same as
149+
the product over `s`, as long as `a` is in `s` or `f a = 1`.
141150
-/
142-
@[simp, to_additive "The sum of `f` over `insert a s` is the same as the sum over `s`, as long as `a` is in `s` or `f a = 0`.
143-
"]
151+
@[simp, to_additive "The sum of `f` over `insert a s` is the same as
152+
the sum over `s`, as long as `a` is in `s` or `f a = 0`."]
144153
lemma prod_insert_of_eq_one_if_not_mem [decidable_eq α] (h : a ∉ s → f a = 1) :
145154
∏ x in insert a s, f x = ∏ x in s, f x :=
146155
begin
@@ -152,7 +161,8 @@ end
152161
/--
153162
The product of `f` over `insert a s` is the same as the product over `s`, as long as `f a = 1`.
154163
-/
155-
@[simp, to_additive "The sum of `f` over `insert a s` is the same as the sum over `s`, as long as `f a = 0`."]
164+
@[simp, to_additive "The sum of `f` over `insert a s` is the same as
165+
the sum over `s`, as long as `f a = 0`."]
156166
lemma prod_insert_one [decidable_eq α] (h : f a = 1) :
157167
∏ x in insert a s, f x = ∏ x in s, f x :=
158168
prod_insert_of_eq_one_if_not_mem (λ _, h)
@@ -220,7 +230,8 @@ end
220230

221231
@[to_additive]
222232
lemma prod_bind [decidable_eq α] {s : finset γ} {t : γ → finset α} :
223-
(∀x∈s, ∀y∈s, x ≠ y → disjoint (t x) (t y)) → (∏ x in (s.bind t), f x) = ∏ x in s, ∏ i in t x, f i :=
233+
(∀ x ∈ s, ∀ y ∈ s, x ≠ y → disjoint (t x) (t y)) →
234+
(∏ x in (s.bind t), f x) = ∏ x in s, ∏ i in t x, f i :=
224235
by haveI := classical.dec_eq γ; exact
225236
finset.induction_on s (λ _, by simp only [bind_empty, prod_empty])
226237
(assume x s hxs ih hd,
@@ -313,7 +324,8 @@ lemma prod_hom_rel [comm_monoid γ] {r : β → γ → Prop} {f : α → β} {g
313324
by { delta finset.prod, apply multiset.prod_hom_rel; assumption }
314325

315326
@[to_additive]
316-
lemma prod_subset (h : s₁ ⊆ s₂) (hf : ∀x∈s₂, x ∉ s₁ → f x = 1) : (∏ x in s₁, f x) = ∏ x in s₂, f x :=
327+
lemma prod_subset (h : s₁ ⊆ s₂) (hf : ∀ x ∈ s₂, x ∉ s₁ → f x = 1) :
328+
(∏ x in s₁, f x) = ∏ x in s₂, f x :=
317329
by haveI := classical.dec_eq α; exact
318330
have ∏ x in s₂ \ s₁, f x = ∏ x in s₂ \ s₁, 1,
319331
from prod_congr rfl $ by simpa only [mem_sdiff, and_imp],
@@ -431,7 +443,8 @@ calc ∏ x in s, h (if hx : p x then f x hx else g x hx)
431443
{p : α → Prop} {hp : decidable_pred p} (f g : α → γ) (h : γ → β) :
432444
(∏ x in s, h (if p x then f x else g x)) =
433445
(∏ x in s.filter p, h (f x)) * (∏ x in s.filter (λ x, ¬ p x), h (g x)) :=
434-
trans (prod_apply_dite _ _ _) (congr_arg2 _ (@prod_attach _ _ _ _ (h ∘ f)) (@prod_attach _ _ _ _ (h ∘ g)))
446+
trans (prod_apply_dite _ _ _)
447+
(congr_arg2 _ (@prod_attach _ _ _ _ (h ∘ f)) (@prod_attach _ _ _ _ (h ∘ g)))
435448

436449
@[to_additive] lemma prod_dite {s : finset α} {p : α → Prop} {hp : decidable_pred p}
437450
(f : Π (x : α), p x → β) (g : Π (x : α), ¬p x → β) :
@@ -536,7 +549,8 @@ calc (∏ x in s, f x) = ∏ x in (s.filter $ λx, f x ≠ 1), f x : prod_filter
536549
⟨hi₁ a h₁ h₂, λ hg, h₂ (hg ▸ h a h₁ h₂)⟩)
537550
(assume a ha, (mem_filter.mp ha).elim $ h a)
538551
(assume a₁ a₂ ha₁ ha₂,
539-
(mem_filter.mp ha₁).elim $ λha₁₁ ha₁₂, (mem_filter.mp ha₂).elim $ λha₂₁ ha₂₂, hi₂ a₁ a₂ _ _ _ _)
552+
(mem_filter.mp ha₁).elim $ λ ha₁₁ ha₁₂,
553+
(mem_filter.mp ha₂).elim $ λ ha₂₁ ha₂₂, hi₂ a₁ a₂ _ _ _ _)
540554
(assume b hb, (mem_filter.mp hb).elim $ λh₁ h₂,
541555
let ⟨a, ha₁, ha₂, eq⟩ := hi₃ b h₁ h₂ in ⟨a, mem_filter.mpr ⟨ha₁, ha₂⟩, eq⟩)
542556
... = (∏ x in t, g x) : prod_filter_ne_one
@@ -601,16 +615,20 @@ begin
601615
{ rw [prod_cons, to_finset_cons, finset.insert_eq_of_mem has, ih,
602616
← finset.insert_erase has, finset.prod_insert (finset.not_mem_erase _ _),
603617
finset.prod_insert (finset.not_mem_erase _ _), ← mul_assoc, count_cons_self, pow_succ],
604-
congr' 1, refine finset.prod_congr rfl (λ x hx, _), rw [count_cons_of_ne (finset.ne_of_mem_erase hx)] },
618+
congr' 1, refine finset.prod_congr rfl (λ x hx, _),
619+
rw [count_cons_of_ne (finset.ne_of_mem_erase hx)] },
605620
rw [prod_cons, to_finset_cons, finset.prod_insert has, count_cons_self],
606621
rw mem_to_finset at has, rw [count_eq_zero_of_not_mem has, pow_one], congr' 1,
607622
rw ih, refine finset.prod_congr rfl (λ x hx, _), rw mem_to_finset at hx, rw count_cons_of_ne,
608623
rintro rfl, exact has hx
609624
end
610625

611-
/-- To prove a property of a product, it suffices to prove that the property is multiplicative and holds on factors.
626+
/--
627+
To prove a property of a product, it suffices to prove that
628+
the property is multiplicative and holds on factors.
612629
-/
613-
@[to_additive "To prove a property of a sum, it suffices to prove that the property is additive and holds on summands."]
630+
@[to_additive "To prove a property of a sum, it suffices to prove that
631+
the property is additive and holds on summands."]
614632
lemma prod_induction {M : Type*} [comm_monoid M] (f : α → M) (p : M → Prop)
615633
(p_mul : ∀ a b, p a → p b → p (a * b)) (p_one : p 1) (p_s : ∀ x ∈ s, p $ f x) :
616634
p $ ∏ x in s, f x :=
@@ -622,7 +640,8 @@ begin
622640
apply hs, intros a ha, apply p_s, simp [ha],
623641
end
624642

625-
/-- For any product along `{0, ..., n-1}` of a commutative-monoid-valued function, we can verify that
643+
/--
644+
For any product along `{0, ..., n-1}` of a commutative-monoid-valued function, we can verify that
626645
it's equal to a different function just by checking ratios of adjacent terms.
627646
This is a multiplicative discrete analogue of the fundamental theorem of calculus. -/
628647
lemma prod_range_induction {M : Type*} [comm_monoid M]
@@ -634,9 +653,13 @@ begin
634653
{ simp only [hk, finset.prod_range_succ, h, mul_comm] }
635654
end
636655

637-
/-- For any sum along `{0, ..., n-1}` of a commutative-monoid-valued function, we can verify that it's equal
638-
to a different function just by checking differences of adjacent terms. This is a discrete analogue
639-
of the fundamental theorem of calculus. -/
656+
/--
657+
For any sum along `{0, ..., n-1}` of a commutative-monoid-valued function,
658+
we can verify that it's equal to a different function
659+
just by checking differences of adjacent terms.
660+
This is a discrete analogue
661+
of the fundamental theorem of calculus.
662+
-/
640663
lemma sum_range_induction {M : Type*} [add_comm_monoid M]
641664
(f s : ℕ → M) (h0 : s 0 = 0) (h : ∀ n, s (n + 1) = s n + f n) (n : ℕ) :
642665
∑ k in finset.range n, f k = s n :=
@@ -664,8 +687,11 @@ lemma prod_range_div' {M : Type*} [comm_group M] (f : ℕ → M) (n : ℕ) :
664687
∏ i in range n, (f i * (f (i+1))⁻¹) = (f 0) * (f n)⁻¹ :=
665688
by apply @sum_range_sub' (additive M)
666689

667-
/-- A telescoping sum along `{0, ..., n-1}` of an `ℕ`-valued function reduces to the difference of
668-
the last and first terms when the function we are summing is monotone. -/
690+
/--
691+
A telescoping sum along `{0, ..., n-1}` of an `ℕ`-valued function
692+
reduces to the difference of the last and first terms
693+
when the function we are summing is monotone.
694+
-/
669695
lemma sum_range_sub_of_monotone {f : ℕ → ℕ} (h : monotone f) (n : ℕ) :
670696
∑ i in range n, (f (i+1) - f i) = f n - f 0 :=
671697
begin
@@ -773,7 +799,8 @@ by { convert s.prod_inter_mul_prod_diff {i} f, simp [h] }
773799
lemma prod_cancels_of_partition_cancels (R : setoid α) [decidable_rel R.r]
774800
(h : ∀ x ∈ s, (∏ a in s.filter (λy, y ≈ x), f a) = 1) : (∏ x in s, f x) = 1 :=
775801
begin
776-
suffices : ∏ xbar in s.image quotient.mk, ∏ y in s.filter (λ y, ⟦y⟧ = xbar), f y = (∏ x in s, f x),
802+
suffices : ∏ xbar in s.image quotient.mk, ∏ y in s.filter (λ y, ⟦y⟧ = xbar),
803+
f y = (∏ x in s, f x),
777804
{ rw [←this, ←finset.prod_eq_one],
778805
intros xbar xbar_in_s,
779806
rcases (mem_image).mp xbar_in_s with ⟨x, x_in_s, xbar_eq_x⟩,

src/algebra/polynomial/big_operators.lean

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ begin
4848
apply polynomial.nat_degree_mul_le, linarith,
4949
end
5050

51-
/-- The leading coefficient of a product of polynomials is equal to the product of the leading coefficients, provided that this product is nonzero.
52-
See `leading_coeff_prod` (without the `'`) for a version for integral domains, where this condition is automatically satisfied. -/
51+
/--
52+
The leading coefficient of a product of polynomials is equal to
53+
the product of the leading coefficients, provided that this product is nonzero.
54+
55+
See `leading_coeff_prod` (without the `'`) for a version for integral domains,
56+
where this condition is automatically satisfied.
57+
-/
5358
lemma leading_coeff_prod' (h : ∏ i in s, (f i).leading_coeff ≠ 0) :
5459
(∏ i in s, f i).leading_coeff = ∏ i in s, (f i).leading_coeff :=
5560
begin
@@ -59,8 +64,13 @@ begin
5964
intro h, rw polynomial.leading_coeff_mul'; { rwa hs, apply right_ne_zero_of_mul h },
6065
end
6166

62-
/-- The degree of a product of polynomials is equal to the product of the degrees, provided that the product of leading coefficients is nonzero.
63-
See `nat_degree_prod` (without the `'`) for a version for integral domains, where this condition is automatically satisfied. -/
67+
/--
68+
The degree of a product of polynomials is equal to
69+
the product of the degrees, provided that the product of leading coefficients is nonzero.
70+
71+
See `nat_degree_prod` (without the `'`) for a version for integral domains,
72+
where this condition is automatically satisfied.
73+
-/
6474
lemma nat_degree_prod' (h : ∏ i in s, (f i).leading_coeff ≠ 0) :
6575
(∏ i in s, f i).nat_degree = ∑ i in s, (f i).nat_degree :=
6676
begin

0 commit comments

Comments
 (0)