|
|
|
|
SSL Finset.lean
Interaktion und PortierbarkeitLean
|
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
module
public import Mathlib.Algebra.BigOperators.Group.Finset.Sigma
public import Mathlib.Algebra.Order.BigOperators.Group.Multiset
public import Mathlib.Algebra.Order.Group.Nat
public import Mathlib.Algebra.Order.Hom.Basic
public import Mathlib.Algebra.Order.Monoid.Multiset
public import Mathlib.Algebra.Order.Monoid.Unbundled.Pow
public import Mathlib.Data.Fintype.Card
public import Mathlib.Data.Multiset.Powerset
public import Mathlib.Tactic.Bound.Attribute
import Mathlib.Algebra.Order.Monoid.OrderDual
set_option doc.verso true
set_option doc.verso.suggestions false
/-!
# Big operators on a finset in ordered groups
This file contains the results concerning the interaction of finset big operators with ordered
groups/monoids.
-/
public section
assert_not_exists Ring
open Function
variable {ι α β M N G k : Type*}
namespace Finset
section OrderedCommMonoid
variable [CommMonoid M] [CommMonoid N] [Preorder N]
/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map
submultiplicative on `{x | p x}`, i.e., `p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be
a nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
`f (∏ x ∈ s, g x) ≤ ∏ x ∈ s, f (g x)`. -/
@[to_additive le_sum_nonempty_of_subadditive_on_pred]
theorem le_prod_nonempty_of_submultiplicative_on_pred [IsOrderedMonoid N] (f : M → N) (p : M → Prop)
(h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))
(g : ι → M) (s : Finset ι) (hs_nonempty : s.Nonempty) (hs : ∀ i ∈ s, p (g i)) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
refine le_trans
(Multiset.le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul _ ?_ ?_) ?_
· simp [hs_nonempty.ne_empty]
· exact Multiset.forall_mem_map_iff.mpr hs
simp
/-- Let `{x | p x}` be an additive subsemigroup of an additive commutative monoid `M`. Let
`f : M → N` be a map subadditive on `{x | p x}`, i.e., `p x → p y → f (x + y) ≤ f x + f y`. Let
`g i`, `i ∈ s`, be a nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
`f (∑ i ∈ s, g i) ≤ ∑ i ∈ s, f (g i)`. -/
add_decl_doc le_sum_nonempty_of_subadditive_on_pred
/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y` and `g i`, `i ∈ s`, is a
nonempty finite family of elements of `M`, then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
@[to_additive le_sum_nonempty_of_subadditive]
theorem le_prod_nonempty_of_submultiplicative [IsOrderedMonoid N] (f : M → N)
(h_mul : ∀ x y, f (x * y) ≤ f x * f y) {s : Finset ι} (hs : s.Nonempty) (g : ι → M) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
le_prod_nonempty_of_submultiplicative_on_pred f (fun _ ↦ True) (fun x y _ _ ↦ h_mul x y)
(fun _ _ _ _ ↦ trivial) g s hs fun _ _ ↦ trivial
/-- If `f : M → N` is a subadditive function, `f (x + y) ≤ f x + f y` and `g i`, `i ∈ s`, is a
nonempty finite family of elements of `M`, then `f (∑ i ∈ s, g i) ≤ ∑ i ∈ s, f (g i)`. -/
add_decl_doc le_sum_nonempty_of_subadditive
/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map
such that `f 1 = 1` and `f` is submultiplicative on `{x | p x}`, i.e.,
`p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be a finite family of elements of `M` such
that `∀ i ∈ s, p (g i)`. Then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
@[to_additive le_sum_of_subadditive_on_pred]
theorem le_prod_of_submultiplicative_on_pred [IsOrderedMonoid N] (f : M → N) (p : M → Prop)
(h_one : f 1 ≤ 1) (h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y)
(hp_mul : ∀ x y, p x → p y → p (x * y)) (g : ι → M) {s : Finset ι} (hs : ∀ i ∈ s, p (g i)) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
rcases eq_empty_or_nonempty s with (rfl | hs_nonempty)
· simp [h_one]
· exact le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul g s hs_nonempty hs
/-- Let `{x | p x}` be a subsemigroup of a commutative additive monoid `M`. Let `f : M → N` be a map
such that `f 0 = 0` and `f` is subadditive on `{x | p x}`, i.e. `p x → p y → f (x + y) ≤ f x + f y`.
Let `g i`, `i ∈ s`, be a finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
`f (∑ x ∈ s, g x) ≤ ∑ x ∈ s, f (g x)`. -/
add_decl_doc le_sum_of_subadditive_on_pred
/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y`, `f 1 = 1`, and `g i`,
`i ∈ s`, is a finite family of elements of `M`, then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
@[to_additive le_sum_of_subadditive]
theorem le_prod_of_submultiplicative [IsOrderedMonoid N] (f : M → N) (h_one : f 1 ≤ 1)
(h_mul : ∀ x y, f (x * y) ≤ f x * f y) (s : Finset ι) (g : ι → M) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) (by simp)
/-- If `f : M → N` is a subadditive function, `f (x + y) ≤ f x + f y`, `f 0 = 0`, and `g i`,
`i ∈ s`, is a finite family of elements of `M`, then `f (∑ i ∈ s, g i) ≤ ∑ i ∈ s, f (g i)`. -/
add_decl_doc le_sum_of_subadditive
@[to_additive]
theorem map_prod_le_prod [IsOrderedMonoid N] {F : Type*} [FunLike F M N] [OneHomClass F M N]
[SubmultiplicativeHomClass F M N] (f : F) (s : Finset ι) (g : ι → M) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
le_prod_of_submultiplicative f (map_one f).le (map_mul_le_mul f) s g
variable {f g : ι → N} {s t : Finset ι}
/-- In an ordered commutative monoid, if each factor `f i` of one finite product is less than or
equal to the corresponding factor `g i` of another finite product, then
`∏ i ∈ s, f i ≤ ∏ i ∈ s, g i`. -/
@[to_additive (attr := gcongr)]
theorem prod_le_prod [MulLeftMono N] (h : ∀ i ∈ s, f i ≤ g i) : ∏ i ∈ s, f i ≤ ∏ i ∈ s, g i :=
Multiset.prod_map_le_prod_map f g h
@[deprecated (since := "2026-09-01")] alias prod_le_prod' := prod_le_prod
attribute [bound] sum_le_sum
/-- In an ordered additive commutative monoid, if each summand `f i` of one finite sum is less than
or equal to the corresponding summand `g i` of another finite sum, then
`∑ i ∈ s, f i ≤ ∑ i ∈ s, g i`. -/
add_decl_doc sum_le_sum
/-- A finite product of monotone functions is monotone. -/
@[to_additive finsetSum /-- A finite sum of monotone functions is monotone. -/]
theorem _root_.Monotone.finsetProd' [MulLeftMono N] {γ : Type*} [Preorder γ]
{f : ι → γ → N} (hf : ∀ i ∈ s, Monotone (f i)) :
Monotone fun x ↦ ∏ i ∈ s, f i x :=
fun _ _ hab ↦ Finset.prod_le_prod fun i hi ↦ hf i hi hab
/-- A finite product of functions monotone on `u` is monotone on `u`. -/
@[to_additive finsetSum /-- A finite sum of functions monotone on `u` is monotone on `u`. -/]
theorem _root_.MonotoneOn.finsetProd' [MulLeftMono N] {γ : Type*} [Preorder γ] {u : Set γ}
{f : ι → γ → N} (hf : ∀ i ∈ s, MonotoneOn (f i) u) :
MonotoneOn (fun x ↦ ∏ i ∈ s, f i x) u :=
fun _ ha _ hb hab ↦ Finset.prod_le_prod fun i hi ↦ hf i hi ha hb hab
/-- A finite product of antitone functions is antitone. -/
@[to_additive finsetSum /-- A finite sum of antitone functions is antitone. -/]
theorem _root_.Antitone.finsetProd' [MulLeftMono N] {γ : Type*} [Preorder γ]
{f : ι → γ → N} (hf : ∀ i ∈ s, Antitone (f i)) :
Antitone fun x ↦ ∏ i ∈ s, f i x :=
fun _ _ hab ↦ Finset.prod_le_prod fun i hi ↦ hf i hi hab
/-- A finite product of functions antitone on `u` is antitone on `u`. -/
@[to_additive finsetSum /-- A finite sum of functions antitone on `u` is antitone on `u`. -/]
theorem _root_.AntitoneOn.finsetProd' [MulLeftMono N] {γ : Type*} [Preorder γ] {u : Set γ}
{f : ι → γ → N} (hf : ∀ i ∈ s, AntitoneOn (f i) u) :
AntitoneOn (fun x ↦ ∏ i ∈ s, f i x) u :=
fun _ ha _ hb hab ↦ Finset.prod_le_prod fun i hi ↦ hf i hi ha hb hab
@[to_additive sum_nonneg]
theorem one_le_prod [MulLeftMono N] (h : ∀ i ∈ s, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
le_trans (by rw [prod_const_one]) (prod_le_prod h)
@[deprecated (since := "2026-09-01")] alias one_le_prod' := one_le_prod
@[to_additive sum_nonneg']
theorem one_le_prod'' [MulLeftMono N] (h : ∀ i : ι, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
Finset.one_le_prod fun i _ ↦ h i
attribute [deprecated sum_nonneg +typeChanged (since := "2026-09-01")] sum_nonneg'
attribute [deprecated one_le_prod +typeChanged (since := "2026-09-01")] one_le_prod''
@[to_additive]
theorem prod_le_one [MulLeftMono N] (h : ∀ i ∈ s, f i ≤ 1) : ∏ i ∈ s, f i ≤ 1 :=
(prod_le_prod h).trans_eq (by rw [prod_const_one])
@[deprecated (since := "2026-09-01")] alias prod_le_one' := prod_le_one
@[to_additive (attr := gcongr)]
theorem prod_le_prod_of_subset_of_one_le [MulLeftMono N] (h : s ⊆ t)
(hf : ∀ i ∈ t, i ∉ s → 1 ≤ f i) : ∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
classical calc
∏ i ∈ s, f i ≤ (∏ i ∈ t \ s, f i) * ∏ i ∈ s, f i :=
le_mul_of_one_le_left' <| one_le_prod <| by simpa only [mem_sdiff, and_imp]
_ = ∏ i ∈ t \ s ∪ s, f i := (prod_union sdiff_disjoint).symm
_ = ∏ i ∈ t, f i := by rw [sdiff_union_of_subset h]
@[deprecated (since := "2026-09-01")]
alias prod_le_prod_of_subset_of_one_le' := prod_le_prod_of_subset_of_one_le
@[to_additive]
lemma prod_le_prod_of_subset_of_le_one [MulLeftMono N] (h : s ⊆ t) (hf : ∀ i ∈ t, i ∉ s → f i ≤ 1) :
∏ i ∈ t, f i ≤ ∏ i ∈ s, f i :=
prod_le_prod_of_subset_of_one_le (N := Nᵒᵈ) h hf
@[deprecated (since := "2026-09-01")]
alias prod_le_prod_of_subset_of_le_one' := prod_le_prod_of_subset_of_le_one
@[deprecated (since := "2026-09-01")]
alias sum_le_sum_of_subset_of_nonpos' := sum_le_sum_of_subset_of_nonpos
@[to_additive]
theorem prod_mono_set_of_one_le [MulLeftMono N] (hf : ∀ x, 1 ≤ f x) :
Monotone fun s ↦ ∏ x ∈ s, f x :=
fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le hst fun x _ _ ↦ hf x
@[deprecated (since := "2026-09-01")] alias prod_mono_set_of_one_le' := prod_mono_set_of_one_le
@[to_additive]
theorem prod_anti_set_of_le_one [MulLeftMono N] (hf : ∀ (x : ι), f x ≤ 1) :
Antitone fun (s : Finset ι) => ∏ x ∈ s, f x :=
fun _ _ hst ↦ prod_le_prod_of_subset_of_le_one hst (by simp [hf])
@[deprecated (since := "2026-09-01")] alias prod_anti_set_of_le_one' := prod_anti_set_of_le_one
@[deprecated (since := "2026-09-01")] alias sum_anti_set_of_nonpos' := sum_anti_set_of_nonpos
@[to_additive]
theorem prod_le_univ_prod_of_one_le [MulLeftMono N] [Fintype ι] {s : Finset ι} (w : ∀ x, 1 ≤ f x) :
∏ x ∈ s, f x ≤ ∏ x, f x :=
prod_le_prod_of_subset_of_one_le (subset_univ s) fun a _ _ ↦ w a
@[deprecated (since := "2026-09-01")]
alias prod_le_univ_prod_of_one_le' := prod_le_univ_prod_of_one_le
@[to_additive]
theorem prod_le_prod_of_injOn [DecidableEq α] [MulLeftMono N]
{g : α → N} {s : Finset ι} {t : Finset α} (e : ι → α) (he : Set.InjOn e s)
(ht : image e s ⊆ t) (h : ∀ i ∈ s, f i ≤ g (e i))
(hg : ∀ a ∈ t, a ∉ image e s → 1 ≤ g a) :
∏ i ∈ s, f i ≤ ∏ a ∈ t, g a := by
refine le_trans ?_ <| prod_le_prod_of_subset_of_one_le ht hg
grw [prod_image he, prod_le_prod h]
@[deprecated (since := "2026-09-01")]
alias prod_le_prod_of_injOn' := prod_le_prod_of_injOn
@[to_additive]
theorem prod_eq_one_iff_of_one_le {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N]
{f : ι → N} {s : Finset ι} [IsOrderedMonoid N] :
(∀ i ∈ s, 1 ≤ f i) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) := by
classical
refine Finset.induction_on s
(fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.notMem_empty _ h), fun _ ↦ rfl⟩) ?_
intro a s ha ih H
have : ∀ i ∈ s, 1 ≤ f i := fun _ ↦ H _ ∘ mem_insert_of_mem
rw [prod_insert ha, mul_eq_one_iff_of_one_le (H _ <| mem_insert_self _ _) (one_le_prod this),
forall_mem_insert, ih this]
@[deprecated (since := "2026-09-01")] alias prod_eq_one_iff_of_one_le' := prod_eq_one_iff_of_one_le
@[to_additive sum_pos_iff_of_nonneg]
lemma one_lt_prod_iff_of_one_le {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N]
{f : ι → N} {s : Finset ι} [IsOrderedMonoid N] (hf : ∀ x ∈ s, 1 ≤ f x) :
1 < ∏ x ∈ s, f x ↔ ∃ x ∈ s, 1 < f x := by
have hsum : 1 ≤ ∏ x ∈ s, f x := one_le_prod hf
rw [hsum.lt_iff_ne', Ne, prod_eq_one_iff_of_one_le hf, not_forall]
simp +contextual [← exists_prop, -exists_const_iff, hf _ _ |>.lt_iff_ne']
@[to_additive]
theorem prod_eq_one_iff_of_le_one {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N]
{f : ι → N} {s : Finset ι} [IsOrderedMonoid N] :
(∀ i ∈ s, f i ≤ 1) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) :=
prod_eq_one_iff_of_one_le (N := Nᵒᵈ)
@[deprecated (since := "2026-09-01")] alias prod_eq_one_iff_of_le_one' := prod_eq_one_iff_of_le_one
@[to_additive]
lemma prod_lt_one_iff_of_le_one {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N]
{f : ι → N} {s : Finset ι} [IsOrderedMonoid N] (hf : ∀ x ∈ s, f x ≤ 1) :
∏ x ∈ s, f x < 1 ↔ ∃ x ∈ s, f x < 1 :=
one_lt_prod_iff_of_one_le (N := Nᵒᵈ) hf
@[to_additive]
theorem single_le_prod [MulLeftMono N] (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) :
f a ≤ ∏ x ∈ s, f x :=
calc
f a = ∏ i ∈ {a}, f i := (prod_singleton _ _).symm
_ ≤ ∏ i ∈ s, f i :=
prod_le_prod_of_subset_of_one_le (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi
@[deprecated (since := "2026-09-01")] alias single_le_prod' := single_le_prod
@[to_additive]
lemma mul_le_prod [MulLeftMono N] {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj : j ∈ s)
(hne : i ≠ j) :
f i * f j ≤ ∏ k ∈ s, f k :=
calc
f i * f j = ∏ k ∈ .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton]
_ ≤ ∏ k ∈ s, f k := by
refine prod_le_prod_of_subset_of_one_le ?_ fun k hk _ ↦ hf k hk
simp [cons_subset, *]
@[to_additive sum_le_card_nsmul]
theorem prod_le_pow_card [MulLeftMono N] (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, f x ≤ n) :
s.prod f ≤ n ^ #s := by
refine (Multiset.prod_le_pow_card (s.val.map f) n ?_).trans ?_
· simpa using h
· simp
@[to_additive card_nsmul_le_sum]
theorem pow_card_le_prod [MulLeftMono N] (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, n ≤ f x) :
n ^ #s ≤ s.prod f := Finset.prod_le_pow_card (N := Nᵒᵈ) _ _ _ h
theorem card_biUnion_le_card_mul [DecidableEq β] (s : Finset ι) (f : ι → Finset β) (n : ℕ)
(h : ∀ a ∈ s, #(f a) ≤ n) : #(s.biUnion f) ≤ #s * n :=
card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h
variable {ι' : Type*} [DecidableEq ι']
@[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg]
theorem prod_fiberwise_le_prod_of_one_le_prod_fiber [MulLeftMono N] {t : Finset ι'} {g : ι → ι'}
{f : ι → N} (h : ∀ y ∉ t, (1 : N) ≤ ∏ x ∈ s with g x = y, f x) :
(∏ y ∈ t, ∏ x ∈ s with g x = y, f x) ≤ ∏ x ∈ s, f x :=
calc
(∏ y ∈ t, ∏ x ∈ s with g x = y, f x) ≤
∏ y ∈ t ∪ s.image g, ∏ x ∈ s with g x = y, f x :=
prod_le_prod_of_subset_of_one_le subset_union_left fun y _ ↦ h y
_ = ∏ x ∈ s, f x :=
prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _
@[deprecated (since := "2026-09-01")]
alias prod_fiberwise_le_prod_of_one_le_prod_fiber' := prod_fiberwise_le_prod_of_one_le_prod_fiber
@[to_additive]
theorem prod_le_prod_fiberwise_of_prod_fiber_le_one [MulLeftMono N] {t : Finset ι'} {g : ι → ι'}
{f : ι → N} (h : ∀ y ∉ t, ∏ x ∈ s with g x = y, f x ≤ 1) :
∏ x ∈ s, f x ≤ ∏ y ∈ t, ∏ x ∈ s with g x = y, f x :=
prod_fiberwise_le_prod_of_one_le_prod_fiber (N := Nᵒᵈ) h
@[deprecated (since := "2026-09-01")]
alias prod_le_prod_fiberwise_of_prod_fiber_le_one' := prod_le_prod_fiberwise_of_prod_fiber_le_one
@[to_additive]
lemma prod_image_le_of_one_le [MulLeftMono N]
{g : ι → ι'} {f : ι' → N} (hf : ∀ u ∈ s.image g, 1 ≤ f u) :
∏ u ∈ s.image g, f u ≤ ∏ u ∈ s, f (g u) := by
rw [prod_comp f g]
refine prod_le_prod fun a hag ↦ ?_
obtain ⟨i, hi, hig⟩ := Finset.mem_image.mp hag
apply le_self_pow (hf a hag)
rw [← Nat.pos_iff_ne_zero, card_pos]
exact ⟨i, mem_filter.mpr ⟨hi, hig⟩⟩
end OrderedCommMonoid
section ProdSum
variable [CommMonoid α] [AddCommMonoid β] [Preorder β] [AddLeftMono β]
(s : Finset ι) {f : ι → α} (g : α → β)
theorem apply_prod_le_sum_apply (h_one : g 1 ≤ 0) (h_mul : ∀ (a b : α), g (a * b) ≤ g a + g b) :
g (∏ x ∈ s, f x) ≤ ∑ x ∈ s, g (f x) := by
refine (Multiset.apply_prod_le_sum_map _ _ h_one h_mul).trans_eq ?_
rw [Multiset.map_map, Function.comp_def, Finset.sum_map_val]
theorem sum_apply_le_apply_prod (h_one : 0 ≤ g 1) (h_mul : ∀ (a b : α), g a + g b ≤ g (a * b)) :
∑ x ∈ s, g (f x) ≤ g (∏ x ∈ s, f x) :=
s.apply_prod_le_sum_apply (β := βᵒᵈ) g h_one h_mul
end ProdSum
@[to_additive]
lemma max_prod_le [CommMonoid M] [LinearOrder M] [IsOrderedMonoid M] {f g : ι → M} {s : Finset ι} :
max (s.prod f) (s.prod g) ≤ s.prod (fun i ↦ max (f i) (g i)) :=
Multiset.max_prod_le
@[to_additive]
lemma prod_min_le [CommMonoid M] [LinearOrder M] [IsOrderedMonoid M] {f g : ι → M} {s : Finset ι} :
s.prod (fun i ↦ min (f i) (g i)) ≤ min (s.prod f) (s.prod g) :=
Multiset.prod_min_le
theorem abs_sum_le_sum_abs {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G]
(f : ι → G) (s : Finset ι) :
|∑ i ∈ s, f i| ≤ ∑ i ∈ s, |f i| := le_sum_of_subadditive _ abs_zero.le abs_add_le s f
theorem abs_sum_of_nonneg {G : Type*} [AddCommGroup G] [LinearOrder G] [AddLeftMono G]
{f : ι → G} {s : Finset ι}
(hf : ∀ i ∈ s, 0 ≤ f i) : |∑ i ∈ s, f i| = ∑ i ∈ s, f i := by
rw [abs_of_nonneg (Finset.sum_nonneg hf)]
set_option linter.deprecated false in
@[deprecated abs_sum_of_nonneg (since := "2026-09-01")]
theorem abs_sum_of_nonneg' {G : Type*} [AddCommGroup G] [LinearOrder G] [AddLeftMono G]
{f : ι → G} {s : Finset ι}
(hf : ∀ i, 0 ≤ f i) : |∑ i ∈ s, f i| = ∑ i ∈ s, f i := by
rw [abs_of_nonneg (Finset.sum_nonneg' hf)]
section CommMonoid
variable [CommMonoid α] [LE α] [MulLeftMono α] {s : Finset ι} {f : ι → α}
@[to_additive (attr := simp)]
lemma mulLECancellable_prod :
MulLECancellable (∏ i ∈ s, f i) ↔ ∀ ⦃i⦄, i ∈ s → MulLECancellable (f i) := by
induction s using Finset.cons_induction <;> simp [*]
end CommMonoid
section Pigeonhole
variable [DecidableEq β]
theorem card_le_mul_card_image_of_maps_to {f : α → β} {s : Finset α} {t : Finset β}
(Hf : ∀ a ∈ s, f a ∈ t) (n : ℕ) (hn : ∀ b ∈ t, #{a ∈ s | f a = b} ≤ n) : #s ≤ n * #t :=
calc
#s = ∑ b ∈ t, #{a ∈ s | f a = b} := card_eq_sum_card_fiberwise Hf
_ ≤ ∑ _b ∈ t, n := sum_le_sum hn
_ = _ := by simp [mul_comm]
theorem card_le_mul_card_image {f : α → β} (s : Finset α) (n : ℕ)
(hn : ∀ b ∈ s.image f, #{a ∈ s | f a = b} ≤ n) : #s ≤ n * #(s.image f) :=
card_le_mul_card_image_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn
theorem mul_card_image_le_card_of_maps_to {f : α → β} {s : Finset α} {t : Finset β}
(Hf : ∀ a ∈ s, f a ∈ t) (n : ℕ) (hn : ∀ b ∈ t, n ≤ #{a ∈ s | f a = b}) :
n * #t ≤ #s :=
calc
n * #t = ∑ _a ∈ t, n := by simp [mul_comm]
_ ≤ ∑ b ∈ t, #{a ∈ s | f a = b} := sum_le_sum hn
_ = #s := by rw [← card_eq_sum_card_fiberwise Hf]
theorem mul_card_image_le_card {f : α → β} (s : Finset α) (n : ℕ)
(hn : ∀ b ∈ s.image f, n ≤ #{a ∈ s | f a = b}) : n * #(s.image f) ≤ #s :=
mul_card_image_le_card_of_maps_to (fun _ ↦ mem_image_of_mem _) n hn
end Pigeonhole
section DoubleCounting
variable [DecidableEq α] {s : Finset α} {B : Finset (Finset α)} {n : ℕ}
/-- If every element belongs to at most `n` Finsets, then the sum of their sizes is at most `n`
times how many they are. -/
theorem sum_card_inter_le (h : ∀ a ∈ s, #{b ∈ B | a ∈ b} ≤ n) : (∑ t ∈ B, #(s ∩ t)) ≤ #s * n := by
refine le_trans ?_ (s.sum_le_card_nsmul _ _ h)
simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]
exact sum_comm.le
/-- If every element belongs to at most `n` Finsets, then the sum of their sizes is at most `n`
times how many they are. -/
lemma sum_card_le [Fintype α] (h : ∀ a, #{b ∈ B | a ∈ b} ≤ n) : ∑ s ∈ B, #s ≤ Fintype.card α * n :=
calc
∑ s ∈ B, #s = ∑ s ∈ B, #(univ ∩ s) := by simp_rw [univ_inter]
_ ≤ Fintype.card α * n := sum_card_inter_le fun a _ ↦ h a
/-- If every element belongs to at least `n` Finsets, then the sum of their sizes is at least `n`
times how many they are. -/
theorem le_sum_card_inter (h : ∀ a ∈ s, n ≤ #{b ∈ B | a ∈ b}) : #s * n ≤ ∑ t ∈ B, #(s ∩ t) := by
apply (s.card_nsmul_le_sum _ _ h).trans
simp_rw [← filter_mem_eq_inter, card_eq_sum_ones, sum_filter]
exact sum_comm.le
/-- If every element belongs to at least `n` Finsets, then the sum of their sizes is at least `n`
times how many they are. -/
theorem le_sum_card [Fintype α] (h : ∀ a, n ≤ #{b ∈ B | a ∈ b}) :
Fintype.card α * n ≤ ∑ s ∈ B, #s :=
calc
Fintype.card α * n ≤ ∑ s ∈ B, #(univ ∩ s) := le_sum_card_inter fun a _ ↦ h a
_ = ∑ s ∈ B, #s := by simp_rw [univ_inter]
/-- If every element belongs to exactly `n` Finsets, then the sum of their sizes is `n` times how
many they are. -/
theorem sum_card_inter (h : ∀ a ∈ s, #{b ∈ B | a ∈ b} = n) :
(∑ t ∈ B, #(s ∩ t)) = #s * n :=
(sum_card_inter_le fun a ha ↦ (h a ha).le).antisymm (le_sum_card_inter fun a ha ↦ (h a ha).ge)
/-- If every element belongs to exactly `n` Finsets, then the sum of their sizes is `n` times how
many they are. -/
theorem sum_card [Fintype α] (h : ∀ a, #{b ∈ B | a ∈ b} = n) :
∑ s ∈ B, #s = Fintype.card α * n := by
simp_rw [Fintype.card, ← sum_card_inter fun a _ ↦ h a, univ_inter]
theorem card_le_card_biUnion {s : Finset ι} {f : ι → Finset α} (hs : (s : Set ι).PairwiseDisjoint f)
(hf : ∀ i ∈ s, (f i).Nonempty) : #s ≤ #(s.biUnion f) := by
rw [card_biUnion hs, card_eq_sum_ones]
exact sum_le_sum fun i hi ↦ (hf i hi).card_pos
theorem card_le_card_biUnion_add_card_fiber {s : Finset ι} {f : ι → Finset α}
(hs : (s : Set ι).PairwiseDisjoint f) : #s ≤ #(s.biUnion f) + #{i ∈ s | f i = ∅} := by
rw [← Finset.card_filter_add_card_filter_not fun i ↦ f i = ∅, add_comm]
grw [card_le_card_biUnion (hs.subset <| filter_subset _ _) fun i hi ↦
nonempty_of_ne_empty (mem_filter.1 hi).2, filter_subset]
theorem card_le_card_biUnion_add_one {s : Finset ι} {f : ι → Finset α} (hf : Injective f)
(hs : (s : Set ι).PairwiseDisjoint f) : #s ≤ #(s.biUnion f) + 1 := by
grw [card_le_card_biUnion_add_card_fiber hs,
card_le_one.2 fun _ hi _ hj ↦ hf <| (mem_filter.1 hi).2.trans (mem_filter.1 hj).2.symm]
end DoubleCounting
section CanonicallyOrderedMul
variable [CommMonoid M] [Preorder M] [CanonicallyOrderedMul M] {f : ι → M} {s t : Finset ι}
/-- In a canonically-ordered monoid, a product bounds each of its terms.
See also `Finset.single_le_prod'`. -/
@[to_additive /-- In a canonically-ordered additive monoid, a sum bounds each of its terms.
See also `Finset.single_le_sum`. -/]
lemma single_le_prod_of_canonicallyOrdered {i : ι} (hi : i ∈ s) :
f i ≤ ∏ j ∈ s, f j :=
have := CanonicallyOrderedMul.toIsOrderedMonoid (α := M)
single_le_prod (fun _ _ ↦ one_le) hi
@[to_additive]
theorem prod_le_prod_of_subset (h : s ⊆ t) : ∏ x ∈ s, f x ≤ ∏ x ∈ t, f x :=
have := CanonicallyOrderedMul.toIsOrderedMonoid (α := M)
prod_le_prod_of_subset_of_one_le h fun _ _ _ ↦ one_le
@[deprecated (since := "2026-09-01")] alias prod_le_prod_of_subset' := prod_le_prod_of_subset
@[to_additive]
theorem prod_mono_set (f : ι → M) : Monotone fun s ↦ ∏ x ∈ s, f x := fun _ _ hs ↦
have := CanonicallyOrderedMul.toIsOrderedMonoid (α := M)
prod_le_prod_of_subset hs
@[deprecated (since := "2026-09-01")] alias prod_mono_set' := prod_mono_set
@[to_additive]
theorem prod_le_prod_of_ne_one (h : ∀ x ∈ s, f x ≠ 1 → x ∈ t) :
∏ x ∈ s, f x ≤ ∏ x ∈ t, f x := by
have := CanonicallyOrderedMul.toIsOrderedMonoid (α := M)
classical calc
∏ x ∈ s, f x = (∏ x ∈ s with f x = 1, f x) * ∏ x ∈ s with f x ≠ 1, f x := by
rw [← prod_union, filter_union_filter_not_eq]
exact disjoint_filter.2 fun _ _ h n_h ↦ n_h h
_ ≤ ∏ x ∈ t, f x :=
mul_le_of_le_one_of_le
(prod_le_one <| by simp only [mem_filter, and_imp]; exact fun _ _ ↦ le_of_eq)
(prod_le_prod_of_subset <| by simpa only [subset_iff, mem_filter, and_imp])
@[deprecated (since := "2026-09-01")] alias prod_le_prod_of_ne_one' := prod_le_prod_of_ne_one
@[to_additive sum_pos_iff]
lemma one_lt_prod_iff {ι M : Type*} [CommMonoid M] [PartialOrder M] [CanonicallyOrderedMul M]
{f : ι → M} {s : Finset ι} : 1 < ∏ x ∈ s, f x ↔ ∃ x ∈ s, 1 < f x :=
have := CanonicallyOrderedMul.toIsOrderedMonoid (α := M)
Finset.one_lt_prod_iff_of_one_le <| fun _ _ => one_le
/-- In a canonically-ordered monoid, if `S'` is contained in `(S.erase d) ∪ {d'}` and
`f d' < f d` for some `d ∈ S`, then the product of `f` over `S'` is strictly less than over `S`. -/
@[to_additive /-- In a canonically-ordered additive monoid, if `S'` is contained in
`(S.erase d) ∪ {d'}` and `f d' < f d` for some `d ∈ S`, then the sum of `f` over `S'` is
strictly less than over `S`. -/]
lemma prod_lt_prod_of_subset_erase_union_singleton {ι M : Type*} [DecidableEq ι] [CommMonoid M]
[PartialOrder M] [CanonicallyOrderedMul M] [MulLeftStrictMono M] {S S' : Finset ι} {f : ι → M}
{d d' : ι} (hd_mem : d ∈ S) (hS' : S' ⊆ S.erase d ∪ {d'}) (hlt : f d' < f d) :
∏ x ∈ S', f x < ∏ x ∈ S, f x := by
have hd_not : d ∉ S' := fun hd ↦ (Finset.mem_union.mp (hS' hd)).elim
(fun h ↦ (Finset.mem_erase.mp h).1 rfl)
(fun h ↦ hlt.ne' (congrArg f (Finset.mem_singleton.mp h)))
by_cases hd'S : d' ∈ S
· calc ∏ x ∈ S', f x
≤ ∏ x ∈ S.erase d, f x := Finset.prod_le_prod_of_subset (fun x hx ↦
Finset.mem_erase.mpr ⟨fun h ↦ hd_not (h ▸ hx),
match Finset.mem_union.mp (hS' hx) with
| .inl h => Finset.mem_of_mem_erase h
| .inr h => Finset.mem_singleton.mp h ▸ hd'S⟩)
_ < (∏ x ∈ S.erase d, f x) * f d :=
lt_mul_of_one_lt_right' _ (one_le.trans_lt hlt)
_ = ∏ x ∈ S, f x := Finset.prod_erase_mul S f hd_mem
· calc ∏ x ∈ S', f x
≤ ∏ x ∈ S.erase d ∪ {d'}, f x := Finset.prod_le_prod_of_subset hS'
_ = (∏ x ∈ S.erase d, f x) * f d' := by
rw [Finset.prod_union (Finset.disjoint_singleton_right.mpr
(fun h ↦ hd'S (Finset.mem_of_mem_erase h))), Finset.prod_singleton]
_ < (∏ x ∈ S.erase d, f x) * f d := mul_lt_mul_right hlt _
_ = ∏ x ∈ S, f x := Finset.prod_erase_mul S f hd_mem
end CanonicallyOrderedMul
section OrderedCancelCommMonoid
variable [CommMonoid M] [Preorder M] [IsOrderedCancelMonoid M] {f g : ι → M} {s t : Finset ι}
@[to_additive]
theorem prod_lt_prod [MulLeftStrictMono M] (hle : ∀ i ∈ s, f i ≤ g i) (hlt : ∃ i ∈ s, f i < g i) :
∏ i ∈ s, f i < ∏ i ∈ s, g i :=
Multiset.prod_lt_prod hle hlt
@[deprecated (since := "2026-09-01")] alias prod_lt_prod' := prod_lt_prod
/-- In an ordered commutative monoid, if each factor `f i` of one nontrivial finite product is
strictly less than the corresponding factor `g i` of another nontrivial finite product, then
`s.prod f < s.prod g`. -/
@[to_additive (attr := gcongr)]
theorem prod_lt_prod_of_nonempty [MulLeftStrictMono M] (hs : s.Nonempty)
(hlt : ∀ i ∈ s, f i < g i) :
∏ i ∈ s, f i < ∏ i ∈ s, g i :=
Multiset.prod_lt_prod_of_nonempty (by aesop) hlt
@[deprecated (since := "2026-09-01")] alias prod_lt_prod_of_nonempty' := prod_lt_prod_of_nonempty
/-- In an ordered additive commutative monoid, if each summand `f i` of one nontrivial finite sum is
strictly less than the corresponding summand `g i` of another nontrivial finite sum, then
`s.sum f < s.sum g`. -/
add_decl_doc sum_lt_sum_of_nonempty
@[to_additive]
theorem prod_lt_prod_of_subset [MulLeftStrictMono M] (h : s ⊆ t) {i : ι} (ht : i ∈ t)
(hs : i ∉ s) (hlt : 1 < f i)
(hle : ∀ j ∈ t, j ∉ s → 1 ≤ f j) : ∏ j ∈ s, f j < ∏ j ∈ t, f j := by
classical calc
∏ j ∈ s, f j < ∏ j ∈ insert i s, f j := by
rw [prod_insert hs]
exact lt_mul_of_one_lt_left' (∏ j ∈ s, f j) hlt
_ ≤ ∏ j ∈ t, f j := by
apply prod_le_prod_of_subset_of_one_le
· simp [Finset.insert_subset_iff, h, ht]
· intro x hx h'x
simp only [mem_insert, not_or] at h'x
exact hle x hx h'x.2
@[deprecated (since := "2026-09-01")] alias prod_lt_prod_of_subset' := prod_lt_prod_of_subset
@[to_additive]
theorem single_lt_prod [MulLeftStrictMono M] {i j : ι} (hij : j ≠ i) (hi : i ∈ s) (hj : j ∈ s)
(hlt : 1 < f j) (hle : ∀ k ∈ s, k ≠ i → 1 ≤ f k) : f i < ∏ k ∈ s, f k :=
calc
f i = ∏ k ∈ {i}, f k := by rw [prod_singleton]
_ < ∏ k ∈ s, f k :=
prod_lt_prod_of_subset (singleton_subset_iff.2 hi) hj (mt mem_singleton.1 hij) hlt
fun k hks hki ↦ hle k hks (mt mem_singleton.2 hki)
@[deprecated (since := "2026-09-01")] alias single_lt_prod' := single_lt_prod
@[to_additive sum_pos]
theorem one_lt_prod [MulLeftStrictMono M] (h : ∀ i ∈ s, 1 < f i) (hs : s.Nonempty) :
1 < ∏ i ∈ s, f i :=
lt_of_le_of_lt (by rw [prod_const_one]) <| prod_lt_prod_of_nonempty hs h
@[to_additive]
theorem prod_lt_one [MulLeftStrictMono M] (h : ∀ i ∈ s, f i < 1) (hs : s.Nonempty) :
∏ i ∈ s, f i < 1 :=
(prod_lt_prod_of_nonempty hs h).trans_le (by rw [prod_const_one])
@[to_additive sum_pos']
theorem one_lt_prod' [MulLeftStrictMono M] (h : ∀ i ∈ s, 1 ≤ f i) (hs : ∃ i ∈ s, 1 < f i) :
1 < ∏ i ∈ s, f i :=
prod_const_one.symm.trans_lt <| prod_lt_prod h hs
@[to_additive]
theorem prod_lt_one' [MulLeftStrictMono M] (h : ∀ i ∈ s, f i ≤ 1) (hs : ∃ i ∈ s, f i < 1) :
∏ i ∈ s, f i < 1 :=
prod_const_one.le.trans_lt' <| prod_lt_prod h hs
@[to_additive]
theorem prod_eq_prod_iff_of_le {ι M : Type*} [CommMonoid M] [PartialOrder M]
[IsOrderedCancelMonoid M] {s : Finset ι} {f g : ι → M} (h : ∀ i ∈ s, f i ≤ g i) :
((∏ i ∈ s, f i) = ∏ i ∈ s, g i) ↔ ∀ i ∈ s, f i = g i := by
classical
revert h
refine Finset.induction_on s (fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.notMem_empty _ h),
fun _ ↦ rfl⟩) fun a s ha ih H ↦ ?_
specialize ih fun i ↦ H i ∘ Finset.mem_insert_of_mem
rw [Finset.prod_insert ha, Finset.prod_insert ha, Finset.forall_mem_insert, ← ih]
exact
mul_eq_mul_iff_eq_and_eq (H a (s.mem_insert_self a))
(Finset.prod_le_prod fun i ↦ H i ∘ Finset.mem_insert_of_mem)
@[to_additive] lemma prod_sdiff_le_prod_sdiff [DecidableEq ι] :
∏ i ∈ s \ t, f i ≤ ∏ i ∈ t \ s, f i ↔ ∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
rw [← mul_le_mul_iff_right, ← prod_union (disjoint_sdiff_inter _ _), sdiff_union_inter,
← prod_union, inter_comm, sdiff_union_inter]
simpa only [inter_comm] using disjoint_sdiff_inter t s
@[to_additive] lemma prod_sdiff_lt_prod_sdiff {ι M : Type*} [CommMonoid M] [PartialOrder M]
[IsOrderedCancelMonoid M] [DecidableEq ι] {s t : Finset ι} {f : ι → M} :
∏ i ∈ s \ t, f i < ∏ i ∈ t \ s, f i ↔ ∏ i ∈ s, f i < ∏ i ∈ t, f i := by
rw [← mul_lt_mul_iff_right, ← prod_union (disjoint_sdiff_inter _ _), sdiff_union_inter,
← prod_union, inter_comm, sdiff_union_inter]
simpa only [inter_comm] using disjoint_sdiff_inter t s
end OrderedCancelCommMonoid
section LinearOrderedCancelCommMonoid
variable [CommMonoid M] [LinearOrder M] {f g : ι → M} {s : Finset ι}
@[to_additive]
theorem exists_lt_of_prod_lt [IsOrderedMonoid M] (Hlt : ∏ i ∈ s, f i < ∏ i ∈ s, g i) :
∃ i ∈ s, f i < g i := by
contrapose! Hlt with Hle
exact prod_le_prod Hle
@[deprecated (since := "2026-09-01")] alias exists_lt_of_prod_lt' := exists_lt_of_prod_lt
@[to_additive exists_pos_of_sum_zero_of_exists_nonzero]
theorem exists_one_lt_of_prod_one_of_exists_ne_one [IsOrderedMonoid M] (f : ι → M)
(h₁ : ∏ i ∈ s, f i = 1) (h₂ : ∃ i ∈ s, f i ≠ 1) : ∃ i ∈ s, 1 < f i := by
by_contra! h
have : ¬ ∃ x ∈ s, f x < 1 := by simp [← prod_lt_one_iff_of_le_one h, h₁]
grind
@[to_additive exists_neg_of_sum_zero_of_exists_nonzero]
theorem exists_lt_one_of_prod_one_of_exists_ne_one [IsOrderedMonoid M] (f : ι → M)
(h₁ : ∏ i ∈ s, f i = 1) (h₂ : ∃ i ∈ s, f i ≠ 1) : ∃ i ∈ s, f i < 1 :=
exists_one_lt_of_prod_one_of_exists_ne_one (M := Mᵒᵈ) f h₁ h₂
variable [IsOrderedCancelMonoid M]
@[to_additive]
theorem exists_le_of_prod_le (hs : s.Nonempty) (Hle : ∏ i ∈ s, f i ≤ ∏ i ∈ s, g i) :
∃ i ∈ s, f i ≤ g i := by
contrapose! Hle with Hlt
exact prod_lt_prod_of_nonempty hs Hlt
@[deprecated (since := "2026-09-01")] alias exists_le_of_prod_le' := exists_le_of_prod_le
@[deprecated (since := "2026-09-01")]
alias exists_one_lt_of_prod_one_of_exists_ne_one' := exists_one_lt_of_prod_one_of_exists_ne_one
end LinearOrderedCancelCommMonoid
theorem apply_sup_le_sum [SemilatticeSup α] [OrderBot α]
[AddCommMonoid β] [Preorder β] [AddLeftMono β]
{f : α → β} (zero : f ⊥ = 0) (ih : ∀ {s t}, f (s ⊔ t) ≤ f s + f t)
{s : ι → α} (t : Finset ι) :
f (t.sup s) ≤ ∑ i ∈ t, f (s i) := by
classical
refine t.induction_on zero.le fun i t it h ↦ ?_
simpa only [sup_insert, Finset.sum_insert it] using ih.trans (by gcongr)
theorem apply_union_le_sum [AddCommMonoid β] [Preorder β] [AddLeftMono β]
{f : Set α → β} (zero : f ∅ = 0) (ih : ∀ {s t}, f (s ∪ t) ≤ f s + f t)
{s : ι → Set α} (t : Finset ι) :
f (⋃ i ∈ t, s i) ≤ ∑ i ∈ t, f (s i) :=
Finset.sup_set_eq_biUnion t s ▸ t.apply_sup_le_sum zero (by simpa)
theorem sum_le_one_iff {s : Finset α} {f : α → ℕ} :
∑ x ∈ s, f x ≤ 1 ↔ ∀ x y, x ∈ s → y ∈ s → f x ≠ 0 → f y ≠ 0 → x = y ∧ f x = 1 := by
classical
refine ⟨fun h x y hsx hsy hfx hfy ↦ ?_, fun h ↦ ?_⟩
· replace h := (sum_mono_set f (show {x, y} ⊆ s by grind)).trans h
grind
· by_cases! hx : ∃ x ∈ s, f x ≠ 0
· obtain ⟨x, hsx, hfx⟩ := hx
have hs : ∀ y ∈ s \ {x}, f y = 0 := by grind
simp [← sum_sdiff (singleton_subset_iff.2 hsx), sum_congr rfl hs, (h x x hsx hsx hfx hfx).2]
· simp [sum_congr rfl hx]
end Finset
namespace Fintype
section OrderedCommMonoid
variable [Fintype ι] [CommMonoid M] [Preorder M] [MulLeftMono M] {f : ι → M}
@[to_additive (attr := mono)]
theorem prod_mono : Monotone fun f : ι → M ↦ ∏ i, f i := fun _ _ hfg ↦
Finset.prod_le_prod fun x _ ↦ hfg x
@[deprecated (since := "2026-09-01")] alias prod_mono' := prod_mono
@[to_additive sum_nonneg]
lemma one_le_prod (hf : 1 ≤ f) : 1 ≤ ∏ i, f i := Finset.one_le_prod fun _ _ ↦ hf _
@[to_additive] lemma prod_le_one (hf : f ≤ 1) : ∏ i, f i ≤ 1 := Finset.prod_le_one fun _ _ ↦ hf _
@[to_additive]
lemma prod_eq_one_iff_of_one_le {ι M : Type*} [Fintype ι] [CommMonoid M] [PartialOrder M]
[IsOrderedMonoid M] {f : ι → M} (hf : 1 ≤ f) : ∏ i, f i = 1 ↔ f = 1 :=
(Finset.prod_eq_one_iff_of_one_le fun i _ ↦ hf i).trans <| by simp [funext_iff]
@[to_additive]
lemma prod_eq_one_iff_of_le_one {ι M : Type*} [Fintype ι] [CommMonoid M] [PartialOrder M]
[IsOrderedMonoid M] {f : ι → M} (hf : f ≤ 1) : ∏ i, f i = 1 ↔ f = 1 :=
(Finset.prod_eq_one_iff_of_le_one fun i _ ↦ hf i).trans <| by simp [funext_iff]
end OrderedCommMonoid
section OrderedCancelCommMonoid
variable [Fintype ι] [CommMonoid M] [PartialOrder M] [IsOrderedCancelMonoid M] {f : ι → M}
@[to_additive]
theorem prod_strictMono : StrictMono fun f : ι → M ↦ ∏ x, f x :=
fun _ _ hfg ↦
let ⟨hle, i, hlt⟩ := Pi.lt_def.mp hfg
Finset.prod_lt_prod (fun i _ ↦ hle i) ⟨i, Finset.mem_univ i, hlt⟩
@[deprecated (since := "2026-09-01")] alias prod_strictMono' := prod_strictMono
@[to_additive sum_pos]
lemma one_lt_prod (hf : 1 < f) : 1 < ∏ i, f i :=
Finset.one_lt_prod' (fun _ _ ↦ hf.le _) <| by simpa using (Pi.lt_def.1 hf).2
@[to_additive]
lemma prod_lt_one (hf : f < 1) : ∏ i, f i < 1 :=
Finset.prod_lt_one' (fun _ _ ↦ hf.le _) <| by simpa using (Pi.lt_def.1 hf).2
@[to_additive sum_pos_iff_of_nonneg]
lemma one_lt_prod_iff_of_one_le (hf : 1 ≤ f) : 1 < ∏ i, f i ↔ 1 < f := by
obtain rfl | hf := hf.eq_or_lt <;> simp [*, one_lt_prod]
@[to_additive]
lemma prod_lt_one_iff_of_le_one (hf : f ≤ 1) : ∏ i, f i < 1 ↔ f < 1 := by
obtain rfl | hf := hf.eq_or_lt <;> simp [*, prod_lt_one]
end OrderedCancelCommMonoid
end Fintype
namespace Multiset
theorem finsetSum_eq_sup_iff_disjoint [DecidableEq α] {i : Finset β} {f : β → Multiset α} :
i.sum f = i.sup f ↔ ∀ x ∈ i, ∀ y ∈ i, x ≠ y → Disjoint (f x) (f y) := by
induction i using Finset.cons_induction_on with
| empty =>
simp only [Finset.notMem_empty, IsEmpty.forall_iff, imp_true_iff, Finset.sum_empty,
Finset.sup_empty, bot_eq_zero]
| cons z i hz hr =>
simp_rw [Finset.sum_cons hz, Finset.sup_cons, Finset.mem_cons, Multiset.sup_eq_union,
forall_eq_or_imp, Ne, not_true_eq_false, IsEmpty.forall_iff, true_and,
imp_and, forall_and, ← hr, @eq_comm _ z]
have := fun x (H : x ∈ i) => ne_of_mem_of_not_mem H hz
simp +contextual only [this, not_false_iff, true_imp_iff]
simp_rw [← disjoint_finsetSum_left, ← disjoint_finsetSum_right, disjoint_comm, ← and_assoc,
and_self_iff]
exact add_eq_union_left_of_le (Finset.sup_le fun x hx => le_sum_of_mem (mem_map_of_mem f hx))
theorem sup_powerset_len [DecidableEq α] (x : Multiset α) :
(Finset.sup (Finset.range (card x + 1)) fun k => x.powersetCard k) = x.powerset := by
convert bind_powerset_len x
rw [Multiset.bind, Multiset.join, ← Finset.range_val, ← Finset.sum_eq_multiset_sum]
exact
Eq.symm (finsetSum_eq_sup_iff_disjoint.mpr fun _ _ _ _ h => pairwise_disjoint_powersetCard x h)
theorem card_le_card_toFinset_add_one_iff [DecidableEq α] {m : Multiset α} :
m.card ≤ m.toFinset.card + 1 ↔
∀ x y, 1 < m.count x → 1 < m.count y → x = y ∧ m.count x = 2 := by
rw [← m.toFinset_sum_count_eq, m.toFinset.card_eq_sum_ones, ← tsub_le_iff_left,
← Finset.sum_tsub_distrib _ (by simp [one_le_count_iff_mem]), Finset.sum_le_one_iff]
simp only [← pos_iff_ne_zero, Nat.sub_pos_iff_lt, mem_toFinset, Nat.pred_eq_succ_iff]
exact ⟨fun h x y hx hy ↦ h x y (one_le_count_iff_mem.mp hx.le)
(one_le_count_iff_mem.mp hy.le) hx hy, fun h x y _ _ hx hy ↦ h x y hx hy⟩
end Multiset
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.77Angebot
¤
*Eine klare Vorstellung vom Zielzustand
|
|
2026-11-24
|
|
|
|
|