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

Commit 4ee67ac

Browse files
committed
chore(*): use prod notation (#2989)
The biggest field test of the new product notation.
1 parent a377993 commit 4ee67ac

File tree

14 files changed

+47
-41
lines changed

14 files changed

+47
-41
lines changed

src/analysis/analytic/basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ variables {𝕜 : Type*} [nondiscrete_normed_field 𝕜]
6969
{F : Type*} [normed_group F] [normed_space 𝕜 F]
7070
{G : Type*} [normed_group G] [normed_space 𝕜 G]
7171

72-
open_locale topological_space classical
72+
open_locale topological_space classical big_operators
7373
open filter
7474

7575
/-! ### The radius of a formal multilinear series -/
@@ -333,7 +333,7 @@ begin
333333
apply norm_sub_le_of_geometric_bound_of_has_sum ha _ (hf.has_sum this),
334334
assume n,
335335
calc ∥(p n) (λ (i : fin n), y)∥
336-
≤ ∥p n∥ * (finset.univ.prod (λ i : fin n, ∥y∥)) : continuous_multilinear_map.le_op_norm _ _
336+
≤ ∥p n∥ * (i : fin n, ∥y∥) : continuous_multilinear_map.le_op_norm _ _
337337
... = nnnorm (p n) * (nnnorm y)^n : by simp
338338
... ≤ nnnorm (p n) * r' ^ n :
339339
mul_le_mul_of_nonneg_left (pow_le_pow_of_le_left (nnreal.coe_nonneg _) (le_of_lt yr') _)
@@ -431,7 +431,7 @@ lemma formal_multilinear_series.has_fpower_series_on_ball [complete_space F]
431431
refine (summable_of_norm_bounded (λ n, (C : ℝ) * a ^ n)
432432
((summable_geometric_of_lt_1 a.2 ha).mul_left _) (λ n, _)).has_sum,
433433
calc ∥(p n) (λ (i : fin n), y)∥
434-
≤ ∥p n∥ * (finset.univ.prod (λ i : fin n, ∥y∥)) : continuous_multilinear_map.le_op_norm _ _
434+
≤ ∥p n∥ * (i : fin n, ∥y∥) : continuous_multilinear_map.le_op_norm _ _
435435
... = nnnorm (p n) * (nnnorm y)^n : by simp
436436
... ≤ C * a ^ n : by exact_mod_cast hC n
437437
end }

src/analysis/convex/specific_functions.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ In this file we prove that the following functions are convex:
2121
-/
2222

2323
open real set
24+
open_locale big_operators
2425

2526
/-- `exp` is convex on the whole real line -/
2627
lemma convex_on_exp : convex_on univ exp :=
@@ -53,15 +54,15 @@ lemma finset.prod_nonneg_of_card_nonpos_even
5354
{α β : Type*} [linear_ordered_comm_ring β]
5455
{f : α → β} [decidable_pred (λ x, f x ≤ 0)]
5556
{s : finset α} (h0 : (s.filter (λ x, f x ≤ 0)).card.even) :
56-
0s.prod f :=
57-
calc 0s.prod (λ x, (if f x ≤ 0 then (-1:β) else 1) * f x) :
57+
0∏ x in s, f x :=
58+
calc 0(∏ x in s, ((if f x ≤ 0 then (-1:β) else 1) * f x)) :
5859
finset.prod_nonneg (λ x _, by
5960
{ split_ifs with hx hx, by simp [hx], simp at hx ⊢, exact le_of_lt hx })
6061
... = _ : by rw [finset.prod_mul_distrib, finset.prod_ite, finset.prod_const_one,
6162
mul_one, finset.prod_const, neg_one_pow_eq_pow_mod_two, nat.even_iff.1 h0, pow_zero, one_mul]
6263

6364
lemma int_prod_range_nonneg (m : ℤ) (n : ℕ) (hn : n.even) :
64-
0(finset.range n).prod (λ k, m - k) :=
65+
0∏ k in finset.range n, (m - k) :=
6566
begin
6667
cases (le_or_lt ↑n m) with hnm hmn,
6768
{ exact finset.prod_nonneg (λ k hk, sub_nonneg.2 (le_trans

src/analysis/mean_inequalities.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ and `n=3`.
3030
universes u v
3131

3232
open real finset
33-
open_locale classical nnreal
33+
open_locale classical nnreal big_operators
3434

3535
variables {ι : Type u} (s : finset ι)
3636

3737
/-- Geometric mean is less than or equal to the arithmetic mean, weighted version
3838
for functions on `finset`s. -/
3939
theorem real.am_gm_weighted (w z : ι → ℝ)
4040
(hw : ∀ i ∈ s, 0 ≤ w i) (hw' : s.sum w = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
41-
s.prod (λ i, (z i) ^ (w i)) ≤ s.sum (λ i, w i * z i) :=
41+
(∏ i in s, (z i) ^ (w i)) ≤ s.sum (λ i, w i * z i) :=
4242
begin
4343
let s' := s.filter (λ i, w i ≠ 0),
4444
rw [← sum_filter_ne_zero] at hw',
45-
suffices : s'.prod (λ i, (z i) ^ (w i)) ≤ s'.sum (λ i, w i * z i),
45+
suffices : (∏ i in s', (z i) ^ (w i)) ≤ s'.sum (λ i, w i * z i),
4646
{ have A : ∀ i ∈ s, i ∉ s' → w i = 0,
4747
{ intros i hi hi',
4848
simpa only [hi, mem_filter, ne.def, true_and, not_not] using hi' },
@@ -69,7 +69,7 @@ begin
6969
end
7070

7171
theorem nnreal.am_gm_weighted (w z : ι → ℝ≥0) (hw' : s.sum w = 1) :
72-
s.prod (λ i, (z i) ^ (w i:ℝ)) ≤ s.sum (λ i, w i * z i) :=
72+
(∏ i in s, (z i) ^ (w i:ℝ)) ≤ s.sum (λ i, w i * z i) :=
7373
begin
7474
rw [← nnreal.coe_le_coe, nnreal.coe_prod, nnreal.coe_sum],
7575
refine real.am_gm_weighted _ _ _ (λ i _, (w i).coe_nonneg) _ (λ i _, (z i).coe_nonneg),

src/data/monoid_algebra.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ seems impossible to use.
3636
-/
3737

3838
noncomputable theory
39-
open_locale classical
39+
open_locale classical big_operators
4040

4141
open finset finsupp
4242

@@ -385,7 +385,7 @@ variable {ι : Type ui}
385385

386386
lemma prod_single [comm_semiring k] [comm_monoid G]
387387
{s : finset ι} {a : ι → G} {b : ι → k} :
388-
s.prod (λi, single (a i) (b i)) = single (s.prod a) (s.prod b) :=
388+
(∏ i in s, single (a i) (b i)) = single (∏ i in s, a i) (∏ i in s, b i) :=
389389
finset.induction_on s rfl $ λ a s has ih, by rw [prod_insert has, ih,
390390
single_mul_single, prod_insert has, prod_insert has]
391391

@@ -645,7 +645,7 @@ variable {ι : Type ui}
645645

646646
lemma prod_single [comm_semiring k] [add_comm_monoid G]
647647
{s : finset ι} {a : ι → G} {b : ι → k} :
648-
s.prod (λi, single (a i) (b i)) = single (s.sum a) (s.prod b) :=
648+
(∏ i in s, single (a i) (b i)) = single (s.sum a) (∏ i in s, b i) :=
649649
finset.induction_on s rfl $ λ a s has ih, by rw [prod_insert has, ih,
650650
single_mul_single, sum_insert has, prod_insert has]
651651

src/data/real/ennreal.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import data.set.intervals
1010
noncomputable theory
1111
open classical set
1212

13-
open_locale classical
13+
open_locale classical big_operators
1414
variables {α : Type*} {β : Type*}
1515

1616
/-- The extended nonnegative real numbers. This is usually denoted [0, ∞],
@@ -210,7 +210,7 @@ by simpa only [lt_top_iff_ne_top] using pow_ne_top
210210
of_nnreal_hom.map_sum f s
211211

212212
@[simp, norm_cast] lemma coe_finset_prod {s : finset α} {f : α → nnreal} :
213-
↑(s.prod f) = (s.prod (λa, f a) : ennreal) :=
213+
↑(∏ a in s, f a) = ((∏ a in s, f a) : ennreal) :=
214214
of_nnreal_hom.map_prod f s
215215

216216
section order

src/data/support.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ In this file we define `function.support f = {x | f x ≠ 0}` and prove its basi
1515
universes u v w x y
1616

1717
open set
18+
open_locale big_operators
1819
namespace function
1920

2021
variables {α : Type u} {β : Type v} {ι : Sort w} {A : Type x} {B : Type y}
@@ -104,7 +105,7 @@ end
104105

105106
-- TODO: Drop `classical` once #2332 is merged
106107
lemma support_prod [integral_domain A] (s : finset α) (f : α → β → A) :
107-
support (λ x, s.prod (λ i, f i x)) = ⋂ i ∈ s, support (f i) :=
108+
support (λ x, ∏ i in s, f i x) = ⋂ i ∈ s, support (f i) :=
108109
set.ext $ λ x, by classical;
109110
simp only [support, ne.def, finset.prod_eq_zero_iff, mem_set_of_eq, set.mem_Inter, not_exists]
110111

src/field_theory/finite.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ begin
9898
end
9999

100100
lemma prod_univ_units_id_eq_neg_one :
101-
univ.prod (λ x, x) = (-1 : units K) :=
101+
(∏ x : units K, x) = (-1 : units K) :=
102102
begin
103103
classical,
104-
have : ((@univ (units K) _).erase (-1)).prod (λ x, x) = 1,
104+
have : (∏ x in (@univ (units K) _).erase (-1), x) = 1,
105105
from prod_involution (λ x _, x⁻¹) (by simp)
106106
(λ a, by simp [units.inv_eq_self_iff] {contextual := tt})
107107
(λ a, by simp [@inv_eq_iff_inv_eq _ _ a, eq_comm] {contextual := tt})

src/field_theory/mv_polynomial.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ noncomputable theory
1313
open_locale classical
1414

1515
open set linear_map submodule
16+
open_locale big_operators
1617

1718
namespace mv_polynomial
1819
universes u v
@@ -109,7 +110,7 @@ variables {α : Type*} {σ : Type*}
109110
variables [field α] [fintype α] [fintype σ]
110111

111112
def indicator (a : σ → α) : mv_polynomial σ α :=
112-
finset.univ.prod (λn, 1 - (X n - C (a n))^(fintype.card α - 1))
113+
∏ n, (1 - (X n - C (a n))^(fintype.card α - 1))
113114

114115
lemma eval_indicator_apply_eq_one (a : σ → α) :
115116
eval a (indicator a) = 1 :=

src/linear_algebra/nonsingular_inverse.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ matrix inverse, cramer, cramer's rule, adjugate
4646
namespace matrix
4747
universes u v
4848
variables {n : Type u} [fintype n] [decidable_eq n] {α : Type v}
49-
open_locale matrix
49+
open_locale matrix big_operators
5050
open equiv equiv.perm finset
5151

5252

@@ -117,8 +117,8 @@ def cramer_map (i : n) : α := (A.update_column i b).det
117117
lemma cramer_map_is_linear (i : n) : is_linear_map α (λ b, cramer_map A b i) :=
118118
begin
119119
have : Π {f : n → n} {i : n} (x : n → α),
120-
finset.prod univ (λ (i' : n), (update_column A i x)ᵀ (f i') i')
121-
= finset.prod univ (λ (i' : n), if i' = i then x (f i') else A i' (f i')),
120+
(∏ i' : n, (update_column A i x)ᵀ (f i') i')
121+
= (∏ i' : n, if i' = i then x (f i') else A i' (f i')),
122122
{ intros, congr, ext i', rw [transpose_val, update_column_val] },
123123
split,
124124
{ intros x y,
@@ -234,7 +234,7 @@ begin
234234
rw [update_column_val, update_row_val],
235235
finish },
236236
{ -- Otherwise, we need to show that there is a `0` somewhere in the product.
237-
have : univ.prod (λ (j' : n), update_row A j (λ (i' : n), ite (i = i') 1 0) (σ j') j') = 0,
237+
have : (∏ j' : n, update_row A j (λ (i' : n), ite (i = i') 1 0) (σ j') j') = 0,
238238
{ apply prod_eq_zero (mem_univ j),
239239
rw [update_row_self],
240240
exact if_neg h },

src/number_theory/quadratic_reciprocity.lean

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The proof of quadratic reciprocity implemented uses Gauss' lemma and Eisenstein'
2828
-/
2929

3030
open function finset nat finite_field zmod
31+
open_locale big_operators
3132

3233
namespace zmod
3334

@@ -117,9 +118,9 @@ end
117118
@[simp] lemma wilsons_lemma : (nat.fact (p - 1) : zmod p) = -1 :=
118119
begin
119120
refine
120-
calc (nat.fact (p - 1) : zmod p) = (Ico 1 (succ (p - 1))).prod (λ (x : ℕ), x) :
121+
calc (nat.fact (p - 1) : zmod p) = (∏ x in Ico 1 (succ (p - 1)), x) :
121122
by rw [← finset.prod_Ico_id_eq_fact, prod_nat_cast]
122-
... = finset.univ.prod (λ x : units (zmod p), x) : _
123+
... = (∏ x : units (zmod p), x) : _
123124
... = -1 :
124125
by rw [prod_hom _ (coe : units (zmod p) → zmod p),
125126
prod_univ_units_id_eq_neg_one, units.coe_neg, units.coe_one],
@@ -142,7 +143,7 @@ begin
142143
{ simp only [val_cast_of_lt hb.right, units.coe_mk0], } }
143144
end
144145

145-
@[simp] lemma prod_Ico_one_prime : (Ico 1 p).prod (λ x, (x : zmod p)) = -1 :=
146+
@[simp] lemma prod_Ico_one_prime : (∏ x in Ico 1 p, (x : zmod p)) = -1 :=
146147
begin
147148
conv in (Ico 1 p) { rw [← succ_sub_one p, succ_sub (nat.prime.pos ‹p.prime›)] },
148149
rw [← prod_nat_cast, finset.prod_Ico_id_eq_fact, wilsons_lemma]
@@ -195,24 +196,24 @@ private lemma gauss_lemma_aux₁ (p : ℕ) [hp : fact p.prime] [hp2 : fact (p %
195196
(-1)^((Ico 1 (p / 2).succ).filter
196197
(λ x : ℕ, ¬(a * x : zmod p).val ≤ p / 2)).card * (p / 2).fact :=
197198
calc (a ^ (p / 2) * (p / 2).fact : zmod p) =
198-
(Ico 1 (p / 2).succ).prod (λ x, a * x) :
199+
(∏ x in Ico 1 (p / 2).succ, a * x) :
199200
by rw [prod_mul_distrib, ← prod_nat_cast, ← prod_nat_cast, prod_Ico_id_eq_fact,
200201
prod_const, Ico.card, succ_sub_one]; simp
201-
... = (Ico 1 (p / 2).succ).prod (λ x, (a * x : zmod p).val) : by simp
202-
... = (Ico 1 (p / 2).succ).prod
203-
(λ x, (if (a * x : zmod p).val ≤ p / 2 then 1 else -1) *
202+
... = (∏ x in Ico 1 (p / 2).succ, (a * x : zmod p).val) : by simp
203+
... = (∏ x in Ico 1 (p / 2).succ,
204+
(if (a * x : zmod p).val ≤ p / 2 then 1 else -1) *
204205
(a * x : zmod p).val_min_abs.nat_abs) :
205206
prod_congr rfl $ λ _ _, begin
206207
simp only [cast_nat_abs_val_min_abs],
207208
split_ifs; simp
208209
end
209210
... = (-1)^((Ico 1 (p / 2).succ).filter
210211
(λ x : ℕ, ¬(a * x : zmod p).val ≤ p / 2)).card *
211-
(Ico 1 (p / 2).succ).prod (λ x, (a * x : zmod p).val_min_abs.nat_abs) :
212-
have (Ico 1 (p / 2).succ).prod
213-
(λ x, if (a * x : zmod p).val ≤ p / 2 then (1 : zmod p) else -1) =
214-
((Ico 1 (p / 2).succ).filter
215-
(λ x : ℕ, ¬(a * x : zmod p).val ≤ p / 2)).prod (λ _, -1),
212+
(∏ x in Ico 1 (p / 2).succ, (a * x : zmod p).val_min_abs.nat_abs) :
213+
have (∏ x in Ico 1 (p / 2).succ,
214+
if (a * x : zmod p).val ≤ p / 2 then (1 : zmod p) else -1) =
215+
(∏ x in (Ico 1 (p / 2).succ).filter
216+
(λ x : ℕ, ¬(a * x : zmod p).val ≤ p / 2), -1),
216217
from prod_bij_ne_one (λ x _ _, x)
217218
(λ x, by split_ifs; simp * at * {contextual := tt})
218219
(λ _ _ _ _ _ _, id)

0 commit comments

Comments
 (0)